diff --git a/deps/exla/c_src/exla/custom_calls/eigh.h b/deps/exla/c_src/exla/custom_calls/eigh.h new file mode 100644 index 0000000000000000000000000000000000000000..9ab743336fab3604939065ef8b8a945ba3d089c2 --- /dev/null +++ b/deps/exla/c_src/exla/custom_calls/eigh.h @@ -0,0 +1,90 @@ +#pragma once + +#include +#include +#include +#include + +#include "Eigen/Eigenvalues" +#include "xla/ffi/api/ffi.h" +#include "xla/ffi/ffi_api.h" + +namespace ffi = xla::ffi; + +template +void single_matrix_eigh_cpu_custom_call(DataType *eigenvalues_out, + DataType *eigenvectors_out, + DataType *in, uint64_t m, uint64_t n) { + typedef Eigen::Matrix + RowMajorMatrix; + + // Map the input matrix + Eigen::Map input(in, m, n); + + // Compute the Eigenvalue decomposition + Eigen::SelfAdjointEigenSolver eigensolver(input); + + if (eigensolver.info() != Eigen::Success) { + std::cerr << "Eigenvalue decomposition failed!" << std::endl; + return; + } + + // Get the eigenvalues and eigenvectors + Eigen::Matrix eigenvalues = + eigensolver.eigenvalues(); + RowMajorMatrix eigenvectors = eigensolver.eigenvectors(); + + // Create a vector of indices and sort it based on eigenvalues in decreasing + // order + std::vector indices(m); + std::iota(indices.begin(), indices.end(), 0); + std::sort(indices.begin(), indices.end(), [&eigenvalues](int i, int j) { + return std::abs(eigenvalues(i)) > std::abs(eigenvalues(j)); + }); + + // Sort eigenvalues and rearrange eigenvectors + Eigen::Matrix sorted_eigenvalues(m); + RowMajorMatrix sorted_eigenvectors(m, n); + for (int i = 0; i < m; ++i) { + sorted_eigenvalues(i) = eigenvalues(indices[i]); + sorted_eigenvectors.col(i) = eigenvectors.col(indices[i]); + } + + // Copy the sorted eigenvalues to the output + std::memcpy(eigenvalues_out, sorted_eigenvalues.data(), m * sizeof(DataType)); + + // Copy the sorted eigenvectors to the output + std::memcpy(eigenvectors_out, sorted_eigenvectors.data(), + m * n * sizeof(DataType)); +} + +template +ffi::Error eigh_cpu_custom_call_impl(BufferType operand, + ffi::Result eigenvalues, + ffi::Result eigenvectors) { + auto operand_dims = operand.dimensions(); + auto eigenvalues_dims = eigenvalues->dimensions(); + auto eigenvectors_dims = eigenvectors->dimensions(); + + uint64_t m = eigenvectors_dims[eigenvectors_dims.size() - 2]; + uint64_t n = eigenvectors_dims[eigenvectors_dims.size() - 1]; + + uint64_t batch_items = 1; + for (auto it = operand_dims.begin(); it != operand_dims.end() - 2; it++) { + batch_items *= *it; + } + + uint64_t eigenvalues_stride = eigenvalues_dims[eigenvalues_dims.size() - 1]; + uint64_t eigenvectors_stride = m * n; + uint64_t inner_stride = m * n; + + for (uint64_t i = 0; i < batch_items; i++) { + single_matrix_eigh_cpu_custom_call( + eigenvalues->typed_data() + i * eigenvalues_stride, + eigenvectors->typed_data() + i * eigenvectors_stride, + operand.typed_data() + i * inner_stride, m, n); + } + + return ffi::Error::Success(); +} diff --git a/deps/exla/c_src/exla/custom_calls/eigh_f32.cc b/deps/exla/c_src/exla/custom_calls/eigh_f32.cc new file mode 100644 index 0000000000000000000000000000000000000000..5e9e15096c880069352b00990cbcbf29779dfed2 --- /dev/null +++ b/deps/exla/c_src/exla/custom_calls/eigh_f32.cc @@ -0,0 +1,19 @@ +#include "eigh.h" + +ffi::Error +eigh_cpu_custom_call_f32_impl(ffi::Buffer operand, + ffi::ResultBuffer eigenvalues, + ffi::ResultBuffer eigenvectors) { + return eigh_cpu_custom_call_impl>( + operand, eigenvalues, eigenvectors); +} + +XLA_FFI_DEFINE_HANDLER_SYMBOL(eigh_cpu_custom_call_f32, + eigh_cpu_custom_call_f32_impl, + ffi::Ffi::Bind() + .Arg>() + .Ret>() + .Ret>()); + +XLA_FFI_REGISTER_HANDLER(ffi::GetXlaFfiApi(), "eigh_cpu_custom_call_f32", + "Host", eigh_cpu_custom_call_f32); diff --git a/deps/exla/c_src/exla/custom_calls/eigh_f64.cc b/deps/exla/c_src/exla/custom_calls/eigh_f64.cc new file mode 100644 index 0000000000000000000000000000000000000000..b047c234e7680ccd98c197eda49db1d3adbd328e --- /dev/null +++ b/deps/exla/c_src/exla/custom_calls/eigh_f64.cc @@ -0,0 +1,19 @@ +#include "eigh.h" + +ffi::Error +eigh_cpu_custom_call_f64_impl(ffi::Buffer operand, + ffi::ResultBuffer eigenvalues, + ffi::ResultBuffer eigenvectors) { + return eigh_cpu_custom_call_impl>( + operand, eigenvalues, eigenvectors); +} + +XLA_FFI_DEFINE_HANDLER_SYMBOL(eigh_cpu_custom_call_f64, + eigh_cpu_custom_call_f64_impl, + ffi::Ffi::Bind() + .Arg>() + .Ret>() + .Ret>()); + +XLA_FFI_REGISTER_HANDLER(ffi::GetXlaFfiApi(), "eigh_cpu_custom_call_f64", + "Host", eigh_cpu_custom_call_f64); diff --git a/deps/exla/c_src/exla/custom_calls/lu.h b/deps/exla/c_src/exla/custom_calls/lu.h new file mode 100644 index 0000000000000000000000000000000000000000..51d100191eeeeacbc90a020c06ca23e900f3a68a --- /dev/null +++ b/deps/exla/c_src/exla/custom_calls/lu.h @@ -0,0 +1,87 @@ +#pragma once + +#include +#include +#include +#include + +#include "Eigen/LU" +#include "xla/ffi/api/ffi.h" +#include "xla/ffi/ffi_api.h" + +namespace ffi = xla::ffi; + +template +void single_matrix_lu_cpu_custom_call(uint8_t *p_out, DataType *l_out, + DataType *u_out, DataType *in, + uint64_t n) { + typedef Eigen::Matrix + RowMajorMatrix; + + Eigen::Map input(in, n, n); + Eigen::PartialPivLU lu = input.partialPivLu(); + + // Get the permutation matrix P and convert to indices + Eigen::PermutationMatrix P = + lu.permutationP(); + for (uint64_t i = 0; i < n; i++) { + for (uint64_t j = 0; j < n; j++) { + p_out[i * n + j] = static_cast(P.indices()[i] == j ? 1 : 0); + } + } + + // Get L and U matrices + RowMajorMatrix L = lu.matrixLU().template triangularView(); + RowMajorMatrix U = lu.matrixLU().template triangularView(); + + // Copy L matrix + for (uint64_t i = 0; i < n; i++) { + for (uint64_t j = 0; j < n; j++) { + if (j < i) { + l_out[i * n + j] = static_cast(L(i, j)); + } else if (j == i) { + l_out[i * n + j] = static_cast(1.0); + } else { + l_out[i * n + j] = static_cast(0.0); + } + } + } + + // Copy U matrix + for (uint64_t i = 0; i < n; i++) { + for (uint64_t j = 0; j < n; j++) { + if (j >= i) { + u_out[i * n + j] = static_cast(U(i, j)); + } else { + u_out[i * n + j] = static_cast(0.0); + } + } + } +} + +template +ffi::Error +lu_cpu_custom_call_impl(BufferType operand, ffi::Result> p, + ffi::Result l, ffi::Result u) { + auto operand_dims = operand.dimensions(); + auto l_dims = l->dimensions(); + uint64_t n = l_dims[l_dims.size() - 1]; + + uint64_t batch_items = 1; + for (auto it = operand_dims.begin(); it != operand_dims.end() - 2; it++) { + batch_items *= *it; + } + + uint64_t stride = n * n; + + for (uint64_t i = 0; i < batch_items; i++) { + single_matrix_lu_cpu_custom_call( + p->typed_data() + i * stride, + (DataType *)l->untyped_data() + i * stride, + (DataType *)u->untyped_data() + i * stride, + (DataType *)operand.untyped_data() + i * stride, n); + } + + return ffi::Error::Success(); +} diff --git a/deps/exla/c_src/exla/custom_calls/lu_bf16.cc b/deps/exla/c_src/exla/custom_calls/lu_bf16.cc new file mode 100644 index 0000000000000000000000000000000000000000..3d040d1121df6cd868c2122c926f7f638fe3607b --- /dev/null +++ b/deps/exla/c_src/exla/custom_calls/lu_bf16.cc @@ -0,0 +1,21 @@ +#include "../exla_types.h" +#include "lu.h" + +ffi::Error lu_cpu_custom_call_bf16_impl(ffi::Buffer operand, + ffi::ResultBuffer p, + ffi::ResultBuffer l, + ffi::ResultBuffer u) { + return lu_cpu_custom_call_impl>( + operand, p, l, u); +} + +XLA_FFI_DEFINE_HANDLER_SYMBOL(lu_cpu_custom_call_bf16, + lu_cpu_custom_call_bf16_impl, + ffi::Ffi::Bind() + .Arg>() + .Ret>() + .Ret>() + .Ret>()); + +XLA_FFI_REGISTER_HANDLER(ffi::GetXlaFfiApi(), "lu_cpu_custom_call_bf16", "Host", + lu_cpu_custom_call_bf16); diff --git a/deps/exla/c_src/exla/custom_calls/lu_f16.cc b/deps/exla/c_src/exla/custom_calls/lu_f16.cc new file mode 100644 index 0000000000000000000000000000000000000000..022248bdef2e64d9d9de9376fd0e56bff42a9e88 --- /dev/null +++ b/deps/exla/c_src/exla/custom_calls/lu_f16.cc @@ -0,0 +1,21 @@ +#include "../exla_types.h" +#include "lu.h" + +ffi::Error lu_cpu_custom_call_f16_impl(ffi::Buffer operand, + ffi::ResultBuffer p, + ffi::ResultBuffer l, + ffi::ResultBuffer u) { + return lu_cpu_custom_call_impl>(operand, + p, l, u); +} + +XLA_FFI_DEFINE_HANDLER_SYMBOL(lu_cpu_custom_call_f16, + lu_cpu_custom_call_f16_impl, + ffi::Ffi::Bind() + .Arg>() + .Ret>() + .Ret>() + .Ret>()); + +XLA_FFI_REGISTER_HANDLER(ffi::GetXlaFfiApi(), "lu_cpu_custom_call_f16", "Host", + lu_cpu_custom_call_f16); diff --git a/deps/exla/c_src/exla/custom_calls/lu_f32.cc b/deps/exla/c_src/exla/custom_calls/lu_f32.cc new file mode 100644 index 0000000000000000000000000000000000000000..033219015840920e1496fd7c0f21a1d108a409bd --- /dev/null +++ b/deps/exla/c_src/exla/custom_calls/lu_f32.cc @@ -0,0 +1,20 @@ +#include "lu.h" + +ffi::Error lu_cpu_custom_call_f32_impl(ffi::Buffer operand, + ffi::ResultBuffer p, + ffi::ResultBuffer l, + ffi::ResultBuffer u) { + return lu_cpu_custom_call_impl>(operand, p, l, + u); +} + +XLA_FFI_DEFINE_HANDLER_SYMBOL(lu_cpu_custom_call_f32, + lu_cpu_custom_call_f32_impl, + ffi::Ffi::Bind() + .Arg>() + .Ret>() + .Ret>() + .Ret>()); + +XLA_FFI_REGISTER_HANDLER(ffi::GetXlaFfiApi(), "lu_cpu_custom_call_f32", "Host", + lu_cpu_custom_call_f32); diff --git a/deps/exla/c_src/exla/custom_calls/lu_f64.cc b/deps/exla/c_src/exla/custom_calls/lu_f64.cc new file mode 100644 index 0000000000000000000000000000000000000000..e129166611c790edb6cdd1238dcf8c59b2605f65 --- /dev/null +++ b/deps/exla/c_src/exla/custom_calls/lu_f64.cc @@ -0,0 +1,20 @@ +#include "lu.h" + +ffi::Error lu_cpu_custom_call_f64_impl(ffi::Buffer operand, + ffi::ResultBuffer p, + ffi::ResultBuffer l, + ffi::ResultBuffer u) { + return lu_cpu_custom_call_impl>(operand, p, l, + u); +} + +XLA_FFI_DEFINE_HANDLER_SYMBOL(lu_cpu_custom_call_f64, + lu_cpu_custom_call_f64_impl, + ffi::Ffi::Bind() + .Arg>() + .Ret>() + .Ret>() + .Ret>()); + +XLA_FFI_REGISTER_HANDLER(ffi::GetXlaFfiApi(), "lu_cpu_custom_call_f64", "Host", + lu_cpu_custom_call_f64); diff --git a/deps/exla/c_src/exla/custom_calls/qr.h b/deps/exla/c_src/exla/custom_calls/qr.h new file mode 100644 index 0000000000000000000000000000000000000000..ff489a69087162d5773da5af93bc9ed50f55afba --- /dev/null +++ b/deps/exla/c_src/exla/custom_calls/qr.h @@ -0,0 +1,88 @@ +#pragma once + +#include +#include +#include +#include + +#include "Eigen/QR" +#include "xla/ffi/api/ffi.h" +#include "xla/ffi/ffi_api.h" + +namespace ffi = xla::ffi; + +template +void single_matrix_qr_cpu_custom_call(DataType *q_out, DataType *r_out, + DataType *in, uint64_t m, uint64_t k, + uint64_t n, bool complete) { + typedef Eigen::Matrix + RowMajorMatrix; + + Eigen::Map input(in, m, n); + Eigen::HouseholderQR qr = input.householderQr(); + + RowMajorMatrix Q, R; + size_t num_bytes_q; + + if (complete) { + Q = qr.householderQ() * RowMajorMatrix::Identity(m, m); + R = qr.matrixQR(); + + num_bytes_q = m * m * sizeof(DataType); + + for (uint64_t i = 0; i < m; ++i) { + for (uint64_t j = 0; j < n; ++j) { + r_out[i * n + j] = (j >= i) ? R(i, j) : static_cast(0.0); + } + } + } else { + Q = qr.householderQ() * RowMajorMatrix::Identity(m, k); + R = qr.matrixQR().topRows(k); + + num_bytes_q = m * k * sizeof(DataType); + + for (uint64_t i = 0; i < k; ++i) { + for (uint64_t j = 0; j < n; ++j) { + r_out[i * n + j] = (j >= i) ? R(i, j) : static_cast(0.0); + } + } + } + + memcpy(q_out, Q.data(), num_bytes_q); +} + +template +ffi::Error qr_cpu_custom_call_impl(BufferType operand, + ffi::Result q, + ffi::Result r) { + auto operand_dims = operand.dimensions(); + auto q_dims = q->dimensions(); + auto r_dims = r->dimensions(); + + uint64_t m = q_dims[q_dims.size() - 2]; + uint64_t k = q_dims[q_dims.size() - 1]; + uint64_t n = r_dims[r_dims.size() - 1]; + uint64_t l = r_dims[r_dims.size() - 2]; + + bool complete = l == m; + + uint64_t batch_items = 1; + for (auto it = operand_dims.begin(); it != operand_dims.end() - 2; it++) { + batch_items *= *it; + } + + uint64_t q_stride = m * k; + uint64_t r_stride = n * l; + uint64_t inner_stride = m * n; + + for (uint64_t i = 0; i < batch_items; i++) { + single_matrix_qr_cpu_custom_call( + (DataType *)q->untyped_data() + i * q_stride, + (DataType *)r->untyped_data() + i * r_stride, + (DataType *)operand.untyped_data() + i * inner_stride, m, k, n, + complete); + } + + return ffi::Error::Success(); +} diff --git a/deps/exla/c_src/exla/custom_calls/qr_bf16.cc b/deps/exla/c_src/exla/custom_calls/qr_bf16.cc new file mode 100644 index 0000000000000000000000000000000000000000..01cc6ca3cc46d6d56508e37f9a331c4bc617797d --- /dev/null +++ b/deps/exla/c_src/exla/custom_calls/qr_bf16.cc @@ -0,0 +1,19 @@ +#include "../exla_types.h" +#include "qr.h" + +ffi::Error qr_cpu_custom_call_bf16_impl(ffi::Buffer operand, + ffi::ResultBuffer q, + ffi::ResultBuffer r) { + return qr_cpu_custom_call_impl>( + operand, q, r); +} + +XLA_FFI_DEFINE_HANDLER_SYMBOL(qr_cpu_custom_call_bf16, + qr_cpu_custom_call_bf16_impl, + ffi::Ffi::Bind() + .Arg>() + .Ret>() + .Ret>()); + +XLA_FFI_REGISTER_HANDLER(ffi::GetXlaFfiApi(), "qr_cpu_custom_call_bf16", "Host", + qr_cpu_custom_call_bf16); diff --git a/deps/exla/c_src/exla/custom_calls/qr_f16.cc b/deps/exla/c_src/exla/custom_calls/qr_f16.cc new file mode 100644 index 0000000000000000000000000000000000000000..49e5f7b96b46c7085d34c8952c25fc0c870668a0 --- /dev/null +++ b/deps/exla/c_src/exla/custom_calls/qr_f16.cc @@ -0,0 +1,19 @@ +#include "../exla_types.h" +#include "qr.h" + +ffi::Error qr_cpu_custom_call_f16_impl(ffi::Buffer operand, + ffi::ResultBuffer q, + ffi::ResultBuffer r) { + return qr_cpu_custom_call_impl>(operand, + q, r); +} + +XLA_FFI_DEFINE_HANDLER_SYMBOL(qr_cpu_custom_call_f16, + qr_cpu_custom_call_f16_impl, + ffi::Ffi::Bind() + .Arg>() + .Ret>() + .Ret>()); + +XLA_FFI_REGISTER_HANDLER(ffi::GetXlaFfiApi(), "qr_cpu_custom_call_f16", "Host", + qr_cpu_custom_call_f16); diff --git a/deps/exla/c_src/exla/custom_calls/qr_f32.cc b/deps/exla/c_src/exla/custom_calls/qr_f32.cc new file mode 100644 index 0000000000000000000000000000000000000000..544a192141403e6a25480c443a6ea75e4188122d --- /dev/null +++ b/deps/exla/c_src/exla/custom_calls/qr_f32.cc @@ -0,0 +1,17 @@ +#include "qr.h" + +ffi::Error qr_cpu_custom_call_f32_impl(ffi::Buffer operand, + ffi::ResultBuffer q, + ffi::ResultBuffer r) { + return qr_cpu_custom_call_impl>(operand, q, r); +} + +XLA_FFI_DEFINE_HANDLER_SYMBOL(qr_cpu_custom_call_f32, + qr_cpu_custom_call_f32_impl, + ffi::Ffi::Bind() + .Arg>() + .Ret>() + .Ret>()); + +XLA_FFI_REGISTER_HANDLER(ffi::GetXlaFfiApi(), "qr_cpu_custom_call_f32", "Host", + qr_cpu_custom_call_f32); diff --git a/deps/exla/c_src/exla/custom_calls/qr_f64.cc b/deps/exla/c_src/exla/custom_calls/qr_f64.cc new file mode 100644 index 0000000000000000000000000000000000000000..64ec1e8aac7867952c2db24a0a51cfdb82208f84 --- /dev/null +++ b/deps/exla/c_src/exla/custom_calls/qr_f64.cc @@ -0,0 +1,17 @@ +#include "qr.h" + +ffi::Error qr_cpu_custom_call_f64_impl(ffi::Buffer operand, + ffi::ResultBuffer q, + ffi::ResultBuffer r) { + return qr_cpu_custom_call_impl>(operand, q, r); +} + +XLA_FFI_DEFINE_HANDLER_SYMBOL(qr_cpu_custom_call_f64, + qr_cpu_custom_call_f64_impl, + ffi::Ffi::Bind() + .Arg>() + .Ret>() + .Ret>()); + +XLA_FFI_REGISTER_HANDLER(ffi::GetXlaFfiApi(), "qr_cpu_custom_call_f64", "Host", + qr_cpu_custom_call_f64); diff --git a/deps/exla/c_src/exla/exla.cc b/deps/exla/c_src/exla/exla.cc new file mode 100644 index 0000000000000000000000000000000000000000..7a32f5e8a0545f2a51a4679f1f53b6f9f0be3bc8 --- /dev/null +++ b/deps/exla/c_src/exla/exla.cc @@ -0,0 +1,508 @@ +#include +#include +#include +#include + +#include "exla_client.h" +#include "exla_cuda.h" +#include "exla_log_sink.h" +#include "exla_mlir.h" +#include "exla_nif_util.h" +#include "ipc.h" +#include "mlir/IR/MLIRContext.h" +#include "stablehlo/dialect/ChloOps.h" +#include "stablehlo/dialect/StablehloOps.h" +#include "xla/pjrt/pjrt_api.h" +#include "xla/service/platform_util.h" +#include "xla/tsl/platform/statusor.h" +#include "llvm/Support/ThreadPool.h" + +namespace exla { + +FINE_RESOURCE(llvm::StdThreadPool); +FINE_RESOURCE(mlir::MLIRContext); +FINE_RESOURCE(mlir::Value); +FINE_RESOURCE(mlir::Region); +FINE_RESOURCE(exla::ExlaClient); +FINE_RESOURCE(exla::ExlaBuffer); +FINE_RESOURCE(exla::ExlaExecutable); +FINE_RESOURCE(exla::MLIRModule); +FINE_RESOURCE(exla::MLIRFunction); + +// MLIR Functions + +fine::ResourcePtr decode_exla_buffer(ErlNifEnv *env, + fine::Term buffer_term) { + try { + return fine::decode>(env, buffer_term); + } catch (std::invalid_argument) { + throw std::invalid_argument( + "unable to get buffer. It may belong to another node, " + "consider using Nx.backend_transfer/1"); + } +} + +fine::ResourcePtr +mlir_new_thread_pool(ErlNifEnv *env, int64_t concurrency) { + auto strategy = llvm::hardware_concurrency(concurrency); + return fine::make_resource(strategy); +} + +FINE_NIF(mlir_new_thread_pool, 0); + +fine::ResourcePtr +mlir_new_context(ErlNifEnv *env, + fine::ResourcePtr thread_pool) { + auto context = fine::make_resource( + mlir::MLIRContext::Threading::DISABLED); + + context->setThreadPool(*thread_pool); + context->getOrLoadDialect(); + context->getOrLoadDialect(); + context->getOrLoadDialect(); + + return context; +} + +FINE_NIF(mlir_new_context, 0); + +fine::ResourcePtr +mlir_new_module(ErlNifEnv *env, fine::ResourcePtr ctx) { + return fine::make_resource(ctx); +} + +FINE_NIF(mlir_new_module, 0); + +fine::ResourcePtr mlir_create_function( + ErlNifEnv *env, fine::ResourcePtr module, std::string func_name, + std::vector arg_type_strings, + std::vector ret_type_strings, bool is_public) { + auto arg_types = std::vector{}; + + for (auto const &type_string : arg_type_strings) { + auto type = module->ParseType(type_string); + arg_types.push_back(type); + } + + auto ret_types = std::vector{}; + + for (auto const &type_string : ret_type_strings) { + auto type = module->ParseType(type_string); + ret_types.push_back(type); + } + + auto func_op = + module->CreateFunction(func_name, arg_types, ret_types, is_public); + return fine::make_resource(module, std::move(func_op)); +} + +FINE_NIF(mlir_create_function, 0); + +std::vector> +mlir_get_function_arguments(ErlNifEnv *env, + fine::ResourcePtr function) { + auto args = function->GetArguments(); + std::vector> values; + values.reserve(args.size()); + + for (const auto &arg : args) { + values.push_back(fine::make_resource(arg)); + } + + return values; +} + +FINE_NIF(mlir_get_function_arguments, 0); + +std::vector> +mlir_op(ErlNifEnv *env, fine::ResourcePtr function, + std::string op_name, + std::vector> operands, + std::vector result_type_strings, + std::vector> attributes_kwlist, + std::vector> regions) { + auto result_types = std::vector{}; + + for (auto const &type_string : result_type_strings) { + auto type = function->module()->ParseType(type_string); + result_types.push_back(type); + } + + auto attributes = std::vector>{}; + + for (auto const &[key, value] : attributes_kwlist) { + auto attribute_value = function->module()->ParseAttribute(value); + attributes.push_back(std::make_tuple(key.to_string(), attribute_value)); + } + + return function->Op(op_name, operands, result_types, attributes, regions); +} + +FINE_NIF(mlir_op, 0); + +std::tuple, + std::vector>> +mlir_push_region(ErlNifEnv *env, fine::ResourcePtr function, + std::vector arg_types) { + auto types = std::vector{}; + + for (auto const &type_string : arg_types) { + auto type = function->module()->ParseType(type_string); + types.push_back(type); + } + + return function->PushRegion(types); +} + +FINE_NIF(mlir_push_region, 0); + +fine::Ok<> mlir_pop_region(ErlNifEnv *env, + fine::ResourcePtr function) { + function->PopRegion(); + return fine::Ok(); +} + +FINE_NIF(mlir_pop_region, 0); + +mlir::Type mlir_get_typespec(ErlNifEnv *env, + fine::ResourcePtr value) { + return value->getType(); +} + +FINE_NIF(mlir_get_typespec, 0); + +std::string mlir_module_to_string(ErlNifEnv *env, + fine::ResourcePtr module) { + return module->ToString(); +} + +FINE_NIF(mlir_module_to_string, 0); + +template T unwrap(tsl::StatusOr status_or) { + if (!status_or.ok()) { + throw std::runtime_error(status_or.status().message().data()); + } + + return std::move(status_or.value()); +} + +void unwrap(tsl::Status status) { + if (!status.ok()) { + throw std::runtime_error(status.message().data()); + } +} + +fine::ResourcePtr +mlir_compile(ErlNifEnv *env, fine::ResourcePtr client, + fine::ResourcePtr module, + std::vector argument_layouts, int64_t num_replicas, + int64_t num_partitions, bool use_spmd, int64_t device_id) { + auto build_options = xla::ExecutableBuildOptions(); + + build_options.set_num_replicas(num_replicas); + build_options.set_num_partitions(num_partitions); + build_options.set_use_spmd_partitioning(use_spmd); + + auto compile_portable_executable = false; + if (device_id >= 0) { + compile_portable_executable = true; + build_options.set_device_ordinal(device_id); + } + + return unwrap(client->Compile(module->module(), argument_layouts, + build_options, compile_portable_executable)); +} + +FINE_NIF(mlir_compile, ERL_NIF_DIRTY_JOB_CPU_BOUND); + +// ExlaBuffer Functions + +std::variant, + std::tuple, + std::tuple> +get_buffer_device_pointer(ErlNifEnv *env, fine::ResourcePtr client, + fine::Term buffer_term, fine::Atom pointer_kind) { + auto buffer = decode_exla_buffer(env, buffer_term); + + uint64_t device_size = unwrap(buffer->GetOnDeviceSizeInBytes()); + uint64_t ptr = unwrap(buffer->GetDevicePointer(client->client())); + + if (pointer_kind == "local") { + return std::make_tuple(pointer_kind, ptr, device_size); + } + + if (pointer_kind == "host_ipc") { + auto handle_name = + "exla:ipc:" + std::to_string(device_size) + ":" + std::to_string(ptr); + auto fd = get_ipc_handle(handle_name.c_str(), device_size); + + if (fd == -1) { + throw std::runtime_error("unable to get IPC handle"); + } + + auto ipc_ptr = open_ipc_handle(fd, device_size); + if (ipc_ptr == nullptr) { + throw std::runtime_error("unable to open IPC handle"); + } + + memcpy(ipc_ptr, reinterpret_cast(ptr), device_size); + + return std::make_tuple(pointer_kind, handle_name, static_cast(fd), + device_size); + } + + if (pointer_kind == "cuda_ipc") { + auto maybe_handle = get_cuda_ipc_handle(ptr); + if (!maybe_handle) { + throw std::runtime_error("unable to get cuda IPC handle"); + } + + return std::make_tuple(pointer_kind, maybe_handle.value(), device_size); + } + + throw std::invalid_argument("unexpected pointer type"); +} + +FINE_NIF(get_buffer_device_pointer, 0); + +fine::ResourcePtr create_buffer_from_device_pointer( + ErlNifEnv *env, fine::ResourcePtr client, + fine::Atom pointer_kind, fine::Term pointer_data, xla::Shape shape, + int64_t device_id) { + void *ptr = nullptr; + std::function on_delete_callback = []() {}; + + if (pointer_kind == "cuda_ipc") { + auto cuda_ipc_handle_bin = fine::decode(env, pointer_data); + auto maybe_pointer = get_pointer_for_ipc_handle( + cuda_ipc_handle_bin.data, cuda_ipc_handle_bin.size, device_id); + if (!maybe_pointer) { + throw std::runtime_error("unable to get pointer for IPC handle"); + } + ptr = maybe_pointer.value(); + } else if (pointer_kind == "host_ipc") { + auto tuple = + fine::decode>(env, pointer_data); + auto fd = std::get<0>(tuple); + auto memname = std::get<1>(tuple); + auto device_size = xla::ShapeUtil::ByteSizeOf(shape); + ptr = open_ipc_handle(fd, device_size); + if (ptr == nullptr) { + throw std::runtime_error("unable to get pointer for IPC handle"); + } + on_delete_callback = [fd, memname, ptr, device_size]() { + close_ipc_handle(fd, ptr, memname.c_str(), device_size); + }; + } else if (pointer_kind == "local") { + auto ptr_int = fine::decode(env, pointer_data); + ptr = reinterpret_cast(ptr_int); + } else { + throw std::invalid_argument("unexpected pointer type"); + } + + auto device = unwrap( + client->client()->LookupDevice(xla::PjRtGlobalDeviceId(device_id))); + auto memory_space = unwrap(device->default_memory_space()); + auto buffer = unwrap(client->client()->CreateViewOfDeviceBuffer( + ptr, shape, memory_space, on_delete_callback)); + return fine::make_resource(std::move(buffer)); +} + +FINE_NIF(create_buffer_from_device_pointer, 0); + +fine::ResourcePtr +binary_to_device_mem(ErlNifEnv *env, fine::ResourcePtr client, + fine::Term data, xla::Shape shape, int64_t device_id) { + return unwrap(client->BufferFromBinary(data, shape, device_id)); +} + +FINE_NIF(binary_to_device_mem, ERL_NIF_DIRTY_JOB_IO_BOUND); + +fine::Term read_device_mem(ErlNifEnv *env, fine::Term buffer_term, + int64_t size) { + auto buffer = decode_exla_buffer(env, buffer_term); + return unwrap(buffer->ToBinary(env, size)); +} + +FINE_NIF(read_device_mem, ERL_NIF_DIRTY_JOB_IO_BOUND); + +std::variant, fine::Error> +deallocate_device_mem(ErlNifEnv *env, fine::Term buffer_term) { + auto buffer = decode_exla_buffer(env, buffer_term); + + tsl::Status dealloc_status = buffer->Deallocate(); + + if (!dealloc_status.ok()) { + return fine::Error(atoms::already_deallocated); + } else { + return fine::Ok(); + } +} + +FINE_NIF(deallocate_device_mem, ERL_NIF_DIRTY_JOB_IO_BOUND); + +fine::Ok<> transfer_to_infeed(ErlNifEnv *env, + fine::ResourcePtr client, + int64_t device_id, + std::vector buffers, + std::vector shapes) { + unwrap(client->TransferToInfeed(env, buffers, shapes, device_id)); + + return fine::Ok(); +} + +FINE_NIF(transfer_to_infeed, ERL_NIF_DIRTY_JOB_IO_BOUND); + +fine::Ok<> transfer_from_outfeed(ErlNifEnv *env, + fine::ResourcePtr client, + int64_t device_id, + std::vector shapes, ErlNifPid pid, + fine::Term ref) { + for (auto &shape : shapes) { + auto msg_env = enif_alloc_env(); + auto msg = unwrap(client->TransferFromOutfeed(msg_env, device_id, shape)); + enif_send(env, &pid, msg_env, enif_make_tuple(msg_env, 2, ref, msg)); + enif_free_env(msg_env); + } + + return fine::Ok(); +} + +FINE_NIF(transfer_from_outfeed, ERL_NIF_DIRTY_JOB_IO_BOUND); + +fine::ResourcePtr +copy_buffer_to_device(ErlNifEnv *env, fine::ResourcePtr client, + fine::Term buffer_term, int64_t device_id) { + auto buffer = decode_exla_buffer(env, buffer_term); + + auto device = unwrap( + client->client()->LookupDevice(xla::PjRtGlobalDeviceId(device_id))); + + return unwrap(buffer->CopyToDevice(device)); +} + +FINE_NIF(copy_buffer_to_device, ERL_NIF_DIRTY_JOB_IO_BOUND); + +// ExlaClient Functions + +fine::ResourcePtr get_host_client(ErlNifEnv *env) { + return unwrap(GetHostClient()); +} + +FINE_NIF(get_host_client, 0); + +fine::ResourcePtr +get_gpu_client(ErlNifEnv *env, double memory_fraction, bool preallocate) { + return unwrap(GetGpuClient(memory_fraction, preallocate, + xla::GpuAllocatorConfig::Kind::kBFC)); +} + +FINE_NIF(get_gpu_client, 0); + +fine::ResourcePtr get_tpu_client(ErlNifEnv *env) { + return unwrap(GetTpuClient()); +} + +FINE_NIF(get_tpu_client, 0); + +fine::ResourcePtr get_c_api_client(ErlNifEnv *env, + std::string device_type) { + return unwrap(GetCApiClient(device_type)); +} + +FINE_NIF(get_c_api_client, 0); + +fine::Ok<> load_pjrt_plugin(ErlNifEnv *env, std::string device_type, + std::string library_path) { + unwrap(pjrt::LoadPjrtPlugin(device_type, library_path)); + return fine::Ok(); +} + +FINE_NIF(load_pjrt_plugin, 0); + +int64_t get_device_count(ErlNifEnv *env, fine::ResourcePtr client) { + return client->client()->device_count(); +} + +FINE_NIF(get_device_count, 0); + +std::map get_supported_platforms(ErlNifEnv *env) { + auto platforms = unwrap(xla::PlatformUtil::GetSupportedPlatforms()); + + std::map platform_info; + + for (auto &platform : platforms) { + auto key = fine::Atom(absl::AsciiStrToLower(platform->Name())); + auto device_count = platform->VisibleDeviceCount(); + platform_info.insert({key, device_count}); + } + + return platform_info; +} + +FINE_NIF(get_supported_platforms, 0); + +// ExlaExecutable Functions + +ExlaExecutable::RunResult run(ErlNifEnv *env, + fine::ResourcePtr executable, + ExlaExecutable::RunArguments arguments, + int64_t device_id) { + return unwrap(executable->Run(env, arguments, device_id)); +} + +ExlaExecutable::RunResult run_cpu(ErlNifEnv *env, + fine::ResourcePtr executable, + ExlaExecutable::RunArguments arguments, + int64_t device_id) { + return run(env, executable, arguments, device_id); +} + +FINE_NIF(run_cpu, ERL_NIF_DIRTY_JOB_CPU_BOUND); + +ExlaExecutable::RunResult run_io(ErlNifEnv *env, + fine::ResourcePtr executable, + ExlaExecutable::RunArguments arguments, + int64_t device_id) { + return run(env, executable, arguments, device_id); +} + +FINE_NIF(run_io, ERL_NIF_DIRTY_JOB_IO_BOUND); + +// Serialization Functions + +std::string serialize_executable(ErlNifEnv *env, + fine::ResourcePtr executable) { + return unwrap(executable->SerializeExecutable()); +} + +FINE_NIF(serialize_executable, 0); + +fine::ResourcePtr +deserialize_executable(ErlNifEnv *env, fine::ResourcePtr client, + std::string serialized) { + return unwrap(client->DeserializeExecutable(serialized)); +} + +FINE_NIF(deserialize_executable, 0); + +// Logging + +fine::Ok<> start_log_sink(ErlNifEnv *env, ErlNifPid logger_pid) { + ExlaLogSink *sink = new ExlaLogSink(logger_pid); + + // NO_DEFAULT_LOGGER doesn't behave right + for (auto *log_sink : tsl::TFGetLogSinks()) { + tsl::TFRemoveLogSink(log_sink); + } + + tsl::TFAddLogSink(sink); + + return fine::Ok(); +} + +FINE_NIF(start_log_sink, 0); + +} // namespace exla + +FINE_INIT("Elixir.EXLA.NIF"); diff --git a/deps/exla/c_src/exla/exla_client.h b/deps/exla/c_src/exla/exla_client.h new file mode 100644 index 0000000000000000000000000000000000000000..fbab1d51e13e32c1eba8cc4702a653ee1606994b --- /dev/null +++ b/deps/exla/c_src/exla/exla_client.h @@ -0,0 +1,120 @@ +#ifndef EXLA_CLIENT_H_ +#define EXLA_CLIENT_H_ + +#include +#include +#include + +#include +#include +#include "exla_types.h" +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/OwningOpRef.h" +#include "xla/pjrt/gpu/gpu_helpers.h" +#include "xla/pjrt/pjrt_client.h" +#include "xla/shape.h" + +// The implementations in this module are designed after implementations +// in the XLA runtime, PjRt. Deviations are made where it makes sense +// to work better with the VM. + +namespace exla { + +class ExlaClient; + +class ExlaBuffer { + public: + ExlaBuffer(std::unique_ptr buffer); + + int device_id() { return buffer_->device()->id(); } + xla::PjRtBuffer* buffer() { return buffer_.get(); } + tsl::StatusOr> CopyToDevice(xla::PjRtDevice* dst_device); + tsl::StatusOr ToBinary(ErlNifEnv* env, exla::int64 size); + tsl::Status Deallocate(); + + tsl::StatusOr GetDevicePointer(xla::PjRtClient* client) { + return client->UnsafeBufferPointer(buffer_.get()); + } + + tsl::StatusOr GetOnDeviceSizeInBytes() { + return buffer_.get()->GetOnDeviceSizeInBytes(); + } + + ~ExlaBuffer() { + // Theoretically this may block if a computation is running + // but we always block the host until the computation is done. + } + + private: + std::unique_ptr buffer_; +}; + +class ExlaExecutable { + public: + using ReplicaArgument = std::variant, std::tuple>; + using RunArguments = std::vector>; + + using RunReplicaResult = std::tuple>, int64_t>; + using RunResult =std::vector; + + ExlaExecutable(std::unique_ptr executable, + absl::optional fingerprint, + ExlaClient* client); + + xla::PjRtLoadedExecutable* executable() { return executable_.get(); } + + tsl::StatusOr Run(ErlNifEnv* env, RunArguments arguments, int device_id); + + tsl::StatusOr SerializeExecutable() { return executable_->SerializeExecutable(); } + + private: + std::unique_ptr executable_; + absl::optional fingerprint_; + ExlaClient* client_; +}; + +class ExlaClient { + public: + explicit ExlaClient(std::shared_ptr client); + + virtual ~ExlaClient() = default; + + xla::PjRtClient* client() { return client_.get(); } + + // Compiles the given computation with the given compile options + + tsl::StatusOr> Compile(mlir::ModuleOp computation, + std::vector argument_layouts, + xla::ExecutableBuildOptions& options, + bool compile_portable_executable); + + tsl::StatusOr> BufferFromBinary(ERL_NIF_TERM binary_term, + xla::Shape& shape, + int device_id); + + tsl::StatusOr> DeserializeExecutable(std::string serialized_executable); + + // TODO(seanmor5): This is device logic and should be refactored + tsl::Status TransferToInfeed(ErlNifEnv* env, + std::vector buffer_bins, + std::vector shapes, + int device_id); + + tsl::StatusOr TransferFromOutfeed(ErlNifEnv* env, int device_id, xla::Shape& shape); + + private: + std::shared_ptr client_; +}; + +tsl::StatusOr> GetHostClient(); + +tsl::StatusOr> GetGpuClient(double memory_fraction, + bool preallocate, + xla::GpuAllocatorConfig::Kind kind); + +tsl::StatusOr> GetTpuClient(); + +tsl::StatusOr> GetCApiClient(std::string device_type); +} // namespace exla + +#endif diff --git a/deps/exla/c_src/exla/exla_log_sink.h b/deps/exla/c_src/exla/exla_log_sink.h new file mode 100644 index 0000000000000000000000000000000000000000..54d2a9cff6de5ecaed9376b66ee25faa307ab144 --- /dev/null +++ b/deps/exla/c_src/exla/exla_log_sink.h @@ -0,0 +1,64 @@ +#ifndef EXLA_LOG_SINK_H_ +#define EXLA_LOG_SINK_H_ + +#include + +#include "absl/base/log_severity.h" +#include "exla_nif_util.h" +#include +#include "tsl/platform/logging.h" + +namespace exla { + +// Redirects calls to logging to the Elixir Logger. `sink_pid` +// is the PID for a GenServer in Elixir which receives messages +// with logging information on every call to `LOG(severity)`. +class ExlaLogSink : public tsl::TFLogSink { +public: + explicit ExlaLogSink(ErlNifPid sink_pid) : sink_pid_(sink_pid) {} + + void Send(const tsl::TFLogEntry &entry) { + auto string = entry.ToString(); + auto fname = entry.FName(); + int64_t line = entry.Line(); + auto severity = entry.log_severity(); + + if (severity == absl::LogSeverity::kFatal) { + // LOG(FATAL) aborts the program before we are able to send and + // log the information from Elixir, so we need to get it out + // there for debugging before everything crashes + std::cerr << "[FATAL] " << fname << ":" << line << " " << string << "\n"; + } + + auto env = enif_alloc_env(); + + auto message = fine::encode( + env, std::make_tuple(severity_to_atom(severity), string, fname, line)); + + enif_send(NULL, &sink_pid_, env, message); + + enif_free_env(env); + } + +private: + fine::Atom severity_to_atom(absl::LogSeverity severity) { + switch (severity) { + case absl::LogSeverity::kInfo: + return atoms::info; + case absl::LogSeverity::kWarning: + return atoms::warning; + case absl::LogSeverity::kError: + return atoms::error; + case absl::LogSeverity::kFatal: + return atoms::error; + default: + return atoms::info; + } + } + + ErlNifPid sink_pid_; +}; + +} // namespace exla + +#endif diff --git a/deps/exla/c_src/exla/exla_mlir.h b/deps/exla/c_src/exla/exla_mlir.h new file mode 100644 index 0000000000000000000000000000000000000000..095ad4c1a789580338dfb47d0d0ad6b2994b9897 --- /dev/null +++ b/deps/exla/c_src/exla/exla_mlir.h @@ -0,0 +1,70 @@ +#ifndef EXLA_MLIR_BUILDER_H_ +#define EXLA_MLIR_BUILDER_H_ + +#include +#include + +#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/MLIRContext.h" +#include "mlir/IR/OwningOpRef.h" + +namespace exla { + +class MLIRModule; + +class MLIRFunction { + public: + MLIRFunction(fine::ResourcePtr module, std::unique_ptr func); + + std::vector> Op( + std::string op_name, std::vector> operands, + std::vector result_types, + std::vector> attributes, + std::vector> regions); + + std::tuple, std::vector>> PushRegion(std::vector types); + void PopRegion(); + + llvm::MutableArrayRef GetArguments() { return func_->getBody().front().getArguments(); } + + fine::ResourcePtr module() { return module_; } + + private: + fine::ResourcePtr module_; + std::unique_ptr func_; + + std::stack> region_stack; + + void setInsertionPoint(); +}; + +class MLIRModule { + public: + MLIRModule(fine::ResourcePtr context); + + std::unique_ptr CreateFunction( + std::string name, + std::vector arg_types, + std::vector ret_types, + bool is_public); + + std::string ToString(); + + // Note: ParseAttribute and ParseType return nullptr if the parsing fails + mlir::Type ParseType(std::string); + mlir::Attribute ParseAttribute(std::string); + + mlir::ModuleOp module() { return module_.get(); } + mlir::OpBuilder *builder() { return builder_.get(); } + + private: + fine::ResourcePtr context_; + mlir::OwningOpRef module_; + std::unique_ptr builder_; +}; + +} // namespace exla + +#endif diff --git a/deps/exla/c_src/exla/exla_nif_util.h b/deps/exla/c_src/exla/exla_nif_util.h new file mode 100644 index 0000000000000000000000000000000000000000..714f74f2dabc7296dd9f55e7a3a5dc0d0cc32c07 --- /dev/null +++ b/deps/exla/c_src/exla/exla_nif_util.h @@ -0,0 +1,270 @@ +#ifndef EXLA_NIF_UTIL_H_ +#define EXLA_NIF_UTIL_H_ + +#include +#include + +#include "xla/shape.h" +#include "xla/shape_util.h" +#include "mlir/IR/Types.h" +#include "stablehlo/dialect/StablehloOps.h" + +namespace exla { + +namespace atoms { +static auto ElixirEXLATypespec = fine::Atom("Elixir.EXLA.Typespec"); +static auto __struct__ = fine::Atom("__struct__"); +static auto already_deallocated = fine::Atom("already_deallocated"); +static auto bf = fine::Atom("bf"); +static auto c = fine::Atom("c"); +static auto error = fine::Atom("error"); +static auto f = fine::Atom("f"); +static auto info = fine::Atom("info"); +static auto pred = fine::Atom("pred"); +static auto s = fine::Atom("s"); +static auto shape = fine::Atom("shape"); +static auto token = fine::Atom("token"); +static auto type = fine::Atom("type"); +static auto u = fine::Atom("u"); +static auto warning = fine::Atom("warning"); +} // namespace atoms +} // namespace exla + +namespace fine { + +// Define decoding for xla::Shape from for %EXLA.Typespec{} term +template <> struct Decoder { + static xla::Shape decode(ErlNifEnv *env, const ERL_NIF_TERM &term) { + ERL_NIF_TERM type_term; + ERL_NIF_TERM shape_term; + + if (!enif_get_map_value(env, term, fine::encode(env, exla::atoms::type), + &type_term)) { + throw std::invalid_argument( + "decode failed, expected EXLA.Typespec struct"); + } + + if (!enif_get_map_value(env, term, fine::encode(env, exla::atoms::shape), + &shape_term)) { + throw std::invalid_argument( + "decode failed, expected EXLA.Typespec struct"); + } + + return xla::ShapeUtil::MakeShape(decode_type(env, type_term), + decode_shape(env, shape_term)); + } + +private: + static std::vector decode_shape(ErlNifEnv *env, + const ERL_NIF_TERM &term) { + int size; + const ERL_NIF_TERM *terms; + + if (!enif_get_tuple(env, term, &size, &terms)) { + throw std::invalid_argument( + "decode failed, expected shape to be a tuple"); + } + + auto vector = std::vector(); + vector.reserve(size); + + for (auto i = 0; i < size; i++) { + auto elem = fine::decode(env, terms[i]); + vector.push_back(elem); + } + + return vector; + } + + static xla::PrimitiveType decode_type(ErlNifEnv *env, + const ERL_NIF_TERM &term) { + auto [element, size] = + fine::decode>(env, term); + + if (element == "u") { + switch (size) { + case 2: + return xla::U2; + case 4: + return xla::U4; + case 8: + return xla::U8; + case 16: + return xla::U16; + case 32: + return xla::U32; + case 64: + return xla::U64; + } + } + if (element == "s") { + switch (size) { + case 2: + return xla::S2; + case 4: + return xla::S4; + case 8: + return xla::S8; + case 16: + return xla::S16; + case 32: + return xla::S32; + case 64: + return xla::S64; + } + } + if (element == "f") { + switch (size) { + case 8: + return xla::F8E5M2; + case 16: + return xla::F16; + case 32: + return xla::F32; + case 64: + return xla::F64; + } + } + if (element == "bf") { + switch (size) { + case 16: + return xla::BF16; + } + } + if (element == "c") { + switch (size) { + case 64: + return xla::C64; + case 128: + return xla::C128; + } + } + if (element == "pred") { + return xla::PRED; + } + + throw std::invalid_argument("decode failed, unexpected type"); + } +}; + +// Define encoding for mlir::Type into %EXLA.Typespec{} term +template <> struct Encoder { + static ERL_NIF_TERM encode(ErlNifEnv *env, const mlir::Type &type) { + ERL_NIF_TERM keys[] = { + fine::encode(env, exla::atoms::__struct__), + fine::encode(env, exla::atoms::type), + fine::encode(env, exla::atoms::shape), + }; + + ERL_NIF_TERM values[] = { + fine::encode(env, exla::atoms::ElixirEXLATypespec), + encode_type(env, type), + encode_shape(env, type), + }; + + ERL_NIF_TERM map; + if (!enif_make_map_from_arrays(env, keys, values, 3, &map)) { + throw std::runtime_error("encode: failed to make a map"); + } + + return map; + } + +private: + static ERL_NIF_TERM encode_type(ErlNifEnv *env, const mlir::Type &type) { + if (mlir::isa(type)) { + return fine::encode(env, exla::atoms::token); + } + + std::optional type_name; + std::optional type_size; + + if (mlir::isa(type)) { + auto tensor_type = mlir::cast(type); + auto element_type = tensor_type.getElementType(); + + if (element_type.isSignlessInteger(1)) { + type_name = exla::atoms::pred; + type_size = 8; + } else if (auto integer_type = + mlir::dyn_cast(element_type)) { + if (integer_type.isUnsigned()) { + type_name = exla::atoms::u; + } else { + type_name = exla::atoms::s; + } + + type_size = integer_type.getWidth(); + } else if (element_type.isBF16()) { + type_name = exla::atoms::bf; + type_size = 16; + } else if (auto float_type = + mlir::dyn_cast(element_type)) { + type_name = exla::atoms::f; + type_size = float_type.getWidth(); + } else if (auto complex_type = + mlir::dyn_cast(element_type)) { + auto element_type = complex_type.getElementType(); + type_name = exla::atoms::c; + type_size = mlir::cast(element_type).getWidth() * 2; + } + } + + if (type_name) { + return fine::encode( + env, std::make_tuple(type_name.value(), type_size.value())); + } else { + throw std::invalid_argument("encode failed, unexpected mlir type"); + } + } + + static ERL_NIF_TERM encode_shape(ErlNifEnv *env, const mlir::Type &type) { + if (mlir::isa(type)) { + return enif_make_tuple(env, 0); + } + + if (mlir::isa(type)) { + auto tensor_type = mlir::cast(type); + auto dims_array = tensor_type.getShape(); + + auto dims = std::vector{}; + dims.reserve(dims_array.size()); + + for (auto dim : dims_array) { + dims.push_back(fine::encode(env, dim)); + } + + return enif_make_tuple_from_array(env, dims.data(), dims.size()); + } + + throw std::invalid_argument("encode failed, unexpected mlir type"); + } +}; +} // namespace fine + +// Helper Macros +// +// See: +// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/stream_executor/lib/statusor.h + +#define EXLA_STATUS_MACROS_CONCAT_NAME(x, y) \ + EXLA_STATUS_MACROS_CONCAT_NAME_IMPL(x, y) + +#define EXLA_STATUS_MACROS_CONCAT_NAME_IMPL(x, y) x##y + +// Macro to be used to consume StatusOr. Will bind lhs +// to value if the status is OK, otherwise will return +// the status. +#define EXLA_ASSIGN_OR_RETURN(lhs, rexpr) \ + EXLA_ASSIGN_OR_RETURN_IMPL( \ + EXLA_STATUS_MACROS_CONCAT_NAME(_status_or_value, __COUNTER__), lhs, \ + rexpr) + +#define EXLA_ASSIGN_OR_RETURN_IMPL(statusor, lhs, rexpr) \ + auto statusor = (rexpr); \ + if (!statusor.ok()) { \ + return statusor.status(); \ + } \ + lhs = std::move(statusor.value()); + +#endif diff --git a/deps/exla/cache/0.10.0/objs/exla_mlir.o b/deps/exla/cache/0.10.0/objs/exla_mlir.o new file mode 100644 index 0000000000000000000000000000000000000000..0173fcce99867ac70afb182d3249335e26db5ad0 Binary files /dev/null and b/deps/exla/cache/0.10.0/objs/exla_mlir.o differ diff --git a/deps/exla/cache/0.10.0/objs/ipc.o b/deps/exla/cache/0.10.0/objs/ipc.o new file mode 100644 index 0000000000000000000000000000000000000000..644370cfb9caa2b0cabccb6c73a9a8d1e09553fa Binary files /dev/null and b/deps/exla/cache/0.10.0/objs/ipc.o differ diff --git a/deps/exla/cache/xla_extension/include/_virtual_includes/FXdiv/fxdiv.h b/deps/exla/cache/xla_extension/include/_virtual_includes/FXdiv/fxdiv.h new file mode 100644 index 0000000000000000000000000000000000000000..2c35038d97c55c524bb97caba2e3560cab9da504 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/_virtual_includes/FXdiv/fxdiv.h @@ -0,0 +1,425 @@ +#pragma once +#ifndef FXDIV_H +#define FXDIV_H + +#if defined(__cplusplus) && (__cplusplus >= 201103L) + #include + #include + #include +#elif !defined(__OPENCL_VERSION__) + #include + #include + #include +#endif + +#if defined(_MSC_VER) + #include + #if defined(_M_IX86) || defined(_M_X64) + #include + #endif +#endif + +#ifndef FXDIV_USE_INLINE_ASSEMBLY + #define FXDIV_USE_INLINE_ASSEMBLY 0 +#endif + +static inline uint64_t fxdiv_mulext_uint32_t(uint32_t a, uint32_t b) { +#if defined(_MSC_VER) && defined(_M_IX86) + return (uint64_t) __emulu((unsigned int) a, (unsigned int) b); +#else + return (uint64_t) a * (uint64_t) b; +#endif +} + +static inline uint32_t fxdiv_mulhi_uint32_t(uint32_t a, uint32_t b) { +#if defined(__OPENCL_VERSION__) + return mul_hi(a, b); +#elif defined(__CUDA_ARCH__) + return (uint32_t) __umulhi((unsigned int) a, (unsigned int) b); +#elif defined(_MSC_VER) && defined(_M_IX86) + return (uint32_t) (__emulu((unsigned int) a, (unsigned int) b) >> 32); +#elif defined(_MSC_VER) && defined(_M_ARM) + return (uint32_t) _MulUnsignedHigh((unsigned long) a, (unsigned long) b); +#else + return (uint32_t) (((uint64_t) a * (uint64_t) b) >> 32); +#endif +} + +static inline uint64_t fxdiv_mulhi_uint64_t(uint64_t a, uint64_t b) { +#if defined(__OPENCL_VERSION__) + return mul_hi(a, b); +#elif defined(__CUDA_ARCH__) + return (uint64_t) __umul64hi((unsigned long long) a, (unsigned long long) b); +#elif defined(_MSC_VER) && defined(_M_X64) + return (uint64_t) __umulh((unsigned __int64) a, (unsigned __int64) b); +#elif defined(__GNUC__) && defined(__SIZEOF_INT128__) + return (uint64_t) (((((unsigned __int128) a) * ((unsigned __int128) b))) >> 64); +#else + const uint32_t a_lo = (uint32_t) a; + const uint32_t a_hi = (uint32_t) (a >> 32); + const uint32_t b_lo = (uint32_t) b; + const uint32_t b_hi = (uint32_t) (b >> 32); + + const uint64_t t = fxdiv_mulext_uint32_t(a_hi, b_lo) + + (uint64_t) fxdiv_mulhi_uint32_t(a_lo, b_lo); + return fxdiv_mulext_uint32_t(a_hi, b_hi) + (t >> 32) + + ((fxdiv_mulext_uint32_t(a_lo, b_hi) + (uint64_t) (uint32_t) t) >> 32); +#endif +} + +static inline size_t fxdiv_mulhi_size_t(size_t a, size_t b) { +#if SIZE_MAX == UINT32_MAX + return (size_t) fxdiv_mulhi_uint32_t((uint32_t) a, (uint32_t) b); +#elif SIZE_MAX == UINT64_MAX + return (size_t) fxdiv_mulhi_uint64_t((uint64_t) a, (uint64_t) b); +#else + #error Unsupported platform +#endif +} + +struct fxdiv_divisor_uint32_t { + uint32_t value; + uint32_t m; + uint8_t s1; + uint8_t s2; +}; + +struct fxdiv_result_uint32_t { + uint32_t quotient; + uint32_t remainder; +}; + +struct fxdiv_divisor_uint64_t { + uint64_t value; + uint64_t m; + uint8_t s1; + uint8_t s2; +}; + +struct fxdiv_result_uint64_t { + uint64_t quotient; + uint64_t remainder; +}; + +struct fxdiv_divisor_size_t { + size_t value; + size_t m; + uint8_t s1; + uint8_t s2; +}; + +struct fxdiv_result_size_t { + size_t quotient; + size_t remainder; +}; + +static inline struct fxdiv_divisor_uint32_t fxdiv_init_uint32_t(uint32_t d) { + struct fxdiv_divisor_uint32_t result = { d }; + if (d == 1) { + result.m = UINT32_C(1); + result.s1 = 0; + result.s2 = 0; + } else { + #if defined(__OPENCL_VERSION__) + const uint32_t l_minus_1 = 31 - clz(d - 1); + #elif defined(__CUDA_ARCH__) + const uint32_t l_minus_1 = 31 - __clz((int) (d - 1)); + #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64)) + unsigned long l_minus_1; + _BitScanReverse(&l_minus_1, (unsigned long) (d - 1)); + #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && FXDIV_USE_INLINE_ASSEMBLY + uint32_t l_minus_1; + __asm__("BSRL %[d_minus_1], %[l_minus_1]" + : [l_minus_1] "=r" (l_minus_1) + : [d_minus_1] "r" (d - 1) + : "cc"); + #elif defined(__GNUC__) + const uint32_t l_minus_1 = 31 - __builtin_clz(d - 1); + #else + /* Based on Algorithm 2 from Hacker's delight */ + + uint32_t l_minus_1 = 0; + uint32_t x = d - 1; + uint32_t y = x >> 16; + if (y != 0) { + l_minus_1 += 16; + x = y; + } + y = x >> 8; + if (y != 0) { + l_minus_1 += 8; + x = y; + } + y = x >> 4; + if (y != 0) { + l_minus_1 += 4; + x = y; + } + y = x >> 2; + if (y != 0) { + l_minus_1 += 2; + x = y; + } + if ((x & 2) != 0) { + l_minus_1 += 1; + } + #endif + uint32_t u_hi = (UINT32_C(2) << (uint32_t) l_minus_1) - d; + + /* Division of 64-bit number u_hi:UINT32_C(0) by 32-bit number d, 32-bit quotient output q */ + #if defined(__GNUC__) && defined(__i386__) && FXDIV_USE_INLINE_ASSEMBLY + uint32_t q; + __asm__("DIVL %[d]" + : "=a" (q), "+d" (u_hi) + : [d] "r" (d), "a" (0) + : "cc"); + #elif (defined(_MSC_VER) && _MSC_VER >= 1920) && !defined(__clang__) && !defined(__INTEL_COMPILER) && (defined(_M_IX86) || defined(_M_X64)) + unsigned int remainder; + const uint32_t q = (uint32_t) _udiv64((unsigned __int64) ((uint64_t) u_hi << 32), (unsigned int) d, &remainder); + #else + const uint32_t q = ((uint64_t) u_hi << 32) / d; + #endif + + result.m = q + UINT32_C(1); + result.s1 = 1; + result.s2 = (uint8_t) l_minus_1; + } + return result; +} + +static inline struct fxdiv_divisor_uint64_t fxdiv_init_uint64_t(uint64_t d) { + struct fxdiv_divisor_uint64_t result = { d }; + if (d == 1) { + result.m = UINT64_C(1); + result.s1 = 0; + result.s2 = 0; + } else { + #if defined(__OPENCL_VERSION__) + const uint32_t nlz_d = clz(d); + const uint32_t l_minus_1 = 63 - clz(d - 1); + #elif defined(__CUDA_ARCH__) + const uint32_t nlz_d = __clzll((long long) d); + const uint32_t l_minus_1 = 63 - __clzll((long long) (d - 1)); + #elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64)) + unsigned long l_minus_1; + _BitScanReverse64(&l_minus_1, (unsigned __int64) (d - 1)); + unsigned long bsr_d; + _BitScanReverse64(&bsr_d, (unsigned __int64) d); + const uint32_t nlz_d = bsr_d ^ 0x3F; + #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_ARM)) + const uint64_t d_minus_1 = d - 1; + const uint8_t d_is_power_of_2 = (d & d_minus_1) == 0; + unsigned long l_minus_1; + if ((uint32_t) (d_minus_1 >> 32) == 0) { + _BitScanReverse(&l_minus_1, (unsigned long) d_minus_1); + } else { + _BitScanReverse(&l_minus_1, (unsigned long) (uint32_t) (d_minus_1 >> 32)); + l_minus_1 += 32; + } + const uint32_t nlz_d = ((uint8_t) l_minus_1 ^ UINT8_C(0x3F)) - d_is_power_of_2; + #elif defined(__GNUC__) && defined(__x86_64__) && FXDIV_USE_INLINE_ASSEMBLY + uint64_t l_minus_1; + __asm__("BSRQ %[d_minus_1], %[l_minus_1]" + : [l_minus_1] "=r" (l_minus_1) + : [d_minus_1] "r" (d - 1) + : "cc"); + #elif defined(__GNUC__) + const uint32_t l_minus_1 = 63 - __builtin_clzll(d - 1); + const uint32_t nlz_d = __builtin_clzll(d); + #else + /* Based on Algorithm 2 from Hacker's delight */ + const uint64_t d_minus_1 = d - 1; + const uint32_t d_is_power_of_2 = (d & d_minus_1) == 0; + uint32_t l_minus_1 = 0; + uint32_t x = (uint32_t) d_minus_1; + uint32_t y = d_minus_1 >> 32; + if (y != 0) { + l_minus_1 += 32; + x = y; + } + y = x >> 16; + if (y != 0) { + l_minus_1 += 16; + x = y; + } + y = x >> 8; + if (y != 0) { + l_minus_1 += 8; + x = y; + } + y = x >> 4; + if (y != 0) { + l_minus_1 += 4; + x = y; + } + y = x >> 2; + if (y != 0) { + l_minus_1 += 2; + x = y; + } + if ((x & 2) != 0) { + l_minus_1 += 1; + } + const uint32_t nlz_d = (l_minus_1 ^ UINT32_C(0x3F)) - d_is_power_of_2; + #endif + uint64_t u_hi = (UINT64_C(2) << (uint32_t) l_minus_1) - d; + + /* Division of 128-bit number u_hi:UINT64_C(0) by 64-bit number d, 64-bit quotient output q */ + #if defined(__GNUC__) && defined(__x86_64__) && FXDIV_USE_INLINE_ASSEMBLY + uint64_t q; + __asm__("DIVQ %[d]" + : "=a" (q), "+d" (u_hi) + : [d] "r" (d), "a" (UINT64_C(0)) + : "cc"); + #elif 0 && defined(__GNUC__) && defined(__SIZEOF_INT128__) + /* GCC, Clang, and Intel Compiler fail to inline optimized implementation and call into support library for 128-bit division */ + const uint64_t q = (uint64_t) (((unsigned __int128) u_hi << 64) / ((unsigned __int128) d)); + #elif (defined(_MSC_VER) && _MSC_VER >= 1920) && !defined(__clang__) && !defined(__INTEL_COMPILER) && defined(_M_X64) + unsigned __int64 remainder; + const uint64_t q = (uint64_t) _udiv128((unsigned __int64) u_hi, 0, (unsigned __int64) d, &remainder); + #else + /* Implementation based on code from Hacker's delight */ + + /* Normalize divisor and shift divident left */ + d <<= nlz_d; + u_hi <<= nlz_d; + /* Break divisor up into two 32-bit digits */ + const uint64_t d_hi = (uint32_t) (d >> 32); + const uint32_t d_lo = (uint32_t) d; + + /* Compute the first quotient digit, q1 */ + uint64_t q1 = u_hi / d_hi; + uint64_t r1 = u_hi - q1 * d_hi; + + while ((q1 >> 32) != 0 || fxdiv_mulext_uint32_t((uint32_t) q1, d_lo) > (r1 << 32)) { + q1 -= 1; + r1 += d_hi; + if ((r1 >> 32) != 0) { + break; + } + } + + /* Multiply and subtract. */ + u_hi = (u_hi << 32) - q1 * d; + + /* Compute the second quotient digit, q0 */ + uint64_t q0 = u_hi / d_hi; + uint64_t r0 = u_hi - q0 * d_hi; + + while ((q0 >> 32) != 0 || fxdiv_mulext_uint32_t((uint32_t) q0, d_lo) > (r0 << 32)) { + q0 -= 1; + r0 += d_hi; + if ((r0 >> 32) != 0) { + break; + } + } + const uint64_t q = (q1 << 32) | (uint32_t) q0; + #endif + result.m = q + UINT64_C(1); + result.s1 = 1; + result.s2 = (uint8_t) l_minus_1; + } + return result; +} + +static inline struct fxdiv_divisor_size_t fxdiv_init_size_t(size_t d) { +#if SIZE_MAX == UINT32_MAX + const struct fxdiv_divisor_uint32_t uint_result = fxdiv_init_uint32_t((uint32_t) d); +#elif SIZE_MAX == UINT64_MAX + const struct fxdiv_divisor_uint64_t uint_result = fxdiv_init_uint64_t((uint64_t) d); +#else + #error Unsupported platform +#endif + struct fxdiv_divisor_size_t size_result = { + (size_t) uint_result.value, + (size_t) uint_result.m, + uint_result.s1, + uint_result.s2 + }; + return size_result; +} + +static inline uint32_t fxdiv_quotient_uint32_t(uint32_t n, const struct fxdiv_divisor_uint32_t divisor) { + const uint32_t t = fxdiv_mulhi_uint32_t(n, divisor.m); + return (t + ((n - t) >> divisor.s1)) >> divisor.s2; +} + +static inline uint64_t fxdiv_quotient_uint64_t(uint64_t n, const struct fxdiv_divisor_uint64_t divisor) { + const uint64_t t = fxdiv_mulhi_uint64_t(n, divisor.m); + return (t + ((n - t) >> divisor.s1)) >> divisor.s2; +} + +static inline size_t fxdiv_quotient_size_t(size_t n, const struct fxdiv_divisor_size_t divisor) { +#if SIZE_MAX == UINT32_MAX + const struct fxdiv_divisor_uint32_t uint32_divisor = { + (uint32_t) divisor.value, + (uint32_t) divisor.m, + divisor.s1, + divisor.s2 + }; + return fxdiv_quotient_uint32_t((uint32_t) n, uint32_divisor); +#elif SIZE_MAX == UINT64_MAX + const struct fxdiv_divisor_uint64_t uint64_divisor = { + (uint64_t) divisor.value, + (uint64_t) divisor.m, + divisor.s1, + divisor.s2 + }; + return fxdiv_quotient_uint64_t((uint64_t) n, uint64_divisor); +#else + #error Unsupported platform +#endif +} + +static inline uint32_t fxdiv_remainder_uint32_t(uint32_t n, const struct fxdiv_divisor_uint32_t divisor) { + const uint32_t quotient = fxdiv_quotient_uint32_t(n, divisor); + return n - quotient * divisor.value; +} + +static inline uint64_t fxdiv_remainder_uint64_t(uint64_t n, const struct fxdiv_divisor_uint64_t divisor) { + const uint64_t quotient = fxdiv_quotient_uint64_t(n, divisor); + return n - quotient * divisor.value; +} + +static inline size_t fxdiv_remainder_size_t(size_t n, const struct fxdiv_divisor_size_t divisor) { + const size_t quotient = fxdiv_quotient_size_t(n, divisor); + return n - quotient * divisor.value; +} + +static inline uint32_t fxdiv_round_down_uint32_t(uint32_t n, const struct fxdiv_divisor_uint32_t granularity) { + const uint32_t quotient = fxdiv_quotient_uint32_t(n, granularity); + return quotient * granularity.value; +} + +static inline uint64_t fxdiv_round_down_uint64_t(uint64_t n, const struct fxdiv_divisor_uint64_t granularity) { + const uint64_t quotient = fxdiv_quotient_uint64_t(n, granularity); + return quotient * granularity.value; +} + +static inline size_t fxdiv_round_down_size_t(size_t n, const struct fxdiv_divisor_size_t granularity) { + const size_t quotient = fxdiv_quotient_size_t(n, granularity); + return quotient * granularity.value; +} + +static inline struct fxdiv_result_uint32_t fxdiv_divide_uint32_t(uint32_t n, const struct fxdiv_divisor_uint32_t divisor) { + const uint32_t quotient = fxdiv_quotient_uint32_t(n, divisor); + const uint32_t remainder = n - quotient * divisor.value; + struct fxdiv_result_uint32_t result = { quotient, remainder }; + return result; +} + +static inline struct fxdiv_result_uint64_t fxdiv_divide_uint64_t(uint64_t n, const struct fxdiv_divisor_uint64_t divisor) { + const uint64_t quotient = fxdiv_quotient_uint64_t(n, divisor); + const uint64_t remainder = n - quotient * divisor.value; + struct fxdiv_result_uint64_t result = { quotient, remainder }; + return result; +} + +static inline struct fxdiv_result_size_t fxdiv_divide_size_t(size_t n, const struct fxdiv_divisor_size_t divisor) { + const size_t quotient = fxdiv_quotient_size_t(n, divisor); + const size_t remainder = n - quotient * divisor.value; + struct fxdiv_result_size_t result = { quotient, remainder }; + return result; +} + +#endif /* FXDIV_H */ diff --git a/deps/exla/cache/xla_extension/include/_virtual_includes/cpuinfo/cpuinfo.h b/deps/exla/cache/xla_extension/include/_virtual_includes/cpuinfo/cpuinfo.h new file mode 100644 index 0000000000000000000000000000000000000000..f1d35d4dbf9885cc9ac3b412f2aad86fdfa7615f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/_virtual_includes/cpuinfo/cpuinfo.h @@ -0,0 +1,2331 @@ +#pragma once +#ifndef CPUINFO_H +#define CPUINFO_H + +#ifndef __cplusplus +#include +#endif + +#ifdef __APPLE__ +#include +#endif + +#include + +/* Identify architecture and define corresponding macro */ + +#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(_M_IX86) +#define CPUINFO_ARCH_X86 1 +#endif + +#if defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) +#define CPUINFO_ARCH_X86_64 1 +#endif + +#if defined(__arm__) || defined(_M_ARM) +#define CPUINFO_ARCH_ARM 1 +#endif + +#if defined(__aarch64__) || defined(_M_ARM64) +#define CPUINFO_ARCH_ARM64 1 +#endif + +#if defined(__PPC64__) || defined(__powerpc64__) || defined(_ARCH_PPC64) +#define CPUINFO_ARCH_PPC64 1 +#endif + +#if defined(__asmjs__) +#define CPUINFO_ARCH_ASMJS 1 +#endif + +#if defined(__wasm__) +#if defined(__wasm_simd128__) +#define CPUINFO_ARCH_WASMSIMD 1 +#else +#define CPUINFO_ARCH_WASM 1 +#endif +#endif + +#if defined(__riscv) +#if (__riscv_xlen == 32) +#define CPUINFO_ARCH_RISCV32 1 +#elif (__riscv_xlen == 64) +#define CPUINFO_ARCH_RISCV64 1 +#endif +#endif + +/* Define other architecture-specific macros as 0 */ + +#ifndef CPUINFO_ARCH_X86 +#define CPUINFO_ARCH_X86 0 +#endif + +#ifndef CPUINFO_ARCH_X86_64 +#define CPUINFO_ARCH_X86_64 0 +#endif + +#ifndef CPUINFO_ARCH_ARM +#define CPUINFO_ARCH_ARM 0 +#endif + +#ifndef CPUINFO_ARCH_ARM64 +#define CPUINFO_ARCH_ARM64 0 +#endif + +#ifndef CPUINFO_ARCH_PPC64 +#define CPUINFO_ARCH_PPC64 0 +#endif + +#ifndef CPUINFO_ARCH_ASMJS +#define CPUINFO_ARCH_ASMJS 0 +#endif + +#ifndef CPUINFO_ARCH_WASM +#define CPUINFO_ARCH_WASM 0 +#endif + +#ifndef CPUINFO_ARCH_WASMSIMD +#define CPUINFO_ARCH_WASMSIMD 0 +#endif + +#ifndef CPUINFO_ARCH_RISCV32 +#define CPUINFO_ARCH_RISCV32 0 +#endif + +#ifndef CPUINFO_ARCH_RISCV64 +#define CPUINFO_ARCH_RISCV64 0 +#endif + +#if CPUINFO_ARCH_X86 && defined(_MSC_VER) +#define CPUINFO_ABI __cdecl +#elif CPUINFO_ARCH_X86 && defined(__GNUC__) +#define CPUINFO_ABI __attribute__((__cdecl__)) +#else +#define CPUINFO_ABI +#endif + +#define CPUINFO_CACHE_UNIFIED 0x00000001 +#define CPUINFO_CACHE_INCLUSIVE 0x00000002 +#define CPUINFO_CACHE_COMPLEX_INDEXING 0x00000004 + +struct cpuinfo_cache { + /** Cache size in bytes */ + uint32_t size; + /** Number of ways of associativity */ + uint32_t associativity; + /** Number of sets */ + uint32_t sets; + /** Number of partitions */ + uint32_t partitions; + /** Line size in bytes */ + uint32_t line_size; + /** + * Binary characteristics of the cache (unified cache, inclusive cache, + * cache with complex indexing). + * + * @see CPUINFO_CACHE_UNIFIED, CPUINFO_CACHE_INCLUSIVE, + * CPUINFO_CACHE_COMPLEX_INDEXING + */ + uint32_t flags; + /** Index of the first logical processor that shares this cache */ + uint32_t processor_start; + /** Number of logical processors that share this cache */ + uint32_t processor_count; +}; + +struct cpuinfo_trace_cache { + uint32_t uops; + uint32_t associativity; +}; + +#define CPUINFO_PAGE_SIZE_4KB 0x1000 +#define CPUINFO_PAGE_SIZE_1MB 0x100000 +#define CPUINFO_PAGE_SIZE_2MB 0x200000 +#define CPUINFO_PAGE_SIZE_4MB 0x400000 +#define CPUINFO_PAGE_SIZE_16MB 0x1000000 +#define CPUINFO_PAGE_SIZE_1GB 0x40000000 + +struct cpuinfo_tlb { + uint32_t entries; + uint32_t associativity; + uint64_t pages; +}; + +/** Vendor of processor core design */ +enum cpuinfo_vendor { + /** Processor vendor is not known to the library, or the library failed + to get vendor information from the OS. */ + cpuinfo_vendor_unknown = 0, + + /* Active vendors of modern CPUs */ + + /** + * Intel Corporation. Vendor of x86, x86-64, IA64, and ARM processor + * microarchitectures. + * + * Sold its ARM design subsidiary in 2006. The last ARM processor design + * was released in 2004. + */ + cpuinfo_vendor_intel = 1, + /** Advanced Micro Devices, Inc. Vendor of x86 and x86-64 processor + microarchitectures. */ + cpuinfo_vendor_amd = 2, + /** ARM Holdings plc. Vendor of ARM and ARM64 processor + microarchitectures. */ + cpuinfo_vendor_arm = 3, + /** Qualcomm Incorporated. Vendor of ARM and ARM64 processor + microarchitectures. */ + cpuinfo_vendor_qualcomm = 4, + /** Apple Inc. Vendor of ARM and ARM64 processor microarchitectures. */ + cpuinfo_vendor_apple = 5, + /** Samsung Electronics Co., Ltd. Vendir if ARM64 processor + microarchitectures. */ + cpuinfo_vendor_samsung = 6, + /** Nvidia Corporation. Vendor of ARM64-compatible processor + microarchitectures. */ + cpuinfo_vendor_nvidia = 7, + /** MIPS Technologies, Inc. Vendor of MIPS processor microarchitectures. + */ + cpuinfo_vendor_mips = 8, + /** International Business Machines Corporation. Vendor of PowerPC + processor microarchitectures. */ + cpuinfo_vendor_ibm = 9, + /** Ingenic Semiconductor. Vendor of MIPS processor microarchitectures. + */ + cpuinfo_vendor_ingenic = 10, + /** + * VIA Technologies, Inc. Vendor of x86 and x86-64 processor + * microarchitectures. + * + * Processors are designed by Centaur Technology, a subsidiary of VIA + * Technologies. + */ + cpuinfo_vendor_via = 11, + /** Cavium, Inc. Vendor of ARM64 processor microarchitectures. */ + cpuinfo_vendor_cavium = 12, + /** Broadcom, Inc. Vendor of ARM processor microarchitectures. */ + cpuinfo_vendor_broadcom = 13, + /** Applied Micro Circuits Corporation (APM). Vendor of ARM64 processor + microarchitectures. */ + cpuinfo_vendor_apm = 14, + /** + * Huawei Technologies Co., Ltd. Vendor of ARM64 processor + * microarchitectures. + * + * Processors are designed by HiSilicon, a subsidiary of Huawei. + */ + cpuinfo_vendor_huawei = 15, + /** + * Hygon (Chengdu Haiguang Integrated Circuit Design Co., Ltd), Vendor + * of x86-64 processor microarchitectures. + * + * Processors are variants of AMD cores. + */ + cpuinfo_vendor_hygon = 16, + /** SiFive, Inc. Vendor of RISC-V processor microarchitectures. */ + cpuinfo_vendor_sifive = 17, + + /* Active vendors of embedded CPUs */ + + /** Texas Instruments Inc. Vendor of ARM processor microarchitectures. + */ + cpuinfo_vendor_texas_instruments = 30, + /** Marvell Technology Group Ltd. Vendor of ARM processor + * microarchitectures. + */ + cpuinfo_vendor_marvell = 31, + /** RDC Semiconductor Co., Ltd. Vendor of x86 processor + microarchitectures. */ + cpuinfo_vendor_rdc = 32, + /** DM&P Electronics Inc. Vendor of x86 processor microarchitectures. */ + cpuinfo_vendor_dmp = 33, + /** Motorola, Inc. Vendor of PowerPC and ARM processor + microarchitectures. */ + cpuinfo_vendor_motorola = 34, + + /* Defunct CPU vendors */ + + /** + * Transmeta Corporation. Vendor of x86 processor microarchitectures. + * + * Now defunct. The last processor design was released in 2004. + * Transmeta processors implemented VLIW ISA and used binary translation + * to execute x86 code. + */ + cpuinfo_vendor_transmeta = 50, + /** + * Cyrix Corporation. Vendor of x86 processor microarchitectures. + * + * Now defunct. The last processor design was released in 1996. + */ + cpuinfo_vendor_cyrix = 51, + /** + * Rise Technology. Vendor of x86 processor microarchitectures. + * + * Now defunct. The last processor design was released in 1999. + */ + cpuinfo_vendor_rise = 52, + /** + * National Semiconductor. Vendor of x86 processor microarchitectures. + * + * Sold its x86 design subsidiary in 1999. The last processor design was + * released in 1998. + */ + cpuinfo_vendor_nsc = 53, + /** + * Silicon Integrated Systems. Vendor of x86 processor + * microarchitectures. + * + * Sold its x86 design subsidiary in 2001. The last processor design was + * released in 2001. + */ + cpuinfo_vendor_sis = 54, + /** + * NexGen. Vendor of x86 processor microarchitectures. + * + * Now defunct. The last processor design was released in 1994. + * NexGen designed the first x86 microarchitecture which decomposed x86 + * instructions into simple microoperations. + */ + cpuinfo_vendor_nexgen = 55, + /** + * United Microelectronics Corporation. Vendor of x86 processor + * microarchitectures. + * + * Ceased x86 in the early 1990s. The last processor design was released + * in 1991. Designed U5C and U5D processors. Both are 486 level. + */ + cpuinfo_vendor_umc = 56, + /** + * Digital Equipment Corporation. Vendor of ARM processor + * microarchitecture. + * + * Sold its ARM designs in 1997. The last processor design was released + * in 1997. + */ + cpuinfo_vendor_dec = 57, +}; + +/** + * Processor microarchitecture + * + * Processors with different microarchitectures often have different instruction + * performance characteristics, and may have dramatically different pipeline + * organization. + */ +enum cpuinfo_uarch { + /** Microarchitecture is unknown, or the library failed to get + information about the microarchitecture from OS */ + cpuinfo_uarch_unknown = 0, + + /** Pentium and Pentium MMX microarchitecture. */ + cpuinfo_uarch_p5 = 0x00100100, + /** Intel Quark microarchitecture. */ + cpuinfo_uarch_quark = 0x00100101, + + /** Pentium Pro, Pentium II, and Pentium III. */ + cpuinfo_uarch_p6 = 0x00100200, + /** Pentium M. */ + cpuinfo_uarch_dothan = 0x00100201, + /** Intel Core microarchitecture. */ + cpuinfo_uarch_yonah = 0x00100202, + /** Intel Core 2 microarchitecture on 65 nm process. */ + cpuinfo_uarch_conroe = 0x00100203, + /** Intel Core 2 microarchitecture on 45 nm process. */ + cpuinfo_uarch_penryn = 0x00100204, + /** Intel Nehalem and Westmere microarchitectures (Core i3/i5/i7 1st + gen). */ + cpuinfo_uarch_nehalem = 0x00100205, + /** Intel Sandy Bridge microarchitecture (Core i3/i5/i7 2nd gen). */ + cpuinfo_uarch_sandy_bridge = 0x00100206, + /** Intel Ivy Bridge microarchitecture (Core i3/i5/i7 3rd gen). */ + cpuinfo_uarch_ivy_bridge = 0x00100207, + /** Intel Haswell microarchitecture (Core i3/i5/i7 4th gen). */ + cpuinfo_uarch_haswell = 0x00100208, + /** Intel Broadwell microarchitecture. */ + cpuinfo_uarch_broadwell = 0x00100209, + /** Intel Sky Lake microarchitecture (14 nm, including + Kaby/Coffee/Whiskey/Amber/Comet/Cascade/Cooper Lake). */ + cpuinfo_uarch_sky_lake = 0x0010020A, + /** DEPRECATED (Intel Kaby Lake microarchitecture). */ + cpuinfo_uarch_kaby_lake = 0x0010020A, + /** Intel Palm Cove microarchitecture (10 nm, Cannon Lake). */ + cpuinfo_uarch_palm_cove = 0x0010020B, + /** Intel Sunny Cove microarchitecture (10 nm, Ice Lake). */ + cpuinfo_uarch_sunny_cove = 0x0010020C, + + /** Pentium 4 with Willamette, Northwood, or Foster cores. */ + cpuinfo_uarch_willamette = 0x00100300, + /** Pentium 4 with Prescott and later cores. */ + cpuinfo_uarch_prescott = 0x00100301, + + /** Intel Atom on 45 nm process. */ + cpuinfo_uarch_bonnell = 0x00100400, + /** Intel Atom on 32 nm process. */ + cpuinfo_uarch_saltwell = 0x00100401, + /** Intel Silvermont microarchitecture (22 nm out-of-order Atom). */ + cpuinfo_uarch_silvermont = 0x00100402, + /** Intel Airmont microarchitecture (14 nm out-of-order Atom). */ + cpuinfo_uarch_airmont = 0x00100403, + /** Intel Goldmont microarchitecture (Denverton, Apollo Lake). */ + cpuinfo_uarch_goldmont = 0x00100404, + /** Intel Goldmont Plus microarchitecture (Gemini Lake). */ + cpuinfo_uarch_goldmont_plus = 0x00100405, + + /** Intel Knights Ferry HPC boards. */ + cpuinfo_uarch_knights_ferry = 0x00100500, + /** Intel Knights Corner HPC boards (aka Xeon Phi). */ + cpuinfo_uarch_knights_corner = 0x00100501, + /** Intel Knights Landing microarchitecture (second-gen MIC). */ + cpuinfo_uarch_knights_landing = 0x00100502, + /** Intel Knights Hill microarchitecture (third-gen MIC). */ + cpuinfo_uarch_knights_hill = 0x00100503, + /** Intel Knights Mill Xeon Phi. */ + cpuinfo_uarch_knights_mill = 0x00100504, + + /** Intel/Marvell XScale series. */ + cpuinfo_uarch_xscale = 0x00100600, + + /** AMD K5. */ + cpuinfo_uarch_k5 = 0x00200100, + /** AMD K6 and alike. */ + cpuinfo_uarch_k6 = 0x00200101, + /** AMD Athlon and Duron. */ + cpuinfo_uarch_k7 = 0x00200102, + /** AMD Athlon 64, Opteron 64. */ + cpuinfo_uarch_k8 = 0x00200103, + /** AMD Family 10h (Barcelona, Istambul, Magny-Cours). */ + cpuinfo_uarch_k10 = 0x00200104, + /** + * AMD Bulldozer microarchitecture + * Zambezi FX-series CPUs, Zurich, Valencia and Interlagos Opteron CPUs. + */ + cpuinfo_uarch_bulldozer = 0x00200105, + /** + * AMD Piledriver microarchitecture + * Vishera FX-series CPUs, Trinity and Richland APUs, Delhi, Seoul, Abu + * Dhabi Opteron CPUs. + */ + cpuinfo_uarch_piledriver = 0x00200106, + /** AMD Steamroller microarchitecture (Kaveri APUs). */ + cpuinfo_uarch_steamroller = 0x00200107, + /** AMD Excavator microarchitecture (Carizzo APUs). */ + cpuinfo_uarch_excavator = 0x00200108, + /** AMD Zen microarchitecture (12/14 nm Ryzen and EPYC CPUs). */ + cpuinfo_uarch_zen = 0x00200109, + /** AMD Zen 2 microarchitecture (7 nm Ryzen and EPYC CPUs). */ + cpuinfo_uarch_zen2 = 0x0020010A, + /** AMD Zen 3 microarchitecture. */ + cpuinfo_uarch_zen3 = 0x0020010B, + /** AMD Zen 4 microarchitecture. */ + cpuinfo_uarch_zen4 = 0x0020010C, + /** AMD Zen 5 microarchitecture. */ + cpuinfo_uarch_zen5 = 0x0020010D, + + /** NSC Geode and AMD Geode GX and LX. */ + cpuinfo_uarch_geode = 0x00200200, + /** AMD Bobcat mobile microarchitecture. */ + cpuinfo_uarch_bobcat = 0x00200201, + /** AMD Jaguar mobile microarchitecture. */ + cpuinfo_uarch_jaguar = 0x00200202, + /** AMD Puma mobile microarchitecture. */ + cpuinfo_uarch_puma = 0x00200203, + + /** ARM7 series. */ + cpuinfo_uarch_arm7 = 0x00300100, + /** ARM9 series. */ + cpuinfo_uarch_arm9 = 0x00300101, + /** ARM 1136, ARM 1156, ARM 1176, or ARM 11MPCore. */ + cpuinfo_uarch_arm11 = 0x00300102, + + /** ARM Cortex-A5. */ + cpuinfo_uarch_cortex_a5 = 0x00300205, + /** ARM Cortex-A7. */ + cpuinfo_uarch_cortex_a7 = 0x00300207, + /** ARM Cortex-A8. */ + cpuinfo_uarch_cortex_a8 = 0x00300208, + /** ARM Cortex-A9. */ + cpuinfo_uarch_cortex_a9 = 0x00300209, + /** ARM Cortex-A12. */ + cpuinfo_uarch_cortex_a12 = 0x00300212, + /** ARM Cortex-A15. */ + cpuinfo_uarch_cortex_a15 = 0x00300215, + /** ARM Cortex-A17. */ + cpuinfo_uarch_cortex_a17 = 0x00300217, + + /** ARM Cortex-A32. */ + cpuinfo_uarch_cortex_a32 = 0x00300332, + /** ARM Cortex-A35. */ + cpuinfo_uarch_cortex_a35 = 0x00300335, + /** ARM Cortex-A53. */ + cpuinfo_uarch_cortex_a53 = 0x00300353, + /** ARM Cortex-A55 revision 0 (restricted dual-issue capabilities + compared to revision 1+). */ + cpuinfo_uarch_cortex_a55r0 = 0x00300354, + /** ARM Cortex-A55. */ + cpuinfo_uarch_cortex_a55 = 0x00300355, + /** ARM Cortex-A57. */ + cpuinfo_uarch_cortex_a57 = 0x00300357, + /** ARM Cortex-A65. */ + cpuinfo_uarch_cortex_a65 = 0x00300365, + /** ARM Cortex-A72. */ + cpuinfo_uarch_cortex_a72 = 0x00300372, + /** ARM Cortex-A73. */ + cpuinfo_uarch_cortex_a73 = 0x00300373, + /** ARM Cortex-A75. */ + cpuinfo_uarch_cortex_a75 = 0x00300375, + /** ARM Cortex-A76. */ + cpuinfo_uarch_cortex_a76 = 0x00300376, + /** ARM Cortex-A77. */ + cpuinfo_uarch_cortex_a77 = 0x00300377, + /** ARM Cortex-A78. */ + cpuinfo_uarch_cortex_a78 = 0x00300378, + + /** ARM Neoverse N1. */ + cpuinfo_uarch_neoverse_n1 = 0x00300400, + /** ARM Neoverse E1. */ + cpuinfo_uarch_neoverse_e1 = 0x00300401, + /** ARM Neoverse V1. */ + cpuinfo_uarch_neoverse_v1 = 0x00300402, + /** ARM Neoverse N2. */ + cpuinfo_uarch_neoverse_n2 = 0x00300403, + /** ARM Neoverse V2. */ + cpuinfo_uarch_neoverse_v2 = 0x00300404, + + /** ARM Cortex-X1. */ + cpuinfo_uarch_cortex_x1 = 0x00300501, + /** ARM Cortex-X2. */ + cpuinfo_uarch_cortex_x2 = 0x00300502, + /** ARM Cortex-X3. */ + cpuinfo_uarch_cortex_x3 = 0x00300503, + /** ARM Cortex-X4. */ + cpuinfo_uarch_cortex_x4 = 0x00300504, + + /** ARM Cortex-A510. */ + cpuinfo_uarch_cortex_a510 = 0x00300551, + /** ARM Cortex-A520. */ + cpuinfo_uarch_cortex_a520 = 0x00300552, + /** ARM Cortex-A710. */ + cpuinfo_uarch_cortex_a710 = 0x00300571, + /** ARM Cortex-A715. */ + cpuinfo_uarch_cortex_a715 = 0x00300572, + /** ARM Cortex-A720. */ + cpuinfo_uarch_cortex_a720 = 0x00300573, + + /** Qualcomm Scorpion. */ + cpuinfo_uarch_scorpion = 0x00400100, + /** Qualcomm Krait. */ + cpuinfo_uarch_krait = 0x00400101, + /** Qualcomm Kryo. */ + cpuinfo_uarch_kryo = 0x00400102, + /** Qualcomm Falkor. */ + cpuinfo_uarch_falkor = 0x00400103, + /** Qualcomm Saphira. */ + cpuinfo_uarch_saphira = 0x00400104, + /** Qualcomm Oryon. */ + cpuinfo_uarch_oryon = 0x00400105, + + /** Nvidia Denver. */ + cpuinfo_uarch_denver = 0x00500100, + /** Nvidia Denver 2. */ + cpuinfo_uarch_denver2 = 0x00500101, + /** Nvidia Carmel. */ + cpuinfo_uarch_carmel = 0x00500102, + + /** Samsung Exynos M1 (Exynos 8890 big cores). */ + cpuinfo_uarch_exynos_m1 = 0x00600100, + /** Samsung Exynos M2 (Exynos 8895 big cores). */ + cpuinfo_uarch_exynos_m2 = 0x00600101, + /** Samsung Exynos M3 (Exynos 9810 big cores). */ + cpuinfo_uarch_exynos_m3 = 0x00600102, + /** Samsung Exynos M4 (Exynos 9820 big cores). */ + cpuinfo_uarch_exynos_m4 = 0x00600103, + /** Samsung Exynos M5 (Exynos 9830 big cores). */ + cpuinfo_uarch_exynos_m5 = 0x00600104, + + /* Deprecated synonym for Cortex-A76 */ + cpuinfo_uarch_cortex_a76ae = 0x00300376, + /* Deprecated names for Exynos. */ + cpuinfo_uarch_mongoose_m1 = 0x00600100, + cpuinfo_uarch_mongoose_m2 = 0x00600101, + cpuinfo_uarch_meerkat_m3 = 0x00600102, + cpuinfo_uarch_meerkat_m4 = 0x00600103, + + /** Apple A6 and A6X processors. */ + cpuinfo_uarch_swift = 0x00700100, + /** Apple A7 processor. */ + cpuinfo_uarch_cyclone = 0x00700101, + /** Apple A8 and A8X processor. */ + cpuinfo_uarch_typhoon = 0x00700102, + /** Apple A9 and A9X processor. */ + cpuinfo_uarch_twister = 0x00700103, + /** Apple A10 and A10X processor. */ + cpuinfo_uarch_hurricane = 0x00700104, + /** Apple A11 processor (big cores). */ + cpuinfo_uarch_monsoon = 0x00700105, + /** Apple A11 processor (little cores). */ + cpuinfo_uarch_mistral = 0x00700106, + /** Apple A12 processor (big cores). */ + cpuinfo_uarch_vortex = 0x00700107, + /** Apple A12 processor (little cores). */ + cpuinfo_uarch_tempest = 0x00700108, + /** Apple A13 processor (big cores). */ + cpuinfo_uarch_lightning = 0x00700109, + /** Apple A13 processor (little cores). */ + cpuinfo_uarch_thunder = 0x0070010A, + /** Apple A14 / M1 processor (big cores). */ + cpuinfo_uarch_firestorm = 0x0070010B, + /** Apple A14 / M1 processor (little cores). */ + cpuinfo_uarch_icestorm = 0x0070010C, + /** Apple A15 / M2 processor (big cores). */ + cpuinfo_uarch_avalanche = 0x0070010D, + /** Apple A15 / M2 processor (little cores). */ + cpuinfo_uarch_blizzard = 0x0070010E, + + /** Cavium ThunderX. */ + cpuinfo_uarch_thunderx = 0x00800100, + /** Cavium ThunderX2 (originally Broadcom Vulkan). */ + cpuinfo_uarch_thunderx2 = 0x00800200, + + /** Marvell PJ4. */ + cpuinfo_uarch_pj4 = 0x00900100, + + /** Broadcom Brahma B15. */ + cpuinfo_uarch_brahma_b15 = 0x00A00100, + /** Broadcom Brahma B53. */ + cpuinfo_uarch_brahma_b53 = 0x00A00101, + + /** Applied Micro X-Gene. */ + cpuinfo_uarch_xgene = 0x00B00100, + + /* Hygon Dhyana (a modification of AMD Zen for Chinese market). */ + cpuinfo_uarch_dhyana = 0x01000100, + + /** HiSilicon TaiShan v110 (Huawei Kunpeng 920 series processors). */ + cpuinfo_uarch_taishan_v110 = 0x00C00100, +}; + +struct cpuinfo_processor { + /** SMT (hyperthread) ID within a core */ + uint32_t smt_id; + /** Core containing this logical processor */ + const struct cpuinfo_core* core; + /** Cluster of cores containing this logical processor */ + const struct cpuinfo_cluster* cluster; + /** Physical package containing this logical processor */ + const struct cpuinfo_package* package; +#if defined(__linux__) + /** + * Linux-specific ID for the logical processor: + * - Linux kernel exposes information about this logical processor in + * /sys/devices/system/cpu/cpu/ + * - Bit in the cpu_set_t identifies this logical processor + */ + int linux_id; +#endif +#if defined(_WIN32) || defined(__CYGWIN__) + /** Windows-specific ID for the group containing the logical processor. + */ + uint16_t windows_group_id; + /** + * Windows-specific ID of the logical processor within its group: + * - Bit in the KAFFINITY mask identifies this + * logical processor within its group. + */ + uint16_t windows_processor_id; +#endif +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + /** APIC ID (unique x86-specific ID of the logical processor) */ + uint32_t apic_id; +#endif + struct { + /** Level 1 instruction cache */ + const struct cpuinfo_cache* l1i; + /** Level 1 data cache */ + const struct cpuinfo_cache* l1d; + /** Level 2 unified or data cache */ + const struct cpuinfo_cache* l2; + /** Level 3 unified or data cache */ + const struct cpuinfo_cache* l3; + /** Level 4 unified or data cache */ + const struct cpuinfo_cache* l4; + } cache; +}; + +struct cpuinfo_core { + /** Index of the first logical processor on this core. */ + uint32_t processor_start; + /** Number of logical processors on this core */ + uint32_t processor_count; + /** Core ID within a package */ + uint32_t core_id; + /** Cluster containing this core */ + const struct cpuinfo_cluster* cluster; + /** Physical package containing this core. */ + const struct cpuinfo_package* package; + /** Vendor of the CPU microarchitecture for this core */ + enum cpuinfo_vendor vendor; + /** CPU microarchitecture for this core */ + enum cpuinfo_uarch uarch; +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + /** Value of CPUID leaf 1 EAX register for this core */ + uint32_t cpuid; +#elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + /** Value of Main ID Register (MIDR) for this core */ + uint32_t midr; +#endif + /** Clock rate (non-Turbo) of the core, in Hz */ + uint64_t frequency; +}; + +struct cpuinfo_cluster { + /** Index of the first logical processor in the cluster */ + uint32_t processor_start; + /** Number of logical processors in the cluster */ + uint32_t processor_count; + /** Index of the first core in the cluster */ + uint32_t core_start; + /** Number of cores on the cluster */ + uint32_t core_count; + /** Cluster ID within a package */ + uint32_t cluster_id; + /** Physical package containing the cluster */ + const struct cpuinfo_package* package; + /** CPU microarchitecture vendor of the cores in the cluster */ + enum cpuinfo_vendor vendor; + /** CPU microarchitecture of the cores in the cluster */ + enum cpuinfo_uarch uarch; +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + /** Value of CPUID leaf 1 EAX register of the cores in the cluster */ + uint32_t cpuid; +#elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + /** Value of Main ID Register (MIDR) of the cores in the cluster */ + uint32_t midr; +#endif + /** Clock rate (non-Turbo) of the cores in the cluster, in Hz */ + uint64_t frequency; +}; + +#define CPUINFO_PACKAGE_NAME_MAX 48 + +struct cpuinfo_package { + /** SoC or processor chip model name */ + char name[CPUINFO_PACKAGE_NAME_MAX]; + /** Index of the first logical processor on this physical package */ + uint32_t processor_start; + /** Number of logical processors on this physical package */ + uint32_t processor_count; + /** Index of the first core on this physical package */ + uint32_t core_start; + /** Number of cores on this physical package */ + uint32_t core_count; + /** Index of the first cluster of cores on this physical package */ + uint32_t cluster_start; + /** Number of clusters of cores on this physical package */ + uint32_t cluster_count; +}; + +struct cpuinfo_uarch_info { + /** Type of CPU microarchitecture */ + enum cpuinfo_uarch uarch; +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + /** Value of CPUID leaf 1 EAX register for the microarchitecture */ + uint32_t cpuid; +#elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + /** Value of Main ID Register (MIDR) for the microarchitecture */ + uint32_t midr; +#endif + /** Number of logical processors with the microarchitecture */ + uint32_t processor_count; + /** Number of cores with the microarchitecture */ + uint32_t core_count; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +bool CPUINFO_ABI cpuinfo_initialize(void); + +void CPUINFO_ABI cpuinfo_deinitialize(void); + +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 +/* This structure is not a part of stable API. Use cpuinfo_has_x86_* functions + * instead. */ +struct cpuinfo_x86_isa { +#if CPUINFO_ARCH_X86 + bool rdtsc; +#endif + bool rdtscp; + bool rdpid; + bool sysenter; +#if CPUINFO_ARCH_X86 + bool syscall; +#endif + bool msr; + bool clzero; + bool clflush; + bool clflushopt; + bool mwait; + bool mwaitx; +#if CPUINFO_ARCH_X86 + bool emmx; +#endif + bool fxsave; + bool xsave; +#if CPUINFO_ARCH_X86 + bool fpu; + bool mmx; + bool mmx_plus; +#endif + bool three_d_now; + bool three_d_now_plus; +#if CPUINFO_ARCH_X86 + bool three_d_now_geode; +#endif + bool prefetch; + bool prefetchw; + bool prefetchwt1; +#if CPUINFO_ARCH_X86 + bool daz; + bool sse; + bool sse2; +#endif + bool sse3; + bool ssse3; + bool sse4_1; + bool sse4_2; + bool sse4a; + bool misaligned_sse; + bool avx; + bool avxvnni; + bool fma3; + bool fma4; + bool xop; + bool f16c; + bool avx2; + bool avx512f; + bool avx512pf; + bool avx512er; + bool avx512cd; + bool avx512dq; + bool avx512bw; + bool avx512vl; + bool avx512ifma; + bool avx512vbmi; + bool avx512vbmi2; + bool avx512bitalg; + bool avx512vpopcntdq; + bool avx512vnni; + bool avx512bf16; + bool avx512fp16; + bool avx512vp2intersect; + bool avx512_4vnniw; + bool avx512_4fmaps; + bool avx10_1; + bool avx10_2; + bool amx_bf16; + bool amx_tile; + bool amx_int8; + bool amx_fp16; + bool avx_vnni_int8; + bool avx_vnni_int16; + bool avx_ne_convert; + bool hle; + bool rtm; + bool xtest; + bool mpx; +#if CPUINFO_ARCH_X86 + bool cmov; + bool cmpxchg8b; +#endif + bool cmpxchg16b; + bool clwb; + bool movbe; +#if CPUINFO_ARCH_X86_64 + bool lahf_sahf; +#endif + bool fs_gs_base; + bool lzcnt; + bool popcnt; + bool tbm; + bool bmi; + bool bmi2; + bool adx; + bool aes; + bool vaes; + bool pclmulqdq; + bool vpclmulqdq; + bool gfni; + bool rdrand; + bool rdseed; + bool sha; + bool rng; + bool ace; + bool ace2; + bool phe; + bool pmm; + bool lwp; +}; + +extern struct cpuinfo_x86_isa cpuinfo_isa; +#endif + +static inline bool cpuinfo_has_x86_rdtsc(void) { +#if CPUINFO_ARCH_X86_64 + return true; +#elif CPUINFO_ARCH_X86 +#if defined(__ANDROID__) + return true; +#else + return cpuinfo_isa.rdtsc; +#endif +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_rdtscp(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.rdtscp; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_rdpid(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.rdpid; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_clzero(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.clzero; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_mwait(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.mwait; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_mwaitx(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.mwaitx; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_fxsave(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.fxsave; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_xsave(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.xsave; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_fpu(void) { +#if CPUINFO_ARCH_X86_64 + return true; +#elif CPUINFO_ARCH_X86 +#if defined(__ANDROID__) + return true; +#else + return cpuinfo_isa.fpu; +#endif +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_mmx(void) { +#if CPUINFO_ARCH_X86_64 + return true; +#elif CPUINFO_ARCH_X86 +#if defined(__ANDROID__) + return true; +#else + return cpuinfo_isa.mmx; +#endif +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_mmx_plus(void) { +#if CPUINFO_ARCH_X86_64 + return true; +#elif CPUINFO_ARCH_X86 +#if defined(__ANDROID__) + return true; +#else + return cpuinfo_isa.mmx_plus; +#endif +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_3dnow(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.three_d_now; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_3dnow_plus(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.three_d_now_plus; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_3dnow_geode(void) { +#if CPUINFO_ARCH_X86_64 + return false; +#elif CPUINFO_ARCH_X86 +#if defined(__ANDROID__) + return false; +#else + return cpuinfo_isa.three_d_now_geode; +#endif +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_prefetch(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.prefetch; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_prefetchw(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.prefetchw; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_prefetchwt1(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.prefetchwt1; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_daz(void) { +#if CPUINFO_ARCH_X86_64 + return true; +#elif CPUINFO_ARCH_X86 +#if defined(__ANDROID__) + return true; +#else + return cpuinfo_isa.daz; +#endif +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_sse(void) { +#if CPUINFO_ARCH_X86_64 + return true; +#elif CPUINFO_ARCH_X86 +#if defined(__ANDROID__) + return true; +#else + return cpuinfo_isa.sse; +#endif +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_sse2(void) { +#if CPUINFO_ARCH_X86_64 + return true; +#elif CPUINFO_ARCH_X86 +#if defined(__ANDROID__) + return true; +#else + return cpuinfo_isa.sse2; +#endif +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_sse3(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 +#if defined(__ANDROID__) + return true; +#else + return cpuinfo_isa.sse3; +#endif +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_ssse3(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 +#if defined(__ANDROID__) + return true; +#else + return cpuinfo_isa.ssse3; +#endif +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_sse4_1(void) { +#if CPUINFO_ARCH_X86_64 +#if defined(__ANDROID__) + return true; +#else + return cpuinfo_isa.sse4_1; +#endif +#elif CPUINFO_ARCH_X86 + return cpuinfo_isa.sse4_1; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_sse4_2(void) { +#if CPUINFO_ARCH_X86_64 +#if defined(__ANDROID__) + return true; +#else + return cpuinfo_isa.sse4_2; +#endif +#elif CPUINFO_ARCH_X86 + return cpuinfo_isa.sse4_2; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_sse4a(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.sse4a; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_misaligned_sse(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.misaligned_sse; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avxvnni(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avxvnni; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_fma3(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.fma3; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_fma4(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.fma4; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_xop(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.xop; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_f16c(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.f16c; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx2(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx2; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512f(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512f; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512pf(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512pf; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512er(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512er; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512cd(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512cd; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512dq(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512dq; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512bw(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512bw; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512vl(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512vl; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512ifma(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512ifma; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512vbmi(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512vbmi; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512vbmi2(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512vbmi2; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512bitalg(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512bitalg; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512vpopcntdq(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512vpopcntdq; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512vnni(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512vnni; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512bf16(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512bf16; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512fp16(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512fp16; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512vp2intersect(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512vp2intersect; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512_4vnniw(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512_4vnniw; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx512_4fmaps(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512_4fmaps; +#else + return false; +#endif +} + +/* [NOTE] Intel Advanced Matrix Extensions (AMX) detection + * + * I. AMX is a new extensions to the x86 ISA to work on matrices, consists of + * 1) 2-dimentional registers (tiles), hold sub-matrices from larger matrices in memory + * 2) Accelerator called Tile Matrix Multiply (TMUL), contains instructions operating on tiles + * + * II. Platforms that supports AMX: + * +-----------------+-----+----------+----------+----------+----------+ + * | Platforms | Gen | amx-bf16 | amx-tile | amx-int8 | amx-fp16 | + * +-----------------+-----+----------+----------+----------+----------+ + * | Sapphire Rapids | 4th | YES | YES | YES | NO | + * +-----------------+-----+----------+----------+----------+----------+ + * | Emerald Rapids | 5th | YES | YES | YES | NO | + * +-----------------+-----+----------+----------+----------+----------+ + * | Granite Rapids | 6th | YES | YES | YES | YES | + * +-----------------+-----+----------+----------+----------+----------+ + * + * Reference: https://www.intel.com/content/www/us/en/products/docs + * /accelerator-engines/advanced-matrix-extensions/overview.html + */ +static inline bool cpuinfo_has_x86_amx_bf16(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.amx_bf16; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_amx_tile(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.amx_tile; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_amx_int8(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.amx_int8; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_amx_fp16(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.amx_fp16; +#else + return false; +#endif +} + +/* + * Intel AVX Vector Neural Network Instructions (VNNI) INT8 + * Supported Platfroms: Sierra Forest, Arrow Lake, Lunar Lake + */ +static inline bool cpuinfo_has_x86_avx_vnni_int8(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx_vnni_int8; +#else + return false; +#endif +} + +/* + * Intel AVX Vector Neural Network Instructions (VNNI) INT16 + * Supported Platfroms: Arrow Lake, Lunar Lake + */ +static inline bool cpuinfo_has_x86_avx_vnni_int16(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx_vnni_int16; +#else + return false; +#endif +} + +/* + * A new set of instructions, which can convert low precision floating point + * like BF16/FP16 to high precision floating point FP32, as well as convert FP32 + * elements to BF16. This instruction allows the platform to have improved AI + * capabilities and better compatibility. + * + * Supported Platforms: Sierra Forest, Arrow Lake, Lunar Lake + */ +static inline bool cpuinfo_has_x86_avx_ne_convert(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx_ne_convert; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx10_1(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx10_1; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_avx10_2(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx10_2; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_hle(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.hle; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_rtm(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.rtm; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_xtest(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.xtest; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_mpx(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.mpx; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_cmov(void) { +#if CPUINFO_ARCH_X86_64 + return true; +#elif CPUINFO_ARCH_X86 + return cpuinfo_isa.cmov; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_cmpxchg8b(void) { +#if CPUINFO_ARCH_X86_64 + return true; +#elif CPUINFO_ARCH_X86 + return cpuinfo_isa.cmpxchg8b; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_cmpxchg16b(void) { +#if CPUINFO_ARCH_X86_64 + return cpuinfo_isa.cmpxchg16b; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_clwb(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.clwb; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_movbe(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.movbe; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_lahf_sahf(void) { +#if CPUINFO_ARCH_X86 + return true; +#elif CPUINFO_ARCH_X86_64 + return cpuinfo_isa.lahf_sahf; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_lzcnt(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.lzcnt; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_popcnt(void) { +#if CPUINFO_ARCH_X86_64 +#if defined(__ANDROID__) + return true; +#else + return cpuinfo_isa.popcnt; +#endif +#elif CPUINFO_ARCH_X86 + return cpuinfo_isa.popcnt; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_tbm(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.tbm; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_bmi(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.bmi; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_bmi2(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.bmi2; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_adx(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.adx; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_aes(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.aes; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_vaes(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.vaes; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_pclmulqdq(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.pclmulqdq; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_vpclmulqdq(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.vpclmulqdq; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_gfni(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.gfni; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_rdrand(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.rdrand; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_rdseed(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.rdseed; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_x86_sha(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.sha; +#else + return false; +#endif +} + +#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 +/* This structure is not a part of stable API. Use cpuinfo_has_arm_* functions + * instead. */ +struct cpuinfo_arm_isa { +#if CPUINFO_ARCH_ARM + bool thumb; + bool thumb2; + bool thumbee; + bool jazelle; + bool armv5e; + bool armv6; + bool armv6k; + bool armv7; + bool armv7mp; + bool armv8; + bool idiv; + + bool vfpv2; + bool vfpv3; + bool d32; + bool fp16; + bool fma; + + bool wmmx; + bool wmmx2; + bool neon; +#endif +#if CPUINFO_ARCH_ARM64 + bool atomics; + bool bf16; + bool sve; + bool sve2; + bool i8mm; + bool sme; + bool sme2; + bool sme2p1; + bool sme_i16i32; + bool sme_bi32i32; + bool sme_b16b16; + bool sme_f16f16; + uint32_t svelen; + uint32_t smelen; +#endif + bool rdm; + bool fp16arith; + bool dot; + bool jscvt; + bool fcma; + bool fhm; + + bool aes; + bool sha1; + bool sha2; + bool pmull; + bool crc32; +}; + +extern struct cpuinfo_arm_isa cpuinfo_isa; +#endif + +static inline bool cpuinfo_has_arm_thumb(void) { +#if CPUINFO_ARCH_ARM + return cpuinfo_isa.thumb; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_thumb2(void) { +#if CPUINFO_ARCH_ARM + return cpuinfo_isa.thumb2; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_v5e(void) { +#if CPUINFO_ARCH_ARM + return cpuinfo_isa.armv5e; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_v6(void) { +#if CPUINFO_ARCH_ARM + return cpuinfo_isa.armv6; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_v6k(void) { +#if CPUINFO_ARCH_ARM + return cpuinfo_isa.armv6k; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_v7(void) { +#if CPUINFO_ARCH_ARM + return cpuinfo_isa.armv7; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_v7mp(void) { +#if CPUINFO_ARCH_ARM + return cpuinfo_isa.armv7mp; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_v8(void) { +#if CPUINFO_ARCH_ARM64 + return true; +#elif CPUINFO_ARCH_ARM + return cpuinfo_isa.armv8; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_idiv(void) { +#if CPUINFO_ARCH_ARM64 + return true; +#elif CPUINFO_ARCH_ARM + return cpuinfo_isa.idiv; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_vfpv2(void) { +#if CPUINFO_ARCH_ARM + return cpuinfo_isa.vfpv2; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_vfpv3(void) { +#if CPUINFO_ARCH_ARM64 + return true; +#elif CPUINFO_ARCH_ARM + return cpuinfo_isa.vfpv3; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_vfpv3_d32(void) { +#if CPUINFO_ARCH_ARM64 + return true; +#elif CPUINFO_ARCH_ARM + return cpuinfo_isa.vfpv3 && cpuinfo_isa.d32; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_vfpv3_fp16(void) { +#if CPUINFO_ARCH_ARM64 + return true; +#elif CPUINFO_ARCH_ARM + return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_vfpv3_fp16_d32(void) { +#if CPUINFO_ARCH_ARM64 + return true; +#elif CPUINFO_ARCH_ARM + return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16 && cpuinfo_isa.d32; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_vfpv4(void) { +#if CPUINFO_ARCH_ARM64 + return true; +#elif CPUINFO_ARCH_ARM + return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_vfpv4_d32(void) { +#if CPUINFO_ARCH_ARM64 + return true; +#elif CPUINFO_ARCH_ARM + return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma && cpuinfo_isa.d32; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_fp16_arith(void) { +#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + return cpuinfo_isa.fp16arith; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_bf16(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.bf16; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_wmmx(void) { +#if CPUINFO_ARCH_ARM + return cpuinfo_isa.wmmx; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_wmmx2(void) { +#if CPUINFO_ARCH_ARM + return cpuinfo_isa.wmmx2; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_neon(void) { +#if CPUINFO_ARCH_ARM64 + return true; +#elif CPUINFO_ARCH_ARM + return cpuinfo_isa.neon; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_neon_fp16(void) { +#if CPUINFO_ARCH_ARM64 + return true; +#elif CPUINFO_ARCH_ARM + return cpuinfo_isa.neon && cpuinfo_isa.fp16; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_neon_fma(void) { +#if CPUINFO_ARCH_ARM64 + return true; +#elif CPUINFO_ARCH_ARM + return cpuinfo_isa.neon && cpuinfo_isa.fma; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_neon_v8(void) { +#if CPUINFO_ARCH_ARM64 + return true; +#elif CPUINFO_ARCH_ARM + return cpuinfo_isa.neon && cpuinfo_isa.armv8; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_atomics(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.atomics; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_neon_rdm(void) { +#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + return cpuinfo_isa.rdm; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_neon_fp16_arith(void) { +#if CPUINFO_ARCH_ARM + return cpuinfo_isa.neon && cpuinfo_isa.fp16arith; +#elif CPUINFO_ARCH_ARM64 + return cpuinfo_isa.fp16arith; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_fhm(void) { +#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + return cpuinfo_isa.fhm; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_neon_dot(void) { +#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + return cpuinfo_isa.dot; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_neon_bf16(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.bf16; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_jscvt(void) { +#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + return cpuinfo_isa.jscvt; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_fcma(void) { +#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + return cpuinfo_isa.fcma; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_i8mm(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.i8mm; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_aes(void) { +#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + return cpuinfo_isa.aes; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_sha1(void) { +#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + return cpuinfo_isa.sha1; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_sha2(void) { +#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + return cpuinfo_isa.sha2; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_pmull(void) { +#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + return cpuinfo_isa.pmull; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_crc32(void) { +#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 + return cpuinfo_isa.crc32; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_sve(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.sve; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_sve_bf16(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.sve && cpuinfo_isa.bf16; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_sve2(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.sve2; +#else + return false; +#endif +} + +// Function to get the max SVE vector length on ARM CPU's which support SVE. +static inline uint32_t cpuinfo_get_max_arm_sve_length(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.svelen * 8; // bytes * 8 = bit length(vector length) +#else + return 0; +#endif +} + +// Function to get the max SME vector length on ARM CPU's which support SME. +static inline uint32_t cpuinfo_get_max_arm_sme_length(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.smelen * 8; // bytes * 8 = bit length(vector length) +#else + return 0; +#endif +} + +static inline bool cpuinfo_has_arm_sme(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.sme; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_sme2(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.sme2; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_sme2p1(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.sme2p1; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_sme_i16i32(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.sme_i16i32; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_sme_bi32i32(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.sme_bi32i32; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_sme_b16b16(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.sme_b16b16; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_arm_sme_f16f16(void) { +#if CPUINFO_ARCH_ARM64 + return cpuinfo_isa.sme_f16f16; +#else + return false; +#endif +} + +#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64 +/* This structure is not a part of stable API. Use cpuinfo_has_riscv_* functions + * instead. */ +struct cpuinfo_riscv_isa { + /** + * Keep fields in line with the canonical order as defined by + * Section 27.11 Subset Naming Convention. + */ + /* RV32I/64I/128I Base ISA. */ + bool i; +#if CPUINFO_ARCH_RISCV32 + /* RV32E Base ISA. */ + bool e; +#endif + /* Integer Multiply/Divide Extension. */ + bool m; + /* Atomic Extension. */ + bool a; + /* Single-Precision Floating-Point Extension. */ + bool f; + /* Double-Precision Floating-Point Extension. */ + bool d; + /* Compressed Extension. */ + bool c; + /* Vector Extension. */ + bool v; +}; + +extern struct cpuinfo_riscv_isa cpuinfo_isa; +#endif + +static inline bool cpuinfo_has_riscv_i(void) { +#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64 + return cpuinfo_isa.i; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_riscv_e(void) { +#if CPUINFO_ARCH_RISCV32 + return cpuinfo_isa.e; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_riscv_m(void) { +#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64 + return cpuinfo_isa.m; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_riscv_a(void) { +#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64 + return cpuinfo_isa.a; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_riscv_f(void) { +#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64 + return cpuinfo_isa.f; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_riscv_d(void) { +#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64 + return cpuinfo_isa.d; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_riscv_g(void) { + // The 'G' extension is simply shorthand for 'IMAFD'. + return cpuinfo_has_riscv_i() && cpuinfo_has_riscv_m() && cpuinfo_has_riscv_a() && cpuinfo_has_riscv_f() && + cpuinfo_has_riscv_d(); +} + +static inline bool cpuinfo_has_riscv_c(void) { +#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64 + return cpuinfo_isa.c; +#else + return false; +#endif +} + +static inline bool cpuinfo_has_riscv_v(void) { +#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64 + return cpuinfo_isa.v; +#else + return false; +#endif +} + +const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processors(void); +const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_cores(void); +const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_clusters(void); +const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_packages(void); +const struct cpuinfo_uarch_info* CPUINFO_ABI cpuinfo_get_uarchs(void); +const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_caches(void); +const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_caches(void); +const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_caches(void); +const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_caches(void); +const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_caches(void); + +const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processor(uint32_t index); +const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_core(uint32_t index); +const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_cluster(uint32_t index); +const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_package(uint32_t index); +const struct cpuinfo_uarch_info* CPUINFO_ABI cpuinfo_get_uarch(uint32_t index); +const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_cache(uint32_t index); +const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_cache(uint32_t index); +const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_cache(uint32_t index); +const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_cache(uint32_t index); +const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_cache(uint32_t index); + +uint32_t CPUINFO_ABI cpuinfo_get_processors_count(void); +uint32_t CPUINFO_ABI cpuinfo_get_cores_count(void); +uint32_t CPUINFO_ABI cpuinfo_get_clusters_count(void); +uint32_t CPUINFO_ABI cpuinfo_get_packages_count(void); +uint32_t CPUINFO_ABI cpuinfo_get_uarchs_count(void); +uint32_t CPUINFO_ABI cpuinfo_get_l1i_caches_count(void); +uint32_t CPUINFO_ABI cpuinfo_get_l1d_caches_count(void); +uint32_t CPUINFO_ABI cpuinfo_get_l2_caches_count(void); +uint32_t CPUINFO_ABI cpuinfo_get_l3_caches_count(void); +uint32_t CPUINFO_ABI cpuinfo_get_l4_caches_count(void); + +/** + * Returns upper bound on cache size. + */ +uint32_t CPUINFO_ABI cpuinfo_get_max_cache_size(void); + +/** + * Identify the logical processor that executes the current thread. + * + * There is no guarantee that the thread will stay on the same logical processor + * for any time. Callers should treat the result as only a hint, and be prepared + * to handle NULL return value. + */ +const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_current_processor(void); + +/** + * Identify the core that executes the current thread. + * + * There is no guarantee that the thread will stay on the same core for any + * time. Callers should treat the result as only a hint, and be prepared to + * handle NULL return value. + */ +const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_current_core(void); + +/** + * Identify the microarchitecture index of the core that executes the current + * thread. If the system does not support such identification, the function + * returns 0. + * + * There is no guarantee that the thread will stay on the same type of core for + * any time. Callers should treat the result as only a hint. + */ +uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index(void); + +/** + * Identify the microarchitecture index of the core that executes the current + * thread. If the system does not support such identification, the function + * returns the user-specified default value. + * + * There is no guarantee that the thread will stay on the same type of core for + * any time. Callers should treat the result as only a hint. + */ +uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index_with_default(uint32_t default_uarch_index); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* CPUINFO_H */ diff --git a/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/google/threading.h b/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/google/threading.h new file mode 100644 index 0000000000000000000000000000000000000000..a374e3d7b3d0d428aff29b36c2fa395ebc661692 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/google/threading.h @@ -0,0 +1,60 @@ +/* Copyright 2023 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef THIRD_PARTY_DUCC_GOOGLE_THREADING_H_ +#define THIRD_PARTY_DUCC_GOOGLE_THREADING_H_ + +#include "ducc/src/ducc0/infra/threading.h" +#include "unsupported/Eigen/CXX11/ThreadPool" + +namespace ducc0 { +namespace google { + +using std::size_t; + +// Pseudo thread-pool for single-threaded execution. +class NoThreadPool : public ducc0::detail_threading::thread_pool { + public: + size_t nthreads() const override { return 1; } + size_t adjust_nthreads(size_t nthreads_in) const override { return 1; }; + void submit(std::function work) override { work(); } +}; + +// Thread-pool wrapper around Eigen's ThreadPool. +class EigenThreadPool : public ducc0::detail_threading::thread_pool { + public: + EigenThreadPool(Eigen::ThreadPoolInterface& pool) : pool_{&pool} {} + size_t nthreads() const override { return pool_->NumThreads(); } + size_t adjust_nthreads(size_t nthreads_in) const override { + // If called by a thread in the pool, return 1 + if (pool_->CurrentThreadId() >= 0) { + return 1; + } else if (nthreads_in == 0) { + return pool_->NumThreads(); + } + return std::min(nthreads_in, pool_->NumThreads()); + }; + void submit(std::function work) override { + pool_->Schedule(std::move(work)); + } + + private: + Eigen::ThreadPoolInterface* pool_; +}; + +} // namespace google +} // namespace ducc0 + +#endif // THIRD_PARTY_DUCC_GOOGLE_THREADING_H_ diff --git a/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/fft/fft.h b/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/fft/fft.h new file mode 100644 index 0000000000000000000000000000000000000000..c65e8ee1537e0e46e6081e27cb697ebbd8d859f4 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/fft/fft.h @@ -0,0 +1,1002 @@ +/* +This file is part of the ducc FFT library + +Copyright (C) 2010-2023 Max-Planck-Society +Copyright (C) 2019 Peter Bell + +Authors: Martin Reinecke, Peter Bell +*/ + +/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later */ + +/* +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. +* Neither the name of the copyright holder nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * This code is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This code is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this code; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef DUCC0_FFT_H +#define DUCC0_FFT_H + +#include +#include +#include +#include +#include +#include "ducc0/infra/error_handling.h" +#include "ducc0/infra/aligned_array.h" +#include "ducc0/infra/mav.h" +#include "ducc0/math/cmplx.h" +#include "ducc0/math/unity_roots.h" + +namespace ducc0 { + +namespace detail_fft { + +using namespace std; + +template using Troots = shared_ptr>>; +template inline auto tidx() { return type_index(typeid(T)); } + +template inline void PM(T &a, T &b, T c, T d) + { a=c+d; b=c-d; } +template inline void PMINPLACE(T &a, T &b) + { T t = a; a+=b; b=t-b; } +template inline void MPINPLACE(T &a, T &b) + { T t = a; a-=b; b=t+b; } +template void special_mul (const Cmplx &v1, const Cmplx &v2, Cmplx &res) + { + res = fwd ? Cmplx(v1.r*v2.r+v1.i*v2.i, v1.i*v2.r-v1.r*v2.i) + : Cmplx(v1.r*v2.r-v1.i*v2.i, v1.r*v2.i+v1.i*v2.r); + } + +struct util1d // hack to avoid duplicate symbols + { + /* returns the smallest composite of 2, 3, 5, 7 and 11 which is >= n */ + DUCC0_NOINLINE static size_t good_size_cmplx(size_t n) + { + if (n<=12) return n; + + size_t bestfac=2*n; + for (size_t f11=1; f11n) + { + if (x>=1; + } + else + return n; + } + } + return bestfac; + } + /* returns the smallest composite of 2, 3, 5, 7 and 11 which is >= n + and a multiple of required_factor. */ + DUCC0_NOINLINE static size_t good_size_cmplx(size_t n, + size_t required_factor) + { + MR_assert(required_factor>=1, "required_factor must not be 0"); + return good_size_cmplx((n+required_factor-1)/required_factor) * required_factor; + } + + /* returns the smallest composite of 2, 3, 5 which is >= n */ + DUCC0_NOINLINE static size_t good_size_real(size_t n) + { + if (n<=6) return n; + + size_t bestfac=2*n; + for (size_t f5=1; f5n) + { + if (x>=1; + } + else + return n; + } + } + return bestfac; + } + /* returns the smallest composite of 2, 3, 5 which is >= n + and a multiple of required_factor. */ + DUCC0_NOINLINE static size_t good_size_real(size_t n, + size_t required_factor) + { + MR_assert(required_factor>=1, "required_factor must not be 0"); + return good_size_real((n+required_factor-1)/required_factor) * required_factor; + } + + DUCC0_NOINLINE static vector prime_factors(size_t N) + { + MR_assert(N>0, "need a positive number"); + vector factors; + while ((N&1)==0) + { N>>=1; factors.push_back(2); } + for (size_t divisor=3; divisor*divisor<=N; divisor+=2) + while ((N%divisor)==0) + { + factors.push_back(divisor); + N/=divisor; + } + if (N>1) factors.push_back(N); + return factors; + } + }; + +// T: "type", f/c: "float/complex", s/v: "scalar/vector" +template class cfftpass + { + public: + virtual ~cfftpass(){} + using Tcs = Cmplx; + + // number of Tcd values required as scratch space during "exec" + // will be provided in "buf" + virtual size_t bufsize() const = 0; + virtual bool needs_copy() const = 0; + virtual void *exec(const type_index &ti, void *in, void *copy, void *buf, + bool fwd, size_t nthreads=1) const = 0; + + static vector factorize(size_t N) + { + MR_assert(N>0, "need a positive number"); + vector factors; + factors.reserve(15); + while ((N&7)==0) + { factors.push_back(8); N>>=3; } + while ((N&3)==0) + { factors.push_back(4); N>>=2; } + if ((N&1)==0) + { + N>>=1; + // factor 2 should be at the front of the factor list + factors.push_back(2); + swap(factors[0], factors.back()); + } + for (size_t divisor=3; divisor*divisor<=N; divisor+=2) + while ((N%divisor)==0) + { + factors.push_back(divisor); + N/=divisor; + } + if (N>1) factors.push_back(N); + return factors; + } + + static shared_ptr make_pass(size_t l1, size_t ido, size_t ip, + const Troots &roots, bool vectorize=false); + static shared_ptr make_pass(size_t ip, bool vectorize=false) + { + return make_pass(1,1,ip,make_shared>>(ip), + vectorize); + } + }; + +template class rfftpass + { + public: + virtual ~rfftpass(){} + + // number of Tfd values required as scratch space during "exec" + // will be provided in "buf" + virtual size_t bufsize() const = 0; + virtual bool needs_copy() const = 0; + virtual void *exec(const type_index &ti, void *in, void *copy, void *buf, + bool fwd, size_t nthreads=1) const = 0; + + static vector factorize(size_t N) + { + MR_assert(N>0, "need a positive number"); + vector factors; + while ((N&3)==0) + { factors.push_back(4); N>>=2; } + if ((N&1)==0) + { + N>>=1; + // factor 2 should be at the front of the factor list + factors.push_back(2); + swap(factors[0], factors.back()); + } + for (size_t divisor=3; divisor*divisor<=N; divisor+=2) + while ((N%divisor)==0) + { + factors.push_back(divisor); + N/=divisor; + } + if (N>1) factors.push_back(N); + return factors; + } + + static shared_ptr make_pass(size_t l1, size_t ido, size_t ip, + const Troots &roots, bool vectorize=false); + static shared_ptr make_pass(size_t ip, bool vectorize=false) + { + return make_pass(1,1,ip,make_shared>>(ip), + vectorize); + } + }; + +template using Tcpass = shared_ptr>; +template using Trpass = shared_ptr>; + +template class pocketfft_c + { + private: + size_t N; + size_t critbuf; + Tcpass plan; + + public: + pocketfft_c(size_t n, bool vectorize=false) + : N(n), critbuf(((N&1023)==0) ? 16 : 0), + plan(cfftpass::make_pass(n,vectorize)) {} + size_t length() const { return N; } + size_t bufsize() const { return N*plan->needs_copy()+2*critbuf+plan->bufsize(); } + template DUCC0_NOINLINE Cmplx *exec(Cmplx *in, Cmplx *buf, + Tfs fct, bool fwd, size_t nthreads=1) const + { + static const auto tic = tidx *>(); + auto res = static_cast *>(plan->exec(tic, + in, buf+critbuf+plan->bufsize(), buf+critbuf, fwd, nthreads)); + if (fct!=Tfs(1)) + for (size_t i=0; i DUCC0_NOINLINE void exec_copyback(Cmplx *in, Cmplx *buf, + Tfs fct, bool fwd, size_t nthreads=1) const + { + static const auto tic = tidx *>(); + auto res = static_cast *>(plan->exec(tic, + in, buf, buf+N*plan->needs_copy(), fwd, nthreads)); + if (res==in) + { + if (fct!=Tfs(1)) + for (size_t i=0; i DUCC0_NOINLINE void exec(Cmplx *in, Tfs fct, bool fwd, size_t nthreads=1) const + { + aligned_array> buf(N*plan->needs_copy()+plan->bufsize()); + exec_copyback(in, buf.data(), fct, fwd, nthreads); + } + }; + +template class pocketfft_r + { + private: + size_t N; + Trpass plan; + + public: + pocketfft_r(size_t n, bool vectorize=false) + : N(n), plan(rfftpass::make_pass(n,vectorize)) {} + size_t length() const { return N; } + size_t bufsize() const { return N*plan->needs_copy()+plan->bufsize(); } + template DUCC0_NOINLINE Tfd *exec(Tfd *in, Tfd *buf, Tfs fct, + bool fwd, size_t nthreads=1) const + { + static const auto tifd = tidx(); + auto res = static_cast(plan->exec(tifd, in, buf, + buf+N*plan->needs_copy(), fwd, nthreads)); + if (fct!=Tfs(1)) + for (size_t i=0; i DUCC0_NOINLINE void exec_copyback(Tfd *in, Tfd *buf, + Tfs fct, bool fwd, size_t nthreads=1) const + { + static const auto tifd = tidx(); + auto res = static_cast(plan->exec(tifd, in, buf, + buf+N*plan->needs_copy(), fwd, nthreads)); + if (res==in) + { + if (fct!=Tfs(1)) + for (size_t i=0; i DUCC0_NOINLINE void exec(Tfd *in, Tfs fct, bool fwd, + size_t nthreads=1) const + { + aligned_array buf(N*plan->needs_copy()+plan->bufsize()); + exec_copyback(in, buf.data(), fct, fwd, nthreads); + } + }; + +template class pocketfft_hartley + { + private: + size_t N; + Trpass plan; + + public: + pocketfft_hartley(size_t n, bool vectorize=false) + : N(n), plan(rfftpass::make_pass(n,vectorize)) {} + size_t length() const { return N; } + size_t bufsize() const { return N+plan->bufsize(); } + template DUCC0_NOINLINE Tfd *exec(Tfd *in, Tfd *buf, Tfs fct, + size_t nthreads=1) const + { + static const auto tifd = tidx(); + auto res = static_cast(plan->exec(tifd, + in, buf, buf+N, true, nthreads)); + auto res2 = (res==buf) ? in : buf; + res2[0] = fct*res[0]; + size_t i=1, i1=1, i2=N-1; + for (i=1; i DUCC0_NOINLINE void exec_copyback(Tfd *in, Tfd *buf, + Tfs fct, size_t nthreads=1) const + { + auto res = exec(in, buf, fct, nthreads); + if (res!=in) + copy_n(res, N, in); + } + template DUCC0_NOINLINE void exec(Tfd *in, Tfs fct, + size_t nthreads=1) const + { + aligned_array buf(N+plan->bufsize()); + exec_copyback(in, buf.data(), fct, nthreads); + } + }; + +template class pocketfft_fht + { + private: + size_t N; + Trpass plan; + + public: + pocketfft_fht(size_t n, bool vectorize=false) + : N(n), plan(rfftpass::make_pass(n,vectorize)) {} + size_t length() const { return N; } + size_t bufsize() const { return N+plan->bufsize(); } + template DUCC0_NOINLINE Tfd *exec(Tfd *in, Tfd *buf, Tfs fct, + size_t nthreads=1) const + { + static const auto tifd = tidx(); + auto res = static_cast(plan->exec(tifd, + in, buf, buf+N, true, nthreads)); + auto res2 = (res==buf) ? in : buf; + res2[0] = fct*res[0]; + size_t i=1, i1=1, i2=N-1; + for (i=1; i DUCC0_NOINLINE void exec_copyback(Tfd *in, Tfd *buf, + Tfs fct, size_t nthreads=1) const + { + auto res = exec(in, buf, fct, nthreads); + if (res!=in) + copy_n(res, N, in); + } + template DUCC0_NOINLINE void exec(Tfd *in, Tfs fct, + size_t nthreads=1) const + { + aligned_array buf(N+plan->bufsize()); + exec_copyback(in, buf.data(), fct, nthreads); + } + }; + +// R2R transforms using FFTW's halfcomplex format +template class pocketfft_fftw + { + private: + size_t N; + Trpass plan; + + public: + pocketfft_fftw(size_t n, bool vectorize=false) + : N(n), plan(rfftpass::make_pass(n,vectorize)) {} + size_t length() const { return N; } + size_t bufsize() const { return N+plan->bufsize(); } + template DUCC0_NOINLINE Tfd *exec(Tfd *in, Tfd *buf, Tfs fct, + bool fwd, size_t nthreads=1) const + { + static const auto tifd = tidx(); + auto res = in; + auto res2 = buf; + if (!fwd) // go to FFTPACK halfcomplex order + { + res2[0] = fct*res[0]; + size_t i=1, i1=1, i2=N-1; + for (i=1; i(plan->exec(tifd, + res, res2, buf+N, fwd, nthreads)); + if (!fwd) return res; + + // go to FFTW halfcomplex order + res2 = (res==buf) ? in : buf; + res2[0] = fct*res[0]; + size_t i=1, i1=1, i2=N-1; + for (i=1; i DUCC0_NOINLINE void exec_copyback(Tfd *in, Tfd *buf, + Tfs fct, bool fwd, size_t nthreads=1) const + { + auto res = exec(in, buf, fct, fwd, nthreads); + if (res!=in) + copy_n(res, N, in); + } + template DUCC0_NOINLINE void exec(Tfd *in, Tfs fct, bool fwd, + size_t nthreads=1) const + { + aligned_array buf(N+plan->bufsize()); + exec_copyback(in, buf.data(), fct, fwd, nthreads); + } + }; + +// +// sine/cosine transforms +// + +template class T_dct1 + { + private: + pocketfft_r fftplan; + + public: + DUCC0_NOINLINE T_dct1(size_t length, bool /*vectorize*/=false) + : fftplan(2*(length-1)) {} + + template DUCC0_NOINLINE T *exec(T c[], T buf[], T0 fct, bool ortho, + int /*type*/, bool /*cosine*/, size_t nthreads=1) const + { + constexpr T0 sqrt2=T0(1.414213562373095048801688724209698L); + size_t N=fftplan.length(), n=N/2+1; + if (ortho) + { c[0]*=sqrt2; c[n-1]*=sqrt2; } + auto tmp=&buf[0]; + tmp[0] = c[0]; + for (size_t i=1; i DUCC0_NOINLINE void exec_copyback(T c[], T buf[], T0 fct, bool ortho, + int /*type*/, bool /*cosine*/, size_t nthreads=1) const + { + exec(c, buf, fct, ortho, 1, true, nthreads); + } + template DUCC0_NOINLINE void exec(T c[], T0 fct, bool ortho, + int /*type*/, bool /*cosine*/, size_t nthreads=1) const + { + aligned_array buf(bufsize()); + exec_copyback(c, buf.data(), fct, ortho, 1, true, nthreads); + } + + size_t length() const { return fftplan.length()/2+1; } + size_t bufsize() const { return fftplan.length()+fftplan.bufsize(); } + }; + +template class T_dst1 + { + private: + pocketfft_r fftplan; + + public: + DUCC0_NOINLINE T_dst1(size_t length, bool /*vectorize*/=false) + : fftplan(2*(length+1)) {} + + template DUCC0_NOINLINE T *exec(T c[], T buf[], T0 fct, + bool /*ortho*/, int /*type*/, bool /*cosine*/, size_t nthreads=1) const + { + size_t N=fftplan.length(), n=N/2-1; + auto tmp = &buf[0]; + tmp[0] = tmp[n+1] = c[0]*0; + for (size_t i=0; i DUCC0_NOINLINE void exec_copyback(T c[], T buf[], T0 fct, + bool /*ortho*/, int /*type*/, bool /*cosine*/, size_t nthreads=1) const + { + exec(c, buf, fct, true, 1, false, nthreads); + } + template DUCC0_NOINLINE void exec(T c[], T0 fct, + bool /*ortho*/, int /*type*/, bool /*cosine*/, size_t nthreads) const + { + aligned_array buf(bufsize()); + exec_copyback(c, buf.data(), fct, true, 1, false, nthreads); + } + + size_t length() const { return fftplan.length()/2-1; } + size_t bufsize() const { return fftplan.length()+fftplan.bufsize(); } + }; + +template class T_dcst23 + { + private: + pocketfft_r fftplan; + std::vector twiddle; + + public: + DUCC0_NOINLINE T_dcst23(size_t length, bool /*vectorize*/=false) + : fftplan(length), twiddle(length) + { + UnityRoots> tw(4*length); + for (size_t i=0; i DUCC0_NOINLINE T *exec(T c[], T buf[], T0 fct, bool ortho, + int type, bool cosine, size_t nthreads=1) const + { + constexpr T0 sqrt2=T0(1.414213562373095048801688724209698L); + size_t N=length(); + size_t NS2 = (N+1)/2; + if (type==2) + { + c[0] *= 2; + if ((N&1)==0) c[N-1]*=2; + if (cosine) + for (size_t k=1; k DUCC0_NOINLINE void exec_copyback(T c[], T buf[], T0 fct, + bool ortho, int type, bool cosine, size_t nthreads=1) const + { + exec(c, buf, fct, ortho, type, cosine, nthreads); + } + template DUCC0_NOINLINE void exec(T c[], T0 fct, bool ortho, + int type, bool cosine, size_t nthreads=1) const + { + aligned_array buf(bufsize()); + exec(c, &buf[0], fct, ortho, type, cosine, nthreads); + } + + size_t length() const { return fftplan.length(); } + size_t bufsize() const { return fftplan.bufsize(); } + }; + +template class T_dcst4 + { + private: + size_t N; + std::unique_ptr> fft; + std::unique_ptr> rfft; + aligned_array> C2; + size_t bufsz; + + public: + DUCC0_NOINLINE T_dcst4(size_t length, bool /*vectorize*/=false) + : N(length), + fft((N&1) ? nullptr : make_unique>(N/2)), + rfft((N&1)? make_unique>(N) : nullptr), + C2((N&1) ? 0 : N/2), + bufsz((N&1) ? (N+rfft->bufsize()) : (N+2*fft->bufsize())) + { + if ((N&1)==0) + { + UnityRoots> tw(16*N); + for (size_t i=0; i DUCC0_NOINLINE T *exec(T c[], T buf[], T0 fct, + bool /*ortho*/, int /*type*/, bool cosine, size_t nthreads) const + { + size_t n2 = N/2; + if (!cosine) + for (size_t k=0, kc=N-1; kexec(y, y+N, fct, true, nthreads); + { + auto SGN = [](size_t i) + { + constexpr T0 sqrt2=T0(1.414213562373095048801688724209698L); + return (i&2) ? -sqrt2 : sqrt2; + }; + c[n2] = res[0]*SGN(n2+1); + size_t i=0, i1=1, k=1; + for (; k *>(buf); + for(size_t i=0; iexec(y2, y2+N/2, fct, true, nthreads); + for(size_t i=0, ic=n2-1; i DUCC0_NOINLINE void exec_copyback(T c[], T buf[], T0 fct, + bool /*ortho*/, int /*type*/, bool cosine, size_t nthreads=1) const + { + exec(c, buf, fct, true, 4, cosine, nthreads); + } + template DUCC0_NOINLINE void exec(T c[], T0 fct, + bool /*ortho*/, int /*type*/, bool cosine, size_t nthreads=1) const + { + aligned_array buf(bufsize()); + exec(c, &buf[0], fct, true, 4, cosine, nthreads); + } + + size_t length() const { return N; } + size_t bufsize() const { return bufsz; } + }; + +using shape_t=fmav_info::shape_t; +using stride_t=fmav_info::stride_t; + +constexpr bool FORWARD = true, + BACKWARD = false; + +/// Complex-to-complex Fast Fourier Transform +/** This executes a Fast Fourier Transform on \a in and stores the result in + * \a out. + * + * \a in and \a out must have identical shapes; they may point to the same + * memory; in this case their strides must also be identical. + * + * \a axes specifies the axes over which the transform is carried out. + * + * If \a forward is true, a minus sign will be used in the exponent. + * + * No normalization factors will be applied by default; if multiplication by + * a constant is desired, it can be supplied in \a fct. + * + * If the underlying array has more than one dimension, the computation will + * be distributed over \a nthreads threads. + */ +template DUCC0_NOINLINE void c2c(const cfmav> &in, + const vfmav> &out, const shape_t &axes, bool forward, + T fct, size_t nthreads=1); + +/// Fast Discrete Cosine Transform +/** This executes a DCT on \a in and stores the result in \a out. + * + * \a in and \a out must have identical shapes; they may point to the same + * memory; in this case their strides must also be identical. + * + * \a axes specifies the axes over which the transform is carried out. + * + * If \a forward is true, a DCT is computed, otherwise an inverse DCT. + * + * \a type specifies the desired type (1-4) of the transform. + * + * No normalization factors will be applied by default; if multiplication by + * a constant is desired, it can be supplied in \a fct. + * + * If \a ortho is true, the first and last array entries are corrected (if + * necessary) to allow an orthonormalized transform. + * + * If the underlying array has more than one dimension, the computation will + * be distributed over \a nthreads threads. + */ +template DUCC0_NOINLINE void dct(const cfmav &in, const vfmav &out, + const shape_t &axes, int type, T fct, bool ortho, size_t nthreads=1); + +/// Fast Discrete Sine Transform +/** This executes a DST on \a in and stores the result in \a out. + * + * \a in and \a out must have identical shapes; they may point to the same + * memory; in this case their strides must also be identical. + * + * \a axes specifies the axes over which the transform is carried out. + * + * If \a forward is true, a DST is computed, otherwise an inverse DST. + * + * \a type specifies the desired type (1-4) of the transform. + * + * No normalization factors will be applied by default; if multiplication by + * a constant is desired, it can be supplied in \a fct. + * + * If \a ortho is true, the first and last array entries are corrected (if + * necessary) to allow an orthonormalized transform. + * + * If the underlying array has more than one dimension, the computation will + * be distributed over \a nthreads threads. + */ +template DUCC0_NOINLINE void dst(const cfmav &in, const vfmav &out, + const shape_t &axes, int type, T fct, bool ortho, size_t nthreads=1); + +template DUCC0_NOINLINE void r2c(const cfmav &in, + const vfmav> &out, size_t axis, bool forward, T fct, + size_t nthreads=1); + +template DUCC0_NOINLINE void r2c(const cfmav &in, + const vfmav> &out, const shape_t &axes, + bool forward, T fct, size_t nthreads=1); + +template DUCC0_NOINLINE void c2r(const cfmav> &in, + const vfmav &out, size_t axis, bool forward, T fct, size_t nthreads=1); + +template DUCC0_NOINLINE void c2r(const cfmav> &in, + const vfmav &out, const shape_t &axes, bool forward, T fct, + size_t nthreads=1); + +template DUCC0_NOINLINE void c2r_mut(const vfmav> &in, + const vfmav &out, const shape_t &axes, bool forward, T fct, + size_t nthreads=1); + +template DUCC0_NOINLINE void r2r_fftpack(const cfmav &in, + const vfmav &out, const shape_t &axes, bool real2hermitian, bool forward, + T fct, size_t nthreads=1); + +template DUCC0_NOINLINE void r2r_fftw(const cfmav &in, + const vfmav &out, const shape_t &axes, bool forward, + T fct, size_t nthreads=1); + +template DUCC0_NOINLINE void r2r_separable_hartley(const cfmav &in, + const vfmav &out, const shape_t &axes, T fct, size_t nthreads=1); + +template DUCC0_NOINLINE void r2r_separable_fht(const cfmav &in, + const vfmav &out, const shape_t &axes, T fct, size_t nthreads=1); + +template void r2r_genuine_hartley(const cfmav &in, + const vfmav &out, const shape_t &axes, T fct, size_t nthreads=1); + +template void r2r_genuine_fht(const cfmav &in, + const vfmav &out, const shape_t &axes, T fct, size_t nthreads=1); + +/// Convolution and zero-padding/truncation along one axis +/** This performs a circular convolution with the kernel \a kernel on axis + * \a axis of \a in, applies the necessary zero-padding/truncation on this + * axis to give it the length \a out.shape(axis),and returns the result + * in \a out. + * + * The main purpose of this routine is efficiency: the combination of the above + * operations can be carried out more quickly than running the individual + * operations in succession. + * + * \a in and \a out must have identical shapes, with the possible exception + * of the axis \a axis; they may point to the same memory; in this case all + * of their strides must be identical. + * + * \a axis specifies the axis over which the operation is carried out. + * + * \a kernel must have the same length as \a in.shape(axis); it must be + * provided in the same domain as \a in (i.e. not pre-transformed). + * + * If \a in has more than one dimension, the computation will + * be distributed over \a nthreads threads. + */ +template DUCC0_NOINLINE void convolve_axis(const cfmav &in, + const vfmav &out, size_t axis, const cmav &kernel, size_t nthreads=1); + +template DUCC0_NOINLINE void convolve_axis(const cfmav> &in, + const vfmav> &out, size_t axis, const cmav,1> &kernel, + size_t nthreads=1); +} + +using detail_fft::pocketfft_c; +using detail_fft::pocketfft_r; +using detail_fft::pocketfft_hartley; +using detail_fft::pocketfft_fht; +using detail_fft::pocketfft_fftw; + +using detail_fft::FORWARD; +using detail_fft::BACKWARD; +using detail_fft::c2c; +using detail_fft::c2r; +using detail_fft::c2r_mut; +using detail_fft::r2c; +using detail_fft::r2r_fftpack; +using detail_fft::r2r_fftw; +using detail_fft::r2r_separable_hartley; +using detail_fft::r2r_genuine_hartley; +using detail_fft::r2r_separable_fht; +using detail_fft::r2r_genuine_fht; +using detail_fft::dct; +using detail_fft::dst; +using detail_fft::convolve_axis; + +inline size_t good_size_complex(size_t n) + { return detail_fft::util1d::good_size_cmplx(n); } +inline size_t good_size_real(size_t n) + { return detail_fft::util1d::good_size_real(n); } +inline size_t good_size_complex(size_t n, size_t required_factor) + { return detail_fft::util1d::good_size_cmplx(n, required_factor); } +inline size_t good_size_real(size_t n, size_t required_factor) + { return detail_fft::util1d::good_size_real(n, required_factor); } + +} + +#endif diff --git a/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/fft/fft1d_impl.h b/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/fft/fft1d_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..2fa14fc3ec37da2320315c3fcf59668460b684dd --- /dev/null +++ b/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/fft/fft1d_impl.h @@ -0,0 +1,2990 @@ +/* +This file is part of the ducc FFT library + +Copyright (C) 2010-2023 Max-Planck-Society +Copyright (C) 2019 Peter Bell + +For the odd-sized DCT-IV transforms: + Copyright (C) 2003, 2007-14 Matteo Frigo + Copyright (C) 2003, 2007-14 Massachusetts Institute of Technology + +Authors: Martin Reinecke, Peter Bell +*/ + +/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later */ + +/* +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. +* Neither the name of the copyright holder nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * This code is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This code is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this code; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef DUCC0_FFT1D_IMPL_H +#define DUCC0_FFT1D_IMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ducc0/infra/useful_macros.h" +#include "ducc0/math/cmplx.h" +#include "ducc0/infra/error_handling.h" +#include "ducc0/infra/aligned_array.h" +#include "ducc0/infra/simd.h" +#include "ducc0/infra/threading.h" +#include "ducc0/math/unity_roots.h" +#include "ducc0/fft/fft.h" + +namespace ducc0 { + +namespace detail_fft { + +using namespace std; + +// the next line is necessary to address some sloppy name choices in AdaptiveCpp +using std::min, std::max; + +template constexpr inline size_t fft1d_simdlen + = min(8, native_simd::size()); +template<> constexpr inline size_t fft1d_simdlen + = min(4, native_simd::size()); +template<> constexpr inline size_t fft1d_simdlen + = min(8, native_simd::size()); +template using fft1d_simd = typename simd_select>::type; +template constexpr inline bool fft1d_simd_exists = (fft1d_simdlen > 1); + +// Always use std:: for functions +template T cos(T) = delete; +template T sin(T) = delete; +template T sqrt(T) = delete; + +template void ROTX90(Cmplx &a) + { auto tmp_= fwd ? -a.r : a.r; a.r = fwd ? a.i : -a.i; a.i=tmp_; } + +#define POCKETFFT_EXEC_DISPATCH \ + virtual void *exec(const type_index &ti, void *in, void *copy, void *buf, \ + bool fwd, size_t nthreads=1) const \ + { \ + static const auto tics = tidx(); \ + if (ti==tics) \ + { \ + auto in1 = static_cast(in); \ + auto copy1 = static_cast(copy); \ + auto buf1 = static_cast(buf); \ + return fwd ? exec_(in1, copy1, buf1, nthreads) \ + : exec_(in1, copy1, buf1, nthreads); \ + } \ + if constexpr (fft1d_simdlen > 1) \ + if constexpr (simd_exists>) \ + { \ + using Tfv = typename simd_select>::type; \ + using Tcv = Cmplx; \ + static const auto ticv = tidx(); \ + if (ti==ticv) \ + { \ + auto in1 = static_cast(in); \ + auto copy1 = static_cast(copy); \ + auto buf1 = static_cast(buf); \ + return fwd ? exec_(in1, copy1, buf1, nthreads) \ + : exec_(in1, copy1, buf1, nthreads); \ + } \ + } \ + if constexpr (fft1d_simdlen > 2) \ + if constexpr (simd_exists/2>) \ + { \ + using Tfv = typename simd_select/2>::type; \ + using Tcv = Cmplx; \ + static const auto ticv = tidx(); \ + if (ti==ticv) \ + { \ + auto in1 = static_cast(in); \ + auto copy1 = static_cast(copy); \ + auto buf1 = static_cast(buf); \ + return fwd ? exec_(in1, copy1, buf1, nthreads) \ + : exec_(in1, copy1, buf1, nthreads); \ + } \ + } \ + if constexpr (fft1d_simdlen > 4) \ + if constexpr (simd_exists/4>) \ + { \ + using Tfv = typename simd_select/4>::type; \ + using Tcv = Cmplx; \ + static const auto ticv = tidx(); \ + if (ti==ticv) \ + { \ + auto in1 = static_cast(in); \ + auto copy1 = static_cast(copy); \ + auto buf1 = static_cast(buf); \ + return fwd ? exec_(in1, copy1, buf1, nthreads) \ + : exec_(in1, copy1, buf1, nthreads); \ + } \ + } \ + if constexpr (fft1d_simdlen > 8) \ + if constexpr (simd_exists/8>) \ + { \ + using Tfv = typename simd_select/8>::type; \ + using Tcv = Cmplx; \ + static const auto ticv = tidx(); \ + if (ti==ticv) \ + { \ + auto in1 = static_cast(in); \ + auto copy1 = static_cast(copy); \ + auto buf1 = static_cast(buf); \ + return fwd ? exec_(in1, copy1, buf1, nthreads) \ + : exec_(in1, copy1, buf1, nthreads); \ + } \ + } \ + MR_fail("impossible vector length requested"); \ + } + +template class cfftp1: public cfftpass + { + public: + cfftp1() {} + virtual size_t bufsize() const { return 0; } + virtual bool needs_copy() const { return false; } + + virtual void *exec(const type_index & /*ti*/, void * in, void * /*copy*/, + void * /*buf*/, bool /*fwd*/, size_t /*nthreads*/) const + { return in; } + }; + +template class cfftp2: public cfftpass + { + private: + using typename cfftpass::Tcs; + + size_t l1, ido; + static constexpr size_t ip=2; + aligned_array wa; + + auto WA(size_t i) const + { return wa[i-1]; } + + template Tcd *exec_ (const Tcd * DUCC0_RESTRICT cc, + Tcd * DUCC0_RESTRICT ch, Tcd * /*buf*/, size_t /*nthreads*/) const + { + if (ido==1) + { + auto CH = [ch,this](size_t b, size_t c) -> Tcd& + { return ch[b+l1*c]; }; + auto CC = [cc](size_t b, size_t c) -> const Tcd& + { return cc[b+ip*c]; }; + for (size_t k=0; k Tcd& + { return ch[a+ido*(b+l1*c)]; }; + auto CC = [cc,this](size_t a, size_t b, size_t c) -> const Tcd& + { return cc[a+ido*(b+ip*c)]; }; + for (size_t k=0; k(CC(i,0,k)-CC(i,1,k),WA(i),CH(i,k,1)); + } + } + return ch; + } + } + + public: + cfftp2(size_t l1_, size_t ido_, const Troots &roots) + : l1(l1_), ido(ido_), wa((ip-1)*(ido-1)) + { + size_t N=ip*l1*ido; + size_t rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t i=1; i class cfftp3: public cfftpass + { + private: + using typename cfftpass::Tcs; + + size_t l1, ido; + static constexpr size_t ip=3; + aligned_array wa; + + auto WA(size_t x, size_t i) const + { return wa[x+(i-1)*(ip-1)]; } + + template Tcd *exec_ + (const Tcd * DUCC0_RESTRICT cc, Tcd * DUCC0_RESTRICT ch, Tcd * /*buf*/, + size_t /*nthreads*/) const + { + constexpr Tfs tw1r=-0.5, + tw1i= (fwd ? -1: 1) * Tfs(0.8660254037844386467637231707529362L); + + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tcd& + { return ch[a+ido*(b+l1*c)]; }; + auto CC = [cc,this](size_t a, size_t b, size_t c) -> const Tcd& + { return cc[a+ido*(b+ip*c)]; }; + +#define POCKETFFT_PREP3(idx) \ + Tcd t0 = CC(idx,0,k), t1, t2; \ + PM (t1,t2,CC(idx,1,k),CC(idx,2,k)); \ + CH(idx,k,0)=t0+t1; +#define POCKETFFT_PARTSTEP3a(u1,u2,twr,twi) \ + { \ + Tcd ca=t0+t1*twr; \ + Tcd cb{-t2.i*twi, t2.r*twi}; \ + PM(CH(0,k,u1),CH(0,k,u2),ca,cb) ;\ + } +#define POCKETFFT_PARTSTEP3b(u1,u2,twr,twi) \ + { \ + Tcd ca=t0+t1*twr; \ + Tcd cb{-t2.i*twi, t2.r*twi}; \ + special_mul(ca+cb,WA(u1-1,i),CH(i,k,u1)); \ + special_mul(ca-cb,WA(u2-1,i),CH(i,k,u2)); \ + } + + if (ido==1) + for (size_t k=0; k &roots) + : l1(l1_), ido(ido_), wa((ip-1)*(ido-1)) + { + size_t N=ip*l1*ido; + size_t rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t i=1; i class cfftp4: public cfftpass + { + private: + using typename cfftpass::Tcs; + + size_t l1, ido; + static constexpr size_t ip=4; + aligned_array wa; + + auto WA(size_t x, size_t i) const + { return wa[x+(i-1)*(ip-1)]; } + + template Tcd *exec_ + (const Tcd * DUCC0_RESTRICT cc, Tcd * DUCC0_RESTRICT ch, Tcd * /*buf*/, + size_t /*nthreads*/) const + { + if (ido==1) + { + auto CH = [ch,this](size_t b, size_t c) -> Tcd& + { return ch[b+l1*c]; }; + auto CC = [cc](size_t b, size_t c) -> const Tcd& + { return cc[b+ip*c]; }; + for (size_t k=0; k(t4); + PM(CH(k,0),CH(k,2),t2,t3); + PM(CH(k,1),CH(k,3),t1,t4); + } + } + else + { + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tcd& + { return ch[a+ido*(b+l1*c)]; }; + auto CC = [cc,this](size_t a, size_t b, size_t c) -> const Tcd& + { return cc[a+ido*(b+ip*c)]; }; + for (size_t k=0; k(t4); + PM(CH(0,k,0),CH(0,k,2),t2,t3); + PM(CH(0,k,1),CH(0,k,3),t1,t4); + } + for (size_t i=1; i(t4); + CH(i,k,0) = t2+t3; + special_mul(t1+t4,WA(0,i),CH(i,k,1)); + special_mul(t2-t3,WA(1,i),CH(i,k,2)); + special_mul(t1-t4,WA(2,i),CH(i,k,3)); + } + } + } + return ch; + } + + public: + cfftp4(size_t l1_, size_t ido_, const Troots &roots) + : l1(l1_), ido(ido_), wa((ip-1)*(ido-1)) + { + size_t N=ip*l1*ido; + size_t rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t i=1; i class cfftp5: public cfftpass + { + private: + using typename cfftpass::Tcs; + + size_t l1, ido; + static constexpr size_t ip=5; + aligned_array wa; + + auto WA(size_t x, size_t i) const + { return wa[x+(i-1)*(ip-1)]; } + + template Tcd *exec_ + (const Tcd * DUCC0_RESTRICT cc, Tcd * DUCC0_RESTRICT ch, Tcd * /*buf*/, + size_t /*nthreads*/) const + { + constexpr Tfs tw1r= Tfs(0.3090169943749474241022934171828191L), + tw1i= (fwd ? -1: 1) * Tfs(0.9510565162951535721164393333793821L), + tw2r= Tfs(-0.8090169943749474241022934171828191L), + tw2i= (fwd ? -1: 1) * Tfs(0.5877852522924731291687059546390728L); + + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tcd& + { return ch[a+ido*(b+l1*c)]; }; + auto CC = [cc,this](size_t a, size_t b, size_t c) -> const Tcd& + { return cc[a+ido*(b+ip*c)]; }; + +#define POCKETFFT_PREP5(idx) \ + Tcd t0 = CC(idx,0,k), t1, t2, t3, t4; \ + PM (t1,t4,CC(idx,1,k),CC(idx,4,k)); \ + PM (t2,t3,CC(idx,2,k),CC(idx,3,k)); \ + CH(idx,k,0).r=t0.r+t1.r+t2.r; \ + CH(idx,k,0).i=t0.i+t1.i+t2.i; + +#define POCKETFFT_PARTSTEP5a(u1,u2,twar,twbr,twai,twbi) \ + { \ + Tcd ca,cb; \ + ca.r=t0.r+twar*t1.r+twbr*t2.r; \ + ca.i=t0.i+twar*t1.i+twbr*t2.i; \ + cb.i=twai*t4.r twbi*t3.r; \ + cb.r=-(twai*t4.i twbi*t3.i); \ + PM(CH(0,k,u1),CH(0,k,u2),ca,cb); \ + } + +#define POCKETFFT_PARTSTEP5b(u1,u2,twar,twbr,twai,twbi) \ + { \ + Tcd ca,cb,da,db; \ + ca.r=t0.r+twar*t1.r+twbr*t2.r; \ + ca.i=t0.i+twar*t1.i+twbr*t2.i; \ + cb.i=twai*t4.r twbi*t3.r; \ + cb.r=-(twai*t4.i twbi*t3.i); \ + special_mul(ca+cb,WA(u1-1,i),CH(i,k,u1)); \ + special_mul(ca-cb,WA(u2-1,i),CH(i,k,u2)); \ + } + + if (ido==1) + for (size_t k=0; k &roots) + : l1(l1_), ido(ido_), wa((ip-1)*(ido-1)) + { + size_t N=ip*l1*ido; + auto rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t i=1; i class cfftp7: public cfftpass + { + private: + using typename cfftpass::Tcs; + + size_t l1, ido; + static constexpr size_t ip=7; + aligned_array wa; + + auto WA(size_t x, size_t i) const + { return wa[x+(i-1)*(ip-1)]; } + + template Tcd *exec_ + (const Tcd * DUCC0_RESTRICT cc, Tcd * DUCC0_RESTRICT ch, Tcd * /*buf*/, + size_t /*nthreads*/) const + { + constexpr Tfs tw1r= Tfs(0.6234898018587335305250048840042398L), + tw1i= (fwd ? -1 : 1) * Tfs(0.7818314824680298087084445266740578L), + tw2r= Tfs(-0.2225209339563144042889025644967948L), + tw2i= (fwd ? -1 : 1) * Tfs(0.9749279121818236070181316829939312L), + tw3r= Tfs(-0.9009688679024191262361023195074451L), + tw3i= (fwd ? -1 : 1) * Tfs(0.433883739117558120475768332848359L); + + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tcd& + { return ch[a+ido*(b+l1*c)]; }; + auto CC = [cc,this](size_t a, size_t b, size_t c) -> const Tcd& + { return cc[a+ido*(b+ip*c)]; }; + +#define POCKETFFT_PREP7(idx) \ + Tcd t1 = CC(idx,0,k), t2, t3, t4, t5, t6, t7; \ + PM (t2,t7,CC(idx,1,k),CC(idx,6,k)); \ + PM (t3,t6,CC(idx,2,k),CC(idx,5,k)); \ + PM (t4,t5,CC(idx,3,k),CC(idx,4,k)); \ + CH(idx,k,0).r=t1.r+t2.r+t3.r+t4.r; \ + CH(idx,k,0).i=t1.i+t2.i+t3.i+t4.i; + +#define POCKETFFT_PARTSTEP7a0(u1,u2,x1,x2,x3,y1,y2,y3,out1,out2) \ + { \ + Tcd ca,cb; \ + ca.r=t1.r+x1*t2.r+x2*t3.r+x3*t4.r; \ + ca.i=t1.i+x1*t2.i+x2*t3.i+x3*t4.i; \ + cb.i=y1*t7.r y2*t6.r y3*t5.r; \ + cb.r=-(y1*t7.i y2*t6.i y3*t5.i); \ + PM(out1,out2,ca,cb); \ + } +#define POCKETFFT_PARTSTEP7a(u1,u2,x1,x2,x3,y1,y2,y3) \ + POCKETFFT_PARTSTEP7a0(u1,u2,x1,x2,x3,y1,y2,y3,CH(0,k,u1),CH(0,k,u2)) +#define POCKETFFT_PARTSTEP7(u1,u2,x1,x2,x3,y1,y2,y3) \ + { \ + Tcd da,db; \ + POCKETFFT_PARTSTEP7a0(u1,u2,x1,x2,x3,y1,y2,y3,da,db) \ + special_mul(da,WA(u1-1,i),CH(i,k,u1)); \ + special_mul(db,WA(u2-1,i),CH(i,k,u2)); \ + } + + if (ido==1) + for (size_t k=0; k &roots) + : l1(l1_), ido(ido_), wa((ip-1)*(ido-1)) + { + size_t N=ip*l1*ido; + auto rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t i=1; i class cfftp8: public cfftpass + { + private: + using typename cfftpass::Tcs; + + size_t l1, ido; + static constexpr size_t ip=8; + aligned_array wa; + + auto WA(size_t x, size_t i) const + { return wa[x+(i-1)*(ip-1)]; } + + template void ROTX45(T &a) const + { + constexpr Tfs hsqt2=Tfs(0.707106781186547524400844362104849L); + if constexpr (fwd) + { auto tmp_=a.r; a.r=hsqt2*(a.r+a.i); a.i=hsqt2*(a.i-tmp_); } + else + { auto tmp_=a.r; a.r=hsqt2*(a.r-a.i); a.i=hsqt2*(a.i+tmp_); } + } + template void ROTX135(T &a) const + { + constexpr Tfs hsqt2=Tfs(0.707106781186547524400844362104849L); + if constexpr (fwd) + { auto tmp_=a.r; a.r=hsqt2*(a.i-a.r); a.i=hsqt2*(-tmp_-a.i); } + else + { auto tmp_=a.r; a.r=hsqt2*(-a.r-a.i); a.i=hsqt2*(tmp_-a.i); } + } + + template Tcd *exec_ + (Tcd * DUCC0_RESTRICT cc, Tcd * DUCC0_RESTRICT ch, Tcd * /*buf*/, size_t /*nthreads*/) const + { + if (l1==1) + { + auto CC = [cc,this](size_t a, size_t b) -> Tcd& + { return cc[a+ido*b]; }; + { + Tcd a0, a1, a2, a3, a4, a5, a6, a7; + PM(a1,a5,CC(0,1),CC(0,5)); + PM(a3,a7,CC(0,3),CC(0,7)); + PMINPLACE(a1,a3); + ROTX90(a3); + + ROTX90(a7); + PMINPLACE(a5,a7); + ROTX45(a5); + ROTX135(a7); + + PM(a0,a4,CC(0,0),CC(0,4)); + PM(a2,a6,CC(0,2),CC(0,6)); + PM(CC(0,0),CC(0,4),a0+a2,a1); + PM(CC(0,2),CC(0,6),a0-a2,a3); + ROTX90(a6); + PM(CC(0,1),CC(0,5),a4+a6,a5); + PM(CC(0,3),CC(0,7),a4-a6,a7); + } + for (size_t i=1; i(a7); + PMINPLACE(a1,a3); + ROTX90(a3); + PMINPLACE(a5,a7); + ROTX45(a5); + ROTX135(a7); + PM(a0,a4,CC(i,0),CC(i,4)); + PM(a2,a6,CC(i,2),CC(i,6)); + PMINPLACE(a0,a2); + CC(i,0) = a0+a1; + special_mul(a0-a1,WA(3,i),CC(i,4)); + special_mul(a2+a3,WA(1,i),CC(i,2)); + special_mul(a2-a3,WA(5,i),CC(i,6)); + ROTX90(a6); + PMINPLACE(a4,a6); + special_mul(a4+a5,WA(0,i),CC(i,1)); + special_mul(a4-a5,WA(4,i),CC(i,5)); + special_mul(a6+a7,WA(2,i),CC(i,3)); + special_mul(a6-a7,WA(6,i),CC(i,7)); + } + return cc; + } + if (ido==1) + { + auto CH = [ch,this](size_t b, size_t c) -> Tcd& + { return ch[b+l1*c]; }; + auto CC = [cc](size_t b, size_t c) -> const Tcd& + { return cc[b+ip*c]; }; + for (size_t k=0; k(a3); + + ROTX90(a7); + PMINPLACE(a5,a7); + ROTX45(a5); + ROTX135(a7); + + PM(a0,a4,CC(0,k),CC(4,k)); + PM(a2,a6,CC(2,k),CC(6,k)); + PM(CH(k,0),CH(k,4),a0+a2,a1); + PM(CH(k,2),CH(k,6),a0-a2,a3); + ROTX90(a6); + PM(CH(k,1),CH(k,5),a4+a6,a5); + PM(CH(k,3),CH(k,7),a4-a6,a7); + } + } + else + { + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tcd& + { return ch[a+ido*(b+l1*c)]; }; + auto CC = [cc,this](size_t a, size_t b, size_t c) -> const Tcd& + { return cc[a+ido*(b+ip*c)]; }; + for (size_t k=0; k(a3); + + ROTX90(a7); + PMINPLACE(a5,a7); + ROTX45(a5); + ROTX135(a7); + + PM(a0,a4,CC(0,0,k),CC(0,4,k)); + PM(a2,a6,CC(0,2,k),CC(0,6,k)); + PM(CH(0,k,0),CH(0,k,4),a0+a2,a1); + PM(CH(0,k,2),CH(0,k,6),a0-a2,a3); + ROTX90(a6); + PM(CH(0,k,1),CH(0,k,5),a4+a6,a5); + PM(CH(0,k,3),CH(0,k,7),a4-a6,a7); + } + for (size_t i=1; i(a7); + PMINPLACE(a1,a3); + ROTX90(a3); + PMINPLACE(a5,a7); + ROTX45(a5); + ROTX135(a7); + PM(a0,a4,CC(i,0,k),CC(i,4,k)); + PM(a2,a6,CC(i,2,k),CC(i,6,k)); + PMINPLACE(a0,a2); + CH(i,k,0) = a0+a1; + special_mul(a0-a1,WA(3,i),CH(i,k,4)); + special_mul(a2+a3,WA(1,i),CH(i,k,2)); + special_mul(a2-a3,WA(5,i),CH(i,k,6)); + ROTX90(a6); + PMINPLACE(a4,a6); + special_mul(a4+a5,WA(0,i),CH(i,k,1)); + special_mul(a4-a5,WA(4,i),CH(i,k,5)); + special_mul(a6+a7,WA(2,i),CH(i,k,3)); + special_mul(a6-a7,WA(6,i),CH(i,k,7)); + } + } + } + return ch; + } + + public: + cfftp8(size_t l1_, size_t ido_, const Troots &roots) + : l1(l1_), ido(ido_), wa((ip-1)*(ido-1)) + { + size_t N=ip*l1*ido; + auto rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t i=1; i1; } + + POCKETFFT_EXEC_DISPATCH + }; + +template class cfftp11: public cfftpass + { + private: + using typename cfftpass::Tcs; + + size_t l1, ido; + static constexpr size_t ip=11; + aligned_array wa; + + auto WA(size_t x, size_t i) const + { return wa[x+(i-1)*(ip-1)]; } + + template [[gnu::hot]] Tcd *exec_ + (const Tcd * DUCC0_RESTRICT cc, Tcd * DUCC0_RESTRICT ch, Tcd * /*buf*/, + size_t /*nthreads*/) const + { + constexpr Tfs tw1r= Tfs(0.8412535328311811688618116489193677L), + tw1i= (fwd ? -1 : 1) * Tfs(0.5406408174555975821076359543186917L), + tw2r= Tfs(0.4154150130018864255292741492296232L), + tw2i= (fwd ? -1 : 1) * Tfs(0.9096319953545183714117153830790285L), + tw3r= Tfs(-0.1423148382732851404437926686163697L), + tw3i= (fwd ? -1 : 1) * Tfs(0.9898214418809327323760920377767188L), + tw4r= Tfs(-0.6548607339452850640569250724662936L), + tw4i= (fwd ? -1 : 1) * Tfs(0.7557495743542582837740358439723444L), + tw5r= Tfs(-0.9594929736144973898903680570663277L), + tw5i= (fwd ? -1 : 1) * Tfs(0.2817325568414296977114179153466169L); + + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tcd& + { return ch[a+ido*(b+l1*c)]; }; + auto CC = [cc,this](size_t a, size_t b, size_t c) -> const Tcd& + { return cc[a+ido*(b+ip*c)]; }; + +#define POCKETFFT_PREP11(idx) \ + Tcd t1 = CC(idx,0,k), t2, t3, t4, t5, t6, t7, t8, t9, t10, t11; \ + PM (t2,t11,CC(idx,1,k),CC(idx,10,k)); \ + PM (t3,t10,CC(idx,2,k),CC(idx, 9,k)); \ + PM (t4,t9 ,CC(idx,3,k),CC(idx, 8,k)); \ + PM (t5,t8 ,CC(idx,4,k),CC(idx, 7,k)); \ + PM (t6,t7 ,CC(idx,5,k),CC(idx, 6,k)); \ + CH(idx,k,0).r=t1.r+t2.r+t3.r+t4.r+t5.r+t6.r; \ + CH(idx,k,0).i=t1.i+t2.i+t3.i+t4.i+t5.i+t6.i; + +#define POCKETFFT_PARTSTEP11a0(u1,u2,x1,x2,x3,x4,x5,y1,y2,y3,y4,y5,out1,out2) \ + { \ + Tcd ca = t1 + t2*x1 + t3*x2 + t4*x3 + t5*x4 +t6*x5, \ + cb; \ + cb.i=y1*t11.r y2*t10.r y3*t9.r y4*t8.r y5*t7.r; \ + cb.r=-(y1*t11.i y2*t10.i y3*t9.i y4*t8.i y5*t7.i ); \ + PM(out1,out2,ca,cb); \ + } +#define POCKETFFT_PARTSTEP11a(u1,u2,x1,x2,x3,x4,x5,y1,y2,y3,y4,y5) \ + POCKETFFT_PARTSTEP11a0(u1,u2,x1,x2,x3,x4,x5,y1,y2,y3,y4,y5,CH(0,k,u1),CH(0,k,u2)) +#define POCKETFFT_PARTSTEP11(u1,u2,x1,x2,x3,x4,x5,y1,y2,y3,y4,y5) \ + { \ + Tcd da,db; \ + POCKETFFT_PARTSTEP11a0(u1,u2,x1,x2,x3,x4,x5,y1,y2,y3,y4,y5,da,db) \ + special_mul(da,WA(u1-1,i),CH(i,k,u1)); \ + special_mul(db,WA(u2-1,i),CH(i,k,u2)); \ + } + + if (ido==1) + for (size_t k=0; k &roots) + : l1(l1_), ido(ido_), wa((ip-1)*(ido-1)) + { + size_t N=ip*l1*ido; + auto rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t i=1; i class cfftpg: public cfftpass + { + private: + using typename cfftpass::Tcs; + + size_t l1, ido; + size_t ip; + aligned_array wa; + aligned_array csarr; + + auto WA(size_t x, size_t i) const + { return wa[i-1+x*(ido-1)]; } + + template Tcd *exec_ + (Tcd * DUCC0_RESTRICT cc, Tcd * DUCC0_RESTRICT ch, Tcd * /*buf*/, size_t /*nthreads*/) const + { + size_t ipph = (ip+1)/2; + size_t idl1 = ido*l1; + + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tcd& + { return ch[a+ido*(b+l1*c)]; }; + auto CC = [cc,this](size_t a, size_t b, size_t c) -> const Tcd& + { return cc[a+ido*(b+ip*c)]; }; + auto CX = [cc,this](size_t a, size_t b, size_t c) -> Tcd& + { return cc[a+ido*(b+l1*c)]; }; + auto CX2 = [cc, idl1](size_t a, size_t b) -> Tcd& + { return cc[a+idl1*b]; }; + auto CH2 = [ch, idl1](size_t a, size_t b) -> const Tcd& + { return ch[a+idl1*b]; }; + + for (size_t k=0; kip) iwal-=ip; + Tcs xwal=fwd ? csarr[iwal].conj() : csarr[iwal]; + iwal+=l; if (iwal>ip) iwal-=ip; + Tcs xwal2=fwd ? csarr[iwal].conj() : csarr[iwal]; + for (size_t ik=0; ikip) iwal-=ip; + Tcs xwal=fwd ? csarr[iwal].conj() : csarr[iwal]; + for (size_t ik=0; ik(x1,wa[idij],CX(i,k,j)); + idij=(jc-1)*(ido-1)+i-1; + special_mul(x2,wa[idij],CX(i,k,jc)); + } + } + } + return cc; + } + + public: + cfftpg(size_t l1_, size_t ido_, size_t ip_, const Troots &roots) + : l1(l1_), ido(ido_), ip(ip_), wa((ip-1)*(ido-1)), csarr(ip) + { + MR_assert((ip&1)&&(ip>=5), "need an odd number >=5"); + size_t N=ip*l1*ido; + auto rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t j=1; j class cfftpblue: public cfftpass + { + private: + using typename cfftpass::Tcs; + + const size_t l1, ido, ip; + const size_t ip2; + const Tcpass subplan; + aligned_array wa, bk, bkf; + size_t bufsz; + bool need_cpy; + + auto WA(size_t x, size_t i) const + { return wa[i-1+x*(ido-1)]; } + + template Tcd *exec_ + (Tcd * DUCC0_RESTRICT cc, Tcd * DUCC0_RESTRICT ch, + Tcd * DUCC0_RESTRICT buf, size_t nthreads) const + { + static const auto ti=tidx(); + Tcd *akf = &buf[0]; + Tcd *akf2 = subplan->needs_copy() ? (&buf[ip2]) : akf; + Tcd *subbuf = akf2+ip2; + + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tcd& + { return ch[a+ido*(b+l1*c)]; }; + auto CC = [cc,this](size_t a, size_t b, size_t c) -> Tcd& + { return cc[a+ido*(b+ip*c)]; }; + +//FIXME: parallelize here? + for (size_t k=0; k(CC(i,m,k),bk[m],akf[m]); + auto zero = akf[0]*Tfs(0); + for (size_t m=ip; m(subplan->exec(ti,akf,akf2, + subbuf, true, nthreads)); + + /* do the convolution */ + res[0] = res[0].template special_mul(bkf[0]); + for (size_t m=1; m<(ip2+1)/2; ++m) + { + res[m] = res[m].template special_mul(bkf[m]); + res[ip2-m] = res[ip2-m].template special_mul(bkf[m]); + } + if ((ip2&1)==0) + res[ip2/2] = res[ip2/2].template special_mul(bkf[ip2/2]); + + /* inverse FFT */ + res = static_cast(subplan->exec(ti, res, + (res==akf) ? akf2 : akf, subbuf, false, nthreads)); + + /* multiply by b_k and write to output buffer */ + if (l1>1) + { + if (i==0) + for (size_t m=0; m(bk[m]); + else + { + CH(i,k,0) = res[0].template special_mul(bk[0]); + for (size_t m=1; m(bk[m]*WA(m-1,i)); + } + } + else + { + if (i==0) + for (size_t m=0; m(bk[m]); + else + { + CC(i,0,0) = res[0].template special_mul(bk[0]); + for (size_t m=1; m(bk[m]*WA(m-1,i)); + } + } + } + + return (l1>1) ? ch : cc; + } + + public: + cfftpblue(size_t l1_, size_t ido_, size_t ip_, const Troots &roots, + bool vectorize=false) + : l1(l1_), ido(ido_), ip(ip_), ip2(util1d::good_size_cmplx(ip*2-1)), + subplan(cfftpass::make_pass(ip2, vectorize)), wa((ip-1)*(ido-1)), + bk(ip), bkf(ip2/2+1) + { + size_t N=ip*l1*ido; + auto rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t j=1; jsize()/(2*ip))*2*ip==roots->size()) ? + roots : make_shared>(2*ip); + size_t rfct2 = roots2->size()/(2*ip); + for (size_t m=1; m=2*ip) coeff-=2*ip; + bk[m] = (*roots2)[coeff*rfct2]; + } + + /* initialize the zero-padded, Fourier transformed b_k. Add normalisation. */ + aligned_array tbkf(ip2), tbkf2(ip2); + Tfs xn2 = Tfs(1)/Tfs(ip2); + tbkf[0] = bk[0]*xn2; + for (size_t m=1; m buf(subplan->bufsize()); + static const auto tics=tidx(); + auto res = static_cast(subplan->exec(tics, tbkf.data(), + tbkf2.data(), buf.data(), true)); + for (size_t i=0; i1; + bufsz = ip2*(1+subplan->needs_copy()) + subplan->bufsize(); + } + + virtual size_t bufsize() const { return bufsz; } + virtual bool needs_copy() const { return need_cpy; } + + POCKETFFT_EXEC_DISPATCH + }; + +template class cfft_multipass: public cfftpass + { + private: + using typename cfftpass::Tcs; + static constexpr size_t bunchsize=8; + + const size_t l1, ido; + size_t ip; + vector> passes; + size_t bufsz; + bool need_cpy; + size_t rfct; + Troots myroots; + +// FIXME split into sub-functions. This is too long! + template Cmplx *exec_(Cmplx *cc, Cmplx *ch, + Cmplx *buf, size_t nthreads) const + { + using Tc = Cmplx; + if ((l1==1) && (ido==1)) // no chance at vectorizing + { + static const auto tic=tidx(); + Tc *p1=cc, *p2=ch; + for(const auto &pass: passes) + { + auto res = static_cast(pass->exec(tic, p1, p2, buf, + fwd, nthreads)); + if (res==p2) swap (p1,p2); + } + return p1; + } + else + { + if constexpr(is_same::value && fft1d_simd_exists) // we can vectorize! + { + using Tfv = fft1d_simd; + using Tcv = Cmplx; + constexpr size_t vlen = Tfv::size(); + size_t nvtrans = (l1*ido + vlen-1)/vlen; + // NOTE: removed "static" here, because it leads to trouble with gcc 7 + // static const type_index ticv = tidx(); + const type_index ticv = tidx(); + + if (ido==1) + { + auto CH = [ch,this](size_t b, size_t c) -> Tc& + { return ch[b+l1*c]; }; + auto CC = [cc,this](size_t b, size_t c) -> Tc& + { return cc[b+ip*c]; }; + + execStatic(nvtrans, nthreads, 0, [&](auto &sched) + { + aligned_array tbuf(2*ip+32+bufsize()); + auto cc2 = &tbuf[0]; + auto ch2 = &tbuf[ip+16]; + auto buf2 = &tbuf[2*ip+32]; + + while (auto rng=sched.getNext()) + for(auto itrans=rng.lo; itrans(pass->exec(ticv, + p1, p2, buf2, fwd)); + if (res==p2) swap (p1,p2); + } + + for (size_t m=0; m Tc& + { return cc[a+ido*b]; }; + + execStatic(nvtrans, nthreads, 0, [&](auto &sched) + { + aligned_array tbuf(2*ip+32+bufsize()); + auto cc2 = &tbuf[0]; + auto ch2 = &tbuf[ip+16]; + auto buf2 = &tbuf[2*ip+32]; + + while (auto rng=sched.getNext()) + for(auto itrans=rng.lo; itrans(pass->exec(ticv, + p1, p2, buf2, fwd)); + if (res==p2) swap (p1,p2); + } + + for (size_t m=0; m= ido) break; + if (i==0) + CC(0,m) = { p1[m].r[n], p1[m].i[n] }; + else + { + if (m==0) + CC(i,0) = { p1[0].r[n], p1[0].i[n] } ; + else + CC(i,m) = Tcs(p1[m].r[n],p1[m].i[n]).template special_mul((*myroots)[rfct*m*i]); + } + } + } + }); + return cc; + } + +MR_fail("must not get here"); +#if 0 +//FIXME this code path is currently unused + aligned_array tbuf(2*ip+bufsize()); + auto cc2 = &tbuf[0]; + auto ch2 = &tbuf[ip]; + auto buf2 = &tbuf[2*ip]; + + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tc& + { return ch[a+ido*(b+l1*c)]; }; + auto CC = [cc,this](size_t a, size_t b, size_t c) -> Tc& + { return cc[a+ido*(b+ip*c)]; }; + +//FIXME parallelize? + for (size_t itrans=0; itrans ix, kx; + size_t ixcur = (itrans*vlen)%ido; + size_t kxcur = (itrans*vlen)/ido; + for (size_t n=0; n(pass->exec(ticv, + p1, p2, buf2, fwd)); + if (res==p2) swap (p1,p2); + } + + for (size_t m=0; m= l1*ido) break; + if (i==0) + CH(0,k,m) = { p1[m].r[n], p1[m].i[n] }; + else + { + if (m==0) + CH(i,k,0) = { p1[0].r[n], p1[0].i[n] } ; + else + CH(i,k,m) = Tcs(p1[m].r[n],p1[m].i[n]).template special_mul((*myroots)[rfct*l1*m*i]); + } + } + } + return ch; +#endif + } + else + { + static const auto tic = tidx *>(); + if (ido==1) + { +// parallelize here! + for (size_t n=0; n *p1=&cc[n*ip], *p2=ch; + Cmplx *res = nullptr; + for(const auto &pass: passes) + { + res = static_cast *>(pass->exec(tic, + p1, p2, buf, fwd)); + if (res==p2) swap (p1,p2); + } + if (res != &cc[n*ip]) + copy(res, res+ip, cc+n*ip); + } + // transpose + size_t nbunch = (l1*ido + bunchsize-1)/bunchsize; +// parallelize here! + for (size_t ibunch=0; ibunch Tc& + { return cc[a+ido*b]; }; + +// parallelize here! + for (size_t ibunch=0; ibunch *p1=&cc2[n*ip], *p2=ch2; + Cmplx *res = nullptr; + for(const auto &pass: passes) + { + res = static_cast *>(pass->exec(tic, + p1, p2, buf2, fwd)); + if (res==p2) swap (p1,p2); + } + if (res==&cc2[n*ip]) // no copying necessary + { + if (i!=0) + { + for (size_t m=1; m((*myroots)[rfct*m*i]); + } + } + else + { + if (i==0) + for (size_t m=0; m((*myroots)[rfct*m*i]); + } + } + } + for (size_t m=0; m Tc& + { return ch[a+ido*(b+l1*c)]; }; + auto CC = [cc,this](size_t a, size_t b, size_t c) -> Tc& + { return cc[a+ido*(b+ip*c)]; }; + +// parallelize here! + for (size_t ibunch=0; ibunch ix, kx; + size_t ixcur = (ibunch*bunchsize)%ido; + size_t kxcur = (ibunch*bunchsize)/ido; + for (size_t n=0; n *p1=&cc2[n*ip], *p2=ch2; + Cmplx *res = nullptr; + for(const auto &pass: passes) + { + res = static_cast *>(pass->exec(tic, + p1, p2, buf2, fwd)); + if (res==p2) swap (p1,p2); + } + if (res==&cc2[n*ip]) // no copying necessary + { + if (i!=0) + { + for (size_t m=1; m((*myroots)[rfct*l1*m*i]); + } + } + else + { + if (i==0) + for (size_t m=0; m((*myroots)[rfct*l1*m*i]); + } + } + } + for (size_t m=0; m &roots, bool /*vectorize*/=false) + : l1(l1_), ido(ido_), ip(ip_), bufsz(0), need_cpy(false), + myroots(roots) + { + size_t N=ip*l1*ido; + rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + + // FIXME TBD +// do we need the vectorize flag at all? + size_t lim = 10000; //vectorize ? 10000 : 10000; + if (ip<=lim) + { + auto factors = cfftpass::factorize(ip); + size_t l1l=1; + for (auto fct: factors) + { + passes.push_back(cfftpass::make_pass(l1l, ip/(fct*l1l), fct, roots, false)); + l1l*=fct; + } + } + else + { + vector packets(2,1); + auto factors = util1d::prime_factors(ip); + sort(factors.begin(), factors.end(), std::greater()); + for (auto fct: factors) + (packets[0]>packets[1]) ? packets[1]*=fct : packets[0]*=fct; + size_t l1l=1; + for (auto pkt: packets) + { + passes.push_back(cfftpass::make_pass(l1l, ip/(pkt*l1l), pkt, roots, false)); + l1l*=pkt; + } + } + for (const auto &pass: passes) + { + bufsz = max(bufsz, pass->bufsize()); + need_cpy |= pass->needs_copy(); + } + if ((l1!=1)||(ido!=1)) + { + need_cpy=true; + bufsz += (bunchsize+1)*ip; + } + } + + virtual size_t bufsize() const { return bufsz; } + virtual bool needs_copy() const { return need_cpy; } + + POCKETFFT_EXEC_DISPATCH + }; + +#undef POCKETFFT_EXEC_DISPATCH + +template class cfftp_vecpass: public cfftpass + { + private: + static_assert(simd_exists, "bad vlen"); + using typename cfftpass::Tcs; + using Tfv=typename simd_select::type; + using Tcv=Cmplx; + + size_t ip; + Tcpass spass; + Tcpass vpass; + size_t bufsz; + + template Tcs *exec_ (Tcs *cc, + Tcs * /*ch*/, Tcs *sbuf, size_t nthreads) const + { + char *xbuf = reinterpret_cast(sbuf); + size_t misalign = reinterpret_cast(xbuf)&(sizeof(Tfv)-1); + if (misalign != 0) + xbuf += sizeof(Tfv)-misalign; + Tcv *buf = reinterpret_cast(xbuf); + auto * cc2 = buf; + auto * ch2 = buf+ip/vlen+7; + auto * buf2 = buf+2*ip/vlen+7+7; + static const auto tics = tidx(); +// run scalar pass + auto res = static_cast(spass->exec(tics, cc, + reinterpret_cast(ch2), reinterpret_cast(buf2), + fwd, nthreads)); +// arrange input in SIMD-friendly way, must be done out-of-place + for (size_t i=0; i(); + auto res2 = static_cast(vpass->exec(ticv, + cc2, ch2, buf2, fwd, nthreads)); +// de-SIMDify, can be done pseudo-inplace + for (size_t i=0; i &roots) + : ip(ip_), spass(cfftpass::make_pass(1, ip/vlen, vlen, roots)), + vpass(cfftpass::make_pass(1, 1, ip/vlen, roots)), bufsz(0) + { + MR_assert((ip/vlen)*vlen==ip, "cannot vectorize this size"); + bufsz = 2*(ip/vlen)+7+7; + bufsz += max(vpass->bufsize(),(spass->bufsize()+vlen-1)/vlen); // buffers for subpasses + bufsz *= vlen; // since we specify in terms of Tcs + bufsz += vlen; // wiggle room for alignment shifts + } + virtual size_t bufsize() const { return bufsz; } + virtual bool needs_copy() const { return false; } + virtual void *exec(const type_index &ti, void *in, void *copy, void *buf, + bool fwd, size_t nthreads=1) const + { + static const auto tics = tidx(); + MR_assert(ti==tics, "bad input type"); + auto in1 = static_cast(in); + auto copy1 = static_cast(copy); + auto buf1 = static_cast(buf); + return fwd ? exec_(in1, copy1, buf1, nthreads) + : exec_(in1, copy1, buf1, nthreads); + } + }; + +template Tcpass cfftpass::make_pass(size_t l1, + size_t ido, size_t ip, const Troots &roots, bool vectorize) + { + MR_assert(ip>=1, "no zero-sized FFTs"); + // do we have an 1D vectorizable FFT? + if (vectorize && (ip>300)&& (ip<=100000) && (l1==1) && (ido==1)) + { +// constexpr auto vlen = native_simd::size(); +// if constexpr(vlen>=4) + constexpr auto vlen = 4; + if constexpr(simd_exists) + if ((ip&(vlen-1))==0) + return make_shared>(ip, roots); + } + + if (ip==1) return make_shared>(); + auto factors=cfftpass::factorize(ip); + if (factors.size()==1) + { + switch(ip) + { + case 2: + return make_shared>(l1, ido, roots); + case 3: + return make_shared>(l1, ido, roots); + case 4: + return make_shared>(l1, ido, roots); + case 5: + return make_shared>(l1, ido, roots); + case 7: + return make_shared>(l1, ido, roots); + case 8: + return make_shared>(l1, ido, roots); + case 11: + return make_shared>(l1, ido, roots); + default: + if (ip<110) + return make_shared>(l1, ido, ip, roots); + else + return make_shared>(l1, ido, ip, roots, vectorize); + } + } + else // more than one factor, need a multipass + return make_shared>(l1, ido, ip, roots, vectorize); + } + +#define POCKETFFT_EXEC_DISPATCH \ + virtual void *exec(const type_index &ti, void *in, void *copy, void *buf, \ + bool fwd, size_t nthreads) const \ + { \ + static const auto tifs=tidx(); \ + if (ti==tifs) \ + { \ + auto in1 = static_cast(in); \ + auto copy1 = static_cast(copy); \ + auto buf1 = static_cast(buf); \ + return fwd ? exec_(in1, copy1, buf1, nthreads) \ + : exec_(in1, copy1, buf1, nthreads); \ + } \ + if constexpr (fft1d_simdlen > 1) \ + if constexpr (simd_exists>) \ + { \ + using Tfv = typename simd_select>::type; \ + static const auto tifv=tidx(); \ + if (ti==tifv) \ + { \ + auto in1 = static_cast(in); \ + auto copy1 = static_cast(copy); \ + auto buf1 = static_cast(buf); \ + return fwd ? exec_(in1, copy1, buf1, nthreads) \ + : exec_(in1, copy1, buf1, nthreads); \ + } \ + } \ + if constexpr (fft1d_simdlen > 2) \ + if constexpr (simd_exists/2>) \ + { \ + using Tfv = typename simd_select/2>::type; \ + static const auto tifv=tidx(); \ + if (ti==tifv) \ + { \ + auto in1 = static_cast(in); \ + auto copy1 = static_cast(copy); \ + auto buf1 = static_cast(buf); \ + return fwd ? exec_(in1, copy1, buf1, nthreads) \ + : exec_(in1, copy1, buf1, nthreads); \ + } \ + } \ + if constexpr (fft1d_simdlen > 4) \ + if constexpr (simd_exists/4>) \ + { \ + using Tfv = typename simd_select/4>::type; \ + static const auto tifv=tidx(); \ + if (ti==tifv) \ + { \ + auto in1 = static_cast(in); \ + auto copy1 = static_cast(copy); \ + auto buf1 = static_cast(buf); \ + return fwd ? exec_(in1, copy1, buf1, nthreads) \ + : exec_(in1, copy1, buf1, nthreads); \ + } \ + } \ + if constexpr (fft1d_simdlen > 8) \ + if constexpr (simd_exists/8>) \ + { \ + using Tfv = typename simd_select/8>::type; \ + static const auto tifv=tidx(); \ + if (ti==tifv) \ + { \ + auto in1 = static_cast(in); \ + auto copy1 = static_cast(copy); \ + auto buf1 = static_cast(buf); \ + return fwd ? exec_(in1, copy1, buf1, nthreads) \ + : exec_(in1, copy1, buf1, nthreads); \ + } \ + } \ + MR_fail("impossible vector length requested"); \ + } + +/* (a+ib) = conj(c+id) * (e+if) */ +template inline void MULPM + (T1 &a, T1 &b, T2 c, T2 d, T3 e, T3 f) + { a=c*e+d*f; b=c*f-d*e; } + +template class rfftp1: public rfftpass + { + public: + rfftp1() {} + virtual size_t bufsize() const { return 0; } + virtual bool needs_copy() const { return false; } + + virtual void *exec(const type_index & /*ti*/, void * in, void * /*copy*/, + void * /*buf*/, bool /*fwd*/, size_t /*nthreads*/) const + { return in; } + }; + +template class rfftp2: public rfftpass + { + private: + size_t l1, ido; + static constexpr size_t ip=2; + aligned_array wa; + + auto WA(size_t x, size_t i) const + { return wa[i+x*(ido-1)]; } + + template Tfd *exec_ (Tfd * DUCC0_RESTRICT cc, + Tfd * DUCC0_RESTRICT ch, Tfd * /*buf*/, size_t /*nthreads*/) const + { + if constexpr(fwd) + { + auto CC = [cc,this](size_t a, size_t b, size_t c) -> const Tfd& + { return cc[a+ido*(b+l1*c)]; }; + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tfd& + { return ch[a+ido*(b+ip*c)]; }; + for (size_t k=0; k const Tfd& + { return cc[a+ido*(b+ip*c)]; }; + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tfd& + { return ch[a+ido*(b+l1*c)]; }; + + for (size_t k=0; k &roots) + : l1(l1_), ido(ido_), wa((ip-1)*(ido-1)) + { + size_t N=ip*l1*ido; + size_t rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t j=1; j class rfftp3: public rfftpass + { + private: + size_t l1, ido; + static constexpr size_t ip=3; + aligned_array wa; + + auto WA(size_t x, size_t i) const + { return wa[i+x*(ido-1)]; } + + template Tfd *exec_ (Tfd * DUCC0_RESTRICT cc, + Tfd * DUCC0_RESTRICT ch, Tfd * /*buf*/, size_t /*nthreads*/) const + { + constexpr Tfs taur=Tfs(-0.5), + taui=Tfs(0.8660254037844386467637231707529362L); + if constexpr(fwd) + { + auto CC = [cc,this](size_t a, size_t b, size_t c) -> const Tfd& + { return cc[a+ido*(b+l1*c)]; }; + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tfd& + { return ch[a+ido*(b+ip*c)]; }; + for (size_t k=0; k const Tfd& + { return cc[a+ido*(b+ip*c)]; }; + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tfd& + { return ch[a+ido*(b+l1*c)]; }; + + for (size_t k=0; k &roots) + : l1(l1_), ido(ido_), wa((ip-1)*(ido-1)) + { + MR_assert(ido&1, "ido must be odd"); + size_t N=ip*l1*ido; + size_t rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t j=1; j class rfftp4: public rfftpass + { + private: + size_t l1, ido; + static constexpr size_t ip=4; + aligned_array wa; + + auto WA(size_t x, size_t i) const + { return wa[i+x*(ido-1)]; } + + template Tfd *exec_ (Tfd * DUCC0_RESTRICT cc, + Tfd * DUCC0_RESTRICT ch, Tfd * /*buf*/, size_t /*nthreads*/) const + { + if constexpr(fwd) + { + constexpr Tfs hsqt2=Tfs(0.707106781186547524400844362104849L); + auto CC = [cc,this](size_t a, size_t b, size_t c) -> const Tfd& + { return cc[a+ido*(b+l1*c)]; }; + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tfd& + { return ch[a+ido*(b+ip*c)]; }; + + for (size_t k=0; k const Tfd& + { return cc[a+ido*(b+ip*c)]; }; + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tfd& + { return ch[a+ido*(b+l1*c)]; }; + + for (size_t k=0; k &roots) + : l1(l1_), ido(ido_), wa((ip-1)*(ido-1)) + { + size_t N=ip*l1*ido; + size_t rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t j=1; j class rfftp5: public rfftpass + { + private: + size_t l1, ido; + static constexpr size_t ip=5; + aligned_array wa; + + auto WA(size_t x, size_t i) const + { return wa[i+x*(ido-1)]; } + + template Tfd *exec_ (Tfd * DUCC0_RESTRICT cc, + Tfd * DUCC0_RESTRICT ch, Tfd * /*buf*/, size_t /*nthreads*/) const + { + constexpr Tfs tr11= Tfs(0.3090169943749474241022934171828191L), + ti11= Tfs(0.9510565162951535721164393333793821L), + tr12= Tfs(-0.8090169943749474241022934171828191L), + ti12= Tfs(0.5877852522924731291687059546390728L); + + if constexpr(fwd) + { + auto CC = [cc,this](size_t a, size_t b, size_t c) -> const Tfd& + { return cc[a+ido*(b+l1*c)]; }; + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tfd& + { return ch[a+ido*(b+ip*c)]; }; + + for (size_t k=0; k const Tfd& + { return cc[a+ido*(b+ip*c)]; }; + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tfd& + { return ch[a+ido*(b+l1*c)]; }; + + for (size_t k=0; k &roots) + : l1(l1_), ido(ido_), wa((ip-1)*(ido-1)) + { + MR_assert(ido&1, "ido must be odd"); + size_t N=ip*l1*ido; + size_t rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t j=1; j class rfftpg: public rfftpass + { + private: + size_t l1, ido; + size_t ip; + aligned_array wa, csarr; + + template Tfd *exec_ (Tfd * DUCC0_RESTRICT cc, + Tfd * DUCC0_RESTRICT ch, Tfd * /*buf*/, size_t /*nthreads*/) const + { + if constexpr(fwd) + { + size_t ipph=(ip+1)/2; + size_t idl1 = ido*l1; + + auto CC = [cc,this](size_t a, size_t b, size_t c) -> Tfd& + { return cc[a+ido*(b+ip*c)]; }; + auto CH = [ch,this](size_t a, size_t b, size_t c) -> const Tfd& + { return ch[a+ido*(b+l1*c)]; }; + auto C1 = [cc,this] (size_t a, size_t b, size_t c) -> Tfd& + { return cc[a+ido*(b+l1*c)]; }; + auto C2 = [cc,idl1] (size_t a, size_t b) -> Tfd& + { return cc[a+idl1*b]; }; + auto CH2 = [ch,idl1] (size_t a, size_t b) -> Tfd& + { return ch[a+idl1*b]; }; + + if (ido>1) + { + for (size_t j=1, jc=ip-1; j=ip) iang-=ip; + Tfs ar1=csarr[2*iang], ai1=csarr[2*iang+1]; + iang+=l; if (iang>=ip) iang-=ip; + Tfs ar2=csarr[2*iang], ai2=csarr[2*iang+1]; + iang+=l; if (iang>=ip) iang-=ip; + Tfs ar3=csarr[2*iang], ai3=csarr[2*iang+1]; + iang+=l; if (iang>=ip) iang-=ip; + Tfs ar4=csarr[2*iang], ai4=csarr[2*iang+1]; + for (size_t ik=0; ik=ip) iang-=ip; + Tfs ar1=csarr[2*iang], ai1=csarr[2*iang+1]; + iang+=l; if (iang>=ip) iang-=ip; + Tfs ar2=csarr[2*iang], ai2=csarr[2*iang+1]; + for (size_t ik=0; ik=ip) iang-=ip; + Tfs ar=csarr[2*iang], ai=csarr[2*iang+1]; + for (size_t ik=0; ik const Tfd& + { return cc[a+ido*(b+ip*c)]; }; + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tfd& + { return ch[a+ido*(b+l1*c)]; }; + auto C1 = [cc,this](size_t a, size_t b, size_t c) -> const Tfd& + { return cc[a+ido*(b+l1*c)]; }; + auto C2 = [cc,idl1](size_t a, size_t b) -> Tfd& + { return cc[a+idl1*b]; }; + auto CH2 = [ch,idl1](size_t a, size_t b) -> Tfd& + { return ch[a+idl1*b]; }; + + for (size_t k=0; kip) iang-=ip; + Tfs ar1=csarr[2*iang], ai1=csarr[2*iang+1]; + iang+=l; if(iang>ip) iang-=ip; + Tfs ar2=csarr[2*iang], ai2=csarr[2*iang+1]; + iang+=l; if(iang>ip) iang-=ip; + Tfs ar3=csarr[2*iang], ai3=csarr[2*iang+1]; + iang+=l; if(iang>ip) iang-=ip; + Tfs ar4=csarr[2*iang], ai4=csarr[2*iang+1]; + for (size_t ik=0; ikip) iang-=ip; + Tfs ar1=csarr[2*iang], ai1=csarr[2*iang+1]; + iang+=l; if(iang>ip) iang-=ip; + Tfs ar2=csarr[2*iang], ai2=csarr[2*iang+1]; + for (size_t ik=0; ikip) iang-=ip; + Tfs war=csarr[2*iang], wai=csarr[2*iang+1]; + for (size_t ik=0; ik &roots) + : l1(l1_), ido(ido_), ip(ip_), wa((ip-1)*(ido-1)), csarr(2*ip) + { + MR_assert(ido&1, "ido must be odd"); + size_t N=ip*l1*ido; + size_t rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t j=1; j class rfftpblue: public rfftpass + { + private: + const size_t l1, ido, ip; + aligned_array wa; + const Tcpass cplan; + size_t bufsz; + bool need_cpy; + + auto WA(size_t x, size_t i) const + { return wa[i+x*(ido-1)]; } + + template Tfd *exec_ + (Tfd * DUCC0_RESTRICT cc, Tfd * DUCC0_RESTRICT ch, + Tfd * DUCC0_RESTRICT buf_, size_t nthreads) const + { + using Tcd = Cmplx; + auto buf = reinterpret_cast(buf_); + Tcd *cc2 = &buf[0]; + Tcd *ch2 = &buf[ip]; + Tcd *subbuf = &buf[2*ip]; + static const auto ticd = tidx(); + + if constexpr(fwd) + { + auto CC = [cc,this](size_t a, size_t b, size_t c) -> const Tfd& + { return cc[a+ido*(b+l1*c)]; }; + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tfd& + { return ch[a+ido*(b+ip*c)]; }; + + for (size_t k=0; k(cplan->exec(ticd, cc2, ch2, + subbuf, fwd, nthreads)); + // copy out + CH(0,0,k) = res[0].r; + for (size_t m=1; m<=ip/2; ++m) + { + CH(ido-1,2*m-1,k)=res[m].r; + CH(0,2*m,k)=res[m].i; + } + } + if (ido==1) return ch; + size_t ipph = (ip+1)/2; + for (size_t k=0; k(cplan->exec(ticd, cc2, ch2, + subbuf, fwd, nthreads)); + CH(i-1,0,k) = res[0].r; + CH(i,0,k) = res[0].i; + for (size_t m=1; m Tfd& + { return cc[a+ido*(b+ip*c)]; }; + auto CH = [ch,this](size_t a, size_t b, size_t c) -> Tfd& + { return ch[a+ido*(b+l1*c)]; }; + + for (size_t k=0; k(cplan->exec(ticd, cc2, ch2, + subbuf, fwd, nthreads)); + for (size_t m=0; m(cplan->exec(ticd, cc2, ch2, + subbuf, fwd, nthreads)); + CH(i-1,k,0) = res[0].r; + CH(i,k,0) = res[0].i; + for (size_t m=1; m &roots, bool vectorize=false) + : l1(l1_), ido(ido_), ip(ip_), wa((ip-1)*(ido-1)), + cplan(cfftpass::make_pass(1,1,ip,roots,vectorize)) + { + MR_assert(ip&1, "Bluestein length must be odd"); + MR_assert(ido&1, "ido must be odd"); + size_t N=ip*l1*ido; + auto rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t j=1; jbufsize(); } + virtual bool needs_copy() const { return true; } + + POCKETFFT_EXEC_DISPATCH + }; + +template class rfft_multipass: public rfftpass + { + private: + const size_t l1, ido; + size_t ip; + vector> passes; + size_t bufsz; + bool need_cpy; + aligned_array wa; + + auto WA(size_t x, size_t i) const + { return wa[(i-1)*(ip-1)+x]; } + + template Tfd *exec_(Tfd *cc, Tfd *ch, Tfd *buf, + size_t nthreads) const + { + static const auto tifd = tidx(); + if ((l1==1) && (ido==1)) + { + Tfd *p1=cc, *p2=ch; + if constexpr (fwd) + for (auto it=passes.rbegin(); it!=passes.rend(); ++it) + { + auto res = static_cast((*it)->exec(tifd, + p1, p2, buf, fwd, nthreads)); + if (res==p2) swap(p1,p2); + } + else + for (const auto &pass: passes) + { + auto res = static_cast(pass->exec(tifd, + p1, p2, buf, fwd, nthreads)); + if (res==p2) swap(p1,p2); + } + return p1; + } + else + MR_fail("not yet supported"); + } + + public: + rfft_multipass(size_t l1_, size_t ido_, size_t ip_, + const Troots &roots, bool /*vectorize*/=false) + : l1(l1_), ido(ido_), ip(ip_), bufsz(0), need_cpy(false), + wa((ip-1)*(ido-1)) + { + size_t N=ip*l1*ido; + auto rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + for (size_t j=1; j::factorize(ip); + + size_t l1l=1; + for (auto fct: factors) + { + passes.push_back(rfftpass::make_pass(l1l, ip/(fct*l1l), fct, roots)); + l1l*=fct; + } + for (const auto &pass: passes) + { + bufsz = max(bufsz, pass->bufsize()); + need_cpy |= pass->needs_copy(); + } + if ((l1!=1)||(ido!=1)) + { + need_cpy=true; + bufsz += 2*ip; + } + } + + virtual size_t bufsize() const { return bufsz; } + virtual bool needs_copy() const { return need_cpy; } + + POCKETFFT_EXEC_DISPATCH + }; + +template class rfftp_complexify: public rfftpass + { + private: + size_t N; + Troots roots; + size_t rfct; + Tcpass pass; + size_t l1, ido; + static constexpr size_t ip=2; + + template Tfd *exec_ (Tfd * DUCC0_RESTRICT cc, + Tfd * DUCC0_RESTRICT ch, Tfd * buf, size_t nthreads) const + { + using Tcd = Cmplx; + auto ccc = reinterpret_cast(cc); + auto cch = reinterpret_cast(ch); + auto cbuf = reinterpret_cast(buf); + static const auto ticd = tidx(); + if constexpr(fwd) + { + auto res = static_cast(pass->exec(ticd, + ccc, cch, cbuf, true, nthreads)); + auto rres = (res==ccc) ? ch : cc; + rres[0] = res[0].r+res[0].i; +//FIXME: parallelize? + for (size_t i=1, xi=N/2-1; i<=xi; ++i, --xi) + { + auto xe = res[i]+res[xi].conj(); + auto xo = Tcd(res[i].i+res[xi].i, res[xi].r-res[i].r) + * (*roots)[rfct*i].conj(); + rres[2*i-1] = Tfs(0.5)*(xe.r+xo.r); + rres[2*i] = Tfs(0.5)*(xe.i+xo.i); + rres[2*xi-1] = Tfs(0.5)*(xe.r-xo.r); + rres[2*xi] = Tfs(0.5)*(xo.i-xe.i); + } + rres[N-1] = res[0].r-res[0].i; + return rres; + } + else + { + cch[0] = Tcd(cc[0]+cc[N-1], cc[0]-cc[N-1]); +//FIXME: parallelize? + for (size_t i=1, xi=N/2-1; i<=xi; ++i, --xi) + { + Tcd t1 (cc[2*i-1], cc[2*i]); + Tcd t2 (cc[2*xi-1], -cc[2*xi]); + auto xe = t1+t2; + auto xo = (t1-t2)*(*roots)[rfct*i]; + cch[i] = (xe + Tcd(-xo.i, xo.r)); + cch[xi] = (xe.conj() + Tcd(xo.i, xo.r)); + } + auto res = static_cast(pass->exec(ticd, + cch, ccc, cbuf, false, nthreads)); + return (res==ccc) ? cc : ch; + } + } + + public: + rfftp_complexify(size_t N_, const Troots &roots_, bool vectorize=false) + : N(N_), roots(roots_), pass(cfftpass::make_pass(N/2, vectorize)) + { + rfct = roots->size()/N; + MR_assert(roots->size()==N*rfct, "mismatch"); + MR_assert((N&1)==0, "N must be even"); + } + + virtual size_t bufsize() const { return 2*pass->bufsize(); } + virtual bool needs_copy() const { return true; } + + POCKETFFT_EXEC_DISPATCH + }; +#undef POCKETFFT_EXEC_DISPATCH + +template Trpass rfftpass::make_pass(size_t l1, + size_t ido, size_t ip, const Troots &roots, bool vectorize) + { + MR_assert(ip>=1, "no zero-sized FFTs"); + if (ip==1) return make_shared>(); + if ((ip>1000) && ((ip&1)==0)) // use complex transform + { + bool doit = vectorize&&((ip&7)==0); // vecpass might be beneficial + doit |= ip>10000; // complex multipass might be beneficial + if (!doit) + { + auto factors = rfftpass::factorize(ip); + for (auto factor: factors) + // complex Bluestein or larger prime factor functions might be beneficial + if (factor>5) { doit=true; break; } + } + if (doit) + return make_shared>(ip, roots, vectorize); + } + auto factors=rfftpass::factorize(ip); + if (factors.size()==1) + { + switch(ip) + { + case 2: + return make_shared>(l1, ido, roots); + case 3: + return make_shared>(l1, ido, roots); + case 4: + return make_shared>(l1, ido, roots); + case 5: + return make_shared>(l1, ido, roots); + default: + if (ip<135) + return make_shared>(l1, ido, ip, roots); + else + return make_shared>(l1, ido, ip, roots, vectorize); + } + } + else // more than one factor, need a multipass + return make_shared>(l1, ido, ip, roots, vectorize); + } + +}} + +#endif diff --git a/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/fft/fftnd_impl.h b/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/fft/fftnd_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..7bded79efb7ade39bc60e122f76e927ddd1508d6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/fft/fftnd_impl.h @@ -0,0 +1,1883 @@ +/* +This file is part of the ducc FFT library. + +Copyright (C) 2010-2024 Max-Planck-Society +Copyright (C) 2019 Peter Bell + +Authors: Martin Reinecke, Peter Bell +*/ + +/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later */ + +/* +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. +* Neither the name of the copyright holder nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * This code is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This code is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this code; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef DUCC0_FFTND_IMPL_H +#define DUCC0_FFTND_IMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ducc0/infra/useful_macros.h" +#include "ducc0/infra/error_handling.h" +#include "ducc0/infra/threading.h" +#include "ducc0/infra/misc_utils.h" +#include "ducc0/infra/simd.h" +#include "ducc0/infra/mav.h" +#include "ducc0/infra/aligned_array.h" +#include "ducc0/math/cmplx.h" +#include "ducc0/math/unity_roots.h" +#include "ducc0/fft/fft1d_impl.h" + +/** \file fft.h + * Implementation of multi-dimensional Fast Fourier and related transforms + * \copyright Copyright (C) 2010-2021 Max-Planck-Society + * \copyright Copyright (C) 2019 Peter Bell + * \copyright + * \copyright For the odd-sized DCT-IV transforms: + * \copyright Copyright (C) 2003, 2007-14 Matteo Frigo + * \copyright Copyright (C) 2003, 2007-14 Massachusetts Institute of Technology + * + * \authors Martin Reinecke, Peter Bell + */ + +namespace ducc0 { + +namespace detail_fft { + +// the next line is necessary to address some sloppy name choices in AdaptiveCpp +using std::min, std::max; + +template constexpr inline size_t fft_simdlen + = min(8, native_simd::size()); +template<> constexpr inline size_t fft_simdlen + = min(4, native_simd::size()); +template<> constexpr inline size_t fft_simdlen + = min(8, native_simd::size()); +template using fft_simd = typename simd_select>::type; +template constexpr inline bool fft_simd_exists = (fft_simdlen > 1); + +struct util // hack to avoid duplicate symbols + { + static void sanity_check_axes(size_t ndim, const shape_t &axes) + { + if (ndim==1) + { + if ((axes.size()!=1) || (axes[0]!=0)) + throw std::invalid_argument("bad axes"); + return; + } + shape_t tmp(ndim,0); + if (axes.empty()) throw std::invalid_argument("no axes specified"); + for (auto ax : axes) + { + if (ax>=ndim) throw std::invalid_argument("bad axis number"); + if (++tmp[ax]>1) throw std::invalid_argument("axis specified repeatedly"); + } + } + + DUCC0_NOINLINE static void sanity_check_onetype(const fmav_info &a1, + const fmav_info &a2, bool inplace, const shape_t &axes) + { + sanity_check_axes(a1.ndim(), axes); + MR_assert(a1.conformable(a2), "array sizes are not conformable"); + if (inplace) MR_assert(a1.stride()==a2.stride(), "stride mismatch"); + } + DUCC0_NOINLINE static void sanity_check_cr(const fmav_info &ac, + const fmav_info &ar, const shape_t &axes) + { + sanity_check_axes(ac.ndim(), axes); + MR_assert(ac.ndim()==ar.ndim(), "dimension mismatch"); + for (size_t i=0; i=ac.ndim()) throw std::invalid_argument("bad axis number"); + MR_assert(ac.ndim()==ar.ndim(), "dimension mismatch"); + for (size_t i=0; i std::shared_ptr get_plan(size_t length, bool vectorize=false) + { +#ifdef DUCC0_NO_FFT_CACHE + return std::make_shared(length, vectorize); +#else + constexpr size_t nmax=10; + struct entry { size_t n; bool vectorize; std::shared_ptr ptr; }; + static std::array cache{{{0,0,nullptr}}}; + static std::array last_access{{0}}; + static size_t access_counter = 0; + static Mutex mut; + + auto find_in_cache = [&]() -> std::shared_ptr + { + for (size_t i=0; i(length, vectorize); + { + LockGuard lock(mut); + + auto p = find_in_cache(); + if (p) return p; + + size_t lru = 0; + for (size_t i=1; i class multi_iter + { + private: + shape_t shp, pos; + stride_t str_i, str_o; + size_t cshp_i, cshp_o, rem; + ptrdiff_t cstr_i, cstr_o, sstr_i, sstr_o, p_ii, p_i[N], p_oi, p_o[N]; + bool uni_i, uni_o; + + void advance_i() + { + for (size_t i=0; i=1, "not enough dimensions"); + // Sort the extraneous dimensions in order of ascending output stride; + // this should improve overall cache re-use and avoid clashes between + // threads as much as possible. + shape_t idx(iarr.ndim()); + std::iota(idx.begin(), idx.end(), 0); + sort(idx.begin(), idx.end(), + [&oarr](size_t i1, size_t i2) {return oarr.stride(i1) < oarr.stride(i2);}); + for (auto i: idx) + if (i!=idim) + { + pos.push_back(0); + MR_assert(iarr.shape(i)==oarr.shape(i), "shape mismatch"); + shp.push_back(iarr.shape(i)); + str_i.push_back(iarr.stride(i)); + str_o.push_back(oarr.stride(i)); + } + MR_assert(idim0) + { + sstr_i = str_i[0]; + sstr_o = str_o[0]; + } + + if (nshares==1) return; + if (nshares==0) throw std::runtime_error("can't run with zero threads"); + if (myshare>=nshares) throw std::runtime_error("impossible share requested"); + auto [lo, hi] = calcShare(nshares, myshare, rem); + size_t todo = hi-lo; + + // this shouldn't normally happen, but make sure we handle it properly + if (todo==0) + { rem=0; return; } + + size_t chunk = rem; + for (size_t i2=0, i=pos.size()-1; i2(stride_in() *tsz)&4095)==0) + || ((abs(stride_out()*tsz)&4095)==0); + } + bool critical_stride_other(size_t tsz) const + { + if (unistride_i()==0) return false; // it's just one transform + return ((abs(unistride_i()*tsz)&4095)==0) + || ((abs(unistride_o()*tsz)&4095)==0); + } + }; + +template class TmpStorage + { + private: + aligned_array d; + size_t dofs, dstride; + + public: + TmpStorage(size_t n_trafo, size_t bufsize_data, size_t bufsize_trafo, + size_t n_simultaneous, bool inplace) + { + if (inplace) + { + d.resize(bufsize_trafo); + return; + } + constexpr auto vlen = fft_simdlen; + // FIXME: when switching to C++20, use bit_floor(othersize) + size_t buffct = std::min(vlen, n_trafo); + size_t datafct = std::min(vlen, n_trafo); + if (n_trafo>=n_simultaneous*vlen) datafct = n_simultaneous*vlen; + dstride = bufsize_data; + dofs = bufsize_trafo; + // critical stride avoidance + if ((dstride&256)==0) dstride+=16; + if ((dofs&256)==0) dofs += 16; + d.resize(buffct*dofs + datafct*dstride); + } + + template T2 *transformBuf() + { return reinterpret_cast(d.data()); } + template T2 *dataBuf() + { return reinterpret_cast(d.data()) + dofs; } + size_t data_stride() const + { return dstride; } + }; + +template class TmpStorage2 + { + private: + TmpStorage &stg; + + public: + using datatype = T2; + TmpStorage2(TmpStorage &stg_): stg(stg_) {} + + T2 *transformBuf() { return stg.template transformBuf(); } + T2 *dataBuf() { return stg.template dataBuf(); } + size_t data_stride() const { return stg.data_stride(); } + }; + +template DUCC0_NOINLINE void copy_input(const Titer &it, + const cfmav> &src, Cmplx *DUCC0_RESTRICT dst) + { + constexpr auto vlen=Tsimd::size(); + const Cmplx * DUCC0_RESTRICT ptr = src.data(); + for (size_t i=0; i tmp; + for (size_t j=0; j DUCC0_NOINLINE void copy_input(const Titer &it, + const cfmav &src, Tsimd *DUCC0_RESTRICT dst) + { + constexpr auto vlen=Tsimd::size(); + const typename Tsimd::value_type * DUCC0_RESTRICT ptr = src.data(); + for (size_t i=0; i DUCC0_NOINLINE void copy_input(const Titer &it, + const cfmav &src, T *DUCC0_RESTRICT dst) + { + const T * DUCC0_RESTRICT ptr = src.data(); + if (dst == &src.raw(it.iofs(0))) return; // in-place + for (size_t i=0; i DUCC0_NOINLINE void copy_output(const Titer &it, + const Cmplx *DUCC0_RESTRICT src, const vfmav> &dst) + { + constexpr auto vlen=Tsimd::size(); + Cmplx * DUCC0_RESTRICT ptr = dst.data(); + for (size_t i=0; i tmp(src[i]); + for (size_t j=0; j DUCC0_NOINLINE void copy_output(const Titer &it, + const Tsimd *DUCC0_RESTRICT src, const vfmav &dst) + { + constexpr auto vlen=Tsimd::size(); + typename Tsimd::value_type * DUCC0_RESTRICT ptr = dst.data(); + for (size_t i=0; i DUCC0_NOINLINE void copy_output(const Titer &it, + const T *DUCC0_RESTRICT src, const vfmav &dst) + { + T * DUCC0_RESTRICT ptr=dst.data(); + if (src == &dst.raw(it.oofs(0))) return; // in-place + for (size_t i=0; i DUCC0_NOINLINE void copy_input(const Titer &it, + const cfmav> &src, Cmplx * DUCC0_RESTRICT dst, size_t nvec, size_t vstr) + { + constexpr auto vlen=Tsimd::size(); + const Cmplx * DUCC0_RESTRICT ptr = src.data(); + for (size_t i=0; i DUCC0_NOINLINE void copy_input(const Titer &it, + const cfmav> &src, Cmplx * DUCC0_RESTRICT dst, size_t nvec, size_t vstr) + { + const Cmplx * DUCC0_RESTRICT ptr = src.data(); + for (size_t i=0; i DUCC0_NOINLINE void copy_input(const Titer &it, + const cfmav &src, Tsimd * DUCC0_RESTRICT dst, size_t nvec, size_t vstr) + { + constexpr auto vlen=Tsimd::size(); + const typename Tsimd::value_type * DUCC0_RESTRICT ptr = src.data(); + for (size_t i=0; i DUCC0_NOINLINE void copy_input(const Titer &it, + const cfmav &src, T * DUCC0_RESTRICT dst, size_t nvec, size_t vstr) + { + const T * DUCC0_RESTRICT ptr = src.data(); + for (size_t i=0; i DUCC0_NOINLINE void copy_output(const Titer &it, + const Cmplx * DUCC0_RESTRICT src, const vfmav> &dst, size_t nvec, size_t vstr) + { + constexpr auto vlen=Tsimd::size(); + Cmplx * DUCC0_RESTRICT ptr = dst.data(); + for (size_t i=0; i tmp(src[j0*vstr+i]); + for (size_t j1=0; j1 DUCC0_NOINLINE void copy_output(const Titer &it, + const Cmplx * DUCC0_RESTRICT src, const vfmav> &dst, size_t nvec, size_t vstr) + { + Cmplx * DUCC0_RESTRICT ptr = dst.data(); + for (size_t i=0; i DUCC0_NOINLINE void copy_output(const Titer &it, + const Tsimd * DUCC0_RESTRICT src, const vfmav &dst, size_t nvec, size_t vstr) + { + constexpr auto vlen=Tsimd::size(); + typename Tsimd::value_type * DUCC0_RESTRICT ptr = dst.data(); + for (size_t i=0; i DUCC0_NOINLINE void copy_output(const Titer &it, + const T * DUCC0_RESTRICT src, const vfmav &dst, size_t nvec, size_t vstr) + { + T * DUCC0_RESTRICT ptr = dst.data(); + for (size_t i=0; i struct add_vec + { using type = typename simd_select::type; }; +template struct add_vec, vlen> + { using type = Cmplx::type>; }; +template using add_vec_t = typename add_vec::type; + +template +DUCC0_NOINLINE void general_nd(const cfmav &in, const vfmav &out, + const shape_t &axes, T0 fct, size_t nthreads, const Exec &exec, + const bool /*allow_inplace*/=true) + { + if ((in.ndim()==1)&&(in.stride(0)==1)&&(out.stride(0)==1)) + { + auto plan = get_plan(in.shape(0), true); + exec.exec_simple(in.data(), out.data(), *plan, fct, nthreads); + return; + } + std::shared_ptr plan, vplan; + size_t nth1d = (in.ndim()==1) ? nthreads : 1; + + for (size_t iax=0; iaxlength())) + { + plan = get_plan(len, in.ndim()==1); + vplan = ((in.ndim()==1)||(len<300)||((len&3)!=0)) ? + plan : get_plan(len, true); + } + + execParallel(util::thread_count(nthreads, in, axes[iax], fft_simdlen), + [&](Scheduler &sched) + { + constexpr auto vlen = fft_simdlen; + constexpr size_t nmax = 16; + const auto &tin(iax==0? in : out); + multi_iter it(tin, out, axes[iax], sched.num_threads(), sched.thread_num()); + + // n_simul: vector size + // n_bunch: total size of bunch (multiple of n_simul) + size_t n_simul=1, n_bunch=1; + bool critstride = (((in.stride(axes[iax])*sizeof(T))&4095)==0) + || (((out.stride(axes[iax])*sizeof(T))&4095)==0); + bool nostride = (in.stride(axes[iax])==1) && (out.stride(axes[iax])==1); + + constexpr size_t l2cache=262144*2; + constexpr size_t cacheline=64; + + // working set size + auto wss = [&](size_t vl) { return sizeof(T)*(2*len*vl + plan->bufsize()); }; + // is the FFT small enough to fit into L2 vectorized? + if (wss(1)>l2cache) // "long" FFT, don't execute more than one at the same time + { + n_simul=1; + if (critstride) // make bunch large to reduce overall copy cost + { + n_bunch=n_simul; + while ((n_bunch storage(in.size()/len, len, max(plan->bufsize(),vplan->bufsize()), (n_bunch+vlen-1)/vlen, inplace); + + // first, do all possible steps of size n_bunch, then n_simul + if (n_bunch>1) + { +#ifndef DUCC0_NO_SIMD + if constexpr (vlen>1) + { + constexpr size_t lvlen = vlen; + if (n_simul>=lvlen) + { + if ((n_bunch>n_simul) && (it.remaining()>=n_bunch)) + { + TmpStorage2,T,T0> storage2(storage); + while (it.remaining()>=n_bunch) + { + it.advance(n_bunch); + exec.exec_n(it, tin, out, storage2, *plan, fct, n_bunch/lvlen, nth1d); + } + } + } + if (n_simul==lvlen) + { + if (it.remaining()>=lvlen) + { + TmpStorage2,T,T0> storage2(storage); + while (it.remaining()>=lvlen) + { + it.advance(lvlen); + exec(it, tin, out, storage2, *plan, fct, nth1d); + } + } + } + } + if constexpr ((vlen>2) && (simd_exists)) + { + constexpr size_t lvlen = vlen/2; + if (n_simul>=lvlen) + { + if ((n_bunch>n_simul) && (it.remaining()>=n_bunch)) + { + TmpStorage2,T,T0> storage2(storage); + while (it.remaining()>=n_bunch) + { + it.advance(n_bunch); + exec.exec_n(it, tin, out, storage2, *plan, fct, n_bunch/lvlen, nth1d); + } + } + } + if (n_simul==lvlen) + { + if (it.remaining()>=lvlen) + { + TmpStorage2,T,T0> storage2(storage); + while (it.remaining()>=lvlen) + { + it.advance(lvlen); + exec(it, tin, out, storage2, *plan, fct, nth1d); + } + } + } + } + if constexpr ((vlen>4) && (simd_exists)) + { + constexpr size_t lvlen = vlen/4; + if (n_simul>=lvlen) + { + if ((n_bunch>n_simul) && (it.remaining()>=n_bunch)) + { + TmpStorage2,T,T0> storage2(storage); + while (it.remaining()>=n_bunch) + { + it.advance(n_bunch); + exec.exec_n(it, tin, out, storage2, *plan, fct, n_bunch/lvlen, nth1d); + } + } + } + if (n_simul==lvlen) + { + if (it.remaining()>=lvlen) + { + TmpStorage2,T,T0> storage2(storage); + while (it.remaining()>=lvlen) + { + it.advance(lvlen); + exec(it, tin, out, storage2, *plan, fct, nth1d); + } + } + } + } +#endif + { + TmpStorage2 storage2(storage); + while ((n_bunch>n_simul) && (it.remaining()>=n_bunch)) + { + it.advance(n_bunch); + exec.exec_n(it, tin, out, storage2, *vplan, fct, n_bunch, nth1d); + } + } + } + { + TmpStorage2 storage2(storage); + while (it.remaining()>0) + { + it.advance(1); + exec(it, tin, out, storage2, *vplan, fct, nth1d, inplace); + } + } + }); // end of parallel region + fct = T0(1); // factor has been applied, use 1 for remaining axes + } + } + +struct ExecC2C + { + bool forward; + + template DUCC0_NOINLINE void operator() ( + const Titer &it, const cfmav> &in, + const vfmav> &out, Tstorage &storage, const pocketfft_c &plan, T0 fct, + size_t nthreads, bool inplace=false) const + { + using T = typename Tstorage::datatype; + if constexpr(is_same, T>::value) + if (inplace) + { + if (in.data()!=out.data()) + copy_input(it, in, out.data()+it.oofs(0)); + plan.exec_copyback(out.data()+it.oofs(0), storage.transformBuf(), fct, forward, nthreads); + return; + } + T *buf1=storage.transformBuf(), *buf2=storage.dataBuf(); + copy_input(it, in, buf2); + auto res = plan.exec(buf2, buf1, fct, forward, nthreads); + copy_output(it, res, out); + } + template DUCC0_NOINLINE void exec_n ( + const Titer &it, const cfmav> &in, + const vfmav> &out, Tstorage &storage, const pocketfft_c &plan, T0 fct, size_t nvec, + size_t nthreads) const + { + using T = typename Tstorage::datatype; + size_t dstr = storage.data_stride(); + T *buf1=storage.transformBuf(), *buf2=storage.dataBuf(); + copy_input(it, in, buf2, nvec, dstr); + for (size_t i=0; i DUCC0_NOINLINE void exec_simple ( + const Cmplx *in, Cmplx *out, const pocketfft_c &plan, T0 fct, + size_t nthreads) const + { + if (in!=out) copy_n(in, plan.length(), out); + plan.exec(out, fct, forward, nthreads); + } + }; + +struct ExecHartley + { + template DUCC0_NOINLINE void operator() ( + const Titer &it, const cfmav &in, const vfmav &out, + Tstorage &storage, const pocketfft_hartley &plan, T0 fct, size_t nthreads, + bool inplace=false) const + { + using T = typename Tstorage::datatype; + if constexpr(is_same::value) + if (inplace) + { + if (in.data()!=out.data()) + copy_input(it, in, out.data()+it.oofs(0)); + plan.exec_copyback(out.data()+it.oofs(0), storage.transformBuf(), fct, nthreads); + return; + } + T *buf1=storage.transformBuf(), *buf2=storage.dataBuf(); + copy_input(it, in, buf2); + auto res = plan.exec(buf2, buf1, fct, nthreads); + copy_output(it, res, out); + } + template DUCC0_NOINLINE void exec_n ( + const Titer &it, const cfmav &in, + const vfmav &out, Tstorage &storage, const pocketfft_hartley &plan, T0 fct, size_t nvec, + size_t nthreads) const + { + using T = typename Tstorage::datatype; + size_t dstr = storage.data_stride(); + T *buf1=storage.transformBuf(), *buf2=storage.dataBuf(); + copy_input(it, in, buf2, nvec, dstr); + for (size_t i=0; i DUCC0_NOINLINE void exec_simple ( + const T0 *in, T0 *out, const pocketfft_hartley &plan, T0 fct, + size_t nthreads) const + { + if (in!=out) copy_n(in, plan.length(), out); + plan.exec(out, fct, nthreads); + } + }; + +struct ExecFHT + { + template DUCC0_NOINLINE void operator() ( + const Titer &it, const cfmav &in, const vfmav &out, + Tstorage &storage, const pocketfft_fht &plan, T0 fct, size_t nthreads, + bool inplace=false) const + { + using T = typename Tstorage::datatype; + if constexpr(is_same::value) + if (inplace) + { + if (in.data()!=out.data()) + copy_input(it, in, out.data()+it.oofs(0)); + plan.exec_copyback(out.data()+it.oofs(0), storage.transformBuf(), fct, nthreads); + return; + } + T *buf1=storage.transformBuf(), *buf2=storage.dataBuf(); + copy_input(it, in, buf2); + auto res = plan.exec(buf2, buf1, fct, nthreads); + copy_output(it, res, out); + } + template DUCC0_NOINLINE void exec_n ( + const Titer &it, const cfmav &in, + const vfmav &out, Tstorage &storage, const pocketfft_fht &plan, T0 fct, size_t nvec, + size_t nthreads) const + { + using T = typename Tstorage::datatype; + size_t dstr = storage.data_stride(); + T *buf1=storage.transformBuf(), *buf2=storage.dataBuf(); + copy_input(it, in, buf2, nvec, dstr); + for (size_t i=0; i DUCC0_NOINLINE void exec_simple ( + const T0 *in, T0 *out, const pocketfft_fht &plan, T0 fct, + size_t nthreads) const + { + if (in!=out) copy_n(in, plan.length(), out); + plan.exec(out, fct, nthreads); + } + }; + +struct ExecFFTW + { + bool forward; + + template DUCC0_NOINLINE void operator() ( + const Titer &it, const cfmav &in, const vfmav &out, + Tstorage &storage, const pocketfft_fftw &plan, T0 fct, size_t nthreads, + bool inplace=false) const + { + using T = typename Tstorage::datatype; + if constexpr(is_same::value) + if (inplace) + { + if (in.data()!=out.data()) + copy_input(it, in, out.data()+it.oofs(0)); + plan.exec_copyback(out.data()+it.oofs(0), storage.transformBuf(), fct, forward, nthreads); + return; + } + T *buf1=storage.transformBuf(), *buf2=storage.dataBuf(); + copy_input(it, in, buf2); + auto res = plan.exec(buf2, buf1, fct, forward, nthreads); + copy_output(it, res, out); + } + template DUCC0_NOINLINE void exec_n ( + const Titer &it, const cfmav &in, + const vfmav &out, Tstorage &storage, const pocketfft_fftw &plan, T0 fct, size_t nvec, + size_t nthreads) const + { + using T = typename Tstorage::datatype; + size_t dstr = storage.data_stride(); + T *buf1=storage.transformBuf(), *buf2=storage.dataBuf(); + copy_input(it, in, buf2, nvec, dstr); + for (size_t i=0; i DUCC0_NOINLINE void exec_simple ( + const T0 *in, T0 *out, const pocketfft_fftw &plan, T0 fct, + size_t nthreads) const + { + if (in!=out) copy_n(in, plan.length(), out); + plan.exec(out, fct, forward, nthreads); + } + }; + +struct ExecDcst + { + bool ortho; + int type; + bool cosine; + + template + DUCC0_NOINLINE void operator() (const Titer &it, const cfmav &in, + const vfmav &out, Tstorage &storage, const Tplan &plan, T0 fct, size_t nthreads, + bool inplace=false) const + { + using T = typename Tstorage::datatype; + if constexpr(is_same::value) + if (inplace) + { + if (in.data()!=out.data()) + copy_input(it, in, out.data()+it.oofs(0)); + plan.exec_copyback(out.data()+it.oofs(0), storage.transformBuf(), fct, ortho, type, cosine, nthreads); + return; + } + T *buf1=storage.transformBuf(), *buf2=storage.dataBuf(); + copy_input(it, in, buf2); + auto res = plan.exec(buf2, buf1, fct, ortho, type, cosine, nthreads); + copy_output(it, res, out); + } + template DUCC0_NOINLINE void exec_n ( + const Titer &it, const cfmav &in, + const vfmav &out, Tstorage &storage, const Tplan &plan, T0 fct, size_t nvec, + size_t nthreads) const + { + using T = typename Tstorage::datatype; + size_t dstr = storage.data_stride(); + T *buf1=storage.transformBuf(), *buf2=storage.dataBuf(); + copy_input(it, in, buf2, nvec, dstr); + for (size_t i=0; i DUCC0_NOINLINE void exec_simple ( + const T0 *in, T0 *out, const Tplan &plan, T0 fct, + size_t nthreads) const + { + if (in!=out) copy_n(in, plan.length(), out); + plan.exec(out, fct, ortho, type, cosine, nthreads); + } + }; + +template DUCC0_NOINLINE void general_r2c( + const cfmav &in, const vfmav> &out, size_t axis, bool forward, T fct, + size_t nthreads) + { + size_t nth1d = (in.ndim()==1) ? nthreads : 1; + auto plan = std::make_unique>(in.shape(axis)); + size_t len=in.shape(axis); + execParallel( + util::thread_count(nthreads, in, axis, fft_simdlen), + [&](Scheduler &sched) { + constexpr auto vlen = fft_simdlen; + TmpStorage storage(in.size()/len, len, plan->bufsize(), 1, false); + multi_iter it(in, out, axis, sched.num_threads(), sched.thread_num()); +#ifndef DUCC0_NO_SIMD + if constexpr (vlen>1) + { + TmpStorage2,T,T> storage2(storage); + auto dbuf = storage2.dataBuf(); + auto tbuf = storage2.transformBuf(); + while (it.remaining()>=vlen) + { + it.advance(vlen); + copy_input(it, in, dbuf); + auto res = plan->exec(dbuf, tbuf, fct, true, nth1d); + auto vout = out.data(); + for (size_t j=0; j2) + if constexpr (simd_exists) + if (it.remaining()>=vlen/2) + { + TmpStorage2,T,T> storage2(storage); + auto dbuf = storage2.dataBuf(); + auto tbuf = storage2.transformBuf(); + it.advance(vlen/2); + copy_input(it, in, dbuf); + auto res = plan->exec(dbuf, tbuf, fct, true, nth1d); + auto vout = out.data(); + for (size_t j=0; j4) + if constexpr( simd_exists) + if (it.remaining()>=vlen/4) + { + TmpStorage2,T,T> storage2(storage); + auto dbuf = storage2.dataBuf(); + auto tbuf = storage2.transformBuf(); + it.advance(vlen/4); + copy_input(it, in, dbuf); + auto res = plan->exec(dbuf, tbuf, fct, true, nth1d); + auto vout = out.data(); + for (size_t j=0; j storage2(storage); + auto dbuf = storage2.dataBuf(); + auto tbuf = storage2.transformBuf(); + while (it.remaining()>0) + { + it.advance(1); + copy_input(it, in, dbuf); + auto res = plan->exec(dbuf, tbuf, fct, true, nth1d); + auto vout = out.data(); + vout[it.oofs(0)].Set(res[0]); + size_t i=1, ii=1; + if (forward) + for (; i DUCC0_NOINLINE void general_c2r( + const cfmav> &in, const vfmav &out, size_t axis, bool forward, T fct, + size_t nthreads) + { + size_t nth1d = (in.ndim()==1) ? nthreads : 1; + auto plan = std::make_unique>(out.shape(axis)); + size_t len=out.shape(axis); + execParallel( + util::thread_count(nthreads, in, axis, fft_simdlen), + [&](Scheduler &sched) { + constexpr auto vlen = fft_simdlen; + TmpStorage storage(out.size()/len, len, plan->bufsize(), 1, false); + multi_iter it(in, out, axis, sched.num_threads(), sched.thread_num()); +#ifndef DUCC0_NO_SIMD + if constexpr (vlen>1) + { + TmpStorage2,T,T> storage2(storage); + auto dbuf = storage2.dataBuf(); + auto tbuf = storage2.transformBuf(); + while (it.remaining()>=vlen) + { + it.advance(vlen); + for (size_t j=0; jexec(dbuf, tbuf, fct, false, nth1d); + copy_output(it, res, out); + } + } + if constexpr (vlen>2) + if constexpr (simd_exists) + if (it.remaining()>=vlen/2) + { + TmpStorage2,T,T> storage2(storage); + auto dbuf = storage2.dataBuf(); + auto tbuf = storage2.transformBuf(); + it.advance(vlen/2); + for (size_t j=0; jexec(dbuf, tbuf, fct, false, nth1d); + copy_output(it, res, out); + } + if constexpr (vlen>4) + if constexpr(simd_exists) + if (it.remaining()>=vlen/4) + { + TmpStorage2,T,T> storage2(storage); + auto dbuf = storage2.dataBuf(); + auto tbuf = storage2.transformBuf(); + it.advance(vlen/4); + for (size_t j=0; jexec(dbuf, tbuf, fct, false, nth1d); + copy_output(it, res, out); + } +#endif + { + TmpStorage2 storage2(storage); + auto dbuf = storage2.dataBuf(); + auto tbuf = storage2.transformBuf(); + while (it.remaining()>0) + { + it.advance(1); + dbuf[0]=in.raw(it.iofs(0)).r; + { + size_t i=1, ii=1; + if (forward) + for (; iexec(dbuf, tbuf, fct, false, nth1d); + copy_output(it, res, out); + } + } + }); // end of parallel region + } + +struct ExecR2R + { + bool r2c, forward; + + template DUCC0_NOINLINE void operator() ( + const Titer &it, const cfmav &in, const vfmav &out, Tstorage &storage, + const pocketfft_r &plan, T0 fct, size_t nthreads, + bool inplace=false) const + { + using T = typename Tstorage::datatype; + if constexpr(is_same::value) + if (inplace) + { + T *buf1=storage.transformBuf(), *buf2=out.data()+it.oofs(0); + if (in.data()!=buf2) + copy_input(it, in, buf2); + if ((!r2c) && forward) + for (size_t i=2; i DUCC0_NOINLINE void exec_n ( + const Titer &it, const cfmav &in, + const vfmav &out, Tstorage &storage, const pocketfft_r &plan, T0 fct, size_t nvec, + size_t nthreads) const + { + using T = typename Tstorage::datatype; + size_t dstr = storage.data_stride(); + T *buf1=storage.transformBuf(), *buf2=storage.dataBuf(); + copy_input(it, in, buf2, nvec, dstr); + if ((!r2c) && forward) + for (size_t k=0; k DUCC0_NOINLINE void exec_simple ( + const T0 *in, T0 *out, const pocketfft_r &plan, T0 fct, + size_t nthreads) const + { + if (in!=out) copy_n(in, plan.length(), out); + if ((!r2c) && forward) + for (size_t i=2; i class Long1dPlan: public UnityRoots> + { + public: + Long1dPlan(size_t length, bool) + : UnityRoots>(length) {} + }; + +template DUCC0_NOINLINE void c2c(const cfmav> &in, + const vfmav> &out, const shape_t &axes, bool forward, + T fct, size_t nthreads) + { + util::sanity_check_onetype(in, out, in.data()==out.data(), axes); + if (in.size()==0) return; + + // special treatment for long 1D transforms (Bailey's algorithm) + // TODO: + // - if not in-place and out has no critical stride, the "tmp" array can be avoided + if ((in.ndim()==1) && (in.shape(0)>=65536*2)) + { + size_t ip = in.shape(0); + auto factors = util1d::prime_factors(ip); + sort(factors.begin(), factors.end(), std::greater()); + size_t f1=1, f2=1; + for (auto fct: factors) + (f2>f1) ? f1*=fct : f2*=fct; + if (f1>f2) swap(f1,f2); + if (f1>=16) // 2D algorithm makes sense + { + auto istr=in.stride(0); + auto ostr=out.stride(0); + cmav,2> in2 (in.data(), {f1,f2}, {ptrdiff_t(f2)*istr, istr}); + auto tmp (vmav,2>::build_noncritical({f1,f2})); + vmav,2> out2 (out.data(), {f1,f2}, {ostr, ptrdiff_t(f1)*ostr}); + auto fin2(in2.to_fmav()); + auto ftmp(tmp.to_fmav()); + auto fout2(out2.to_fmav()); + c2c(fin2, ftmp, {0}, forward, T(1), nthreads); + auto roots_p = get_plan>(ip); + const auto &roots(*roots_p); + if (forward) + execStatic(f1, nthreads, 0, [&](Scheduler &sched) { + while (auto rng=sched.getNext()) + for (auto i=rng.lo; i >&>(in)); + const auto &out2(reinterpret_cast >&>(out)); + if ((axes.size()>1) && (in.data()!=out.data())) // optimize axis order + { + if ((in.stride(axes[0])!=1)&&(out.stride(axes[0])==1)) + { + shape_t axes2(axes); + swap(axes2[0],axes2.back()); + general_nd>(in2, out2, axes2, fct, nthreads, ExecC2C{forward}); + return; + } + for (size_t i=1; i>(in2, out2, axes2, fct, nthreads, ExecC2C{forward}); + return; + } + } + general_nd>(in2, out2, axes, fct, nthreads, ExecC2C{forward}); + } + +template DUCC0_NOINLINE void dct(const cfmav &in, const vfmav &out, + const shape_t &axes, int type, T fct, bool ortho, size_t nthreads) + { + if ((type<1) || (type>4)) throw std::invalid_argument("invalid DCT type"); + util::sanity_check_onetype(in, out, in.data()==out.data(), axes); + if (in.size()==0) return; + const ExecDcst exec{ortho, type, true}; + if (type==1) + general_nd>(in, out, axes, fct, nthreads, exec); + else if (type==4) + general_nd>(in, out, axes, fct, nthreads, exec); + else + general_nd>(in, out, axes, fct, nthreads, exec); + } + +template DUCC0_NOINLINE void dst(const cfmav &in, const vfmav &out, + const shape_t &axes, int type, T fct, bool ortho, size_t nthreads) + { + if ((type<1) || (type>4)) throw std::invalid_argument("invalid DST type"); + util::sanity_check_onetype(in, out, in.data()==out.data(), axes); + if (in.size()==0) return; + const ExecDcst exec{ortho, type, false}; + if (type==1) + general_nd>(in, out, axes, fct, nthreads, exec); + else if (type==4) + general_nd>(in, out, axes, fct, nthreads, exec); + else + general_nd>(in, out, axes, fct, nthreads, exec); + } + +template DUCC0_NOINLINE void r2c(const cfmav &in, + const vfmav> &out, size_t axis, bool forward, T fct, + size_t nthreads) + { + util::sanity_check_cr(out, in, axis); + if (in.size()==0) return; + const auto &out2(reinterpret_cast>&>(out)); + general_r2c(in, out2, axis, forward, fct, nthreads); + } + +template DUCC0_NOINLINE void r2c(const cfmav &in, + const vfmav> &out, const shape_t &axes, + bool forward, T fct, size_t nthreads) + { + util::sanity_check_cr(out, in, axes); + if (in.size()==0) return; + r2c(in, out, axes.back(), forward, fct, nthreads); + if (axes.size()==1) return; + + auto newaxes = shape_t{axes.begin(), --axes.end()}; + c2c(out, out, newaxes, forward, T(1), nthreads); + } + +template DUCC0_NOINLINE void c2r(const cfmav> &in, + const vfmav &out, size_t axis, bool forward, T fct, size_t nthreads) + { + util::sanity_check_cr(in, out, axis); + if (in.size()==0) return; + const auto &in2(reinterpret_cast>&>(in)); + general_c2r(in2, out, axis, forward, fct, nthreads); + } + +template DUCC0_NOINLINE void c2r(const cfmav> &in, + const vfmav &out, const shape_t &axes, bool forward, T fct, + size_t nthreads) + { + if (axes.size()==1) + return c2r(in, out, axes[0], forward, fct, nthreads); + util::sanity_check_cr(in, out, axes); + if (in.size()==0) return; + auto atmp(vfmav>::build_noncritical(in.shape(), UNINITIALIZED)); + auto newaxes = shape_t{axes.begin(), --axes.end()}; + c2c(in, atmp, newaxes, forward, T(1), nthreads); + c2r(atmp, out, axes.back(), forward, fct, nthreads); + } + +template DUCC0_NOINLINE void c2r_mut(const vfmav> &in, + const vfmav &out, const shape_t &axes, bool forward, T fct, + size_t nthreads) + { + if (axes.size()==1) + return c2r(in, out, axes[0], forward, fct, nthreads); + util::sanity_check_cr(in, out, axes); + if (in.size()==0) return; + auto newaxes = shape_t{axes.begin(), --axes.end()}; + c2c(in, in, newaxes, forward, T(1), nthreads); + c2r(in, out, axes.back(), forward, fct, nthreads); + } + +template DUCC0_NOINLINE void r2r_fftpack(const cfmav &in, + const vfmav &out, const shape_t &axes, bool real2hermitian, bool forward, + T fct, size_t nthreads) + { + util::sanity_check_onetype(in, out, in.data()==out.data(), axes); + if (in.size()==0) return; + general_nd>(in, out, axes, fct, nthreads, + ExecR2R{real2hermitian, forward}); + } + +template DUCC0_NOINLINE void r2r_fftw(const cfmav &in, + const vfmav &out, const shape_t &axes, bool forward, + T fct, size_t nthreads) + { + util::sanity_check_onetype(in, out, in.data()==out.data(), axes); + if (in.size()==0) return; + general_nd>(in, out, axes, fct, nthreads, + ExecFFTW{forward}); + } + +template DUCC0_NOINLINE void r2r_separable_hartley(const cfmav &in, + const vfmav &out, const shape_t &axes, T fct, size_t nthreads) + { + util::sanity_check_onetype(in, out, in.data()==out.data(), axes); + if (in.size()==0) return; + general_nd>(in, out, axes, fct, nthreads, + ExecHartley{}, false); + } + +template DUCC0_NOINLINE void r2r_separable_fht(const cfmav &in, + const vfmav &out, const shape_t &axes, T fct, size_t nthreads) + { + util::sanity_check_onetype(in, out, in.data()==out.data(), axes); + if (in.size()==0) return; + general_nd>(in, out, axes, fct, nthreads, + ExecFHT{}, false); + } + +template void hermiteHelper(size_t idim, ptrdiff_t iin, + ptrdiff_t iout0, ptrdiff_t iout1, const cfmav &c, + const vfmav &r, const shape_t &axes, Func func, size_t nthreads) + { + auto cstr=c.stride(idim), str=r.stride(idim); + auto len=r.shape(idim); + + if (idim+1==c.ndim()) // last dimension, not much gain in parallelizing + { + if (idim==axes.back()) // halfcomplex axis + for (size_t i=0,ic=0; i void oscarize(const vfmav &data, size_t ax0, size_t ax1, + size_t nthreads) + { + auto nu=data.shape(ax0), nv=data.shape(ax1); + if ((nu<3)||(nv<3)) return; + vector slc(data.ndim()); + slc[ax0] = slice(1,(nu+1)/2); + slc[ax1] = slice(1,(nv+1)/2); + auto all = subarray(data, slc); + slc[ax0] = slice(nu-1,nu/2,-1); + auto ahl = subarray(data, slc); + slc[ax1] = slice(nv-1,nv/2,-1); + auto ahh = subarray(data, slc); + slc[ax0] = slice(1,(nu+1)/2); + auto alh = subarray(data, slc); + mav_apply([](T &ll, T &hl, T &hh, T &lh) + { + T tll=ll, thl=hl, tlh=lh, thh=hh; + T v = T(0.5)*(tll+tlh+thl+thh); + ll = v-thh; + hl = v-tlh; + lh = v-thl; + hh = v-tll; + }, nthreads, all, ahl, ahh, alh); + } + +template void r2r_genuine_hartley(const cfmav &in, + const vfmav &out, const shape_t &axes, T fct, size_t nthreads) + { + if (axes.size()==1) + return r2r_separable_hartley(in, out, axes, fct, nthreads); + if (axes.size()==2) + { + r2r_separable_hartley(in, out, axes, fct, nthreads); + oscarize(out, axes[0], axes[1], nthreads); + return; + } + util::sanity_check_onetype(in, out, in.data()==out.data(), axes); + if (in.size()==0) return; + shape_t tshp(in.shape()); + tshp[axes.back()] = tshp[axes.back()]/2+1; + auto atmp(vfmav>::build_noncritical(tshp, UNINITIALIZED)); + r2c(in, atmp, axes, true, fct, nthreads); + hermiteHelper(0, 0, 0, 0, atmp, out, axes, [](const std::complex &c, T &r0, T &r1) + { + auto ccopy = c; + r0 = ccopy.real()+ccopy.imag(); + r1 = ccopy.real()-ccopy.imag(); + }, nthreads); + } + +template void r2r_genuine_fht(const cfmav &in, + const vfmav &out, const shape_t &axes, T fct, size_t nthreads) + { + if (axes.size()==1) + return r2r_separable_fht(in, out, axes, fct, nthreads); + if (axes.size()==2) + { + r2r_separable_fht(in, out, axes, fct, nthreads); + oscarize(out, axes[0], axes[1], nthreads); + return; + } + util::sanity_check_onetype(in, out, in.data()==out.data(), axes); + if (in.size()==0) return; + shape_t tshp(in.shape()); + tshp[axes.back()] = tshp[axes.back()]/2+1; + auto atmp(vfmav>::build_noncritical(tshp, UNINITIALIZED)); + r2c(in, atmp, axes, true, fct, nthreads); + hermiteHelper(0, 0, 0, 0, atmp, out, axes, [](const std::complex &c, T &r0, T &r1) + { + auto ccopy = c; + r0 = ccopy.real()-ccopy.imag(); + r1 = ccopy.real()+ccopy.imag(); + }, nthreads); + } + +template +DUCC0_NOINLINE void general_convolve_axis(const cfmav &in, const vfmav &out, + const size_t axis, const cmav &kernel, size_t nthreads, + const Exec &exec) + { + std::unique_ptr plan1, plan2; + + size_t l_in=in.shape(axis), l_out=out.shape(axis); + MR_assert(kernel.size()==l_in, "bad kernel size"); + plan1 = std::make_unique(l_in); + plan2 = std::make_unique(l_out); + size_t bufsz = max(plan1->bufsize(), plan2->bufsize()); + + vmav fkernel({kernel.shape(0)}, UNINITIALIZED); + for (size_t i=0; iexec(fkernel.data(), T0(1)/T0(l_in), true, nthreads); + + execParallel( + util::thread_count(nthreads, in, axis, fft_simdlen), + [&](Scheduler &sched) { + constexpr auto vlen = fft_simdlen; + TmpStorage storage(in.size()/l_in, l_in+l_out, bufsz, 1, false); + multi_iter it(in, out, axis, sched.num_threads(), sched.thread_num()); +#ifndef DUCC0_NO_SIMD + if constexpr (vlen>1) + { + TmpStorage2,T,T0> storage2(storage); + while (it.remaining()>=vlen) + { + it.advance(vlen); + exec(it, in, out, storage2, *plan1, *plan2, fkernel); + } + } + if constexpr (vlen>2) + if constexpr (simd_exists) + if (it.remaining()>=vlen/2) + { + TmpStorage2,T,T0> storage2(storage); + it.advance(vlen/2); + exec(it, in, out, storage2, *plan1, *plan2, fkernel); + } + if constexpr (vlen>4) + if constexpr (simd_exists) + if (it.remaining()>=vlen/4) + { + TmpStorage2,T,T0> storage2(storage); + it.advance(vlen/4); + exec(it, in, out, storage2, *plan1, *plan2, fkernel); + } +#endif + { + TmpStorage2 storage2(storage); + while (it.remaining()>0) + { + it.advance(1); + exec(it, in, out, storage2, *plan1, *plan2, fkernel); + } + } + }); // end of parallel region + } + +struct ExecConv1R + { + template void operator() ( + const Titer &it, const cfmav &in, const vfmav &out, + Tstorage &storage, const pocketfft_r &plan1, const pocketfft_r &plan2, + const cmav &fkernel) const + { + using T = typename Tstorage::datatype; + size_t l_in = plan1.length(), + l_out = plan2.length(), + l_min = std::min(l_in, l_out); + T *buf1=storage.transformBuf(), *buf2=storage.dataBuf(); + copy_input(it, in, buf2); + plan1.exec_copyback(buf2, buf1, T0(1), true); + auto res = buf2; + { + res[0] *= fkernel(0); + size_t i; + for (i=1; 2*i t1(res[2*i-1], res[2*i]); + Cmplx t2(fkernel(2*i-1), fkernel(2*i)); + auto t3 = t1*t2; + res[2*i-1] = t3.r; + res[2*i] = t3.i; + } + if (2*i==l_min) + { + if (l_min t1(res[2*i-1], res[2*i]); + Cmplx t2(fkernel(2*i-1), fkernel(2*i)); + res[2*i-1] = (t1*t2).r*T0(2); + } + else + res[2*i-1] *= fkernel(2*i-1); + } + } + for (size_t i=l_in; i void operator() ( + const Titer &it, const cfmav> &in, const vfmav> &out, + Tstorage &storage, const pocketfft_c &plan1, const pocketfft_c &plan2, + const cmav,1> &fkernel) const + { + using T = typename Tstorage::datatype; + size_t l_in = plan1.length(), + l_out = plan2.length(), + l_min = std::min(l_in, l_out); + T *buf1=storage.transformBuf(), *buf2=storage.dataBuf(); + copy_input(it, in, buf2); + auto res = plan1.exec(buf2, buf1, T0(1), true); + auto res2 = buf2+l_in; + { + res2[0] = res[0]*fkernel(0); + size_t i; + for (i=1; 2*i DUCC0_NOINLINE void convolve_axis(const cfmav &in, + const vfmav &out, size_t axis, const cmav &kernel, size_t nthreads) + { + MR_assert(axis, T>(in, out, axis, kernel, nthreads, + ExecConv1R()); + } +template DUCC0_NOINLINE void convolve_axis(const cfmav> &in, + const vfmav> &out, size_t axis, const cmav,1> &kernel, + size_t nthreads) + { + MR_assert(axis>&>(in)); + const auto &out2(reinterpret_cast>&>(out)); + const auto &kernel2(reinterpret_cast,1>&>(kernel)); + general_convolve_axis, T>(in2, out2, axis, kernel2, nthreads, + ExecConv1C()); + } + +} // namespace detail_fft + +} // namespace ducc0 + +#endif // POCKETFFT_HDRONLY_H diff --git a/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/infra/mav.h b/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/infra/mav.h new file mode 100644 index 0000000000000000000000000000000000000000..73f0441bb621cb9030cb7121fdeeea9663c976d3 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/infra/mav.h @@ -0,0 +1,1354 @@ +/*! \file ducc0/infra/mav.h + * Classes for dealing with multidimensional arrays + * + * \copyright Copyright (C) 2019-2024 Max-Planck-Society + * \author Martin Reinecke + * */ + +/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later */ + +/* +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. +* Neither the name of the copyright holder nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * This code is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This code is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this code; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef DUCC0_MAV_H +#define DUCC0_MAV_H + +#include +#include +#include +#include +#include +#include +#include +#include "ducc0/infra/error_handling.h" +#include "ducc0/infra/aligned_array.h" +#include "ducc0/infra/misc_utils.h" +#include "ducc0/infra/threading.h" + +namespace ducc0 { + +namespace detail_mav { + +using namespace std; + +// the next line is necessary to address some sloppy name choices in AdaptiveCpp +using std::min, std::max; + +struct uninitialized_dummy {}; +constexpr uninitialized_dummy UNINITIALIZED; + +template class cmembuf + { + protected: + shared_ptr> ptr; + shared_ptr> rawptr; + const T *d; + + cmembuf(const T *d_, const cmembuf &other) + : ptr(other.ptr), rawptr(other.rawptr), d(d_) {} + + // externally owned data pointer + cmembuf(const T *d_) + : d(d_) {} + // share another memory buffer, but read-only + cmembuf(const cmembuf &other) + : ptr(other.ptr), rawptr(other.rawptr), d(other.d) {} + cmembuf(size_t sz) + : ptr(make_shared>(sz)), d(ptr->data()) {} +#if 1 + cmembuf(size_t sz, uninitialized_dummy) + : rawptr(make_shared>(sz)), d(rawptr->data()) {} +# else // "poison" the array with a fixed value; use for debugging + cmembuf(size_t sz, uninitialized_dummy) + : rawptr(make_shared>(sz)), d(rawptr->data()) + { for (size_t i=0; i const T &raw(I i) const + { return d[i]; } + // read access to data area + const T *data() const + { return d; } + }; + +constexpr size_t MAXIDX=~(size_t(0)); + +struct slice + { + size_t beg, end; + ptrdiff_t step; + slice() : beg(0), end(MAXIDX), step(1) {} + slice(size_t idx) : beg(idx), end(idx), step(1) {} + slice(size_t beg_, size_t end_, ptrdiff_t step_=1) + : beg(beg_), end(end_), step(step_) + { +// FIXME: add sanity checks here + } + + size_t size(size_t shp) const + { + if (beg==end) return 0; + if (step>0) return (min(shp,end)-beg+step-1)/step; + // negative step + if (end==MAXIDX) + return (beg-step)/(-step); + return (beg-end-step-1)/(-step); + } + }; + +/// Helper class containing shape and stride information of an `fmav` object +class fmav_info + { + public: + /// vector of nonnegative integers for storing the array shape + using shape_t = vector; + /// vector of integers for storing the array strides + using stride_t = vector; + + protected: + shape_t shp; + stride_t str; + size_t sz; + + static stride_t shape2stride(const shape_t &shp) + { + auto ndim = shp.size(); + // MR using the static_cast just to avoid a GCC warning. +// stride_t res(ndim); + stride_t res(static_cast(ndim)); + if (ndim==0) return res; + res[ndim-1]=1; + for (size_t i=2; i<=ndim; ++i) + res[ndim-i] = res[ndim-i+1]*ptrdiff_t(shp[ndim-i+1]); + return res; + } + template ptrdiff_t getIdx(size_t dim, size_t n, Ns... ns) const + { return str[dim]*ptrdiff_t(n) + getIdx(dim+1, ns...); } + ptrdiff_t getIdx(size_t dim, size_t n) const + { return str[dim]*ptrdiff_t(n); } + ptrdiff_t getIdx(size_t /*dim*/) const + { return 0; } + + public: + /// Constructs a 1D object with all extents and strides set to zero. + fmav_info() : shp(1,0), str(1,0), sz(0) {} + /// Constructs an object with the given shape and stride. + fmav_info(const shape_t &shape_, const stride_t &stride_) + : shp(shape_), str(stride_), + sz(accumulate(shp.begin(),shp.end(),size_t(1),multiplies<>())) + { + MR_assert(shp.size()==str.size(), "dimensions mismatch"); + } + /// Constructs an object with the given shape and computes the strides + /// automatically, assuming a C-contiguous memory layout. + fmav_info(const shape_t &shape_) + : fmav_info(shape_, shape2stride(shape_)) {} + void assign(const fmav_info &other) + { + shp = other.shp; + str = other.str; + sz = other.sz; + } + /// Returns the dimensionality of the object. + size_t ndim() const { return shp.size(); } + /// Returns the total number of entries in the object. + size_t size() const { return sz; } + /// Returns the shape of the object. + const shape_t &shape() const { return shp; } + /// Returns the length along dimension \a i. + size_t shape(size_t i) const { return shp[i]; } + /// Returns the strides of the object. + const stride_t &stride() const { return str; } + /// Returns the stride along dimension \a i. + const ptrdiff_t &stride(size_t i) const { return str[i]; } + /// Returns true iff the last dimension has stride 1. + /** Typically used for optimization purposes. */ + bool last_contiguous() const + { return ((ndim()==0) || (str.back()==1)); } + /** Returns true iff the object is C-contiguous, i.e. if the stride of the + * last dimension is 1, the stride for the next-to-last dimension is the + * shape of the last dimension etc. */ + bool contiguous() const + { + auto ndim = shp.size(); + ptrdiff_t stride=1; + for (size_t i=0; ishape and \a other.shape match. + bool conformable(const fmav_info &other) const + { return shp==other.shp; } + /// Returns the one-dimensional index of an entry from the given + /// multi-dimensional index tuple, taking strides into account. + template ptrdiff_t idx(Ns... ns) const + { + MR_assert(ndim()==sizeof...(ns), "incorrect number of indices"); + return getIdx(0, ns...); + } + ptrdiff_t idx(const shape_t &ns) const + { + MR_assert(ndim()==ns.size(), "incorrect number of indices"); + size_t res = 0; + for (size_t i=0; i ptrdiff_t idxval(RAiter beg, RAiter end) const + { + MR_assert(ndim()==size_t(end-beg), "incorrect number of indices"); + size_t res = 0; + for (size_t i=0; i=shp.size(), "cannot reduce dimensionality"); + stride_t newstr(shp2.size(), 0); + for (size_t i=0; i=ndim(), + "new shape smaller than original one"); + MR_assert(axpos.size()==ndim(), "bad axpos size"); + stride_t new_stride(new_shape.size(), 0); + vector used(new_shape.size(),0); + for (size_t i=0; i &slices) const + { + auto ndim = shp.size(); + shape_t nshp(ndim); + stride_t nstr(ndim); + MR_assert(slices.size()==ndim, "incorrect number of slices"); + size_t n0=0; + for (auto x:slices) if (x.beg==x.end) ++n0; + ptrdiff_t nofs=0; + nshp.resize(ndim-n0); + nstr.resize(ndim-n0); + for (size_t i=0, i2=0; i class mav_info + { + public: + /// Fixed-size array of nonnegative integers for storing the array shape + using shape_t = array; + /// Fixed-size array of integers for storing the array strides + using stride_t = array; + + protected: + shape_t shp; + stride_t str; + size_t sz; + + static stride_t shape2stride(const shape_t &shp) + { + stride_t res; + if (ndim==0) return res; + res[ndim-1]=1; + for (size_t i=2; i<=ndim; ++i) + res[ndim-i] = res[ndim-i+1]*ptrdiff_t(shp[ndim-i+1]); + return res; + } + template ptrdiff_t getIdx(size_t dim, size_t n, Ns... ns) const + { return str[dim]*n + getIdx(dim+1, ns...); } + ptrdiff_t getIdx(size_t dim, size_t n) const + { return str[dim]*n; } + ptrdiff_t getIdx(size_t /*dim*/) const + { return 0; } + + public: + /// Constructs an object with all extents and strides set to zero. + mav_info() : sz(0) + { + for (size_t i=0; i())) {} + /// Constructs an object with the given shape and computes the strides + /// automatically, assuming a C-contiguous memory layout. + mav_info(const shape_t &shape_) + : mav_info(shape_, shape2stride(shape_)) {} + mav_info(const fmav_info &inp) + { + MR_assert(inp.ndim()==ndim, "dimensionality mismatch"); + sz=1; + for (size_t i=0; ishape and \a other.shape match. + bool conformable(const mav_info &other) const + { return shp==other.shp; } + /// Returns true iff this->shape and \a other match. + bool conformable(const shape_t &other) const + { return shp==other; } + /// Returns the one-dimensional index of an entry from the given + /// multi-dimensional index tuple, taking strides into account. + template ptrdiff_t idx(Ns... ns) const + { + static_assert(ndim==sizeof...(ns), "incorrect number of indices"); + return getIdx(0, ns...); + } + mav_info transpose() const + { + shape_t shp2; + stride_t str2; + for (size_t i=0; i prepend_1() const + { + typename mav_info::shape_t newshp; + typename mav_info::stride_t newstr; + newshp[0] = 1; + newstr[0] = 0; + for (size_t i=0; i(newshp, newstr); + } + + protected: + template auto subdata(const vector &slices) const + { + MR_assert(slices.size()==ndim, "bad number of slices"); + array nshp; + array nstr; + + // unnecessary, but gcc warns otherwise + for (size_t i=0; i(nshp, nstr), nofs); + } + }; + +template class cfmav: public fmav_info, public cmembuf + { + protected: + using tbuf = cmembuf; + using tinfo = fmav_info; + using fmav_info::idx; + + public: + using typename tinfo::shape_t; + using typename tinfo::stride_t; + using tbuf::raw, tbuf::data; + + + protected: + cfmav(const shape_t &shp_) + : tinfo(shp_), tbuf(size()) {} + cfmav(const shape_t &shp_, uninitialized_dummy) + : tinfo(shp_), tbuf(size(), UNINITIALIZED) {} + cfmav(const shape_t &shp_, const stride_t &str_, uninitialized_dummy) + : tinfo(shp_, str_), tbuf(size(), UNINITIALIZED) + { + ptrdiff_t ofs=0; + for (size_t i=0; i const T &operator()(Ns... ns) const + { return raw(idx(ns...)); } + const T &operator()(const shape_t &ns) const + { return raw(idx(ns)); } + template const T& val(RAiter beg, RAiter end) const + { return raw(idxval(beg, end)); } + + cfmav subarray(const vector &slices) const + { + auto [ninfo, nofs] = subdata(slices); + return cfmav(ninfo, tbuf::d+nofs, *this); + } + cfmav extend_and_broadcast(const shape_t &new_shape, const shape_t &axpos) const + { + return cfmav(fmav_info::extend_and_broadcast(new_shape, axpos), *this); + } + cfmav extend_and_broadcast(const shape_t &new_shape, size_t firstaxis) const + { + return cfmav(fmav_info::extend_and_broadcast(new_shape, firstaxis), *this); + } + cfmav transpose() const + { + return cfmav(static_cast(this)->transpose(), *static_cast(this)); + } + }; + +template cfmav subarray + (const cfmav &arr, const vector &slices) + { return arr.subarray(slices); } + +template class vfmav: public cfmav + { + protected: + using tbuf = cmembuf; + using tinfo = fmav_info; + using tinfo::shp, tinfo::str; + using fmav_info::idx; + + public: + using typename tinfo::shape_t; + using typename tinfo::stride_t; + using tinfo::size, tinfo::shape, tinfo::stride; + + protected: + vfmav(const fmav_info &info, const tbuf &buf) + : cfmav(info, buf) {} + vfmav(const fmav_info &info, T *d_, const tbuf &buf) + : cfmav(info, d_, buf) {} + + public: + using tbuf::raw, tbuf::data, tinfo::ndim; + vfmav() {} + vfmav(T *d_, const fmav_info &info) + : cfmav(d_, info) {} + vfmav(T *d_, const shape_t &shp_, const stride_t &str_) + : cfmav(d_, shp_, str_) {} + vfmav(T *d_, const shape_t &shp_) + : cfmav(d_, shp_) {} + vfmav(const shape_t &shp_) + : cfmav(shp_) {} + vfmav(const shape_t &shp_, uninitialized_dummy) + : cfmav(shp_, UNINITIALIZED) {} + vfmav(const shape_t &shp_, const stride_t &str_, uninitialized_dummy) + : cfmav(shp_, str_, UNINITIALIZED) + { + ptrdiff_t ofs=0; + for (size_t i=0; i(buf, shp_, str_) {} + + T *data() const + { return const_cast(tbuf::d); } + template T &raw(I i) const + { return data()[i]; } + + // no-op. Needed for template tricks. + using cfmav::to_fmav; + vfmav to_fmav() const { return *this; } + + void assign(const vfmav &other) + { + fmav_info::assign(other); + cmembuf::assign(other); + } + + using cfmav::operator(); + template T &operator()(Ns... ns) const + { return raw(idx(ns...)); } + T &operator()(const shape_t &ns) const + { return raw(idx(ns)); } + using cfmav::val; + template T& val(RAiter beg, RAiter end) const + { return raw(idxval(beg, end)); } + + vfmav subarray(const vector &slices) const + { + auto [ninfo, nofs] = tinfo::subdata(slices); + return vfmav(ninfo, data()+nofs, *this); + } + /** Returns a writable fmav with the specified shape. + * The strides are chosen in such a way that critical strides (multiples + * of 4096 bytes) along any dimension are avoided, by enlarging the + * allocated memory slightly if necessary. + * The array data is default-initialized. */ + static vfmav build_noncritical(const shape_t &shape) + { + auto ndim = shape.size(); + auto shape2 = noncritical_shape(shape, sizeof(T)); + vfmav tmp(shape2); + vector slc(ndim); + for (size_t i=0; i slc(ndim); + for (size_t i=0; i(this)->transpose(), *static_cast(this)); + } + }; + +template vfmav subarray + (const vfmav &arr, const vector &slices) + { return arr.subarray(slices); } + +template class cmav: public mav_info, public cmembuf + { + protected: + template friend class cmav; + template friend class vmav; + + using tinfo = mav_info; + using tbuf = cmembuf; + using tinfo::shp, tinfo::str; + + public: + using typename tinfo::shape_t; + using typename tinfo::stride_t; + using tbuf::raw, tbuf::data; + using tinfo::contiguous, tinfo::size, tinfo::idx, tinfo::conformable; + + protected: + cmav() {} + cmav(const shape_t &shp_, uninitialized_dummy) + : tinfo(shp_), tbuf(size(), UNINITIALIZED) {} + cmav(const shape_t &shp_) + : tinfo(shp_), tbuf(size()) {} + cmav(const tbuf &buf, const shape_t &shp_, const stride_t &str_) + : tinfo(shp_, str_), tbuf(buf) {} + cmav(const tinfo &info, const T *d_, const tbuf &buf) + : tinfo(info), tbuf(d_, buf) {} + cmav(const tinfo &info, const tbuf &buf) + : tinfo(info), tbuf(buf) {} + + public: + cmav(const T *d_, const shape_t &shp_, const stride_t &str_) + : tinfo(shp_, str_), tbuf(d_) {} + cmav(const T *d_, const shape_t &shp_) + : tinfo(shp_), tbuf(d_) {} + cmav(const cfmav &inp) + : tinfo(inp), tbuf(inp) {} + void assign(const cmav &other) + { + mav_info::assign(other); + cmembuf::assign(other); + } + operator cfmav() const + { + return cfmav(*this, {shp.begin(), shp.end()}, {str.begin(), str.end()}); + } + // Needed for template tricks. + cfmav to_fmav() const { return operator cfmav(); } + + template const T &operator()(Ns... ns) const + { return raw(idx(ns...)); } + template cmav subarray(const vector &slices) const + { + auto [ninfo, nofs] = tinfo::template subdata (slices); + return cmav (ninfo, tbuf::d+nofs, *this); + } + + static cmav build_uniform(const shape_t &shape, const T &value) + { + // Don't do this at home! + shape_t tshp; + tshp.fill(1); + cmav tmp(tshp); + const_cast(tmp.raw(0)) = value; + stride_t nstr; + nstr.fill(0); + return cmav(tmp, shape, nstr); + } + cmav transpose() const + { + return cmav(static_cast(this)->transpose(), *static_cast(this)); + } + cmav prepend_1() const + { + return cmav(static_cast(this)->prepend_1(), *static_cast(this)); + } + template cmav reinterpret + (const typename cmav::shape_t &newshp, + const typename cmav::stride_t &newstr) const + { + return cmav(*static_cast(this), newshp, newstr); + } + }; +template cmav subarray + (const cmav &arr, const vector &slices) + { return arr.template subarray(slices); } + +template class vmav: public cmav + { + protected: + template friend class vmav; + + using parent = cmav; + using tinfo = mav_info; + using tbuf = cmembuf; + using tinfo::shp, tinfo::str; + + public: + using typename tinfo::shape_t; + using typename tinfo::stride_t; + using tbuf::raw, tbuf::data; + using tinfo::contiguous, tinfo::size, tinfo::idx, tinfo::conformable; + + protected: + vmav(const tinfo &info, T *d_, const tbuf &buf) + : parent(info, d_, buf) {} + vmav(const tinfo &info, const tbuf &buf) + : parent(info, buf) {} + vmav(const tbuf &buf, const shape_t &shp_, const stride_t &str_) + : parent(buf, shp_, str_){} + + public: + vmav() {} + vmav(T *d_, const shape_t &shp_, const stride_t &str_) + : parent(d_, shp_, str_) {} + vmav(T *d_, const shape_t &shp_) + : parent(d_, shp_) {} + vmav(const shape_t &shp_) + : parent(shp_) {} + vmav(const shape_t &shp_, uninitialized_dummy) + : parent(shp_, UNINITIALIZED) {} + vmav(const vfmav &inp) + : parent(inp) {} + + void assign(vmav &other) + { parent::assign(other); } + void dealloc() + { + vmav empty; + assign(empty); + } + operator vfmav() const + { + return vfmav(*const_cast(static_cast(this)), {shp.begin(), shp.end()}, {str.begin(), str.end()}); + } + // Needed for template tricks. + using cmav::to_fmav; + vfmav to_fmav() const { return operator vfmav(); } + + using parent::operator(); + template T &operator()(Ns... ns) const + { return const_cast(parent::operator()(ns...)); } + + template vmav subarray(const vector &slices) const + { + auto [ninfo, nofs] = tinfo::template subdata (slices); + return vmav (ninfo, data()+nofs, *this); + } + + T *data() const + { return const_cast(tbuf::d); } + // read access to element #i + template T &raw(I i) const + { return data()[i]; } + + static vmav build_empty() + { + shape_t nshp; + nshp.fill(0); + return vmav(static_cast(nullptr), nshp); + } + + static vmav build_noncritical(const shape_t &shape) + { + auto shape2 = noncritical_shape(shape, sizeof(T)); + vmav tmp(shape2); + vector slc(ndim); + for (size_t i=0; i(slc); + } + static vmav build_noncritical(const shape_t &shape, uninitialized_dummy) + { + if (ndim<=1) return vmav(shape, UNINITIALIZED); + auto shape2 = noncritical_shape(shape, sizeof(T)); + vmav tmp(shape2, UNINITIALIZED); + vector slc(ndim); + for (size_t i=0; i(slc); + } + vmav transpose() const + { + return vmav(static_cast(this)->transpose(), *static_cast(this)); + } + vmav prepend_1() const + { + return vmav(static_cast(this)->prepend_1(), *static_cast(this)); + } + template vmav reinterpret + (const typename vmav::shape_t &newshp, + const typename vmav::stride_t &newstr) const + { + return vmav(*static_cast(this), newshp, newstr); + } + }; + +template vmav subarray + (const vmav &arr, const vector &slices) + { return arr.template subarray(slices); } + +// various operations involving fmav objects of the same shape -- experimental + +DUCC0_NOINLINE tuple, size_t, size_t> + multiprep(const vector &info, const vector &tsizes); +DUCC0_NOINLINE tuple> + multiprep(const vector &info); + +template constexpr inline size_t tuplelike_size() + { return tuple_size_v>; } + +template +inline void call_with_tuple_impl(Func &&func, const Ttuple& tuple, + index_sequence) + { func(std::forward::type>(get(tuple))...); } +template inline void call_with_tuple + (Func &&func, Ttuple &&tuple) + { + call_with_tuple_impl(std::forward(func), tuple, + make_index_sequence()>()); + } +template +inline void call_with_tuple2_impl(Func &&func, const Ttuple& tuple, + index_sequence) + { func(get(tuple)...); } +template inline void call_with_tuple2 + (Func &&func, Ttuple &&tuple) + { + call_with_tuple2_impl(std::forward(func), tuple, + make_index_sequence()>()); + } + +template +inline auto tuple_transform_impl(tuple const& inputs, Func &&func, + index_sequence) + { return tuple...>{func(get(inputs))...}; } +template +inline auto tuple_transform(tuple const& inputs, Func &&func) + { + return tuple_transform_impl(inputs, std::forward(func), + make_index_sequence{}); + } +template +inline void tuple_for_each_impl(tuple &tpl, Func &&func, + index_sequence) + { (func(get(tpl)), ...); } +template +inline void tuple_for_each(tuple &tpl, Func &&func) + { + tuple_for_each_impl(tpl, std::forward(func), make_index_sequence{}); + } +template +inline void tuple_for_each_impl(const tuple &tpl, Func &&func, + index_sequence) + { (func(get(tpl)), ...); } +template +inline void tuple_for_each(const tuple &tpl, Func &&func) + { + tuple_for_each_impl(tpl, std::forward(func), make_index_sequence{}); + } + +template +inline auto tuple_transform_idx_impl(const tuple &inputs, + Func &&func, index_sequence) + { + return tuple...> + {func(get(inputs), Is)...}; + } + +template +inline auto tuple_transform_idx(const tuple &inputs, Func &&func) + { + return tuple_transform_idx_impl(inputs, std::forward(func), + make_index_sequence{}); + } +template +inline void tuple_for_each_idx_impl(tuple &tpl, Func &&func, + index_sequence) + { (func(get(tpl), Is), ...); } +template +inline void tuple_for_each_idx(tuple &tpl, Func &&func) + { + tuple_for_each_idx_impl(tpl, std::forward(func), make_index_sequence{}); + } + +template inline auto to_ref (const Ttuple &tuple) + { + return tuple_transform(tuple,[](auto &&ptr) -> typename std::add_lvalue_reference_t{ return *ptr; }); + } + +template inline Ttuple update_pointers (const Ttuple &ptrs, + const vector> &str, size_t idim, size_t i) + { + return tuple_transform_idx(ptrs, [i,idim,&str](auto &&ptr, size_t idx) + { return ptr + i*str[idx][idim]; }); + } + +template inline Ttuple update_pointers_contiguous (const Ttuple &ptrs, + size_t i) + { + return tuple_transform(ptrs, [i](auto &&ptr) { return ptr+i; }); + } +template inline void advance_contiguous (Ttuple &ptrs) + { tuple_for_each(ptrs, [](auto &&ptr) { ++ptr; }); } +template inline void advance (Ttuple &ptrs, + const vector> &str, size_t idim) + { + tuple_for_each_idx(ptrs, [idim,&str](auto &&ptr, size_t idx) + { ptr += str[idx][idim]; }); + } +template inline void advance_by_n (Ttuple &ptrs, + const vector> &str, size_t idim, size_t n) + { + tuple_for_each_idx(ptrs, [idim,n,&str](auto &&ptr, size_t idx) + { ptr += n*str[idx][idim]; }); + } + +template + DUCC0_NOINLINE void applyHelper_block(size_t idim, const vector &shp, + const vector> &str, size_t bsi, size_t bsj, + const Ttuple &ptrs, Func &&func) + { + auto leni=shp[idim], lenj=shp[idim+1]; + size_t nbi = (leni+bsi-1)/bsi; + size_t nbj = (lenj+bsj-1)/bsj; + for (size_t bi=0; bi + DUCC0_NOINLINE void applyHelper(size_t idim, const vector &shp, + const vector> &str, size_t block0, size_t block1, + const Ttuple &ptrs, Func &&func, bool last_contiguous) + { + auto len = shp[idim]; + if ((idim+2==shp.size()) && (block0!=0)) // we should do blocking + applyHelper_block(idim, shp, str, block0, block1, ptrs, func); + else if (idim+1 + inline void applyHelper(const vector &shp, + const vector> &str, size_t block0, size_t block1, + const Ttuple &ptrs, Func &&func, size_t nthreads, bool last_contiguous) + { + if (shp.size()==0) + call_with_tuple(std::forward(func), to_ref(ptrs)); + else if (nthreads==1) + applyHelper(0, shp, str, block0, block1, ptrs, std::forward(func), last_contiguous); + else + execParallel(shp[0], nthreads, [&](size_t lo, size_t hi) + { + auto locptrs = update_pointers(ptrs, str, 0, lo); + auto locshp(shp); + locshp[0] = hi-lo; + applyHelper(0, locshp, str, block0, block1, locptrs, func, last_contiguous); + }); + } + +template + void mav_apply(Func &&func, int nthreads, Targs... args) + { + vector infos; + (infos.push_back(args), ...); + vector tsizes; + (tsizes.push_back(sizeof(args.data()[0])), ...); + auto [shp, str, block0, block1] = multiprep(infos, tsizes); + bool last_contiguous = true; + if (shp.size()>0) + for (const auto &s:str) + last_contiguous &= (s.back()==1); + + auto ptrs = tuple_transform(forward_as_tuple(args...), + [](auto &&arg){return arg.data();}); + applyHelper(shp, str, block0, block1, ptrs, std::forward(func), nthreads, last_contiguous); + } + +DUCC0_NOINLINE tuple> + multiprep_noopt(const vector &info); + +template +inline void call_with_tuple_arg_impl(Func &&func, Arg &&arg, const Ttuple& tuple, + index_sequence) + { func(std::forward::type>(get(tuple))..., arg); } +template inline void call_with_tuple_arg + (Func &&func, Arg &&arg, Ttuple &&tuple) + { + call_with_tuple_arg_impl(std::forward(func), arg, tuple, + make_index_sequence()>()); + } +template + DUCC0_NOINLINE void applyHelper_with_index(size_t idim, const vector &shp, + const vector> &str, const Ttuple &ptrs, Func &&func, + vector &index) + { + auto len = shp[idim]; + if (idim+1 &>(index), to_ref(locptrs)); + index[idim] = idxbak; + } + } +template + inline void applyHelper_with_index(const vector &shp, + const vector> &str, const Ttuple &ptrs, Func &&func, + size_t nthreads, vector &index) + { + if (shp.size()==0) + call_with_tuple_arg(std::forward(func), const_cast &>(index), to_ref(ptrs)); + else if (nthreads==1) + applyHelper_with_index(0, shp, str, ptrs, std::forward(func), index); + else + execParallel(shp[0], nthreads, [&](size_t lo, size_t hi) + { + auto locptrs = update_pointers(ptrs, str, 0, lo); + auto locshp(shp); + locshp[0] = hi-lo; + auto locidx(index); + locidx[0]=lo; + applyHelper_with_index(0, locshp, str, locptrs, func, locidx); + }); + } +template + void mav_apply_with_index(Func &&func, int nthreads, Targs... args) + { + vector infos; + (infos.push_back(args), ...); + auto [shp, str] = multiprep_noopt(infos); + vector index(shp.size(), 0); + + auto ptrs = tuple_transform(forward_as_tuple(args...), + [](auto &&arg){return arg.data();}); + applyHelper_with_index(shp, str, ptrs, std::forward(func), nthreads, index); + } + + +template class mavref + { + private: + const mav_info &info; + T *d; + + public: + using shape_t = typename mav_info::shape_t; + using stride_t = typename mav_info::stride_t; + mavref(const mav_info &info_, T *d_) : info(info_), d(d_) {} + template T &operator()(Ns... ns) const + { return d[info.idx(ns...)]; } + /// Returns the total number of entries in the object. + size_t size() const { return info.size(); } + /// Returns the shape of the object. + const shape_t &shape() const { return info.shape(); } + /// Returns the length along dimension \a i. + size_t shape(size_t i) const { return info.shape(i); } + /// Returns the strides of the object. + const stride_t &stride() const { return info.stride(); } + /// Returns the stride along dimension \a i. + const ptrdiff_t &stride(size_t i) const { return info.stride(i); } + /// Returns true iff the last dimension has stride 1. + /** Typically used for optimization purposes. */ + bool last_contiguous() const + { return info.last_contiguous(); } + /** Returns true iff the object is C-contiguous, i.e. if the stride of the + * last dimension is 1, the stride for the next-to-last dimension is the + * shape of the last dimension etc. */ + bool contiguous() const + { return info.contiguous(); } + /// Returns true iff this->shape and \a other.shape match. + bool conformable(const mavref &other) const + { return shape()==other.shape(); } + }; + +template + mavref make_mavref(const mav_info &info_, T *d_) + { return mavref(info_, d_); } + +template +inline auto tuple_transform2_impl(const tuple &i1, const tuple &i2, + Func &&func, index_sequence) + { return tuple...>{func(get(i1),get(i2))...}; } +template +inline auto tuple_transform2(const tuple &i1, const tuple &i2, + Func &&func) + { + return tuple_transform2_impl(i1, i2, std::forward(func), + make_index_sequence{}); + } +template + auto make_mavrefs(const Tptrs &ptrs, const Tinfos &infos) + { + return tuple_transform2(ptrs, infos, [](auto &&ptr, auto &&info) + { return make_mavref(info, ptr); }); + } + +template auto make_infos(const fmav_info &info) + { + if constexpr(ndim>0) + MR_assert(ndim<=info.ndim(), "bad dimensionality"); + auto iterdim = info.ndim()-ndim; + fmav_info fout({info.shape().begin(),info.shape().begin()+iterdim}, + {info.stride().begin(),info.stride().begin()+iterdim}); + + typename mav_info::shape_t shp; + typename mav_info::stride_t str; + if constexpr (ndim>0) // just to silence compiler warnings + for (size_t i=0; i iout(shp, str); + return make_tuple(fout, iout); + } + +template + DUCC0_NOINLINE void flexible_mav_applyHelper(size_t idim, const vector &shp, + const vector> &str, const Tptrs &ptrs, + const Tinfos &infos, Func &&func) + { + auto len = shp[idim]; + auto locptrs(ptrs); + if (idim+1 + DUCC0_NOINLINE void flexible_mav_applyHelper(const vector &shp, + const vector> &str, const Tptrs &ptrs, + const Tinfos &infos, Func &&func, size_t nthreads) + { + if (shp.size()==0) + call_with_tuple2(func, make_mavrefs(ptrs, infos)); + else if (nthreads==1) + flexible_mav_applyHelper(0, shp, str, ptrs, infos, std::forward(func)); + else + execParallel(shp[0], nthreads, [&](size_t lo, size_t hi) + { + auto locptrs = update_pointers(ptrs, str, 0, lo); + auto locshp(shp); + locshp[0] = hi-lo; + flexible_mav_applyHelper(0, locshp, str, locptrs, infos, func); + }); + } + +template struct Xdim { static constexpr size_t dim=ndim; }; + +template + void xflexible_mav_apply(const Ttuple &tuple, const Tdim &dim, Func &&func, size_t nthreads) + { + auto fullinfos = tuple_transform2(tuple, dim, [](const auto &arg, const auto &dim) + { return make_infos::dim>(fmav_info(arg)); }); + vector iter_infos; + tuple_for_each(fullinfos,[&iter_infos](const auto &entry){iter_infos.push_back(get<0>(entry));}); + auto [shp, str] = multiprep(iter_infos); + + auto infos2 = tuple_transform(fullinfos, [](const auto &arg) + { return get<1>(arg); }); + auto ptrs = tuple_transform(tuple, [](auto &&arg){return arg.data();}); + flexible_mav_applyHelper(shp, str, ptrs, infos2, std::forward(func), nthreads); + } + +template + void flexible_mav_apply(Func &&func, size_t nthreads, T0 &&m0) + { + xflexible_mav_apply(forward_as_tuple(m0), + forward_as_tuple(Xdim()), + std::forward(func), nthreads); + } + +template + void flexible_mav_apply(Func &&func, size_t nthreads, T0 &&m0, T1 &&m1) + { + xflexible_mav_apply(forward_as_tuple(m0, m1), + forward_as_tuple(Xdim(), Xdim()), + std::forward(func), nthreads); + } + +template + void flexible_mav_apply(Func &&func, size_t nthreads, T0 &&m0, T1 &&m1, T2 &&m2) + { + xflexible_mav_apply(forward_as_tuple(m0, m1, m2), + forward_as_tuple(Xdim(), Xdim(), Xdim()), + std::forward(func), nthreads); + } + +} + +using detail_mav::UNINITIALIZED; +using detail_mav::fmav_info; +using detail_mav::mav_info; +using detail_mav::slice; +using detail_mav::MAXIDX; +using detail_mav::cfmav; +using detail_mav::vfmav; +using detail_mav::cmav; +using detail_mav::vmav; +using detail_mav::subarray; +using detail_mav::mav_apply; +using detail_mav::mav_apply_with_index; +using detail_mav::flexible_mav_apply; +} + +#endif diff --git a/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/infra/threading.h b/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/infra/threading.h new file mode 100644 index 0000000000000000000000000000000000000000..fad3a73d944dc518edf357e885ef581ce382875a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/_virtual_includes/fft/ducc/src/ducc0/infra/threading.h @@ -0,0 +1,337 @@ +/** \file ducc0/infra/threading.h + * Mulithreading support, similar to functionality provided by OpenMP + * + * \copyright Copyright (C) 2019-2023 Peter Bell, Max-Planck-Society + * \authors Peter Bell, Martin Reinecke + */ + +/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later */ + +/* +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. +* Neither the name of the copyright holder nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * This code is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This code is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this code; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef DUCC0_THREADING_H +#define DUCC0_THREADING_H + +// Low level threading support can be influenced by the following macros: +// - DUCC0_NO_LOWLEVEL_THREADING: if defined, multithreading is disabled +// and all parallel regions will be executed sequentially +// on the invoking thread. +// - DUCC0_CUSTOM_LOWLEVEL_THREADING: if defined, external definitions of +// Mutex, UniqueLock, LockGuard, CondVar, set_active_pool(), +// and get active_pool() must be supplied in "ducc0_custom_lowlevel_threading.h" +// and the code will use those. +// Both macros must not be defined at the same time. +// If neither macro is defined, standard ducc0 multihreading will be active. + +#if (defined(DUCC0_NO_LOWLEVEL_THREADING) && defined(DUCC0_CUSTOM_LOWLEVEL_THREADING)) +static_assert(false, "DUCC0_NO_LOWLEVEL_THREADING and DUCC0_CUSTOMLOWLEVEL_THREADING must not be both defined"); +#endif + +#if defined(DUCC0_STDCXX_LOWLEVEL_THREADING) +static_assert(false, "DUCC0_STDCXX_LOWLEVEL_THREADING must not be defined externally"); +#endif + +#if ((!defined(DUCC0_NO_LOWLEVEL_THREADING)) && (!defined(DUCC0_CUSTOM_LOWLEVEL_THREADING))) +#define DUCC0_STDCXX_LOWLEVEL_THREADING +#endif + +#include +#include +#include +#include + +#include "ducc0/infra/error_handling.h" + +// threading-specific headers +#ifdef DUCC0_STDCXX_LOWLEVEL_THREADING +#include +#include +#endif + +#ifdef DUCC0_NO_LOWLEVEL_THREADING +// no headers needed +#endif + +namespace ducc0 { +namespace detail_threading { + +using std::size_t; + +/// Abstract base class for minimalistic thread pool functionality +class thread_pool + { + public: + virtual ~thread_pool() {} + /// Returns the total number of threads managed by the pool + virtual size_t nthreads() const = 0; + /** "Normalizes" a requested number of threads. A useful convention could be + return (nthreads_in==0) ? nthreads() : min(nthreads(), nthreads_in); */ + virtual void resize(size_t /*nthreads_new*/) + { MR_fail("Resizing is not supported by this thread pool"); } + virtual size_t adjust_nthreads(size_t nthreads_in) const = 0; + virtual void submit(std::function work) = 0; + }; + +}} + +#ifdef DUCC0_CUSTOM_LOWLEVEL_THREADING +#include "ducc0_custom_lowlevel_threading.h" +#endif + +namespace ducc0 { + +namespace detail_threading { + +thread_pool *set_active_pool(thread_pool *new_pool); +thread_pool *get_active_pool(); + +// define threading related types dependent on the underlying implementation +#ifdef DUCC0_STDCXX_LOWLEVEL_THREADING +using Mutex = std::mutex; +using UniqueLock = std::unique_lock; +using LockGuard = std::lock_guard; +using CondVar = std::condition_variable; +#endif + +#ifdef DUCC0_NO_LOWLEVEL_THREADING +struct Mutex + { + void lock(){} + void unlock(){} + }; +struct LockGuard + { + LockGuard(const Mutex &){} + }; +struct UniqueLock + { + UniqueLock(const Mutex &){} + void lock() {} + void unlock() {} + }; +struct CondVar + { + template + void wait(UniqueLock &, Predicate) {} + void notify_one() noexcept {} + void notify_all() noexcept {} + }; +#endif + +using std::size_t; + +class ScopedUseThreadPool + { + private: + thread_pool *old_pool_; + public: + ScopedUseThreadPool(thread_pool &pool) + { old_pool_ = set_active_pool(&pool); } + ~ScopedUseThreadPool() + { set_active_pool(old_pool_); } + }; + +/// Index range describing a chunk of work inside a parallelized loop +struct Range + { + size_t lo, //< first index of the chunk + hi; //< one-past-last index of the chunk + Range() : lo(0), hi(0) {} + Range(size_t lo_, size_t hi_) : lo(lo_), hi(hi_) {} + /// Returns true iff the chunk is not empty + operator bool() const { return hi>lo; } + }; + +/// Class supplied to parallel regions, which allows them to determine their +/// work chunks. +class Scheduler + { + public: + virtual ~Scheduler() {} + /// Returns the number of threads working in this parallel region + virtual size_t num_threads() const = 0; + /// Returns the number of this thread, from the range 0 to num_threads()-1. + virtual size_t thread_num() const = 0; + /// Returns information about the next chunk of work. + /// If this chunk is empty, the work on this thread is done. + virtual Range getNext() = 0; + }; + +size_t available_hardware_threads(); +/** Returns the maximum number of threads that are supported by currently + active thread pool. */ +size_t thread_pool_size(); +void resize_thread_pool(size_t nthreads_new); +size_t adjust_nthreads(size_t nthreads); + +/// Execute \a func over \a nwork work items, on a single thread. +void execSingle(size_t nwork, + std::function func); +/// Execute \a func over \a nwork work items, on \a nthreads threads. +/** Chunks will have the size \a chunksize, except for the last one which + * may be smaller. + * + * Chunks are statically assigned to threads at startup. */ +void execStatic(size_t nwork, size_t nthreads, size_t chunksize, + std::function func); +/// Execute \a func over \a nwork work items, on \a nthreads threads. +/** Chunks will have the size \a chunksize, except for the last one which + * may be smaller. + * + * Chunks are assigned dynamically to threads;whenever a thread is finished + * with its current chunk, it will obtain the next one from the list of + * remaining chunks. */ +void execDynamic(size_t nwork, size_t nthreads, size_t chunksize, + std::function func); +void execGuided(size_t nwork, size_t nthreads, size_t chunksize_min, + double fact_max, std::function func); +/// Execute \a func on \a nthreads threads. +/** Work subdivision must be organized within \a func. */ +void execParallel(size_t nthreads, std::function func); +/// Execute \a func on \a nthreads threads, passing only the thread number. +/** Work subdivision must be organized within \a func. */ +void execParallel(size_t nthreads, std::function func); +/// Execute \a func on work items [\a lo; \a hi[ over \a nthreads threads. +/** Work items are subdivided fairly among threads. */ +void execParallel(size_t work_lo, size_t work_hi, size_t nthreads, + std::function func); +/// Execute \a func on work items [0; \a nwork[ over \a nthreads threads. +/** Work items are subdivided fairly among threads. */ +inline void execParallel(size_t nwork, size_t nthreads, + std::function func) + { execParallel(0, nwork, nthreads, func); } +/// Execute \a func on work items [\a lo; \a hi[ over \a nthreads threads. +/** The first argument to \a func is the thread number. + * + * Work items are subdivided fairly among threads. */ +void execParallel(size_t work_lo, size_t work_hi, size_t nthreads, + std::function func); +/// Execute \a func on work items [0; \a nwork[ over \a nthreads threads. +/** The first argument to \a func is the thread number. + * + * Work items are subdivided fairly among threads. */ +inline void execParallel(size_t nwork, size_t nthreads, + std::function func) + { execParallel(0, nwork, nthreads, func); } + +template class Worklist + { + private: + Mutex mtx; + CondVar cv; + size_t nworking{0}; + std::vector items; + + public: + Worklist(const std::vector &items_) + : items(items_) {} + + std::optional get_item() + { + UniqueLock lck(mtx); + if ((--nworking==0) && items.empty()) cv.notify_all(); + cv.wait(lck,[&](){return (!items.empty()) || (nworking==0);}); + if (!items.empty()) + { + auto res = items.back(); + items.pop_back(); + ++nworking; + return res; + } + else + return {}; + } + void startup() + { + LockGuard lck(mtx); + ++nworking; + } + void put_item(const T &item) + { + LockGuard lck(mtx); + items.push_back(item); + cv.notify_one(); + } + }; + +/// Execute \a func on work items in \a items over \a nthreads threads. +/** While processing a work item, \a func may submit further items to the list + * of work items. For this purpose, \a func must take a const T & + * (the work item to be processed) as well as a function which also takes + * a const T & (the insert function). Work items will be assigned whenever a + * thread becomes available. */ +template auto execWorklist + (size_t nthreads, const std::vector &items, Func &&func) + { + Worklist wl(items); + execParallel(nthreads, [&wl, &func](auto &) { + wl.startup(); + while(auto wrk=wl.get_item()) + func(wrk.value(), [&wl](const T &item){wl.put_item(item);}); + }); + } + +} // end of namespace detail_threading + +using detail_threading::Mutex; +using detail_threading::LockGuard; +using detail_threading::UniqueLock; +using detail_threading::CondVar; +using detail_threading::thread_pool; +using detail_threading::ScopedUseThreadPool; +using detail_threading::available_hardware_threads; +using detail_threading::thread_pool_size; +using detail_threading::resize_thread_pool; +using detail_threading::adjust_nthreads; +using detail_threading::Scheduler; +using detail_threading::execSingle; +using detail_threading::execStatic; +using detail_threading::execDynamic; +using detail_threading::execGuided; +using detail_threading::execParallel; +using detail_threading::execWorklist; + +} // end of namespace ducc0 + +#endif diff --git a/deps/exla/cache/xla_extension/include/_virtual_includes/fft_wrapper/ducc/google/fft.h b/deps/exla/cache/xla_extension/include/_virtual_includes/fft_wrapper/ducc/google/fft.h new file mode 100644 index 0000000000000000000000000000000000000000..8c1691d36cadd8dbae3743b8eaa3bff9c1e88a96 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/_virtual_includes/fft_wrapper/ducc/google/fft.h @@ -0,0 +1,77 @@ +/* Copyright 2023 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef THIRD_PARTY_DUCC_GOOGLE_FFT_H_ +#define THIRD_PARTY_DUCC_GOOGLE_FFT_H_ + +// Wrapper around the DUCC FFT library to isolate usage of exceptions +// and RTTI. Eliminates all direct usage of DUCC headers. + +#include +#include +#include + +#include "unsupported/Eigen/CXX11/ThreadPool" + +namespace ducc0 { +namespace google { + +using Shape = std::vector; +using Stride = std::vector; + +template +void c2c(const std::complex* in, const Shape& in_shape, + const Stride& in_stride, std::complex* out, + const Shape& out_shape, const Stride& out_stride, const Shape& axes, + bool forward, RealScalar scale, + Eigen::ThreadPoolInterface* thread_pool); + +template +void r2c(const RealScalar* in, const Shape& in_shape, const Stride& in_stride, + std::complex* out, const Shape& out_shape, + const Stride& out_stride, const Shape& axes, bool forward, + RealScalar scale, Eigen::ThreadPoolInterface* thread_pool); + +template +void c2r(const std::complex* in, const Shape& in_shape, + const Stride& in_stride, RealScalar* out, const Shape& out_shape, + const Stride& out_stride, const Shape& axes, bool forward, + RealScalar scale, Eigen::ThreadPoolInterface* thread_pool); + +#define FFT_DECLARATIONS(RealScalar) \ + extern template void c2c( \ + const std::complex* in, const Shape& in_shape, \ + const Stride& in_stride, std::complex* out, \ + const Shape& out_shape, const Stride& out_stride, const Shape& axes, \ + bool forward, RealScalar scale, \ + Eigen::ThreadPoolInterface* thread_pool); \ + extern template void r2c( \ + const RealScalar* in, const Shape& in_shape, const Stride& in_stride, \ + std::complex* out, const Shape& out_shape, \ + const Stride& out_stride, const Shape& axes, bool forward, \ + RealScalar scale, Eigen::ThreadPoolInterface* thread_pool); \ + extern template void c2r( \ + const std::complex* in, const Shape& in_shape, \ + const Stride& in_stride, RealScalar* out, const Shape& out_shape, \ + const Stride& out_stride, const Shape& axes, bool forward, \ + RealScalar scale, Eigen::ThreadPoolInterface* thread_pool) +FFT_DECLARATIONS(float); +FFT_DECLARATIONS(double); +#undef FFT_DECLARATIONS + +} // namespace google +} // namespace ducc0 + +#endif // THIRD_PARTY_DUCC_GOOGLE_FFT_H_ \ No newline at end of file diff --git a/deps/exla/cache/xla_extension/include/_virtual_includes/pthreadpool/pthreadpool.h b/deps/exla/cache/xla_extension/include/_virtual_includes/pthreadpool/pthreadpool.h new file mode 100644 index 0000000000000000000000000000000000000000..9ec49d6b11080a821872f1343b210d98fe6c6fd0 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/_virtual_includes/pthreadpool/pthreadpool.h @@ -0,0 +1,3290 @@ +// Copyright (c) 2017 Facebook Inc. +// Copyright (c) 2015-2017 Georgia Institute of Technology +// All rights reserved. +// +// Copyright 2019 Google LLC +// +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. + +#ifndef __PTHREADPOOL_INCLUDE_PTHREADPOOL_H_ +#define __PTHREADPOOL_INCLUDE_PTHREADPOOL_H_ + +#include +#include + +typedef struct pthreadpool* pthreadpool_t; + +typedef void (*pthreadpool_task_1d_t)(void*, size_t); +typedef void (*pthreadpool_task_1d_with_thread_t)(void*, size_t, size_t); +typedef void (*pthreadpool_task_1d_tile_1d_t)(void*, size_t, size_t); +typedef void (*pthreadpool_task_1d_tile_1d_dynamic_t)(void*, size_t, size_t); +typedef void (*pthreadpool_task_1d_tile_1d_dynamic_with_id_t)(void*, uint32_t, + size_t, size_t); +typedef void (*pthreadpool_task_2d_t)(void*, size_t, size_t); +typedef void (*pthreadpool_task_2d_with_thread_t)(void*, size_t, size_t, + size_t); +typedef void (*pthreadpool_task_2d_tile_1d_t)(void*, size_t, size_t, size_t); +typedef void (*pthreadpool_task_2d_tile_1d_dynamic_t)(void*, size_t, size_t, + size_t); +typedef void (*pthreadpool_task_2d_tile_2d_t)(void*, size_t, size_t, size_t, + size_t); +typedef void (*pthreadpool_task_2d_tile_2d_dynamic_t)(void*, size_t, size_t, + size_t, size_t); +typedef void (*pthreadpool_task_3d_t)(void*, size_t, size_t, size_t); +typedef void (*pthreadpool_task_3d_tile_1d_t)(void*, size_t, size_t, size_t, + size_t); +typedef void (*pthreadpool_task_3d_tile_1d_with_thread_t)(void*, size_t, size_t, + size_t, size_t, + size_t); +typedef void (*pthreadpool_task_3d_tile_1d_dynamic_t)(void*, size_t, size_t, + size_t, size_t); +typedef void (*pthreadpool_task_3d_tile_2d_t)(void*, size_t, size_t, size_t, + size_t, size_t); +typedef void (*pthreadpool_task_3d_tile_2d_dynamic_t)(void*, size_t, size_t, + size_t, size_t, size_t); +typedef void (*pthreadpool_task_4d_t)(void*, size_t, size_t, size_t, size_t); +typedef void (*pthreadpool_task_4d_tile_1d_t)(void*, size_t, size_t, size_t, + size_t, size_t); +typedef void (*pthreadpool_task_4d_tile_2d_t)(void*, size_t, size_t, size_t, + size_t, size_t, size_t); +typedef void (*pthreadpool_task_4d_tile_2d_dynamic_t)(void*, size_t, size_t, + size_t, size_t, size_t, + size_t); +typedef void (*pthreadpool_task_5d_t)(void*, size_t, size_t, size_t, size_t, + size_t); +typedef void (*pthreadpool_task_5d_tile_1d_t)(void*, size_t, size_t, size_t, + size_t, size_t, size_t); +typedef void (*pthreadpool_task_5d_tile_2d_t)(void*, size_t, size_t, size_t, + size_t, size_t, size_t, size_t); +typedef void (*pthreadpool_task_6d_t)(void*, size_t, size_t, size_t, size_t, + size_t, size_t); +typedef void (*pthreadpool_task_6d_tile_1d_t)(void*, size_t, size_t, size_t, + size_t, size_t, size_t, size_t); +typedef void (*pthreadpool_task_6d_tile_2d_t)(void*, size_t, size_t, size_t, + size_t, size_t, size_t, size_t, + size_t); + +typedef void (*pthreadpool_task_1d_with_id_t)(void*, uint32_t, size_t); +typedef void (*pthreadpool_task_2d_tile_1d_with_id_t)(void*, uint32_t, size_t, + size_t, size_t); +typedef void (*pthreadpool_task_2d_tile_1d_dynamic_with_id_t)(void*, uint32_t, + size_t, size_t, + size_t); +typedef void (*pthreadpool_task_2d_tile_2d_with_id_t)(void*, uint32_t, size_t, + size_t, size_t, size_t); +typedef void (*pthreadpool_task_2d_tile_2d_dynamic_with_id_t)(void*, uint32_t, + size_t, size_t, + size_t, size_t); +typedef void (*pthreadpool_task_3d_tile_1d_with_id_t)(void*, uint32_t, size_t, + size_t, size_t, size_t); +typedef void (*pthreadpool_task_3d_tile_1d_dynamic_with_id_t)(void*, uint32_t, + size_t, size_t, + size_t, size_t); +typedef void (*pthreadpool_task_3d_tile_2d_with_id_t)(void*, uint32_t, size_t, + size_t, size_t, size_t, + size_t); +typedef void (*pthreadpool_task_3d_tile_2d_dynamic_with_id_t)(void*, uint32_t, + size_t, size_t, + size_t, size_t, + size_t); +typedef void (*pthreadpool_task_4d_tile_2d_with_id_t)(void*, uint32_t, size_t, + size_t, size_t, size_t, + size_t, size_t); +typedef void (*pthreadpool_task_4d_tile_2d_dynamic_with_id_t)(void*, uint32_t, + size_t, size_t, + size_t, size_t, + size_t, size_t); + +typedef void (*pthreadpool_task_1d_tile_1d_dynamic_with_id_with_thread_t)( + void*, uint32_t, size_t, size_t, size_t); +typedef void (*pthreadpool_task_2d_tile_1d_with_id_with_thread_t)( + void*, uint32_t, size_t, size_t, size_t, size_t); +typedef void (*pthreadpool_task_2d_tile_1d_dynamic_with_id_with_thread_t)( + void*, uint32_t, size_t, size_t, size_t, size_t); +typedef void (*pthreadpool_task_3d_tile_1d_with_id_with_thread_t)( + void*, uint32_t, size_t, size_t, size_t, size_t, size_t); + +/** + * Disable support for denormalized numbers to the maximum extent possible for + * the duration of the computation. + * + * Handling denormalized floating-point numbers is often implemented in + * microcode, and incurs significant performance degradation. This hint + * instructs the thread pool to disable support for denormalized numbers before + * running the computation by manipulating architecture-specific control + * registers, and restore the initial value of control registers after the + * computation is complete. The thread pool temporary disables denormalized + * numbers on all threads involved in the computation (i.e. the caller threads, + * and potentially worker threads). + * + * Disabling denormalized numbers may have a small negative effect on results' + * accuracy. As various architectures differ in capabilities to control + * processing of denormalized numbers, using this flag may also hurt results' + * reproducibility across different instruction set architectures. + */ +#define PTHREADPOOL_FLAG_DISABLE_DENORMALS 0x00000001 + +/** + * Yield worker threads to the system scheduler after the operation is finished. + * + * Force workers to use kernel wait (instead of active spin-wait by default) for + * new commands after this command is processed. This flag affects only the + * immediate next operation on this thread pool. To make the thread pool always + * use kernel wait, pass this flag to all parallelization functions. + */ +#define PTHREADPOOL_FLAG_YIELD_WORKERS 0x00000002 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Create a thread pool with the specified number of threads. + * + * @param threads_count the number of threads in the thread pool. + * A value of 0 has special interpretation: it creates a thread pool with as + * many threads as there are logical processors in the system. + * + * @returns A pointer to an opaque thread pool object if the call is + * successful, or NULL pointer if the call failed. + */ +pthreadpool_t pthreadpool_create(size_t threads_count); + +/** + * Query the number of threads in a thread pool. + * + * @param threadpool the thread pool to query. + * + * @returns The number of threads in the thread pool. + */ +size_t pthreadpool_get_threads_count(pthreadpool_t threadpool); + +/** + * Process items on a 1D grid. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range; i++) + * function(context, i); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each item. + * @param context the first argument passed to the specified function. + * @param range the number of items on the 1D grid to process. The + * specified function will be called once for each item. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_1d(pthreadpool_t threadpool, + pthreadpool_task_1d_t function, void* context, + size_t range, uint32_t flags); + +/** + * Process items on a 1D grid passing along the current thread id. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range; i++) + * function(context, thread_index, i); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each item. + * @param context the first argument passed to the specified function. + * @param range the number of items on the 1D grid to process. The + * specified function will be called once for each item. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_1d_with_thread( + pthreadpool_t threadpool, pthreadpool_task_1d_with_thread_t function, + void* context, size_t range, uint32_t flags); + +/** + * Process items on a 1D grid using a microarchitecture-aware task function. + * + * The function implements a parallel version of the following snippet: + * + * uint32_t uarch_index = cpuinfo_initialize() ? + * cpuinfo_get_current_uarch_index() : default_uarch_index; + * if (uarch_index > max_uarch_index) uarch_index = default_uarch_index; + * for (size_t i = 0; i < range; i++) + * function(context, uarch_index, i); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If + * threadpool is NULL, all items are processed serially on the calling + * thread. + * @param function the function to call for each item. + * @param context the first argument passed to the specified + * function. + * @param default_uarch_index the microarchitecture index to use when + * pthreadpool is configured without cpuinfo, cpuinfo initialization failed, + * or index returned by cpuinfo_get_current_uarch_index() exceeds the + * max_uarch_index value. + * @param max_uarch_index the maximum microarchitecture index expected by + * the specified function. If the index returned by + * cpuinfo_get_current_uarch_index() exceeds this value, default_uarch_index + * will be used instead. default_uarch_index can exceed max_uarch_index. + * @param range the number of items on the 1D grid to process. + * The specified function will be called once for each item. + * @param flags a bitwise combination of zero or more optional + * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_1d_with_uarch( + pthreadpool_t threadpool, pthreadpool_task_1d_with_id_t function, + void* context, uint32_t default_uarch_index, uint32_t max_uarch_index, + size_t range, uint32_t flags); + +/** + * Process items on a 1D grid with specified maximum tile size. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range; i += tile) + * function(context, i, min(range - i, tile)); + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range the number of items on the 1D grid to process. + * @param tile the maximum number of items on the 1D grid to process in + * one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_1d_tile_1d(pthreadpool_t threadpool, + pthreadpool_task_1d_tile_1d_t function, + void* context, size_t range, + size_t tile, uint32_t flags); + +/** + * Process items on a 1D grid with specified prefered tile size. + * + * The function repeatedly calls + * + * function(context, i, count) + * + * in parallel where `i` is in the range `[0, range)` and a multiple of the + * provided @a tile and `count` is an integer multiple of @a tile unless `i + * + count == range`. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range the number of items on the 1D grid to process. + * @param tile the preferred multiple number of items on the 1D grid to + * process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_1d_tile_1d_dynamic( + pthreadpool_t threadpool, pthreadpool_task_1d_tile_1d_dynamic_t function, + void* context, size_t range, size_t tile, uint32_t flags); + +/** + * Process items on a 1D grid with specified prefered tile size, passing along + * the current thread id. + * + * The function repeatedly calls + * + * function(context, thread_id, i, count) + * + * in parallel where `i` is in the range `[0, range)` and a multiple of the + * provided @a tile and `count` is an integer multiple of @a tile unless `i + * + count == range`. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range the number of items on the 1D grid to process. + * @param tile the preferred multiple number of items on the 1D grid to + * process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_1d_tile_1d_dynamic_with_thread( + pthreadpool_t threadpool, + pthreadpool_task_1d_tile_1d_dynamic_with_id_t function, void* context, + size_t range, size_t tile, uint32_t flags); + +/** + * Process items on a 1D grid with specified prefered tile size, passing along + * the current uarch index and thread id. + * + * The function repeatedly calls + * + * function(context, uarch_index, thread_id, i, count) + * + * in parallel where `i` is in the range `[0, range)` and a multiple of the + * provided @a tile and `count` is an integer multiple of @a tile unless `i + * + count == range`. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range the number of items on the 1D grid to process. + * @param tile the preferred multiple number of items on the 1D grid to + * process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_1d_tile_1d_dynamic_with_uarch_with_thread( + pthreadpool_t threadpool, + pthreadpool_task_1d_tile_1d_dynamic_with_id_with_thread_t function, + void* context, uint32_t default_uarch_index, uint32_t max_uarch_index, + size_t range, size_t tile, uint32_t flags); + +/** + * Process items on a 2D grid. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * function(context, i, j); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each item. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 2D grid. + * @param range_j the number of items to process along the second dimension + * of the 2D grid. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_2d(pthreadpool_t threadpool, + pthreadpool_task_2d_t function, void* context, + size_t range_i, size_t range_j, uint32_t flags); + +/** + * Process items on a 2D grid passing along the current thread id. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * function(context, thread_index, i, j); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each item. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 2D grid. + * @param range_j the number of items to process along the second dimension + * of the 2D grid. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_2d_with_thread( + pthreadpool_t threadpool, pthreadpool_task_2d_with_thread_t function, + void* context, size_t range_i, size_t range_j, uint32_t flags); + +/** + * Process items on a 2D grid with the specified maximum tile size along the + * last grid dimension. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j += tile_j) + * function(context, i, j, min(range_j - j, tile_j)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 2D grid. + * @param range_j the number of items to process along the second dimension + * of the 2D grid. + * @param tile_j the maximum number of items along the second dimension of + * the 2D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_2d_tile_1d(pthreadpool_t threadpool, + pthreadpool_task_2d_tile_1d_t function, + void* context, size_t range_i, + size_t range_j, size_t tile_j, + uint32_t flags); + +/** + * Process items on a 2D grid with the specified maximum tile size along the + * last grid dimension using a microarchitecture-aware task function. + * + * The function implements a parallel version of the following snippet: + * + * uint32_t uarch_index = cpuinfo_initialize() ? + * cpuinfo_get_current_uarch_index() : default_uarch_index; + * if (uarch_index > max_uarch_index) uarch_index = default_uarch_index; + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j += tile_j) + * function(context, uarch_index, i, j, min(range_j - j, tile_j)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param default_uarch_index the microarchitecture index to use when + * pthreadpool is configured without cpuinfo, cpuinfo initialization failed, + * or index returned by cpuinfo_get_current_uarch_index() exceeds the + * max_uarch_index value. + * @param max_uarch_index the maximum microarchitecture index expected by + * the specified function. If the index returned by + * cpuinfo_get_current_uarch_index() exceeds this value, default_uarch_index + * will be used instead. default_uarch_index can exceed max_uarch_index. + * @param range_i the number of items to process along the first dimension + * of the 2D grid. + * @param range_j the number of items to process along the second dimension + * of the 2D grid. + * @param tile_j the maximum number of items along the second dimension of + * the 2D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_2d_tile_1d_with_uarch( + pthreadpool_t threadpool, pthreadpool_task_2d_tile_1d_with_id_t function, + void* context, uint32_t default_uarch_index, uint32_t max_uarch_index, + size_t range_i, size_t range_j, size_t tile_j, uint32_t flags); + +/** + * Process items on a 2D grid with the specified maximum tile size along the + * last grid dimension using a microarchitecture-aware task function and passing + * along the current thread id. + * + * The function implements a parallel version of the following snippet: + * + * uint32_t uarch_index = cpuinfo_initialize() ? + * cpuinfo_get_current_uarch_index() : default_uarch_index; + * if (uarch_index > max_uarch_index) uarch_index = default_uarch_index; + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j += tile_j) + * function(context, uarch_index, thread_index, i, j, min(range_j - j, + * tile_j)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param default_uarch_index the microarchitecture index to use when + * pthreadpool is configured without cpuinfo, cpuinfo initialization failed, + * or index returned by cpuinfo_get_current_uarch_index() exceeds the + * max_uarch_index value. + * @param max_uarch_index the maximum microarchitecture index expected by + * the specified function. If the index returned by + * cpuinfo_get_current_uarch_index() exceeds this value, default_uarch_index + * will be used instead. default_uarch_index can exceed max_uarch_index. + * @param range_i the number of items to process along the first dimension + * of the 2D grid. + * @param range_j the number of items to process along the second dimension + * of the 2D grid. + * @param tile_j the maximum number of items along the second dimension of + * the 2D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_2d_tile_1d_with_uarch_with_thread( + pthreadpool_t threadpool, + pthreadpool_task_2d_tile_1d_with_id_with_thread_t function, void* context, + uint32_t default_uarch_index, uint32_t max_uarch_index, size_t range_i, + size_t range_j, size_t tile_j, uint32_t flags); + +/** + * Process items on a 2D grid with specified prefered tile size along the + * last grid dimension. + * + * The function repeatedly calls + * + * function(context, i, j, count_j) + * + * in parallel where `i` is in the range `[0, range_i)`, `j` is in the range + * `[0, range_j)` and a multiple of the provided @a tile_j, and `count_j` is an + * integer multiple of @a tile_j unless `j + count_j == range_j`. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range_i the number of items on the first dimension of the 2D + * grid to process. + * @param range_j the number of items on the second dimension of the 2D + * grid to process. + * @param tile_j the preferred multiple number of items on the second + * dimension of the 2D grid to process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_2d_tile_1d_dynamic( + pthreadpool_t threadpool, pthreadpool_task_2d_tile_1d_dynamic_t function, + void* context, size_t range_i, size_t range_j, size_t tile_j, + uint32_t flags); + +/** + * Process items on a 2D grid with specified prefered tile size along the + * last grid dimension, passing along the current thread id. + * + * The function repeatedly calls + * + * function(context, thread_id, i, j, count_j) + * + * in parallel where `i` is in the range `[0, range_i)`, `j` is in the range + * `[0, range_j)` and a multiple of the provided @a tile_j, and `count_j` is an + * integer multiple of @a tile_j unless `j + count_j == range_j`. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range_i the number of items on the first dimension of the 2D + * grid to process. + * @param range_j the number of items on the second dimension of the 2D + * grid to process. + * @param tile_j the preferred multiple number of items on the second + * dimension of the 2D grid to process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_2d_tile_1d_dynamic_with_thread( + pthreadpool_t threadpool, + pthreadpool_task_2d_tile_1d_dynamic_with_id_t function, void* context, + size_t range_i, size_t range_j, size_t tile_j, uint32_t flags); + +/** + * Process items on a 2D grid with specified prefered tile size along the + * last grid dimension, passing along the current uarch index and thread id. + * + * The function repeatedly calls + * + * function(context, uarch_index, thread_id, i, j, count_j) + * + * in parallel where `i` is in the range `[0, range_i)`, `j` is in the range + * `[0, range_j)` and a multiple of the provided @a tile_j, and `count_j` is an + * integer multiple of @a tile_j unless `j + count_j == range_j`. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range_i the number of items on the first dimension of the 2D + * grid to process. + * @param range_j the number of items on the second dimension of the 2D + * grid to process. + * @param tile_j the preferred multiple number of items on the second + * dimension of the 2D grid to process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_2d_tile_1d_dynamic_with_uarch_with_thread( + pthreadpool_t threadpool, + pthreadpool_task_2d_tile_1d_dynamic_with_id_with_thread_t function, + void* context, uint32_t default_uarch_index, uint32_t max_uarch_index, + size_t range_i, size_t range_j, size_t tile_j, uint32_t flags); + +/** + * Process items on a 2D grid with the specified maximum tile size along each + * grid dimension. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i += tile_i) + * for (size_t j = 0; j < range_j; j += tile_j) + * function(context, i, j, + * min(range_i - i, tile_i), min(range_j - j, tile_j)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 2D grid. + * @param range_j the number of items to process along the second dimension + * of the 2D grid. + * @param tile_j the maximum number of items along the first dimension of + * the 2D grid to process in one function call. + * @param tile_j the maximum number of items along the second dimension of + * the 2D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_2d_tile_2d(pthreadpool_t threadpool, + pthreadpool_task_2d_tile_2d_t function, + void* context, size_t range_i, + size_t range_j, size_t tile_i, + size_t tile_j, uint32_t flags); + +/** + * Process items on a 2D grid with specified prefered tile size along each grid + * dimension. + * + * The function repeatedly calls + * + * function(context, i, j, count_i, count_j) + * + * in parallel where `i` is in the range `[0, range_i)` and a multiple of the + * provided @a tile_i, `j` is in the range `[0, range_j)` and a multiple of the + * provided @a tile_j, and `count_i` and `count_j` are integer multiples of @a + * tile__i and @a tile_j, unless `i + count_i == range_i` or `j + count_j == + * range_j`, respectivly. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling + * thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range_i the number of items on the first dimension of the 2D + * grid to process. + * @param range_j the number of items on the second dimension of the 2D + * grid to process. + * @param tile_i the preferred multiple number of items on the first + * dimension of the 2D grid to process in each function call. + * @param tile_j the preferred multiple number of items on the second + * dimension of the 2D grid to process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_2d_tile_2d_dynamic( + pthreadpool_t threadpool, pthreadpool_task_2d_tile_2d_dynamic_t function, + void* context, size_t range_i, size_t range_j, size_t tile_i, size_t tile_j, + uint32_t flags); + +/** + * Process items on a 2D grid with specified prefered tile size along each grid + * dimension using a microarchitecture-aware task function. + * + * The function repeatedly calls + * + * function(context, uarch_index, i, j, count_i, count_j) + * + * in parallel where `i` is in the range `[0, range_i)` and a multiple of the + * provided @a tile_i, `j` is in the range `[0, range_j)` and a multiple of the + * provided @a tile_j, and `count_i` and `count_j` are integer multiples of @a + * tile__i and @a tile_j, unless `i + count_i == range_i` or `j + count_j == + * range_j`, respectivly. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If + * threadpool is NULL, all items are processed + * serially on the calling thread. + * @param function the function to call for each interval of the + * given range. + * @param context the first argument passed to the specified + * function. + * @param default_uarch_index the microarchitecture index to use when + * pthreadpool is configured without cpuinfo, + * cpuinfo initialization failed, or index returned + * by cpuinfo_get_current_uarch_index() exceeds + * the max_uarch_index value. + * @param max_uarch_index the maximum microarchitecture index expected + * by the specified function. If the index returned + * by cpuinfo_get_current_uarch_index() exceeds this + * value, default_uarch_index will be used instead. + * default_uarch_index can exceed max_uarch_index. + * @param range_i the number of items on the first dimension of the + * 2D grid to process. + * @param range_j the number of items on the second dimension of + * the 2D grid to process. + * @param tile_i the preferred multiple number of items on the + * first dimension of the 2D grid to process in each + * function call. + * @param tile_j the preferred multiple number of items on the + * second dimension of the 2D grid to process in + * each function call. + * @param flags a bitwise combination of zero or more optional + * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_2d_tile_2d_dynamic_with_uarch( + pthreadpool_t threadpool, + pthreadpool_task_2d_tile_2d_dynamic_with_id_t function, void* context, + uint32_t default_uarch_index, uint32_t max_uarch_index, size_t range_i, + size_t range_j, size_t tile_i, size_t tile_j, uint32_t flags); + +/** + * Process items on a 2D grid with specified prefered tile size along each grid + * dimension passing along the current thread id. + * + * The function repeatedly calls + * + * function(context, thread_id, i, j, count_i, count_j) + * + * in parallel where `i` is in the range `[0, range_i)` and a multiple of the + * provided @a tile_i, `j` is in the range `[0, range_j)` and a multiple of the + * provided @a tile_j, and `count_i` and `count_j` are integer multiples of @a + * tile__i and @a tile_j, unless `i + count_i == range_i` or `j + count_j == + * range_j`, respectivly. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If + * threadpool is NULL, all items are processed + * serially on the calling thread. + * @param function the function to call for each interval of the + * given range. + * @param context the first argument passed to the specified + * function. + * @param range_i the number of items on the first dimension of the + * 2D grid to process. + * @param range_j the number of items on the second dimension of + * the 2D grid to process. + * @param tile_i the preferred multiple number of items on the + * first dimension of the 2D grid to process in each + * function call. + * @param tile_j the preferred multiple number of items on the + * second dimension of the 2D grid to process in + * each function call. + * @param flags a bitwise combination of zero or more optional + * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_2d_tile_2d_dynamic_with_thread( + pthreadpool_t threadpool, + pthreadpool_task_2d_tile_2d_dynamic_with_id_t function, void* context, + size_t range_i, size_t range_j, size_t tile_i, size_t tile_j, + uint32_t flags); + +/** + * Process items on a 2D grid with the specified maximum tile size along each + * grid dimension using a microarchitecture-aware task function. + * + * The function implements a parallel version of the following snippet: + * + * uint32_t uarch_index = cpuinfo_initialize() ? + * cpuinfo_get_current_uarch_index() : default_uarch_index; + * if (uarch_index > max_uarch_index) uarch_index = default_uarch_index; + * for (size_t i = 0; i < range_i; i += tile_i) + * for (size_t j = 0; j < range_j; j += tile_j) + * function(context, uarch_index, i, j, + * min(range_i - i, tile_i), min(range_j - j, tile_j)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If + * threadpool is NULL, all items are processed serially on the calling + * thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified + * function. + * @param default_uarch_index the microarchitecture index to use when + * pthreadpool is configured without cpuinfo, + * cpuinfo initialization failed, or index returned + * by cpuinfo_get_current_uarch_index() exceeds + * the max_uarch_index value. + * @param max_uarch_index the maximum microarchitecture index expected + * by the specified function. If the index returned + * by cpuinfo_get_current_uarch_index() exceeds this + * value, default_uarch_index will be used instead. + * default_uarch_index can exceed max_uarch_index. + * @param range_i the number of items to process along the first + * dimension of the 2D grid. + * @param range_j the number of items to process along the second + * dimension of the 2D grid. + * @param tile_j the maximum number of items along the first + * dimension of the 2D grid to process in one function call. + * @param tile_j the maximum number of items along the second + * dimension of the 2D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional + * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_2d_tile_2d_with_uarch( + pthreadpool_t threadpool, pthreadpool_task_2d_tile_2d_with_id_t function, + void* context, uint32_t default_uarch_index, uint32_t max_uarch_index, + size_t range_i, size_t range_j, size_t tile_i, size_t tile_j, + uint32_t flags); + +/** + * Process items on a 3D grid. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * function(context, i, j, k); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 3D grid. + * @param range_j the number of items to process along the second dimension + * of the 3D grid. + * @param range_k the number of items to process along the third dimension + * of the 3D grid. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_3d(pthreadpool_t threadpool, + pthreadpool_task_3d_t function, void* context, + size_t range_i, size_t range_j, size_t range_k, + uint32_t flags); + +/** + * Process items on a 3D grid with the specified maximum tile size along the + * last grid dimension. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k += tile_k) + * function(context, i, j, k, min(range_k - k, tile_k)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 3D grid. + * @param range_j the number of items to process along the second dimension + * of the 3D grid. + * @param range_k the number of items to process along the third dimension + * of the 3D grid. + * @param tile_k the maximum number of items along the third dimension of + * the 3D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_3d_tile_1d(pthreadpool_t threadpool, + pthreadpool_task_3d_tile_1d_t function, + void* context, size_t range_i, + size_t range_j, size_t range_k, + size_t tile_k, uint32_t flags); + +/** + * Process items on a 3D grid with the specified maximum tile size along the + * last grid dimension and passing along the current thread id. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k += tile_k) + * function(context, thread_index, i, j, k, min(range_k - k, tile_k)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 3D grid. + * @param range_j the number of items to process along the second dimension + * of the 3D grid. + * @param range_k the number of items to process along the third dimension + * of the 3D grid. + * @param tile_k the maximum number of items along the third dimension of + * the 3D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_3d_tile_1d_with_thread( + pthreadpool_t threadpool, + pthreadpool_task_3d_tile_1d_with_thread_t function, void* context, + size_t range_i, size_t range_j, size_t range_k, size_t tile_k, + uint32_t flags); + +/** + * Process items on a 3D grid with the specified maximum tile size along the + * last grid dimension using a microarchitecture-aware task function. + * + * The function implements a parallel version of the following snippet: + * + * uint32_t uarch_index = cpuinfo_initialize() ? + * cpuinfo_get_current_uarch_index() : default_uarch_index; + * if (uarch_index > max_uarch_index) uarch_index = default_uarch_index; + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k += tile_k) + * function(context, uarch_index, i, j, k, min(range_k - k, tile_k)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If + * threadpool is NULL, all items are processed serially on the calling + * thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified + * function. + * @param default_uarch_index the microarchitecture index to use when + * pthreadpool is configured without cpuinfo, cpuinfo initialization failed, + * or index returned by cpuinfo_get_current_uarch_index() exceeds the + * max_uarch_index value. + * @param max_uarch_index the maximum microarchitecture index expected by + * the specified function. If the index returned by + * cpuinfo_get_current_uarch_index() exceeds this value, default_uarch_index + * will be used instead. default_uarch_index can exceed max_uarch_index. + * @param range_i the number of items to process along the first + * dimension of the 3D grid. + * @param range_j the number of items to process along the second + * dimension of the 3D grid. + * @param range_k the number of items to process along the third + * dimension of the 3D grid. + * @param tile_k the maximum number of items along the third + * dimension of the 3D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional + * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_3d_tile_1d_with_uarch( + pthreadpool_t threadpool, pthreadpool_task_3d_tile_1d_with_id_t function, + void* context, uint32_t default_uarch_index, uint32_t max_uarch_index, + size_t range_i, size_t range_j, size_t range_k, size_t tile_k, + uint32_t flags); + +/** + * Process items on a 3D grid with the specified maximum tile size along the + * last grid dimension using a microarchitecture-aware task function and passing + * along the current thread id. + * + * The function implements a parallel version of the following snippet: + * + * uint32_t uarch_index = cpuinfo_initialize() ? + * cpuinfo_get_current_uarch_index() : default_uarch_index; + * if (uarch_index > max_uarch_index) uarch_index = default_uarch_index; + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k += tile_k) + * function(context, uarch_index, thread_index, i, j, k, min(range_k - + * k, tile_k)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If + * threadpool is NULL, all items are processed serially on the calling + * thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified + * function. + * @param default_uarch_index the microarchitecture index to use when + * pthreadpool is configured without cpuinfo, cpuinfo initialization failed, + * or index returned by cpuinfo_get_current_uarch_index() exceeds the + * max_uarch_index value. + * @param max_uarch_index the maximum microarchitecture index expected by + * the specified function. If the index returned by + * cpuinfo_get_current_uarch_index() exceeds this value, default_uarch_index + * will be used instead. default_uarch_index can exceed max_uarch_index. + * @param range_i the number of items to process along the first + * dimension of the 3D grid. + * @param range_j the number of items to process along the second + * dimension of the 3D grid. + * @param range_k the number of items to process along the third + * dimension of the 3D grid. + * @param tile_k the maximum number of items along the third + * dimension of the 3D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional + * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_3d_tile_1d_with_uarch_with_thread( + pthreadpool_t threadpool, + pthreadpool_task_3d_tile_1d_with_id_with_thread_t function, void* context, + uint32_t default_uarch_index, uint32_t max_uarch_index, size_t range_i, + size_t range_j, size_t range_k, size_t tile_k, uint32_t flags); + +/** + * Process items on a 3D grid with specified prefered tile size along the last + * grid dimension, passing along the thread ID. + * + * The function repeatedly calls + * + * function(context, thread_id, i, j, k, count_k) + * + * in parallel where: + * - `i` is in the range `[0, range_i)`, + * - `j` is in the range `[0, range_j)`, + * - `k` is in the range `[0, range_k)` and a multiple of the provided @a + * tile_k, + * - `count_k` is an integer multiple of @a tile_k, unless `k + count_k == + * range_k`. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If + * threadpool is NULL, all items are processed + * serially on the calling thread. + * @param function the function to call for each interval of the + * given range. + * @param context the first argument passed to the specified + * function. + * @param range_i the number of items on the first dimension of the + * 3D grid to process. + * @param range_j the number of items on the second dimension of + * the 3D grid to process. + * @param range_k the number of items on the third dimension of the + * 3D grid to process. + * @param tile_k the preferred multiple number of items on the + * third dimension of the 3D grid to process in each + * function call. + * @param flags a bitwise combination of zero or more optional + * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_3d_tile_1d_dynamic_with_thread( + pthreadpool_t threadpool, + pthreadpool_task_3d_tile_1d_dynamic_with_id_t function, void* context, + size_t range_i, size_t range_j, size_t range_k, size_t tile_k, + uint32_t flags); + +/** + * Process items on a 3D grid with the specified maximum tile size along the + * last two grid dimensions. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j += tile_j) + * for (size_t k = 0; k < range_k; k += tile_k) + * function(context, i, j, k, + * min(range_j - j, tile_j), min(range_k - k, tile_k)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 3D grid. + * @param range_j the number of items to process along the second dimension + * of the 3D grid. + * @param range_k the number of items to process along the third dimension + * of the 3D grid. + * @param tile_j the maximum number of items along the second dimension of + * the 3D grid to process in one function call. + * @param tile_k the maximum number of items along the third dimension of + * the 3D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_3d_tile_2d(pthreadpool_t threadpool, + pthreadpool_task_3d_tile_2d_t function, + void* context, size_t range_i, + size_t range_j, size_t range_k, + size_t tile_j, size_t tile_k, + uint32_t flags); + +/** + * Process items on a 3D grid with specified prefered tile size along the last + * two grid dimensions. + * + * The function repeatedly calls + * + * function(context, i, j, k, count_j, count_k) + * + * in parallel where: + * - `i` is in the range `[0, range_i)`, + * - `j` is in the range `[0, range_j)` and a multiple of the provided @a + * tile_j, + * - `k` is in the range `[0, range_k)` and a multiple of the provided @a + * tile_k, + * - `count_j` and `count_k` are integer multiples of @a tile__j and @a tile_k, + * unless `j + count_j == range_j` or `k + count_k == range_k`, respectivly. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling + * thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range_i the number of items on the first dimension of the 3D + * grid to process. + * @param range_j the number of items on the second dimension of the 3D + * grid to process. + * @param range_k the number of items on the third dimension of the 3D + * grid to process. + * @param tile_j the preferred multiple number of items on the second + * dimension of the 3D grid to process in each function call. + * @param tile_k the preferred multiple number of items on the third + * dimension of the 3D grid to process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_3d_tile_2d_dynamic( + pthreadpool_t threadpool, pthreadpool_task_3d_tile_2d_dynamic_t function, + void* context, size_t range_i, size_t range_j, size_t range_k, + size_t tile_j, size_t tile_k, uint32_t flags); + +/** + * Process items on a 3D grid with specified prefered tile size along the last + * two grid dimensions using a microarchitecture-aware task function. + * + * The function repeatedly calls + * + * function(context, uarch_index, i, j, k, count_j, count_k) + * + * in parallel where: + * - `i` is in the range `[0, range_i)`, + * - `j` is in the range `[0, range_j)` and a multiple of the provided @a + * tile_j, + * - `k` is in the range `[0, range_k)` and a multiple of the provided @a + * tile_k, + * - `count_j` and `count_k` are integer multiples of @a tile__j and @a tile_k, + * unless `j + count_j == range_j` or `k + count_k == range_k`, respectivly. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If + * threadpool is NULL, all items are processed + * serially on the calling thread. + * @param function the function to call for each interval of the + * given range. + * @param context the first argument passed to the specified + * function. + * @param default_uarch_index the microarchitecture index to use when + * pthreadpool is configured without cpuinfo, + * cpuinfo initialization failed, or index returned + * by cpuinfo_get_current_uarch_index() exceeds + * the max_uarch_index value. + * @param max_uarch_index the maximum microarchitecture index expected + * by the specified function. If the index returned + * by cpuinfo_get_current_uarch_index() exceeds this + * value, default_uarch_index will be used instead. + * default_uarch_index can exceed max_uarch_index. + * @param range_i the number of items on the first dimension of the + * 3D grid to process. + * @param range_j the number of items on the second dimension of + * the 3D grid to process. + * @param range_k the number of items on the third dimension of the + * 3D grid to process. + * @param tile_j the preferred multiple number of items on the + * second dimension of the 3D grid to process in + * each function call. + * @param tile_k the preferred multiple number of items on the + * third dimension of the 3D grid to process in each + * function call. + * @param flags a bitwise combination of zero or more optional + * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_3d_tile_2d_dynamic_with_uarch( + pthreadpool_t threadpool, + pthreadpool_task_3d_tile_2d_dynamic_with_id_t function, void* context, + uint32_t default_uarch_index, uint32_t max_uarch_index, size_t range_i, + size_t range_j, size_t range_k, size_t tile_j, size_t tile_k, + uint32_t flags); + +/** + * Process items on a 3D grid with specified prefered tile size along the last + * two grid dimensions passing along the thread ID. + * + * The function repeatedly calls + * + * function(context, thread_id, i, j, k, count_j, count_k) + * + * in parallel where: + * - `i` is in the range `[0, range_i)`, + * - `j` is in the range `[0, range_j)` and a multiple of the provided @a + * tile_j, + * - `k` is in the range `[0, range_k)` and a multiple of the provided @a + * tile_k, + * - `count_j` and `count_k` are integer multiples of @a tile__j and @a tile_k, + * unless `j + count_j == range_j` or `k + count_k == range_k`, respectivly. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If + * threadpool is NULL, all items are processed + * serially on the calling thread. + * @param function the function to call for each interval of the + * given range. + * @param context the first argument passed to the specified + * function. + * @param range_i the number of items on the first dimension of the + * 3D grid to process. + * @param range_j the number of items on the second dimension of + * the 3D grid to process. + * @param range_k the number of items on the third dimension of the + * 3D grid to process. + * @param tile_j the preferred multiple number of items on the + * second dimension of the 3D grid to process in + * each function call. + * @param tile_k the preferred multiple number of items on the + * third dimension of the 3D grid to process in each + * function call. + * @param flags a bitwise combination of zero or more optional + * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_3d_tile_2d_dynamic_with_thread( + pthreadpool_t threadpool, + pthreadpool_task_3d_tile_2d_dynamic_with_id_t function, void* context, + size_t range_i, size_t range_j, size_t range_k, size_t tile_j, + size_t tile_k, uint32_t flags); + +/** + * Process items on a 3D grid with the specified maximum tile size along the + * last two grid dimensions using a microarchitecture-aware task function. + * + * The function implements a parallel version of the following snippet: + * + * uint32_t uarch_index = cpuinfo_initialize() ? + * cpuinfo_get_current_uarch_index() : default_uarch_index; + * if (uarch_index > max_uarch_index) uarch_index = default_uarch_index; + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j += tile_j) + * for (size_t k = 0; k < range_k; k += tile_k) + * function(context, uarch_index, i, j, k, + * min(range_j - j, tile_j), min(range_k - k, tile_k)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If + * threadpool is NULL, all items are processed serially on the calling + * thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified + * function. + * @param default_uarch_index the microarchitecture index to use when + * pthreadpool is configured without cpuinfo, cpuinfo initialization failed, + * or index returned by cpuinfo_get_current_uarch_index() exceeds the + * max_uarch_index value. + * @param max_uarch_index the maximum microarchitecture index expected by + * the specified function. If the index returned by + * cpuinfo_get_current_uarch_index() exceeds this value, default_uarch_index + * will be used instead. default_uarch_index can exceed max_uarch_index. + * @param range_i the number of items to process along the first + * dimension of the 3D grid. + * @param range_j the number of items to process along the second + * dimension of the 3D grid. + * @param range_k the number of items to process along the third + * dimension of the 3D grid. + * @param tile_j the maximum number of items along the second + * dimension of the 3D grid to process in one function call. + * @param tile_k the maximum number of items along the third + * dimension of the 3D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional + * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_3d_tile_2d_with_uarch( + pthreadpool_t threadpool, pthreadpool_task_3d_tile_2d_with_id_t function, + void* context, uint32_t default_uarch_index, uint32_t max_uarch_index, + size_t range_i, size_t range_j, size_t range_k, size_t tile_j, + size_t tile_k, uint32_t flags); + +/** + * Process items on a 4D grid. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l++) + * function(context, i, j, k, l); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 4D grid. + * @param range_j the number of items to process along the second dimension + * of the 4D grid. + * @param range_k the number of items to process along the third dimension + * of the 4D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 4D grid. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_4d(pthreadpool_t threadpool, + pthreadpool_task_4d_t function, void* context, + size_t range_i, size_t range_j, size_t range_k, + size_t range_l, uint32_t flags); + +/** + * Process items on a 4D grid with the specified maximum tile size along the + * last grid dimension. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l += tile_l) + * function(context, i, j, k, l, min(range_l - l, tile_l)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 4D grid. + * @param range_j the number of items to process along the second dimension + * of the 4D grid. + * @param range_k the number of items to process along the third dimension + * of the 4D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 4D grid. + * @param tile_l the maximum number of items along the fourth dimension of + * the 4D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_4d_tile_1d(pthreadpool_t threadpool, + pthreadpool_task_4d_tile_1d_t function, + void* context, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t tile_l, + uint32_t flags); + +/** + * Process items on a 4D grid with the specified maximum tile size along the + * last two grid dimensions. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k += tile_k) + * for (size_t l = 0; l < range_l; l += tile_l) + * function(context, i, j, k, l, + * min(range_k - k, tile_k), min(range_l - l, tile_l)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 4D grid. + * @param range_j the number of items to process along the second dimension + * of the 4D grid. + * @param range_k the number of items to process along the third dimension + * of the 4D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 4D grid. + * @param tile_k the maximum number of items along the third dimension of + * the 4D grid to process in one function call. + * @param tile_l the maximum number of items along the fourth dimension of + * the 4D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_4d_tile_2d(pthreadpool_t threadpool, + pthreadpool_task_4d_tile_2d_t function, + void* context, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t tile_k, + size_t tile_l, uint32_t flags); + +/** + * Process items on a 4D grid with the specified maximum tile size along the + * last two grid dimensions using a microarchitecture-aware task function. + * + * The function implements a parallel version of the following snippet: + * + * uint32_t uarch_index = cpuinfo_initialize() ? + * cpuinfo_get_current_uarch_index() : default_uarch_index; + * if (uarch_index > max_uarch_index) uarch_index = default_uarch_index; + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k += tile_k) + * for (size_t l = 0; l < range_l; l += tile_l) + * function(context, uarch_index, i, j, k, l, + * min(range_k - k, tile_k), min(range_l - l, tile_l)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If + * threadpool is NULL, all items are processed serially on the calling + * thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified + * function. + * @param default_uarch_index the microarchitecture index to use when + * pthreadpool is configured without cpuinfo, cpuinfo initialization failed, + * or index returned by cpuinfo_get_current_uarch_index() exceeds the + * max_uarch_index value. + * @param max_uarch_index the maximum microarchitecture index expected by + * the specified function. If the index returned by + * cpuinfo_get_current_uarch_index() exceeds this value, default_uarch_index + * will be used instead. default_uarch_index can exceed max_uarch_index. + * @param range_i the number of items to process along the first + * dimension of the 4D grid. + * @param range_j the number of items to process along the second + * dimension of the 4D grid. + * @param range_k the number of items to process along the third + * dimension of the 4D grid. + * @param range_l the number of items to process along the fourth + * dimension of the 4D grid. + * @param tile_k the maximum number of items along the third + * dimension of the 4D grid to process in one function call. + * @param tile_l the maximum number of items along the fourth + * dimension of the 4D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional + * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_4d_tile_2d_with_uarch( + pthreadpool_t threadpool, pthreadpool_task_4d_tile_2d_with_id_t function, + void* context, uint32_t default_uarch_index, uint32_t max_uarch_index, + size_t range_i, size_t range_j, size_t range_k, size_t range_l, + size_t tile_k, size_t tile_l, uint32_t flags); + +/** + * Process items on a 4D grid with specified prefered tile size along the last + * two grid dimensions. + * + * The function repeatedly calls + * + * function(context, i, j, k, l, count_k, count_l) + * + * in parallel where: + * - `i` is in the range `[0, range_i)`, + * - `j` is in the range `[0, range_j)`, + * - `k` is in the range `[0, range_k)` and a multiple of the provided @a + * tile_k, + * - `l` is in the range `[0, range_l)` and a multiple of the provided @a + * tile_l, + * - `count_k` and `count_l` are integer multiples of @a tile_k and @a tile_l, + * unless `k + count_k == range_k` or `l + count_l == range_l`, respectivly. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling + * thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range_i the number of items on the first dimension of the 4D + * grid to process. + * @param range_j the number of items on the second dimension of the 4D + * grid to process. + * @param range_k the number of items on the third dimension of the 4D + * grid to process. + * @param range_l the number of items on the fourth dimension of the 4D + * grid to process. + * @param tile_k the preferred multiple number of items on the third + * dimension of the 4D grid to process in each function call. + * @param tile_l the preferred multiple number of items on the fourth + * dimension of the 4D grid to process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_4d_tile_2d_dynamic( + pthreadpool_t threadpool, pthreadpool_task_4d_tile_2d_dynamic_t function, + void* context, size_t range_i, size_t range_j, size_t range_k, + size_t range_l, size_t tile_k, size_t tile_l, uint32_t flags); + +/** + * Process items on a 4D grid with specified prefered tile size along the last + * two grid dimensions using a microarchitecture-aware task function. + * + * The function repeatedly calls + * + * function(context, uarch_index, i, j, k, l, count_k, count_l) + * + * in parallel where: + * - `i` is in the range `[0, range_i)`, + * - `j` is in the range `[0, range_j)`, + * - `k` is in the range `[0, range_k)` and a multiple of the provided @a + * tile_k, + * - `l` is in the range `[0, range_l)` and a multiple of the provided @a + * tile_l, + * - `count_k` and `count_l` are integer multiples of @a tile_k and @a tile_l, + * unless `k + count_k == range_k` or `l + count_l == range_l`, respectivly. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If + * threadpool is NULL, all items are processed + * serially on the calling thread. + * @param function the function to call for each interval of the + * given range. + * @param context the first argument passed to the specified + * function. + * @param default_uarch_index the microarchitecture index to use when + * pthreadpool is configured without cpuinfo, + * cpuinfo initialization failed, or index returned + * by cpuinfo_get_current_uarch_index() exceeds + * the max_uarch_index value. + * @param max_uarch_index the maximum microarchitecture index expected + * by the specified function. If the index returned + * by cpuinfo_get_current_uarch_index() exceeds this + * value, default_uarch_index will be used instead. + * default_uarch_index can exceed max_uarch_index. + * @param range_i the number of items on the first dimension of the + * 4D grid to process. + * @param range_j the number of items on the second dimension of + * the 4D grid to process. + * @param range_k the number of items on the third dimension of the + * 4D grid to process. + * @param range_l the number of items on the fourth dimension of + * the 4D grid to process. + * @param tile_k the preferred multiple number of items on the + * third dimension of the 4D grid to process in each + * function call. + * @param tile_l the preferred multiple number of items on the + * fourth dimension of the 4D grid to process in + * each function call. + * @param flags a bitwise combination of zero or more optional + * flags (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_4d_tile_2d_dynamic_with_uarch( + pthreadpool_t threadpool, + pthreadpool_task_4d_tile_2d_dynamic_with_id_t function, void* context, + uint32_t default_uarch_index, uint32_t max_uarch_index, size_t range_i, + size_t range_j, size_t range_k, size_t range_l, size_t tile_k, + size_t tile_l, uint32_t flags); + +/** + * Process items on a 5D grid. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l++) + * for (size_t m = 0; m < range_m; m++) + * function(context, i, j, k, l, m); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 5D grid. + * @param range_j the number of items to process along the second dimension + * of the 5D grid. + * @param range_k the number of items to process along the third dimension + * of the 5D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 5D grid. + * @param range_m the number of items to process along the fifth dimension + * of the 5D grid. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_5d(pthreadpool_t threadpool, + pthreadpool_task_5d_t function, void* context, + size_t range_i, size_t range_j, size_t range_k, + size_t range_l, size_t range_m, uint32_t flags); + +/** + * Process items on a 5D grid with the specified maximum tile size along the + * last grid dimension. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l++) + * for (size_t m = 0; m < range_m; m += tile_m) + * function(context, i, j, k, l, m, min(range_m - m, tile_m)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 5D grid. + * @param range_j the number of items to process along the second dimension + * of the 5D grid. + * @param range_k the number of items to process along the third dimension + * of the 5D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 5D grid. + * @param range_m the number of items to process along the fifth dimension + * of the 5D grid. + * @param tile_m the maximum number of items along the fifth dimension of + * the 5D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_5d_tile_1d(pthreadpool_t threadpool, + pthreadpool_task_5d_tile_1d_t function, + void* context, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t range_m, + size_t tile_m, uint32_t flags); + +/** + * Process items on a 5D grid with the specified maximum tile size along the + * last two grid dimensions. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l += tile_l) + * for (size_t m = 0; m < range_m; m += tile_m) + * function(context, i, j, k, l, m, + * min(range_l - l, tile_l), min(range_m - m, tile_m)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 5D grid. + * @param range_j the number of items to process along the second dimension + * of the 5D grid. + * @param range_k the number of items to process along the third dimension + * of the 5D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 5D grid. + * @param range_m the number of items to process along the fifth dimension + * of the 5D grid. + * @param tile_l the maximum number of items along the fourth dimension of + * the 5D grid to process in one function call. + * @param tile_m the maximum number of items along the fifth dimension of + * the 5D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_5d_tile_2d(pthreadpool_t threadpool, + pthreadpool_task_5d_tile_2d_t function, + void* context, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t range_m, + size_t tile_l, size_t tile_m, + uint32_t flags); + +/** + * Process items on a 6D grid. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l++) + * for (size_t m = 0; m < range_m; m++) + * for (size_t n = 0; n < range_n; n++) + * function(context, i, j, k, l, m, n); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 6D grid. + * @param range_j the number of items to process along the second dimension + * of the 6D grid. + * @param range_k the number of items to process along the third dimension + * of the 6D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 6D grid. + * @param range_m the number of items to process along the fifth dimension + * of the 6D grid. + * @param range_n the number of items to process along the sixth dimension + * of the 6D grid. + * @param tile_n the maximum number of items along the sixth dimension of + * the 6D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_6d(pthreadpool_t threadpool, + pthreadpool_task_6d_t function, void* context, + size_t range_i, size_t range_j, size_t range_k, + size_t range_l, size_t range_m, size_t range_n, + uint32_t flags); + +/** + * Process items on a 6D grid with the specified maximum tile size along the + * last grid dimension. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l++) + * for (size_t m = 0; m < range_m; m++) + * for (size_t n = 0; n < range_n; n += tile_n) + * function(context, i, j, k, l, m, n, min(range_n - n, tile_n)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 6D grid. + * @param range_j the number of items to process along the second dimension + * of the 6D grid. + * @param range_k the number of items to process along the third dimension + * of the 6D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 6D grid. + * @param range_m the number of items to process along the fifth dimension + * of the 6D grid. + * @param range_n the number of items to process along the sixth dimension + * of the 6D grid. + * @param tile_n the maximum number of items along the sixth dimension of + * the 6D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_6d_tile_1d(pthreadpool_t threadpool, + pthreadpool_task_6d_tile_1d_t function, + void* context, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t range_m, + size_t range_n, size_t tile_n, + uint32_t flags); + +/** + * Process items on a 6D grid with the specified maximum tile size along the + * last two grid dimensions. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l++) + * for (size_t m = 0; m < range_m; m += tile_m) + * for (size_t n = 0; n < range_n; n += tile_n) + * function(context, i, j, k, l, m, n, + * min(range_m - m, tile_m), min(range_n - n, tile_n)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each tile. + * @param context the first argument passed to the specified function. + * @param range_i the number of items to process along the first dimension + * of the 6D grid. + * @param range_j the number of items to process along the second dimension + * of the 6D grid. + * @param range_k the number of items to process along the third dimension + * of the 6D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 6D grid. + * @param range_m the number of items to process along the fifth dimension + * of the 6D grid. + * @param range_n the number of items to process along the sixth dimension + * of the 6D grid. + * @param tile_m the maximum number of items along the fifth dimension of + * the 6D grid to process in one function call. + * @param tile_n the maximum number of items along the sixth dimension of + * the 6D grid to process in one function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +void pthreadpool_parallelize_6d_tile_2d(pthreadpool_t threadpool, + pthreadpool_task_6d_tile_2d_t function, + void* context, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t range_m, + size_t range_n, size_t tile_m, + size_t tile_n, uint32_t flags); + +/** + * Terminates threads in the thread pool and releases associated resources. + * + * @warning Accessing the thread pool after a call to this function constitutes + * undefined behaviour and may cause data corruption. + * + * @param[in,out] threadpool The thread pool to destroy. + */ +void pthreadpool_destroy(pthreadpool_t threadpool); + +#ifndef PTHREADPOOL_NO_DEPRECATED_API + +/* Legacy API for compatibility with pre-existing users (e.g. NNPACK) */ +#if defined(__GNUC__) +#define PTHREADPOOL_DEPRECATED __attribute__((__deprecated__)) +#else +#define PTHREADPOOL_DEPRECATED +#endif + +typedef void (*pthreadpool_function_1d_t)(void*, size_t); +typedef void (*pthreadpool_function_1d_tiled_t)(void*, size_t, size_t); +typedef void (*pthreadpool_function_2d_t)(void*, size_t, size_t); +typedef void (*pthreadpool_function_2d_tiled_t)(void*, size_t, size_t, size_t, + size_t); +typedef void (*pthreadpool_function_3d_tiled_t)(void*, size_t, size_t, size_t, + size_t, size_t, size_t); +typedef void (*pthreadpool_function_4d_tiled_t)(void*, size_t, size_t, size_t, + size_t, size_t, size_t, size_t, + size_t); + +void pthreadpool_compute_1d(pthreadpool_t threadpool, + pthreadpool_function_1d_t function, void* argument, + size_t range) PTHREADPOOL_DEPRECATED; + +void pthreadpool_compute_1d_tiled(pthreadpool_t threadpool, + pthreadpool_function_1d_tiled_t function, + void* argument, size_t range, + size_t tile) PTHREADPOOL_DEPRECATED; + +void pthreadpool_compute_2d(pthreadpool_t threadpool, + pthreadpool_function_2d_t function, void* argument, + size_t range_i, + size_t range_j) PTHREADPOOL_DEPRECATED; + +void pthreadpool_compute_2d_tiled(pthreadpool_t threadpool, + pthreadpool_function_2d_tiled_t function, + void* argument, size_t range_i, + size_t range_j, size_t tile_i, + size_t tile_j) PTHREADPOOL_DEPRECATED; + +void pthreadpool_compute_3d_tiled(pthreadpool_t threadpool, + pthreadpool_function_3d_tiled_t function, + void* argument, size_t range_i, + size_t range_j, size_t range_k, size_t tile_i, + size_t tile_j, + size_t tile_k) PTHREADPOOL_DEPRECATED; + +void pthreadpool_compute_4d_tiled(pthreadpool_t threadpool, + pthreadpool_function_4d_tiled_t function, + void* argument, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t tile_i, size_t tile_j, + size_t tile_k, + size_t tile_l) PTHREADPOOL_DEPRECATED; + +#endif /* PTHREADPOOL_NO_DEPRECATED_API */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#ifdef __cplusplus + +namespace libpthreadpool { +namespace detail { +namespace { // NOLINT: Naming this namespace would expose it. + +template +void call_wrapper_1d(void* arg, size_t i) { + (*static_cast(arg))(i); +} + +template +void call_wrapper_1d_tile_1d(void* arg, size_t range_i, size_t tile_i) { + (*static_cast(arg))(range_i, tile_i); +} + +template +void call_wrapper_1d_tile_1d_dynamic(void* arg, size_t range_i, size_t tile_i) { + (*static_cast(arg))(range_i, tile_i); +} + +template +void call_wrapper_2d(void* functor, size_t i, size_t j) { + (*static_cast(functor))(i, j); +} + +template +void call_wrapper_2d_tile_1d(void* functor, size_t i, size_t range_j, + size_t tile_j) { + (*static_cast(functor))(i, range_j, tile_j); +} + +template +void call_wrapper_2d_tile_1d_dynamic(void* functor, size_t i, size_t range_j, + size_t tile_j) { + (*static_cast(functor))(i, range_j, tile_j); +} + +template +void call_wrapper_2d_tile_2d(void* functor, size_t range_i, size_t range_j, + size_t tile_i, size_t tile_j) { + (*static_cast(functor))(range_i, range_j, tile_i, tile_j); +} + +template +void call_wrapper_2d_tile_2d_dynamic(void* functor, size_t range_i, + size_t range_j, size_t tile_i, + size_t tile_j) { + (*static_cast(functor))(range_i, range_j, tile_i, tile_j); +} + +template +void call_wrapper_3d(void* functor, size_t i, size_t j, size_t k) { + (*static_cast(functor))(i, j, k); +} + +template +void call_wrapper_3d_tile_1d(void* functor, size_t i, size_t j, size_t range_k, + size_t tile_k) { + (*static_cast(functor))(i, j, range_k, tile_k); +} + +template +void call_wrapper_3d_tile_2d(void* functor, size_t i, size_t range_j, + size_t range_k, size_t tile_j, size_t tile_k) { + (*static_cast(functor))(i, range_j, range_k, tile_j, tile_k); +} + +template +void call_wrapper_3d_tile_2d_dynamic(void* functor, size_t i, size_t range_j, + size_t range_k, size_t tile_j, + size_t tile_k) { + (*static_cast(functor))(i, range_j, range_k, tile_j, tile_k); +} + +template +void call_wrapper_4d(void* functor, size_t i, size_t j, size_t k, size_t l) { + (*static_cast(functor))(i, j, k, l); +} + +template +void call_wrapper_4d_tile_1d(void* functor, size_t i, size_t j, size_t k, + size_t range_l, size_t tile_l) { + (*static_cast(functor))(i, j, k, range_l, tile_l); +} + +template +void call_wrapper_4d_tile_2d(void* functor, size_t i, size_t j, size_t range_k, + size_t range_l, size_t tile_k, size_t tile_l) { + (*static_cast(functor))(i, j, range_k, range_l, tile_k, tile_l); +} + +template +void call_wrapper_4d_tile_2d_dynamic(void* functor, size_t i, size_t j, + size_t range_k, size_t range_l, + size_t tile_k, size_t tile_l) { + (*static_cast(functor))(i, j, range_k, range_l, tile_k, tile_l); +} + +template +void call_wrapper_5d(void* functor, size_t i, size_t j, size_t k, size_t l, + size_t m) { + (*static_cast(functor))(i, j, k, l, m); +} + +template +void call_wrapper_5d_tile_1d(void* functor, size_t i, size_t j, size_t k, + size_t l, size_t range_m, size_t tile_m) { + (*static_cast(functor))(i, j, k, l, range_m, tile_m); +} + +template +void call_wrapper_5d_tile_2d(void* functor, size_t i, size_t j, size_t k, + size_t range_l, size_t range_m, size_t tile_l, + size_t tile_m) { + (*static_cast(functor))(i, j, k, range_l, range_m, tile_l, tile_m); +} + +template +void call_wrapper_6d(void* functor, size_t i, size_t j, size_t k, size_t l, + size_t m, size_t n) { + (*static_cast(functor))(i, j, k, l, m, n); +} + +template +void call_wrapper_6d_tile_1d(void* functor, size_t i, size_t j, size_t k, + size_t l, size_t m, size_t range_n, + size_t tile_n) { + (*static_cast(functor))(i, j, k, l, m, range_n, tile_n); +} + +template +void call_wrapper_6d_tile_2d(void* functor, size_t i, size_t j, size_t k, + size_t l, size_t range_m, size_t range_n, + size_t tile_m, size_t tile_n) { + (*static_cast(functor))(i, j, k, l, range_m, range_n, tile_m, + tile_n); +} + +} /* namespace */ +} /* namespace detail */ +} /* namespace libpthreadpool */ + +/** + * Process items on a 1D grid. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range; i++) + * functor(i); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each item. + * @param range the number of items on the 1D grid to process. The + * specified functor will be called once for each item. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_1d(pthreadpool_t threadpool, + const T& functor, size_t range, + uint32_t flags = 0) { + pthreadpool_parallelize_1d( + threadpool, &libpthreadpool::detail::call_wrapper_1d, + const_cast(static_cast(&functor)), range, flags); +} + +/** + * Process items on a 1D grid with specified maximum tile size. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range; i += tile) + * functor(i, min(range - i, tile)); + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range the number of items on the 1D grid to process. + * @param tile the maximum number of items on the 1D grid to process in + * one functor call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_1d_tile_1d(pthreadpool_t threadpool, + const T& functor, size_t range, + size_t tile, + uint32_t flags = 0) { + pthreadpool_parallelize_1d_tile_1d( + threadpool, &libpthreadpool::detail::call_wrapper_1d_tile_1d, + const_cast(static_cast(&functor)), range, tile, + flags); +} + +/** + * Process items on a 1D grid with specified prefered tile size. + * + * The function repeatedly calls + * + * function(context, i, count) + * + * in parallel where `i` is in the range `[0, range)` and a multiple of the + * provided @a tile and `count` is an integer multiple of @a tile unless `i + * + count == range`. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range the number of items on the 1D grid to process. + * @param tile the preferred multiple number of items on the 1D grid to + * process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_1d_tile_1d_dynamic(pthreadpool_t threadpool, + const T& functor, + size_t range, + size_t tile, + uint32_t flags = 0) { + pthreadpool_parallelize_1d_tile_1d_dynamic( + threadpool, + &libpthreadpool::detail::call_wrapper_1d_tile_1d_dynamic, + const_cast(static_cast(&functor)), range, tile, + flags); +} + +/** + * Process items on a 2D grid. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * functor(i, j); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each item. + * @param range_i the number of items to process along the first dimension + * of the 2D grid. + * @param range_j the number of items to process along the second dimension + * of the 2D grid. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_2d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, uint32_t flags = 0) { + pthreadpool_parallelize_2d( + threadpool, &libpthreadpool::detail::call_wrapper_2d, + const_cast(static_cast(&functor)), range_i, range_j, + flags); +} + +/** + * Process items on a 2D grid with the specified maximum tile size along the + * last grid dimension. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j += tile_j) + * functor(i, j, min(range_j - j, tile_j)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 2D grid. + * @param range_j the number of items to process along the second dimension + * of the 2D grid. + * @param tile_j the maximum number of items along the second dimension of + * the 2D grid to process in one functor call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_2d_tile_1d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, size_t tile_j, + uint32_t flags = 0) { + pthreadpool_parallelize_2d_tile_1d( + threadpool, &libpthreadpool::detail::call_wrapper_2d_tile_1d, + const_cast(static_cast(&functor)), range_i, range_j, + tile_j, flags); +} + +/** + * Process items on a 2D grid with specified prefered tile size along the + * last grid dimension. + * + * The function repeatedly calls + * + * function(context, i, j, count_j) + * + * in parallel where `i` is in the range `[0, range_i)`, `j` is in the range + * `[0, range_j)` and a multiple of the provided @a tile_j, and `count_j` is an + * integer multiple of @a tile_j unless `j + count_j == range_j`. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range_i the number of items on the first dimension of the 2D + * grid to process. + * @param range_j the number of items on the second dimension of the 2D + * grid to process. + * @param tile_j the preferred multiple number of items on the second + * dimension of the 2D grid to process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_2d_tile_1d_dynamic( + pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, + size_t tile_j, uint32_t flags = 0) { + pthreadpool_parallelize_2d_tile_1d_dynamic( + threadpool, + &libpthreadpool::detail::call_wrapper_2d_tile_1d_dynamic, + const_cast(static_cast(&functor)), range_i, range_j, + tile_j, flags); +} + +/** + * Process items on a 2D grid with the specified maximum tile size along each + * grid dimension. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i += tile_i) + * for (size_t j = 0; j < range_j; j += tile_j) + * functor(i, j, + * min(range_i - i, tile_i), min(range_j - j, tile_j)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 2D grid. + * @param range_j the number of items to process along the second dimension + * of the 2D grid. + * @param tile_j the maximum number of items along the first dimension of + * the 2D grid to process in one functor call. + * @param tile_j the maximum number of items along the second dimension of + * the 2D grid to process in one functor call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_2d_tile_2d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, size_t tile_i, + size_t tile_j, + uint32_t flags = 0) { + pthreadpool_parallelize_2d_tile_2d( + threadpool, &libpthreadpool::detail::call_wrapper_2d_tile_2d, + const_cast(static_cast(&functor)), range_i, range_j, + tile_i, tile_j, flags); +} + +/** + * Process items on a 2D grid with specified prefered tile size along each grid + * dimension. + * + * The function repeatedly calls + * + * function(context, i, j, count_i, count_j) + * + * in parallel where `i` is in the range `[0, range_i)` and a multiple of the + * provided @a tile_i, `j` is in the range `[0, range_j)` and a multiple of the + * provided @a tile_j, and `count_i` and `count_j` are integer multiples of @a + * tile__i and @a tile_j, unless `i + count_i == range_i` or `j + count_j == + * range_j`, respectivly. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range_i the number of items on the first dimension of the 2D + * grid to process. + * @param range_j the number of items on the second dimension of the 2D + * grid to process. + * @param tile_i the preferred multiple number of items on the first + * dimension of the 2D grid to process in each function call. + * @param tile_j the preferred multiple number of items on the second + * dimension of the 2D grid to process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_2d_tile_2d_dynamic( + pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, + size_t tile_i, size_t tile_j, uint32_t flags = 0) { + pthreadpool_parallelize_2d_tile_2d_dynamic( + threadpool, + &libpthreadpool::detail::call_wrapper_2d_tile_2d_dynamic, + const_cast(static_cast(&functor)), range_i, range_j, + tile_i, tile_j, flags); +} + +/** + * Process items on a 3D grid. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * functor(i, j, k); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 3D grid. + * @param range_j the number of items to process along the second dimension + * of the 3D grid. + * @param range_k the number of items to process along the third dimension + * of the 3D grid. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_3d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, size_t range_k, + uint32_t flags = 0) { + pthreadpool_parallelize_3d( + threadpool, &libpthreadpool::detail::call_wrapper_3d, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, flags); +} + +/** + * Process items on a 3D grid with the specified maximum tile size along the + * last grid dimension. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k += tile_k) + * functor(i, j, k, min(range_k - k, tile_k)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 3D grid. + * @param range_j the number of items to process along the second dimension + * of the 3D grid. + * @param range_k the number of items to process along the third dimension + * of the 3D grid. + * @param tile_k the maximum number of items along the third dimension of + * the 3D grid to process in one functor call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_3d_tile_1d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, size_t range_k, + size_t tile_k, + uint32_t flags = 0) { + pthreadpool_parallelize_3d_tile_1d( + threadpool, &libpthreadpool::detail::call_wrapper_3d_tile_1d, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, tile_k, flags); +} + +/** + * Process items on a 3D grid with the specified maximum tile size along the + * last two grid dimensions. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j += tile_j) + * for (size_t k = 0; k < range_k; k += tile_k) + * functor(i, j, k, + * min(range_j - j, tile_j), min(range_k - k, tile_k)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 3D grid. + * @param range_j the number of items to process along the second dimension + * of the 3D grid. + * @param range_k the number of items to process along the third dimension + * of the 3D grid. + * @param tile_j the maximum number of items along the second dimension of + * the 3D grid to process in one functor call. + * @param tile_k the maximum number of items along the third dimension of + * the 3D grid to process in one functor call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_3d_tile_2d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, size_t range_k, + size_t tile_j, size_t tile_k, + uint32_t flags = 0) { + pthreadpool_parallelize_3d_tile_2d( + threadpool, &libpthreadpool::detail::call_wrapper_3d_tile_2d, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, tile_j, tile_k, flags); +} + +/** + * Process items on a 3D grid with specified prefered tile size along the last + * two grid dimensions. + * + * The function repeatedly calls + * + * function(context, i, j, k, count_j, count_k) + * + * in parallel where: + * - `i` is in the range `[0, range_i)`, + * - `j` is in the range `[0, range_j)` and a multiple of the provided @a + * tile_j, + * - `k` is in the range `[0, range_k)` and a multiple of the provided @a + * tile_k, + * - `count_j` and `count_k` are integer multiples of @a tile__j and @a tile_k, + * unless `j + count_j == range_j` or `k + count_k == range_k`, respectivly. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range_i the number of items on the first dimension of the 3D + * grid to process. + * @param range_j the number of items on the second dimension of the 3D + * grid to process. + * @param range_k the number of items on the third dimension of the 3D + * grid to process. + * @param tile_j the preferred multiple number of items on the second + * dimension of the 3D grid to process in each function call. + * @param tile_k the preferred multiple number of items on the third + * dimension of the 3D grid to process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_3d_tile_2d_dynamic( + pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, + size_t range_k, size_t tile_j, size_t tile_k, uint32_t flags = 0) { + pthreadpool_parallelize_3d_tile_2d_dynamic( + threadpool, + &libpthreadpool::detail::call_wrapper_3d_tile_2d_dynamic, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, tile_j, tile_k, flags); +} + +/** + * Process items on a 4D grid. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l++) + * functor(i, j, k, l); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 4D grid. + * @param range_j the number of items to process along the second dimension + * of the 4D grid. + * @param range_k the number of items to process along the third dimension + * of the 4D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 4D grid. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_4d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, uint32_t flags = 0) { + pthreadpool_parallelize_4d( + threadpool, &libpthreadpool::detail::call_wrapper_4d, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, range_l, flags); +} + +/** + * Process items on a 4D grid with the specified maximum tile size along the + * last grid dimension. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l += tile_l) + * functor(i, j, k, l, min(range_l - l, tile_l)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 4D grid. + * @param range_j the number of items to process along the second dimension + * of the 4D grid. + * @param range_k the number of items to process along the third dimension + * of the 4D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 4D grid. + * @param tile_l the maximum number of items along the fourth dimension of + * the 4D grid to process in one functor call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_4d_tile_1d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t tile_l, + uint32_t flags = 0) { + pthreadpool_parallelize_4d_tile_1d( + threadpool, &libpthreadpool::detail::call_wrapper_4d_tile_1d, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, range_l, tile_l, flags); +} + +/** + * Process items on a 4D grid with the specified maximum tile size along the + * last two grid dimensions. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k += tile_k) + * for (size_t l = 0; l < range_l; l += tile_l) + * functor(i, j, k, l, + * min(range_k - k, tile_k), min(range_l - l, tile_l)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 4D grid. + * @param range_j the number of items to process along the second dimension + * of the 4D grid. + * @param range_k the number of items to process along the third dimension + * of the 4D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 4D grid. + * @param tile_k the maximum number of items along the third dimension of + * the 4D grid to process in one functor call. + * @param tile_l the maximum number of items along the fourth dimension of + * the 4D grid to process in one functor call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_4d_tile_2d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t tile_k, + size_t tile_l, + uint32_t flags = 0) { + pthreadpool_parallelize_4d_tile_2d( + threadpool, &libpthreadpool::detail::call_wrapper_4d_tile_2d, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, range_l, tile_k, tile_l, flags); +} + +/** + * Process items on a 4D grid with specified prefered tile size along the last + * two grid dimensions. + * + * The function repeatedly calls + * + * function(context, i, j, k, l, count_k, count_l) + * + * in parallel where: + * - `i` is in the range `[0, range_i)`, + * - `j` is in the range `[0, range_j)`, + * - `k` is in the range `[0, range_k)` and a multiple of the provided @a + * tile_k, + * - `l` is in the range `[0, range_l)` and a multiple of the provided @a + * tile_l, + * - `count_k` and `count_l` are integer multiples of @a tile_k and @a tile_l, + * unless `k + count_k == range_k` or `l + count_l == range_l`, respectivly. + * + * The `count`s are chosen such as to minimize the number of calls to @a + * function while keeping the computation load balanced across all threads. + * + * When the call returns, all items have been processed and the thread pool is + * ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, + * the calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling + * thread. + * @param function the function to call for each interval of the given range. + * @param context the first argument passed to the specified function. + * @param range_i the number of items on the first dimension of the 4D + * grid to process. + * @param range_j the number of items on the second dimension of the 4D + * grid to process. + * @param range_k the number of items on the third dimension of the 4D + * grid to process. + * @param range_l the number of items on the fourth dimension of the 4D + * grid to process. + * @param tile_k the preferred multiple number of items on the third + * dimension of the 4D grid to process in each function call. + * @param tile_l the preferred multiple number of items on the fourth + * dimension of the 4D grid to process in each function call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or + * PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_4d_tile_2d_dynamic( + pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, + size_t range_k, size_t range_l, size_t tile_k, size_t tile_l, + uint32_t flags = 0) { + pthreadpool_parallelize_3d_tile_2d_dynamic( + threadpool, + &libpthreadpool::detail::call_wrapper_4d_tile_2d_dynamic, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, range_l, tile_k, tile_l, flags); +} + +/** + * Process items on a 5D grid. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l++) + * for (size_t m = 0; m < range_m; m++) + * functor(i, j, k, l, m); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 5D grid. + * @param range_j the number of items to process along the second dimension + * of the 5D grid. + * @param range_k the number of items to process along the third dimension + * of the 5D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 5D grid. + * @param range_m the number of items to process along the fifth dimension + * of the 5D grid. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_5d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t range_m, + uint32_t flags = 0) { + pthreadpool_parallelize_5d( + threadpool, &libpthreadpool::detail::call_wrapper_5d, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, range_l, range_m, flags); +} + +/** + * Process items on a 5D grid with the specified maximum tile size along the + * last grid dimension. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l++) + * for (size_t m = 0; m < range_m; m += tile_m) + * functor(i, j, k, l, m, min(range_m - m, tile_m)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 5D grid. + * @param range_j the number of items to process along the second dimension + * of the 5D grid. + * @param range_k the number of items to process along the third dimension + * of the 5D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 5D grid. + * @param range_m the number of items to process along the fifth dimension + * of the 5D grid. + * @param tile_m the maximum number of items along the fifth dimension of + * the 5D grid to process in one functor call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_5d_tile_1d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t range_m, + size_t tile_m, + uint32_t flags = 0) { + pthreadpool_parallelize_5d_tile_1d( + threadpool, &libpthreadpool::detail::call_wrapper_5d_tile_1d, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, range_l, range_m, tile_m, flags); +} + +/** + * Process items on a 5D grid with the specified maximum tile size along the + * last two grid dimensions. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l += tile_l) + * for (size_t m = 0; m < range_m; m += tile_m) + * functor(i, j, k, l, m, + * min(range_l - l, tile_l), min(range_m - m, tile_m)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 5D grid. + * @param range_j the number of items to process along the second dimension + * of the 5D grid. + * @param range_k the number of items to process along the third dimension + * of the 5D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 5D grid. + * @param range_m the number of items to process along the fifth dimension + * of the 5D grid. + * @param tile_l the maximum number of items along the fourth dimension of + * the 5D grid to process in one functor call. + * @param tile_m the maximum number of items along the fifth dimension of + * the 5D grid to process in one functor call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_5d_tile_2d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t range_m, + size_t tile_l, size_t tile_m, + uint32_t flags = 0) { + pthreadpool_parallelize_5d_tile_2d( + threadpool, &libpthreadpool::detail::call_wrapper_5d_tile_2d, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, range_l, range_m, tile_l, tile_m, flags); +} + +/** + * Process items on a 6D grid. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l++) + * for (size_t m = 0; m < range_m; m++) + * for (size_t n = 0; n < range_n; n++) + * functor(i, j, k, l, m, n); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 6D grid. + * @param range_j the number of items to process along the second dimension + * of the 6D grid. + * @param range_k the number of items to process along the third dimension + * of the 6D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 6D grid. + * @param range_m the number of items to process along the fifth dimension + * of the 6D grid. + * @param range_n the number of items to process along the sixth dimension + * of the 6D grid. + * @param tile_n the maximum number of items along the sixth dimension of + * the 6D grid to process in one functor call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_6d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t range_m, + size_t range_n, uint32_t flags = 0) { + pthreadpool_parallelize_6d( + threadpool, &libpthreadpool::detail::call_wrapper_6d, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, range_l, range_m, range_n, flags); +} + +/** + * Process items on a 6D grid with the specified maximum tile size along the + * last grid dimension. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l++) + * for (size_t m = 0; m < range_m; m++) + * for (size_t n = 0; n < range_n; n += tile_n) + * functor(i, j, k, l, m, n, min(range_n - n, tile_n)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 6D grid. + * @param range_j the number of items to process along the second dimension + * of the 6D grid. + * @param range_k the number of items to process along the third dimension + * of the 6D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 6D grid. + * @param range_m the number of items to process along the fifth dimension + * of the 6D grid. + * @param range_n the number of items to process along the sixth dimension + * of the 6D grid. + * @param tile_n the maximum number of items along the sixth dimension of + * the 6D grid to process in one functor call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_6d_tile_1d(pthreadpool_t threadpool, + const T& functor, size_t range_i, + size_t range_j, size_t range_k, + size_t range_l, size_t range_m, + size_t range_n, size_t tile_n, + uint32_t flags = 0) { + pthreadpool_parallelize_6d_tile_1d( + threadpool, &libpthreadpool::detail::call_wrapper_6d_tile_1d, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, range_l, range_m, range_n, tile_n, flags); +} + +/** + * Process items on a 6D grid with the specified maximum tile size along the + * last two grid dimensions. + * + * The function implements a parallel version of the following snippet: + * + * for (size_t i = 0; i < range_i; i++) + * for (size_t j = 0; j < range_j; j++) + * for (size_t k = 0; k < range_k; k++) + * for (size_t l = 0; l < range_l; l++) + * for (size_t m = 0; m < range_m; m += tile_m) + * for (size_t n = 0; n < range_n; n += tile_n) + * functor(i, j, k, l, m, n, + * min(range_m - m, tile_m), min(range_n - n, tile_n)); + * + * When the function returns, all items have been processed and the thread pool + * is ready for a new task. + * + * @note If multiple threads call this function with the same thread pool, the + * calls are serialized. + * + * @param threadpool the thread pool to use for parallelisation. If threadpool + * is NULL, all items are processed serially on the calling thread. + * @param functor the functor to call for each tile. + * @param range_i the number of items to process along the first dimension + * of the 6D grid. + * @param range_j the number of items to process along the second dimension + * of the 6D grid. + * @param range_k the number of items to process along the third dimension + * of the 6D grid. + * @param range_l the number of items to process along the fourth dimension + * of the 6D grid. + * @param range_m the number of items to process along the fifth dimension + * of the 6D grid. + * @param range_n the number of items to process along the sixth dimension + * of the 6D grid. + * @param tile_m the maximum number of items along the fifth dimension of + * the 6D grid to process in one functor call. + * @param tile_n the maximum number of items along the sixth dimension of + * the 6D grid to process in one functor call. + * @param flags a bitwise combination of zero or more optional flags + * (PTHREADPOOL_FLAG_DISABLE_DENORMALS or PTHREADPOOL_FLAG_YIELD_WORKERS) + */ +template +inline void pthreadpool_parallelize_6d_tile_2d( + pthreadpool_t threadpool, const T& functor, size_t range_i, size_t range_j, + size_t range_k, size_t range_l, size_t range_m, size_t range_n, + size_t tile_m, size_t tile_n, uint32_t flags = 0) { + pthreadpool_parallelize_6d_tile_2d( + threadpool, &libpthreadpool::detail::call_wrapper_6d_tile_2d, + const_cast(static_cast(&functor)), range_i, range_j, + range_k, range_l, range_m, range_n, tile_m, tile_n, flags); +} + +#endif /* __cplusplus */ + +#endif /* __PTHREADPOOL_INCLUDE_PTHREADPOOL_H_ */ diff --git a/deps/exla/cache/xla_extension/include/external/snappy/config.h b/deps/exla/cache/xla_extension/include/external/snappy/config.h new file mode 100644 index 0000000000000000000000000000000000000000..cb53918d86d9256e482e5999121eec757941c6c6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/snappy/config.h @@ -0,0 +1,44 @@ +#define HAVE_STDDEF_H 1 +#define HAVE_STDINT_H 1 + +#ifdef __has_builtin +# if !defined(HAVE_BUILTIN_EXPECT) && __has_builtin(__builtin_expect) +# define HAVE_BUILTIN_EXPECT 1 +# endif +# if !defined(HAVE_BUILTIN_CTZ) && __has_builtin(__builtin_ctzll) +# define HAVE_BUILTIN_CTZ 1 +# endif +#elif defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef HAVE_BUILTIN_EXPECT +# define HAVE_BUILTIN_EXPECT 1 +# endif +# ifndef HAVE_BUILTIN_CTZ +# define HAVE_BUILTIN_CTZ 1 +# endif +#endif + +#ifdef __has_include +# if !defined(HAVE_BYTESWAP_H) && __has_include() +# define HAVE_BYTESWAP_H 1 +# endif +# if !defined(HAVE_UNISTD_H) && __has_include() +# define HAVE_UNISTD_H 1 +# endif +# if !defined(HAVE_SYS_ENDIAN_H) && __has_include() +# define HAVE_SYS_ENDIAN_H 1 +# endif +# if !defined(HAVE_SYS_MMAN_H) && __has_include() +# define HAVE_SYS_MMAN_H 1 +# endif +# if !defined(HAVE_SYS_UIO_H) && __has_include() +# define HAVE_SYS_UIO_H 1 +# endif +#endif + +#ifndef SNAPPY_IS_BIG_ENDIAN +# ifdef __s390x__ +# define SNAPPY_IS_BIG_ENDIAN 1 +# elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +# define SNAPPY_IS_BIG_ENDIAN 1 +# endif +#endif diff --git a/deps/exla/cache/xla_extension/include/external/snappy/snappy-internal.h b/deps/exla/cache/xla_extension/include/external/snappy/snappy-internal.h new file mode 100644 index 0000000000000000000000000000000000000000..e552ea0b492b66f0c0c0cbe8ca434973acbcaaf9 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/snappy/snappy-internal.h @@ -0,0 +1,393 @@ +// Copyright 2008 Google Inc. All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Internals shared between the Snappy implementation and its unittest. + +#ifndef THIRD_PARTY_SNAPPY_SNAPPY_INTERNAL_H_ +#define THIRD_PARTY_SNAPPY_SNAPPY_INTERNAL_H_ + +#include "snappy-stubs-internal.h" + +#if SNAPPY_HAVE_SSSE3 +// Please do not replace with or with headers that assume more +// advanced SSE versions without checking with all the OWNERS. +#include +#include +#endif + +#if SNAPPY_HAVE_NEON +#include +#endif + +#if SNAPPY_HAVE_SSSE3 || SNAPPY_HAVE_NEON +#define SNAPPY_HAVE_VECTOR_BYTE_SHUFFLE 1 +#else +#define SNAPPY_HAVE_VECTOR_BYTE_SHUFFLE 0 +#endif + +namespace snappy { +namespace internal { + +#if SNAPPY_HAVE_VECTOR_BYTE_SHUFFLE +#if SNAPPY_HAVE_SSSE3 +using V128 = __m128i; +#elif SNAPPY_HAVE_NEON +using V128 = uint8x16_t; +#endif + +// Load 128 bits of integer data. `src` must be 16-byte aligned. +inline V128 V128_Load(const V128* src); + +// Load 128 bits of integer data. `src` does not need to be aligned. +inline V128 V128_LoadU(const V128* src); + +// Store 128 bits of integer data. `dst` does not need to be aligned. +inline void V128_StoreU(V128* dst, V128 val); + +// Shuffle packed 8-bit integers using a shuffle mask. +// Each packed integer in the shuffle mask must be in [0,16). +inline V128 V128_Shuffle(V128 input, V128 shuffle_mask); + +// Constructs V128 with 16 chars |c|. +inline V128 V128_DupChar(char c); + +#if SNAPPY_HAVE_SSSE3 +inline V128 V128_Load(const V128* src) { return _mm_load_si128(src); } + +inline V128 V128_LoadU(const V128* src) { return _mm_loadu_si128(src); } + +inline void V128_StoreU(V128* dst, V128 val) { _mm_storeu_si128(dst, val); } + +inline V128 V128_Shuffle(V128 input, V128 shuffle_mask) { + return _mm_shuffle_epi8(input, shuffle_mask); +} + +inline V128 V128_DupChar(char c) { return _mm_set1_epi8(c); } + +#elif SNAPPY_HAVE_NEON +inline V128 V128_Load(const V128* src) { + return vld1q_u8(reinterpret_cast(src)); +} + +inline V128 V128_LoadU(const V128* src) { + return vld1q_u8(reinterpret_cast(src)); +} + +inline void V128_StoreU(V128* dst, V128 val) { + vst1q_u8(reinterpret_cast(dst), val); +} + +inline V128 V128_Shuffle(V128 input, V128 shuffle_mask) { + assert(vminvq_u8(shuffle_mask) >= 0 && vmaxvq_u8(shuffle_mask) <= 15); + return vqtbl1q_u8(input, shuffle_mask); +} + +inline V128 V128_DupChar(char c) { return vdupq_n_u8(c); } +#endif +#endif // SNAPPY_HAVE_VECTOR_BYTE_SHUFFLE + +// Working memory performs a single allocation to hold all scratch space +// required for compression. +class WorkingMemory { + public: + explicit WorkingMemory(size_t input_size); + ~WorkingMemory(); + + // Allocates and clears a hash table using memory in "*this", + // stores the number of buckets in "*table_size" and returns a pointer to + // the base of the hash table. + uint16_t* GetHashTable(size_t fragment_size, int* table_size) const; + char* GetScratchInput() const { return input_; } + char* GetScratchOutput() const { return output_; } + + private: + char* mem_; // the allocated memory, never nullptr + size_t size_; // the size of the allocated memory, never 0 + uint16_t* table_; // the pointer to the hashtable + char* input_; // the pointer to the input scratch buffer + char* output_; // the pointer to the output scratch buffer + + // No copying + WorkingMemory(const WorkingMemory&); + void operator=(const WorkingMemory&); +}; + +// Flat array compression that does not emit the "uncompressed length" +// prefix. Compresses "input" string to the "*op" buffer. +// +// REQUIRES: "input_length <= kBlockSize" +// REQUIRES: "op" points to an array of memory that is at least +// "MaxCompressedLength(input_length)" in size. +// REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero. +// REQUIRES: "table_size" is a power of two +// +// Returns an "end" pointer into "op" buffer. +// "end - op" is the compressed size of "input". +char* CompressFragment(const char* input, + size_t input_length, + char* op, + uint16_t* table, + const int table_size); + +// Find the largest n such that +// +// s1[0,n-1] == s2[0,n-1] +// and n <= (s2_limit - s2). +// +// Return make_pair(n, n < 8). +// Does not read *s2_limit or beyond. +// Does not read *(s1 + (s2_limit - s2)) or beyond. +// Requires that s2_limit >= s2. +// +// In addition populate *data with the next 5 bytes from the end of the match. +// This is only done if 8 bytes are available (s2_limit - s2 >= 8). The point is +// that on some arch's this can be done faster in this routine than subsequent +// loading from s2 + n. +// +// Separate implementation for 64-bit, little-endian cpus. +#if !SNAPPY_IS_BIG_ENDIAN && \ + (defined(__x86_64__) || defined(_M_X64) || defined(ARCH_PPC) || \ + defined(ARCH_ARM)) +static inline std::pair FindMatchLength(const char* s1, + const char* s2, + const char* s2_limit, + uint64_t* data) { + assert(s2_limit >= s2); + size_t matched = 0; + + // This block isn't necessary for correctness; we could just start looping + // immediately. As an optimization though, it is useful. It creates some not + // uncommon code paths that determine, without extra effort, whether the match + // length is less than 8. In short, we are hoping to avoid a conditional + // branch, and perhaps get better code layout from the C++ compiler. + if (SNAPPY_PREDICT_TRUE(s2 <= s2_limit - 16)) { + uint64_t a1 = UNALIGNED_LOAD64(s1); + uint64_t a2 = UNALIGNED_LOAD64(s2); + if (SNAPPY_PREDICT_TRUE(a1 != a2)) { + // This code is critical for performance. The reason is that it determines + // how much to advance `ip` (s2). This obviously depends on both the loads + // from the `candidate` (s1) and `ip`. Furthermore the next `candidate` + // depends on the advanced `ip` calculated here through a load, hash and + // new candidate hash lookup (a lot of cycles). This makes s1 (ie. + // `candidate`) the variable that limits throughput. This is the reason we + // go through hoops to have this function update `data` for the next iter. + // The straightforward code would use *data, given by + // + // *data = UNALIGNED_LOAD64(s2 + matched_bytes) (Latency of 5 cycles), + // + // as input for the hash table lookup to find next candidate. However + // this forces the load on the data dependency chain of s1, because + // matched_bytes directly depends on s1. However matched_bytes is 0..7, so + // we can also calculate *data by + // + // *data = AlignRight(UNALIGNED_LOAD64(s2), UNALIGNED_LOAD64(s2 + 8), + // matched_bytes); + // + // The loads do not depend on s1 anymore and are thus off the bottleneck. + // The straightforward implementation on x86_64 would be to use + // + // shrd rax, rdx, cl (cl being matched_bytes * 8) + // + // unfortunately shrd with a variable shift has a 4 cycle latency. So this + // only wins 1 cycle. The BMI2 shrx instruction is a 1 cycle variable + // shift instruction but can only shift 64 bits. If we focus on just + // obtaining the least significant 4 bytes, we can obtain this by + // + // *data = ConditionalMove(matched_bytes < 4, UNALIGNED_LOAD64(s2), + // UNALIGNED_LOAD64(s2 + 4) >> ((matched_bytes & 3) * 8); + // + // Writen like above this is not a big win, the conditional move would be + // a cmp followed by a cmov (2 cycles) followed by a shift (1 cycle). + // However matched_bytes < 4 is equal to + // static_cast(xorval) != 0. Writen that way, the conditional + // move (2 cycles) can execute in parallel with FindLSBSetNonZero64 + // (tzcnt), which takes 3 cycles. + uint64_t xorval = a1 ^ a2; + int shift = Bits::FindLSBSetNonZero64(xorval); + size_t matched_bytes = shift >> 3; + uint64_t a3 = UNALIGNED_LOAD64(s2 + 4); +#ifndef __x86_64__ + a2 = static_cast(xorval) == 0 ? a3 : a2; +#else + // Ideally this would just be + // + // a2 = static_cast(xorval) == 0 ? a3 : a2; + // + // However clang correctly infers that the above statement participates on + // a critical data dependency chain and thus, unfortunately, refuses to + // use a conditional move (it's tuned to cut data dependencies). In this + // case there is a longer parallel chain anyway AND this will be fairly + // unpredictable. + asm("testl %k2, %k2\n\t" + "cmovzq %1, %0\n\t" + : "+r"(a2) + : "r"(a3), "r"(xorval)); +#endif + *data = a2 >> (shift & (3 * 8)); + return std::pair(matched_bytes, true); + } else { + matched = 8; + s2 += 8; + } + } + + // Find out how long the match is. We loop over the data 64 bits at a + // time until we find a 64-bit block that doesn't match; then we find + // the first non-matching bit and use that to calculate the total + // length of the match. + while (SNAPPY_PREDICT_TRUE(s2 <= s2_limit - 16)) { + uint64_t a1 = UNALIGNED_LOAD64(s1 + matched); + uint64_t a2 = UNALIGNED_LOAD64(s2); + if (a1 == a2) { + s2 += 8; + matched += 8; + } else { + uint64_t xorval = a1 ^ a2; + int shift = Bits::FindLSBSetNonZero64(xorval); + size_t matched_bytes = shift >> 3; + uint64_t a3 = UNALIGNED_LOAD64(s2 + 4); +#ifndef __x86_64__ + a2 = static_cast(xorval) == 0 ? a3 : a2; +#else + asm("testl %k2, %k2\n\t" + "cmovzq %1, %0\n\t" + : "+r"(a2) + : "r"(a3), "r"(xorval)); +#endif + *data = a2 >> (shift & (3 * 8)); + matched += matched_bytes; + assert(matched >= 8); + return std::pair(matched, false); + } + } + while (SNAPPY_PREDICT_TRUE(s2 < s2_limit)) { + if (s1[matched] == *s2) { + ++s2; + ++matched; + } else { + if (s2 <= s2_limit - 8) { + *data = UNALIGNED_LOAD64(s2); + } + return std::pair(matched, matched < 8); + } + } + return std::pair(matched, matched < 8); +} +#else +static inline std::pair FindMatchLength(const char* s1, + const char* s2, + const char* s2_limit, + uint64_t* data) { + // Implementation based on the x86-64 version, above. + assert(s2_limit >= s2); + int matched = 0; + + while (s2 <= s2_limit - 4 && + UNALIGNED_LOAD32(s2) == UNALIGNED_LOAD32(s1 + matched)) { + s2 += 4; + matched += 4; + } + if (LittleEndian::IsLittleEndian() && s2 <= s2_limit - 4) { + uint32_t x = UNALIGNED_LOAD32(s2) ^ UNALIGNED_LOAD32(s1 + matched); + int matching_bits = Bits::FindLSBSetNonZero(x); + matched += matching_bits >> 3; + s2 += matching_bits >> 3; + } else { + while ((s2 < s2_limit) && (s1[matched] == *s2)) { + ++s2; + ++matched; + } + } + if (s2 <= s2_limit - 8) *data = LittleEndian::Load64(s2); + return std::pair(matched, matched < 8); +} +#endif + +// Lookup tables for decompression code. Give --snappy_dump_decompression_table +// to the unit test to recompute char_table. + +enum { + LITERAL = 0, + COPY_1_BYTE_OFFSET = 1, // 3 bit length + 3 bits of offset in opcode + COPY_2_BYTE_OFFSET = 2, + COPY_4_BYTE_OFFSET = 3 +}; +static const int kMaximumTagLength = 5; // COPY_4_BYTE_OFFSET plus the actual offset. + +// Data stored per entry in lookup table: +// Range Bits-used Description +// ------------------------------------ +// 1..64 0..7 Literal/copy length encoded in opcode byte +// 0..7 8..10 Copy offset encoded in opcode byte / 256 +// 0..4 11..13 Extra bytes after opcode +// +// We use eight bits for the length even though 7 would have sufficed +// because of efficiency reasons: +// (1) Extracting a byte is faster than a bit-field +// (2) It properly aligns copy offset so we do not need a <<8 +static constexpr uint16_t char_table[256] = { + // clang-format off + 0x0001, 0x0804, 0x1001, 0x2001, 0x0002, 0x0805, 0x1002, 0x2002, + 0x0003, 0x0806, 0x1003, 0x2003, 0x0004, 0x0807, 0x1004, 0x2004, + 0x0005, 0x0808, 0x1005, 0x2005, 0x0006, 0x0809, 0x1006, 0x2006, + 0x0007, 0x080a, 0x1007, 0x2007, 0x0008, 0x080b, 0x1008, 0x2008, + 0x0009, 0x0904, 0x1009, 0x2009, 0x000a, 0x0905, 0x100a, 0x200a, + 0x000b, 0x0906, 0x100b, 0x200b, 0x000c, 0x0907, 0x100c, 0x200c, + 0x000d, 0x0908, 0x100d, 0x200d, 0x000e, 0x0909, 0x100e, 0x200e, + 0x000f, 0x090a, 0x100f, 0x200f, 0x0010, 0x090b, 0x1010, 0x2010, + 0x0011, 0x0a04, 0x1011, 0x2011, 0x0012, 0x0a05, 0x1012, 0x2012, + 0x0013, 0x0a06, 0x1013, 0x2013, 0x0014, 0x0a07, 0x1014, 0x2014, + 0x0015, 0x0a08, 0x1015, 0x2015, 0x0016, 0x0a09, 0x1016, 0x2016, + 0x0017, 0x0a0a, 0x1017, 0x2017, 0x0018, 0x0a0b, 0x1018, 0x2018, + 0x0019, 0x0b04, 0x1019, 0x2019, 0x001a, 0x0b05, 0x101a, 0x201a, + 0x001b, 0x0b06, 0x101b, 0x201b, 0x001c, 0x0b07, 0x101c, 0x201c, + 0x001d, 0x0b08, 0x101d, 0x201d, 0x001e, 0x0b09, 0x101e, 0x201e, + 0x001f, 0x0b0a, 0x101f, 0x201f, 0x0020, 0x0b0b, 0x1020, 0x2020, + 0x0021, 0x0c04, 0x1021, 0x2021, 0x0022, 0x0c05, 0x1022, 0x2022, + 0x0023, 0x0c06, 0x1023, 0x2023, 0x0024, 0x0c07, 0x1024, 0x2024, + 0x0025, 0x0c08, 0x1025, 0x2025, 0x0026, 0x0c09, 0x1026, 0x2026, + 0x0027, 0x0c0a, 0x1027, 0x2027, 0x0028, 0x0c0b, 0x1028, 0x2028, + 0x0029, 0x0d04, 0x1029, 0x2029, 0x002a, 0x0d05, 0x102a, 0x202a, + 0x002b, 0x0d06, 0x102b, 0x202b, 0x002c, 0x0d07, 0x102c, 0x202c, + 0x002d, 0x0d08, 0x102d, 0x202d, 0x002e, 0x0d09, 0x102e, 0x202e, + 0x002f, 0x0d0a, 0x102f, 0x202f, 0x0030, 0x0d0b, 0x1030, 0x2030, + 0x0031, 0x0e04, 0x1031, 0x2031, 0x0032, 0x0e05, 0x1032, 0x2032, + 0x0033, 0x0e06, 0x1033, 0x2033, 0x0034, 0x0e07, 0x1034, 0x2034, + 0x0035, 0x0e08, 0x1035, 0x2035, 0x0036, 0x0e09, 0x1036, 0x2036, + 0x0037, 0x0e0a, 0x1037, 0x2037, 0x0038, 0x0e0b, 0x1038, 0x2038, + 0x0039, 0x0f04, 0x1039, 0x2039, 0x003a, 0x0f05, 0x103a, 0x203a, + 0x003b, 0x0f06, 0x103b, 0x203b, 0x003c, 0x0f07, 0x103c, 0x203c, + 0x0801, 0x0f08, 0x103d, 0x203d, 0x1001, 0x0f09, 0x103e, 0x203e, + 0x1801, 0x0f0a, 0x103f, 0x203f, 0x2001, 0x0f0b, 0x1040, 0x2040, + // clang-format on +}; + +} // end namespace internal +} // end namespace snappy + +#endif // THIRD_PARTY_SNAPPY_SNAPPY_INTERNAL_H_ diff --git a/deps/exla/cache/xla_extension/include/external/snappy/snappy-sinksource.h b/deps/exla/cache/xla_extension/include/external/snappy/snappy-sinksource.h new file mode 100644 index 0000000000000000000000000000000000000000..3c74e1bb6e90e0ac4c553ae2efa4ea2480c4b976 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/snappy/snappy-sinksource.h @@ -0,0 +1,182 @@ +// Copyright 2011 Google Inc. All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef THIRD_PARTY_SNAPPY_SNAPPY_SINKSOURCE_H_ +#define THIRD_PARTY_SNAPPY_SNAPPY_SINKSOURCE_H_ + +#include + +namespace snappy { + +// A Sink is an interface that consumes a sequence of bytes. +class Sink { + public: + Sink() { } + virtual ~Sink(); + + // Append "bytes[0,n-1]" to this. + virtual void Append(const char* bytes, size_t n) = 0; + + // Returns a writable buffer of the specified length for appending. + // May return a pointer to the caller-owned scratch buffer which + // must have at least the indicated length. The returned buffer is + // only valid until the next operation on this Sink. + // + // After writing at most "length" bytes, call Append() with the + // pointer returned from this function and the number of bytes + // written. Many Append() implementations will avoid copying + // bytes if this function returned an internal buffer. + // + // If a non-scratch buffer is returned, the caller may only pass a + // prefix of it to Append(). That is, it is not correct to pass an + // interior pointer of the returned array to Append(). + // + // The default implementation always returns the scratch buffer. + virtual char* GetAppendBuffer(size_t length, char* scratch); + + // For higher performance, Sink implementations can provide custom + // AppendAndTakeOwnership() and GetAppendBufferVariable() methods. + // These methods can reduce the number of copies done during + // compression/decompression. + + // Append "bytes[0,n-1] to the sink. Takes ownership of "bytes" + // and calls the deleter function as (*deleter)(deleter_arg, bytes, n) + // to free the buffer. deleter function must be non NULL. + // + // The default implementation just calls Append and frees "bytes". + // Other implementations may avoid a copy while appending the buffer. + virtual void AppendAndTakeOwnership( + char* bytes, size_t n, void (*deleter)(void*, const char*, size_t), + void *deleter_arg); + + // Returns a writable buffer for appending and writes the buffer's capacity to + // *allocated_size. Guarantees *allocated_size >= min_size. + // May return a pointer to the caller-owned scratch buffer which must have + // scratch_size >= min_size. + // + // The returned buffer is only valid until the next operation + // on this ByteSink. + // + // After writing at most *allocated_size bytes, call Append() with the + // pointer returned from this function and the number of bytes written. + // Many Append() implementations will avoid copying bytes if this function + // returned an internal buffer. + // + // If the sink implementation allocates or reallocates an internal buffer, + // it should use the desired_size_hint if appropriate. If a caller cannot + // provide a reasonable guess at the desired capacity, it should set + // desired_size_hint = 0. + // + // If a non-scratch buffer is returned, the caller may only pass + // a prefix to it to Append(). That is, it is not correct to pass an + // interior pointer to Append(). + // + // The default implementation always returns the scratch buffer. + virtual char* GetAppendBufferVariable( + size_t min_size, size_t desired_size_hint, char* scratch, + size_t scratch_size, size_t* allocated_size); + + private: + // No copying + Sink(const Sink&); + void operator=(const Sink&); +}; + +// A Source is an interface that yields a sequence of bytes +class Source { + public: + Source() { } + virtual ~Source(); + + // Return the number of bytes left to read from the source + virtual size_t Available() const = 0; + + // Peek at the next flat region of the source. Does not reposition + // the source. The returned region is empty iff Available()==0. + // + // Returns a pointer to the beginning of the region and store its + // length in *len. + // + // The returned region is valid until the next call to Skip() or + // until this object is destroyed, whichever occurs first. + // + // The returned region may be larger than Available() (for example + // if this ByteSource is a view on a substring of a larger source). + // The caller is responsible for ensuring that it only reads the + // Available() bytes. + virtual const char* Peek(size_t* len) = 0; + + // Skip the next n bytes. Invalidates any buffer returned by + // a previous call to Peek(). + // REQUIRES: Available() >= n + virtual void Skip(size_t n) = 0; + + private: + // No copying + Source(const Source&); + void operator=(const Source&); +}; + +// A Source implementation that yields the contents of a flat array +class ByteArraySource : public Source { + public: + ByteArraySource(const char* p, size_t n) : ptr_(p), left_(n) { } + ~ByteArraySource() override; + size_t Available() const override; + const char* Peek(size_t* len) override; + void Skip(size_t n) override; + private: + const char* ptr_; + size_t left_; +}; + +// A Sink implementation that writes to a flat array without any bound checks. +class UncheckedByteArraySink : public Sink { + public: + explicit UncheckedByteArraySink(char* dest) : dest_(dest) { } + ~UncheckedByteArraySink() override; + void Append(const char* data, size_t n) override; + char* GetAppendBuffer(size_t len, char* scratch) override; + char* GetAppendBufferVariable( + size_t min_size, size_t desired_size_hint, char* scratch, + size_t scratch_size, size_t* allocated_size) override; + void AppendAndTakeOwnership( + char* bytes, size_t n, void (*deleter)(void*, const char*, size_t), + void *deleter_arg) override; + + // Return the current output pointer so that a caller can see how + // many bytes were produced. + // Note: this is not a Sink method. + char* CurrentDestination() const { return dest_; } + private: + char* dest_; +}; + +} // namespace snappy + +#endif // THIRD_PARTY_SNAPPY_SNAPPY_SINKSOURCE_H_ diff --git a/deps/exla/cache/xla_extension/include/external/snappy/snappy-stubs-internal.h b/deps/exla/cache/xla_extension/include/external/snappy/snappy-stubs-internal.h new file mode 100644 index 0000000000000000000000000000000000000000..7d43c922c04b0f47e82a1b7d67df49db367b5a3c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/snappy/snappy-stubs-internal.h @@ -0,0 +1,492 @@ +// Copyright 2011 Google Inc. All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Various stubs for the open-source version of Snappy. + +#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_INTERNAL_H_ +#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_INTERNAL_H_ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include +#include +#include +#include + +#if HAVE_SYS_MMAN_H +#include +#endif + +#if HAVE_UNISTD_H +#include +#endif + +#if defined(_MSC_VER) +#include +#endif // defined(_MSC_VER) + +#ifndef __has_feature +#define __has_feature(x) 0 +#endif + +#if __has_feature(memory_sanitizer) +#include +#define SNAPPY_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) \ + __msan_unpoison((address), (size)) +#else +#define SNAPPY_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) /* empty */ +#endif // __has_feature(memory_sanitizer) + +#include "snappy-stubs-public.h" + +// Used to enable 64-bit optimized versions of some routines. +#if defined(__PPC64__) || defined(__powerpc64__) +#define ARCH_PPC 1 +#elif defined(__aarch64__) || defined(_M_ARM64) +#define ARCH_ARM 1 +#endif + +// Needed by OS X, among others. +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +// The size of an array, if known at compile-time. +// Will give unexpected results if used on a pointer. +// We undefine it first, since some compilers already have a definition. +#ifdef ARRAYSIZE +#undef ARRAYSIZE +#endif +#define ARRAYSIZE(a) int{sizeof(a) / sizeof(*(a))} + +// Static prediction hints. +#if HAVE_BUILTIN_EXPECT +#define SNAPPY_PREDICT_FALSE(x) (__builtin_expect(x, 0)) +#define SNAPPY_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) +#else +#define SNAPPY_PREDICT_FALSE(x) x +#define SNAPPY_PREDICT_TRUE(x) x +#endif // HAVE_BUILTIN_EXPECT + +// Inlining hints. +#if HAVE_ATTRIBUTE_ALWAYS_INLINE +#define SNAPPY_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) +#else +#define SNAPPY_ATTRIBUTE_ALWAYS_INLINE +#endif // HAVE_ATTRIBUTE_ALWAYS_INLINE + +// Stubbed version of ABSL_FLAG. +// +// In the open source version, flags can only be changed at compile time. +#define SNAPPY_FLAG(flag_type, flag_name, default_value, help) \ + flag_type FLAGS_ ## flag_name = default_value + +namespace snappy { + +// Stubbed version of absl::GetFlag(). +template +inline T GetFlag(T flag) { return flag; } + +static const uint32_t kuint32max = std::numeric_limits::max(); +static const int64_t kint64max = std::numeric_limits::max(); + +// Potentially unaligned loads and stores. + +inline uint16_t UNALIGNED_LOAD16(const void *p) { + // Compiles to a single movzx/ldrh on clang/gcc/msvc. + uint16_t v; + std::memcpy(&v, p, sizeof(v)); + return v; +} + +inline uint32_t UNALIGNED_LOAD32(const void *p) { + // Compiles to a single mov/ldr on clang/gcc/msvc. + uint32_t v; + std::memcpy(&v, p, sizeof(v)); + return v; +} + +inline uint64_t UNALIGNED_LOAD64(const void *p) { + // Compiles to a single mov/ldr on clang/gcc/msvc. + uint64_t v; + std::memcpy(&v, p, sizeof(v)); + return v; +} + +inline void UNALIGNED_STORE16(void *p, uint16_t v) { + // Compiles to a single mov/strh on clang/gcc/msvc. + std::memcpy(p, &v, sizeof(v)); +} + +inline void UNALIGNED_STORE32(void *p, uint32_t v) { + // Compiles to a single mov/str on clang/gcc/msvc. + std::memcpy(p, &v, sizeof(v)); +} + +inline void UNALIGNED_STORE64(void *p, uint64_t v) { + // Compiles to a single mov/str on clang/gcc/msvc. + std::memcpy(p, &v, sizeof(v)); +} + +// Convert to little-endian storage, opposite of network format. +// Convert x from host to little endian: x = LittleEndian.FromHost(x); +// convert x from little endian to host: x = LittleEndian.ToHost(x); +// +// Store values into unaligned memory converting to little endian order: +// LittleEndian.Store16(p, x); +// +// Load unaligned values stored in little endian converting to host order: +// x = LittleEndian.Load16(p); +class LittleEndian { + public: + // Functions to do unaligned loads and stores in little-endian order. + static inline uint16_t Load16(const void *ptr) { + const uint8_t* const buffer = reinterpret_cast(ptr); + + // Compiles to a single mov/str on recent clang and gcc. + return (static_cast(buffer[0])) | + (static_cast(buffer[1]) << 8); + } + + static inline uint32_t Load32(const void *ptr) { + const uint8_t* const buffer = reinterpret_cast(ptr); + + // Compiles to a single mov/str on recent clang and gcc. + return (static_cast(buffer[0])) | + (static_cast(buffer[1]) << 8) | + (static_cast(buffer[2]) << 16) | + (static_cast(buffer[3]) << 24); + } + + static inline uint64_t Load64(const void *ptr) { + const uint8_t* const buffer = reinterpret_cast(ptr); + + // Compiles to a single mov/str on recent clang and gcc. + return (static_cast(buffer[0])) | + (static_cast(buffer[1]) << 8) | + (static_cast(buffer[2]) << 16) | + (static_cast(buffer[3]) << 24) | + (static_cast(buffer[4]) << 32) | + (static_cast(buffer[5]) << 40) | + (static_cast(buffer[6]) << 48) | + (static_cast(buffer[7]) << 56); + } + + static inline void Store16(void *dst, uint16_t value) { + uint8_t* const buffer = reinterpret_cast(dst); + + // Compiles to a single mov/str on recent clang and gcc. + buffer[0] = static_cast(value); + buffer[1] = static_cast(value >> 8); + } + + static void Store32(void *dst, uint32_t value) { + uint8_t* const buffer = reinterpret_cast(dst); + + // Compiles to a single mov/str on recent clang and gcc. + buffer[0] = static_cast(value); + buffer[1] = static_cast(value >> 8); + buffer[2] = static_cast(value >> 16); + buffer[3] = static_cast(value >> 24); + } + + static void Store64(void* dst, uint64_t value) { + uint8_t* const buffer = reinterpret_cast(dst); + + // Compiles to a single mov/str on recent clang and gcc. + buffer[0] = static_cast(value); + buffer[1] = static_cast(value >> 8); + buffer[2] = static_cast(value >> 16); + buffer[3] = static_cast(value >> 24); + buffer[4] = static_cast(value >> 32); + buffer[5] = static_cast(value >> 40); + buffer[6] = static_cast(value >> 48); + buffer[7] = static_cast(value >> 56); + } + + static inline constexpr bool IsLittleEndian() { +#if SNAPPY_IS_BIG_ENDIAN + return false; +#else + return true; +#endif // SNAPPY_IS_BIG_ENDIAN + } +}; + +// Some bit-manipulation functions. +class Bits { + public: + // Return floor(log2(n)) for positive integer n. + static int Log2FloorNonZero(uint32_t n); + + // Return floor(log2(n)) for positive integer n. Returns -1 iff n == 0. + static int Log2Floor(uint32_t n); + + // Return the first set least / most significant bit, 0-indexed. Returns an + // undefined value if n == 0. FindLSBSetNonZero() is similar to ffs() except + // that it's 0-indexed. + static int FindLSBSetNonZero(uint32_t n); + + static int FindLSBSetNonZero64(uint64_t n); + + private: + // No copying + Bits(const Bits&); + void operator=(const Bits&); +}; + +#if HAVE_BUILTIN_CTZ + +inline int Bits::Log2FloorNonZero(uint32_t n) { + assert(n != 0); + // (31 ^ x) is equivalent to (31 - x) for x in [0, 31]. An easy proof + // represents subtraction in base 2 and observes that there's no carry. + // + // GCC and Clang represent __builtin_clz on x86 as 31 ^ _bit_scan_reverse(x). + // Using "31 ^" here instead of "31 -" allows the optimizer to strip the + // function body down to _bit_scan_reverse(x). + return 31 ^ __builtin_clz(n); +} + +inline int Bits::Log2Floor(uint32_t n) { + return (n == 0) ? -1 : Bits::Log2FloorNonZero(n); +} + +inline int Bits::FindLSBSetNonZero(uint32_t n) { + assert(n != 0); + return __builtin_ctz(n); +} + +#elif defined(_MSC_VER) + +inline int Bits::Log2FloorNonZero(uint32_t n) { + assert(n != 0); + // NOLINTNEXTLINE(runtime/int): The MSVC intrinsic demands unsigned long. + unsigned long where; + _BitScanReverse(&where, n); + return static_cast(where); +} + +inline int Bits::Log2Floor(uint32_t n) { + // NOLINTNEXTLINE(runtime/int): The MSVC intrinsic demands unsigned long. + unsigned long where; + if (_BitScanReverse(&where, n)) + return static_cast(where); + return -1; +} + +inline int Bits::FindLSBSetNonZero(uint32_t n) { + assert(n != 0); + // NOLINTNEXTLINE(runtime/int): The MSVC intrinsic demands unsigned long. + unsigned long where; + if (_BitScanForward(&where, n)) + return static_cast(where); + return 32; +} + +#else // Portable versions. + +inline int Bits::Log2FloorNonZero(uint32_t n) { + assert(n != 0); + + int log = 0; + uint32_t value = n; + for (int i = 4; i >= 0; --i) { + int shift = (1 << i); + uint32_t x = value >> shift; + if (x != 0) { + value = x; + log += shift; + } + } + assert(value == 1); + return log; +} + +inline int Bits::Log2Floor(uint32_t n) { + return (n == 0) ? -1 : Bits::Log2FloorNonZero(n); +} + +inline int Bits::FindLSBSetNonZero(uint32_t n) { + assert(n != 0); + + int rc = 31; + for (int i = 4, shift = 1 << 4; i >= 0; --i) { + const uint32_t x = n << shift; + if (x != 0) { + n = x; + rc -= shift; + } + shift >>= 1; + } + return rc; +} + +#endif // End portable versions. + +#if HAVE_BUILTIN_CTZ + +inline int Bits::FindLSBSetNonZero64(uint64_t n) { + assert(n != 0); + return __builtin_ctzll(n); +} + +#elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64)) +// _BitScanForward64() is only available on x64 and ARM64. + +inline int Bits::FindLSBSetNonZero64(uint64_t n) { + assert(n != 0); + // NOLINTNEXTLINE(runtime/int): The MSVC intrinsic demands unsigned long. + unsigned long where; + if (_BitScanForward64(&where, n)) + return static_cast(where); + return 64; +} + +#else // Portable version. + +// FindLSBSetNonZero64() is defined in terms of FindLSBSetNonZero(). +inline int Bits::FindLSBSetNonZero64(uint64_t n) { + assert(n != 0); + + const uint32_t bottombits = static_cast(n); + if (bottombits == 0) { + // Bottom bits are zero, so scan the top bits. + return 32 + FindLSBSetNonZero(static_cast(n >> 32)); + } else { + return FindLSBSetNonZero(bottombits); + } +} + +#endif // HAVE_BUILTIN_CTZ + +// Variable-length integer encoding. +class Varint { + public: + // Maximum lengths of varint encoding of uint32_t. + static const int kMax32 = 5; + + // Attempts to parse a varint32 from a prefix of the bytes in [ptr,limit-1]. + // Never reads a character at or beyond limit. If a valid/terminated varint32 + // was found in the range, stores it in *OUTPUT and returns a pointer just + // past the last byte of the varint32. Else returns NULL. On success, + // "result <= limit". + static const char* Parse32WithLimit(const char* ptr, const char* limit, + uint32_t* OUTPUT); + + // REQUIRES "ptr" points to a buffer of length sufficient to hold "v". + // EFFECTS Encodes "v" into "ptr" and returns a pointer to the + // byte just past the last encoded byte. + static char* Encode32(char* ptr, uint32_t v); + + // EFFECTS Appends the varint representation of "value" to "*s". + static void Append32(std::string* s, uint32_t value); +}; + +inline const char* Varint::Parse32WithLimit(const char* p, + const char* l, + uint32_t* OUTPUT) { + const unsigned char* ptr = reinterpret_cast(p); + const unsigned char* limit = reinterpret_cast(l); + uint32_t b, result; + if (ptr >= limit) return NULL; + b = *(ptr++); result = b & 127; if (b < 128) goto done; + if (ptr >= limit) return NULL; + b = *(ptr++); result |= (b & 127) << 7; if (b < 128) goto done; + if (ptr >= limit) return NULL; + b = *(ptr++); result |= (b & 127) << 14; if (b < 128) goto done; + if (ptr >= limit) return NULL; + b = *(ptr++); result |= (b & 127) << 21; if (b < 128) goto done; + if (ptr >= limit) return NULL; + b = *(ptr++); result |= (b & 127) << 28; if (b < 16) goto done; + return NULL; // Value is too long to be a varint32 + done: + *OUTPUT = result; + return reinterpret_cast(ptr); +} + +inline char* Varint::Encode32(char* sptr, uint32_t v) { + // Operate on characters as unsigneds + uint8_t* ptr = reinterpret_cast(sptr); + static const uint8_t B = 128; + if (v < (1 << 7)) { + *(ptr++) = static_cast(v); + } else if (v < (1 << 14)) { + *(ptr++) = static_cast(v | B); + *(ptr++) = static_cast(v >> 7); + } else if (v < (1 << 21)) { + *(ptr++) = static_cast(v | B); + *(ptr++) = static_cast((v >> 7) | B); + *(ptr++) = static_cast(v >> 14); + } else if (v < (1 << 28)) { + *(ptr++) = static_cast(v | B); + *(ptr++) = static_cast((v >> 7) | B); + *(ptr++) = static_cast((v >> 14) | B); + *(ptr++) = static_cast(v >> 21); + } else { + *(ptr++) = static_cast(v | B); + *(ptr++) = static_cast((v>>7) | B); + *(ptr++) = static_cast((v>>14) | B); + *(ptr++) = static_cast((v>>21) | B); + *(ptr++) = static_cast(v >> 28); + } + return reinterpret_cast(ptr); +} + +// If you know the internal layout of the std::string in use, you can +// replace this function with one that resizes the string without +// filling the new space with zeros (if applicable) -- +// it will be non-portable but faster. +inline void STLStringResizeUninitialized(std::string* s, size_t new_size) { + s->resize(new_size); +} + +// Return a mutable char* pointing to a string's internal buffer, +// which may not be null-terminated. Writing through this pointer will +// modify the string. +// +// string_as_array(&str)[i] is valid for 0 <= i < str.size() until the +// next call to a string method that invalidates iterators. +// +// As of 2006-04, there is no standard-blessed way of getting a +// mutable reference to a string's internal buffer. However, issue 530 +// (http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-defects.html#530) +// proposes this as the method. It will officially be part of the standard +// for C++0x. This should already work on all current implementations. +inline char* string_as_array(std::string* str) { + return str->empty() ? NULL : &*str->begin(); +} + +} // namespace snappy + +#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_INTERNAL_H_ diff --git a/deps/exla/cache/xla_extension/include/external/snappy/snappy-stubs-public.h b/deps/exla/cache/xla_extension/include/external/snappy/snappy-stubs-public.h new file mode 100644 index 0000000000000000000000000000000000000000..7fe803aa73f147e94b7be701b4f8568c647c07f6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/snappy/snappy-stubs-public.h @@ -0,0 +1,63 @@ +// Copyright 2011 Google Inc. All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Various type stubs for the open-source version of Snappy. +// +// This file cannot include config.h, as it is included from snappy.h, +// which is a public header. Instead, snappy-stubs-public.h is generated by +// from snappy-stubs-public.h.in at configure time. + +#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ +#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ + +#include + +#if HAVE_SYS_UIO_H // HAVE_SYS_UIO_H +#include +#endif // HAVE_SYS_UIO_H + +#define SNAPPY_MAJOR ${PROJECT_VERSION_MAJOR} +#define SNAPPY_MINOR ${PROJECT_VERSION_MINOR} +#define SNAPPY_PATCHLEVEL ${PROJECT_VERSION_PATCH} +#define SNAPPY_VERSION \ + ((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL) + +namespace snappy { + +#if !HAVE_SYS_UIO_H // !HAVE_SYS_UIO_H +// Windows does not have an iovec type, yet the concept is universally useful. +// It is simple to define it ourselves, so we put it inside our own namespace. +struct iovec { + void* iov_base; + size_t iov_len; +}; +#endif // !HAVE_SYS_UIO_H + +} // namespace snappy + +#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ diff --git a/deps/exla/cache/xla_extension/include/external/snappy/snappy.h b/deps/exla/cache/xla_extension/include/external/snappy/snappy.h new file mode 100644 index 0000000000000000000000000000000000000000..e12b658ebd8d41729336283d7d0238a32693a29f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/snappy/snappy.h @@ -0,0 +1,222 @@ +// Copyright 2005 and onwards Google Inc. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// A light-weight compression algorithm. It is designed for speed of +// compression and decompression, rather than for the utmost in space +// savings. +// +// For getting better compression ratios when you are compressing data +// with long repeated sequences or compressing data that is similar to +// other data, while still compressing fast, you might look at first +// using BMDiff and then compressing the output of BMDiff with +// Snappy. + +#ifndef THIRD_PARTY_SNAPPY_SNAPPY_H__ +#define THIRD_PARTY_SNAPPY_SNAPPY_H__ + +#include +#include + +#include + +#include "snappy-stubs-public.h" + +namespace snappy { + class Source; + class Sink; + + // ------------------------------------------------------------------------ + // Generic compression/decompression routines. + // ------------------------------------------------------------------------ + + // Compress the bytes read from "*source" and append to "*sink". Return the + // number of bytes written. + size_t Compress(Source* source, Sink* sink); + + // Find the uncompressed length of the given stream, as given by the header. + // Note that the true length could deviate from this; the stream could e.g. + // be truncated. + // + // Also note that this leaves "*source" in a state that is unsuitable for + // further operations, such as RawUncompress(). You will need to rewind + // or recreate the source yourself before attempting any further calls. + bool GetUncompressedLength(Source* source, uint32_t* result); + + // ------------------------------------------------------------------------ + // Higher-level string based routines (should be sufficient for most users) + // ------------------------------------------------------------------------ + + // Sets "*compressed" to the compressed version of "input[0..input_length-1]". + // Original contents of *compressed are lost. + // + // REQUIRES: "input[]" is not an alias of "*compressed". + size_t Compress(const char* input, size_t input_length, + std::string* compressed); + + // Same as `Compress` above but taking an `iovec` array as input. Note that + // this function preprocesses the inputs to compute the sum of + // `iov[0..iov_cnt-1].iov_len` before reading. To avoid this, use + // `RawCompressFromIOVec` below. + size_t CompressFromIOVec(const struct iovec* iov, size_t iov_cnt, + std::string* compressed); + + // Decompresses "compressed[0..compressed_length-1]" to "*uncompressed". + // Original contents of "*uncompressed" are lost. + // + // REQUIRES: "compressed[]" is not an alias of "*uncompressed". + // + // returns false if the message is corrupted and could not be decompressed + bool Uncompress(const char* compressed, size_t compressed_length, + std::string* uncompressed); + + // Decompresses "compressed" to "*uncompressed". + // + // returns false if the message is corrupted and could not be decompressed + bool Uncompress(Source* compressed, Sink* uncompressed); + + // This routine uncompresses as much of the "compressed" as possible + // into sink. It returns the number of valid bytes added to sink + // (extra invalid bytes may have been added due to errors; the caller + // should ignore those). The emitted data typically has length + // GetUncompressedLength(), but may be shorter if an error is + // encountered. + size_t UncompressAsMuchAsPossible(Source* compressed, Sink* uncompressed); + + // ------------------------------------------------------------------------ + // Lower-level character array based routines. May be useful for + // efficiency reasons in certain circumstances. + // ------------------------------------------------------------------------ + + // REQUIRES: "compressed" must point to an area of memory that is at + // least "MaxCompressedLength(input_length)" bytes in length. + // + // Takes the data stored in "input[0..input_length]" and stores + // it in the array pointed to by "compressed". + // + // "*compressed_length" is set to the length of the compressed output. + // + // Example: + // char* output = new char[snappy::MaxCompressedLength(input_length)]; + // size_t output_length; + // RawCompress(input, input_length, output, &output_length); + // ... Process(output, output_length) ... + // delete [] output; + void RawCompress(const char* input, + size_t input_length, + char* compressed, + size_t* compressed_length); + + // Same as `RawCompress` above but taking an `iovec` array as input. Note that + // `uncompressed_length` is the total number of bytes to be read from the + // elements of `iov` (_not_ the number of elements in `iov`). + void RawCompressFromIOVec(const struct iovec* iov, size_t uncompressed_length, + char* compressed, size_t* compressed_length); + + // Given data in "compressed[0..compressed_length-1]" generated by + // calling the Snappy::Compress routine, this routine + // stores the uncompressed data to + // uncompressed[0..GetUncompressedLength(compressed)-1] + // returns false if the message is corrupted and could not be decrypted + bool RawUncompress(const char* compressed, size_t compressed_length, + char* uncompressed); + + // Given data from the byte source 'compressed' generated by calling + // the Snappy::Compress routine, this routine stores the uncompressed + // data to + // uncompressed[0..GetUncompressedLength(compressed,compressed_length)-1] + // returns false if the message is corrupted and could not be decrypted + bool RawUncompress(Source* compressed, char* uncompressed); + + // Given data in "compressed[0..compressed_length-1]" generated by + // calling the Snappy::Compress routine, this routine + // stores the uncompressed data to the iovec "iov". The number of physical + // buffers in "iov" is given by iov_cnt and their cumulative size + // must be at least GetUncompressedLength(compressed). The individual buffers + // in "iov" must not overlap with each other. + // + // returns false if the message is corrupted and could not be decrypted + bool RawUncompressToIOVec(const char* compressed, size_t compressed_length, + const struct iovec* iov, size_t iov_cnt); + + // Given data from the byte source 'compressed' generated by calling + // the Snappy::Compress routine, this routine stores the uncompressed + // data to the iovec "iov". The number of physical + // buffers in "iov" is given by iov_cnt and their cumulative size + // must be at least GetUncompressedLength(compressed). The individual buffers + // in "iov" must not overlap with each other. + // + // returns false if the message is corrupted and could not be decrypted + bool RawUncompressToIOVec(Source* compressed, const struct iovec* iov, + size_t iov_cnt); + + // Returns the maximal size of the compressed representation of + // input data that is "source_bytes" bytes in length; + size_t MaxCompressedLength(size_t source_bytes); + + // REQUIRES: "compressed[]" was produced by RawCompress() or Compress() + // Returns true and stores the length of the uncompressed data in + // *result normally. Returns false on parsing error. + // This operation takes O(1) time. + bool GetUncompressedLength(const char* compressed, size_t compressed_length, + size_t* result); + + // Returns true iff the contents of "compressed[]" can be uncompressed + // successfully. Does not return the uncompressed data. Takes + // time proportional to compressed_length, but is usually at least + // a factor of four faster than actual decompression. + bool IsValidCompressedBuffer(const char* compressed, + size_t compressed_length); + + // Returns true iff the contents of "compressed" can be uncompressed + // successfully. Does not return the uncompressed data. Takes + // time proportional to *compressed length, but is usually at least + // a factor of four faster than actual decompression. + // On success, consumes all of *compressed. On failure, consumes an + // unspecified prefix of *compressed. + bool IsValidCompressed(Source* compressed); + + // The size of a compression block. Note that many parts of the compression + // code assumes that kBlockSize <= 65536; in particular, the hash table + // can only store 16-bit offsets, and EmitCopy() also assumes the offset + // is 65535 bytes or less. Note also that if you change this, it will + // affect the framing format (see framing_format.txt). + // + // Note that there might be older data around that is compressed with larger + // block sizes, so the decompression code should not rely on the + // non-existence of long backreferences. + static constexpr int kBlockLog = 16; + static constexpr size_t kBlockSize = 1 << kBlockLog; + + static constexpr int kMinHashTableBits = 8; + static constexpr size_t kMinHashTableSize = 1 << kMinHashTableBits; + + static constexpr int kMaxHashTableBits = 14; + static constexpr size_t kMaxHashTableSize = 1 << kMaxHashTableBits; +} // end namespace snappy + +#endif // THIRD_PARTY_SNAPPY_SNAPPY_H__ diff --git a/deps/exla/cache/xla_extension/include/external/zlib/crc32.h b/deps/exla/cache/xla_extension/include/external/zlib/crc32.h new file mode 100644 index 0000000000000000000000000000000000000000..137df68d616c5ed38913579ba37b4e4c533fa903 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/zlib/crc32.h @@ -0,0 +1,9446 @@ +/* crc32.h -- tables for rapid CRC calculation + * Generated automatically by crc32.c + */ + +local const z_crc_t FAR crc_table[] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d}; + +#ifdef W + +#if W == 8 + +local const z_word_t FAR crc_big_table[] = { + 0x0000000000000000, 0x9630077700000000, 0x2c610eee00000000, + 0xba51099900000000, 0x19c46d0700000000, 0x8ff46a7000000000, + 0x35a563e900000000, 0xa395649e00000000, 0x3288db0e00000000, + 0xa4b8dc7900000000, 0x1ee9d5e000000000, 0x88d9d29700000000, + 0x2b4cb60900000000, 0xbd7cb17e00000000, 0x072db8e700000000, + 0x911dbf9000000000, 0x6410b71d00000000, 0xf220b06a00000000, + 0x4871b9f300000000, 0xde41be8400000000, 0x7dd4da1a00000000, + 0xebe4dd6d00000000, 0x51b5d4f400000000, 0xc785d38300000000, + 0x56986c1300000000, 0xc0a86b6400000000, 0x7af962fd00000000, + 0xecc9658a00000000, 0x4f5c011400000000, 0xd96c066300000000, + 0x633d0ffa00000000, 0xf50d088d00000000, 0xc8206e3b00000000, + 0x5e10694c00000000, 0xe44160d500000000, 0x727167a200000000, + 0xd1e4033c00000000, 0x47d4044b00000000, 0xfd850dd200000000, + 0x6bb50aa500000000, 0xfaa8b53500000000, 0x6c98b24200000000, + 0xd6c9bbdb00000000, 0x40f9bcac00000000, 0xe36cd83200000000, + 0x755cdf4500000000, 0xcf0dd6dc00000000, 0x593dd1ab00000000, + 0xac30d92600000000, 0x3a00de5100000000, 0x8051d7c800000000, + 0x1661d0bf00000000, 0xb5f4b42100000000, 0x23c4b35600000000, + 0x9995bacf00000000, 0x0fa5bdb800000000, 0x9eb8022800000000, + 0x0888055f00000000, 0xb2d90cc600000000, 0x24e90bb100000000, + 0x877c6f2f00000000, 0x114c685800000000, 0xab1d61c100000000, + 0x3d2d66b600000000, 0x9041dc7600000000, 0x0671db0100000000, + 0xbc20d29800000000, 0x2a10d5ef00000000, 0x8985b17100000000, + 0x1fb5b60600000000, 0xa5e4bf9f00000000, 0x33d4b8e800000000, + 0xa2c9077800000000, 0x34f9000f00000000, 0x8ea8099600000000, + 0x18980ee100000000, 0xbb0d6a7f00000000, 0x2d3d6d0800000000, + 0x976c649100000000, 0x015c63e600000000, 0xf4516b6b00000000, + 0x62616c1c00000000, 0xd830658500000000, 0x4e0062f200000000, + 0xed95066c00000000, 0x7ba5011b00000000, 0xc1f4088200000000, + 0x57c40ff500000000, 0xc6d9b06500000000, 0x50e9b71200000000, + 0xeab8be8b00000000, 0x7c88b9fc00000000, 0xdf1ddd6200000000, + 0x492dda1500000000, 0xf37cd38c00000000, 0x654cd4fb00000000, + 0x5861b24d00000000, 0xce51b53a00000000, 0x7400bca300000000, + 0xe230bbd400000000, 0x41a5df4a00000000, 0xd795d83d00000000, + 0x6dc4d1a400000000, 0xfbf4d6d300000000, 0x6ae9694300000000, + 0xfcd96e3400000000, 0x468867ad00000000, 0xd0b860da00000000, + 0x732d044400000000, 0xe51d033300000000, 0x5f4c0aaa00000000, + 0xc97c0ddd00000000, 0x3c71055000000000, 0xaa41022700000000, + 0x10100bbe00000000, 0x86200cc900000000, 0x25b5685700000000, + 0xb3856f2000000000, 0x09d466b900000000, 0x9fe461ce00000000, + 0x0ef9de5e00000000, 0x98c9d92900000000, 0x2298d0b000000000, + 0xb4a8d7c700000000, 0x173db35900000000, 0x810db42e00000000, + 0x3b5cbdb700000000, 0xad6cbac000000000, 0x2083b8ed00000000, + 0xb6b3bf9a00000000, 0x0ce2b60300000000, 0x9ad2b17400000000, + 0x3947d5ea00000000, 0xaf77d29d00000000, 0x1526db0400000000, + 0x8316dc7300000000, 0x120b63e300000000, 0x843b649400000000, + 0x3e6a6d0d00000000, 0xa85a6a7a00000000, 0x0bcf0ee400000000, + 0x9dff099300000000, 0x27ae000a00000000, 0xb19e077d00000000, + 0x44930ff000000000, 0xd2a3088700000000, 0x68f2011e00000000, + 0xfec2066900000000, 0x5d5762f700000000, 0xcb67658000000000, + 0x71366c1900000000, 0xe7066b6e00000000, 0x761bd4fe00000000, + 0xe02bd38900000000, 0x5a7ada1000000000, 0xcc4add6700000000, + 0x6fdfb9f900000000, 0xf9efbe8e00000000, 0x43beb71700000000, + 0xd58eb06000000000, 0xe8a3d6d600000000, 0x7e93d1a100000000, + 0xc4c2d83800000000, 0x52f2df4f00000000, 0xf167bbd100000000, + 0x6757bca600000000, 0xdd06b53f00000000, 0x4b36b24800000000, + 0xda2b0dd800000000, 0x4c1b0aaf00000000, 0xf64a033600000000, + 0x607a044100000000, 0xc3ef60df00000000, 0x55df67a800000000, + 0xef8e6e3100000000, 0x79be694600000000, 0x8cb361cb00000000, + 0x1a8366bc00000000, 0xa0d26f2500000000, 0x36e2685200000000, + 0x95770ccc00000000, 0x03470bbb00000000, 0xb916022200000000, + 0x2f26055500000000, 0xbe3bbac500000000, 0x280bbdb200000000, + 0x925ab42b00000000, 0x046ab35c00000000, 0xa7ffd7c200000000, + 0x31cfd0b500000000, 0x8b9ed92c00000000, 0x1daede5b00000000, + 0xb0c2649b00000000, 0x26f263ec00000000, 0x9ca36a7500000000, + 0x0a936d0200000000, 0xa906099c00000000, 0x3f360eeb00000000, + 0x8567077200000000, 0x1357000500000000, 0x824abf9500000000, + 0x147ab8e200000000, 0xae2bb17b00000000, 0x381bb60c00000000, + 0x9b8ed29200000000, 0x0dbed5e500000000, 0xb7efdc7c00000000, + 0x21dfdb0b00000000, 0xd4d2d38600000000, 0x42e2d4f100000000, + 0xf8b3dd6800000000, 0x6e83da1f00000000, 0xcd16be8100000000, + 0x5b26b9f600000000, 0xe177b06f00000000, 0x7747b71800000000, + 0xe65a088800000000, 0x706a0fff00000000, 0xca3b066600000000, + 0x5c0b011100000000, 0xff9e658f00000000, 0x69ae62f800000000, + 0xd3ff6b6100000000, 0x45cf6c1600000000, 0x78e20aa000000000, + 0xeed20dd700000000, 0x5483044e00000000, 0xc2b3033900000000, + 0x612667a700000000, 0xf71660d000000000, 0x4d47694900000000, + 0xdb776e3e00000000, 0x4a6ad1ae00000000, 0xdc5ad6d900000000, + 0x660bdf4000000000, 0xf03bd83700000000, 0x53aebca900000000, + 0xc59ebbde00000000, 0x7fcfb24700000000, 0xe9ffb53000000000, + 0x1cf2bdbd00000000, 0x8ac2baca00000000, 0x3093b35300000000, + 0xa6a3b42400000000, 0x0536d0ba00000000, 0x9306d7cd00000000, + 0x2957de5400000000, 0xbf67d92300000000, 0x2e7a66b300000000, + 0xb84a61c400000000, 0x021b685d00000000, 0x942b6f2a00000000, + 0x37be0bb400000000, 0xa18e0cc300000000, 0x1bdf055a00000000, + 0x8def022d00000000}; + +#else /* W == 4 */ + +local const z_word_t FAR crc_big_table[] = { + 0x00000000, 0x96300777, 0x2c610eee, 0xba510999, 0x19c46d07, + 0x8ff46a70, 0x35a563e9, 0xa395649e, 0x3288db0e, 0xa4b8dc79, + 0x1ee9d5e0, 0x88d9d297, 0x2b4cb609, 0xbd7cb17e, 0x072db8e7, + 0x911dbf90, 0x6410b71d, 0xf220b06a, 0x4871b9f3, 0xde41be84, + 0x7dd4da1a, 0xebe4dd6d, 0x51b5d4f4, 0xc785d383, 0x56986c13, + 0xc0a86b64, 0x7af962fd, 0xecc9658a, 0x4f5c0114, 0xd96c0663, + 0x633d0ffa, 0xf50d088d, 0xc8206e3b, 0x5e10694c, 0xe44160d5, + 0x727167a2, 0xd1e4033c, 0x47d4044b, 0xfd850dd2, 0x6bb50aa5, + 0xfaa8b535, 0x6c98b242, 0xd6c9bbdb, 0x40f9bcac, 0xe36cd832, + 0x755cdf45, 0xcf0dd6dc, 0x593dd1ab, 0xac30d926, 0x3a00de51, + 0x8051d7c8, 0x1661d0bf, 0xb5f4b421, 0x23c4b356, 0x9995bacf, + 0x0fa5bdb8, 0x9eb80228, 0x0888055f, 0xb2d90cc6, 0x24e90bb1, + 0x877c6f2f, 0x114c6858, 0xab1d61c1, 0x3d2d66b6, 0x9041dc76, + 0x0671db01, 0xbc20d298, 0x2a10d5ef, 0x8985b171, 0x1fb5b606, + 0xa5e4bf9f, 0x33d4b8e8, 0xa2c90778, 0x34f9000f, 0x8ea80996, + 0x18980ee1, 0xbb0d6a7f, 0x2d3d6d08, 0x976c6491, 0x015c63e6, + 0xf4516b6b, 0x62616c1c, 0xd8306585, 0x4e0062f2, 0xed95066c, + 0x7ba5011b, 0xc1f40882, 0x57c40ff5, 0xc6d9b065, 0x50e9b712, + 0xeab8be8b, 0x7c88b9fc, 0xdf1ddd62, 0x492dda15, 0xf37cd38c, + 0x654cd4fb, 0x5861b24d, 0xce51b53a, 0x7400bca3, 0xe230bbd4, + 0x41a5df4a, 0xd795d83d, 0x6dc4d1a4, 0xfbf4d6d3, 0x6ae96943, + 0xfcd96e34, 0x468867ad, 0xd0b860da, 0x732d0444, 0xe51d0333, + 0x5f4c0aaa, 0xc97c0ddd, 0x3c710550, 0xaa410227, 0x10100bbe, + 0x86200cc9, 0x25b56857, 0xb3856f20, 0x09d466b9, 0x9fe461ce, + 0x0ef9de5e, 0x98c9d929, 0x2298d0b0, 0xb4a8d7c7, 0x173db359, + 0x810db42e, 0x3b5cbdb7, 0xad6cbac0, 0x2083b8ed, 0xb6b3bf9a, + 0x0ce2b603, 0x9ad2b174, 0x3947d5ea, 0xaf77d29d, 0x1526db04, + 0x8316dc73, 0x120b63e3, 0x843b6494, 0x3e6a6d0d, 0xa85a6a7a, + 0x0bcf0ee4, 0x9dff0993, 0x27ae000a, 0xb19e077d, 0x44930ff0, + 0xd2a30887, 0x68f2011e, 0xfec20669, 0x5d5762f7, 0xcb676580, + 0x71366c19, 0xe7066b6e, 0x761bd4fe, 0xe02bd389, 0x5a7ada10, + 0xcc4add67, 0x6fdfb9f9, 0xf9efbe8e, 0x43beb717, 0xd58eb060, + 0xe8a3d6d6, 0x7e93d1a1, 0xc4c2d838, 0x52f2df4f, 0xf167bbd1, + 0x6757bca6, 0xdd06b53f, 0x4b36b248, 0xda2b0dd8, 0x4c1b0aaf, + 0xf64a0336, 0x607a0441, 0xc3ef60df, 0x55df67a8, 0xef8e6e31, + 0x79be6946, 0x8cb361cb, 0x1a8366bc, 0xa0d26f25, 0x36e26852, + 0x95770ccc, 0x03470bbb, 0xb9160222, 0x2f260555, 0xbe3bbac5, + 0x280bbdb2, 0x925ab42b, 0x046ab35c, 0xa7ffd7c2, 0x31cfd0b5, + 0x8b9ed92c, 0x1daede5b, 0xb0c2649b, 0x26f263ec, 0x9ca36a75, + 0x0a936d02, 0xa906099c, 0x3f360eeb, 0x85670772, 0x13570005, + 0x824abf95, 0x147ab8e2, 0xae2bb17b, 0x381bb60c, 0x9b8ed292, + 0x0dbed5e5, 0xb7efdc7c, 0x21dfdb0b, 0xd4d2d386, 0x42e2d4f1, + 0xf8b3dd68, 0x6e83da1f, 0xcd16be81, 0x5b26b9f6, 0xe177b06f, + 0x7747b718, 0xe65a0888, 0x706a0fff, 0xca3b0666, 0x5c0b0111, + 0xff9e658f, 0x69ae62f8, 0xd3ff6b61, 0x45cf6c16, 0x78e20aa0, + 0xeed20dd7, 0x5483044e, 0xc2b30339, 0x612667a7, 0xf71660d0, + 0x4d476949, 0xdb776e3e, 0x4a6ad1ae, 0xdc5ad6d9, 0x660bdf40, + 0xf03bd837, 0x53aebca9, 0xc59ebbde, 0x7fcfb247, 0xe9ffb530, + 0x1cf2bdbd, 0x8ac2baca, 0x3093b353, 0xa6a3b424, 0x0536d0ba, + 0x9306d7cd, 0x2957de54, 0xbf67d923, 0x2e7a66b3, 0xb84a61c4, + 0x021b685d, 0x942b6f2a, 0x37be0bb4, 0xa18e0cc3, 0x1bdf055a, + 0x8def022d}; + +#endif + +#if N == 1 + +#if W == 8 + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xccaa009e, 0x4225077d, 0x8e8f07e3, 0x844a0efa, + 0x48e00e64, 0xc66f0987, 0x0ac50919, 0xd3e51bb5, 0x1f4f1b2b, + 0x91c01cc8, 0x5d6a1c56, 0x57af154f, 0x9b0515d1, 0x158a1232, + 0xd92012ac, 0x7cbb312b, 0xb01131b5, 0x3e9e3656, 0xf23436c8, + 0xf8f13fd1, 0x345b3f4f, 0xbad438ac, 0x767e3832, 0xaf5e2a9e, + 0x63f42a00, 0xed7b2de3, 0x21d12d7d, 0x2b142464, 0xe7be24fa, + 0x69312319, 0xa59b2387, 0xf9766256, 0x35dc62c8, 0xbb53652b, + 0x77f965b5, 0x7d3c6cac, 0xb1966c32, 0x3f196bd1, 0xf3b36b4f, + 0x2a9379e3, 0xe639797d, 0x68b67e9e, 0xa41c7e00, 0xaed97719, + 0x62737787, 0xecfc7064, 0x205670fa, 0x85cd537d, 0x496753e3, + 0xc7e85400, 0x0b42549e, 0x01875d87, 0xcd2d5d19, 0x43a25afa, + 0x8f085a64, 0x562848c8, 0x9a824856, 0x140d4fb5, 0xd8a74f2b, + 0xd2624632, 0x1ec846ac, 0x9047414f, 0x5ced41d1, 0x299dc2ed, + 0xe537c273, 0x6bb8c590, 0xa712c50e, 0xadd7cc17, 0x617dcc89, + 0xeff2cb6a, 0x2358cbf4, 0xfa78d958, 0x36d2d9c6, 0xb85dde25, + 0x74f7debb, 0x7e32d7a2, 0xb298d73c, 0x3c17d0df, 0xf0bdd041, + 0x5526f3c6, 0x998cf358, 0x1703f4bb, 0xdba9f425, 0xd16cfd3c, + 0x1dc6fda2, 0x9349fa41, 0x5fe3fadf, 0x86c3e873, 0x4a69e8ed, + 0xc4e6ef0e, 0x084cef90, 0x0289e689, 0xce23e617, 0x40ace1f4, + 0x8c06e16a, 0xd0eba0bb, 0x1c41a025, 0x92cea7c6, 0x5e64a758, + 0x54a1ae41, 0x980baedf, 0x1684a93c, 0xda2ea9a2, 0x030ebb0e, + 0xcfa4bb90, 0x412bbc73, 0x8d81bced, 0x8744b5f4, 0x4beeb56a, + 0xc561b289, 0x09cbb217, 0xac509190, 0x60fa910e, 0xee7596ed, + 0x22df9673, 0x281a9f6a, 0xe4b09ff4, 0x6a3f9817, 0xa6959889, + 0x7fb58a25, 0xb31f8abb, 0x3d908d58, 0xf13a8dc6, 0xfbff84df, + 0x37558441, 0xb9da83a2, 0x7570833c, 0x533b85da, 0x9f918544, + 0x111e82a7, 0xddb48239, 0xd7718b20, 0x1bdb8bbe, 0x95548c5d, + 0x59fe8cc3, 0x80de9e6f, 0x4c749ef1, 0xc2fb9912, 0x0e51998c, + 0x04949095, 0xc83e900b, 0x46b197e8, 0x8a1b9776, 0x2f80b4f1, + 0xe32ab46f, 0x6da5b38c, 0xa10fb312, 0xabcaba0b, 0x6760ba95, + 0xe9efbd76, 0x2545bde8, 0xfc65af44, 0x30cfafda, 0xbe40a839, + 0x72eaa8a7, 0x782fa1be, 0xb485a120, 0x3a0aa6c3, 0xf6a0a65d, + 0xaa4de78c, 0x66e7e712, 0xe868e0f1, 0x24c2e06f, 0x2e07e976, + 0xe2ade9e8, 0x6c22ee0b, 0xa088ee95, 0x79a8fc39, 0xb502fca7, + 0x3b8dfb44, 0xf727fbda, 0xfde2f2c3, 0x3148f25d, 0xbfc7f5be, + 0x736df520, 0xd6f6d6a7, 0x1a5cd639, 0x94d3d1da, 0x5879d144, + 0x52bcd85d, 0x9e16d8c3, 0x1099df20, 0xdc33dfbe, 0x0513cd12, + 0xc9b9cd8c, 0x4736ca6f, 0x8b9ccaf1, 0x8159c3e8, 0x4df3c376, + 0xc37cc495, 0x0fd6c40b, 0x7aa64737, 0xb60c47a9, 0x3883404a, + 0xf42940d4, 0xfeec49cd, 0x32464953, 0xbcc94eb0, 0x70634e2e, + 0xa9435c82, 0x65e95c1c, 0xeb665bff, 0x27cc5b61, 0x2d095278, + 0xe1a352e6, 0x6f2c5505, 0xa386559b, 0x061d761c, 0xcab77682, + 0x44387161, 0x889271ff, 0x825778e6, 0x4efd7878, 0xc0727f9b, + 0x0cd87f05, 0xd5f86da9, 0x19526d37, 0x97dd6ad4, 0x5b776a4a, + 0x51b26353, 0x9d1863cd, 0x1397642e, 0xdf3d64b0, 0x83d02561, + 0x4f7a25ff, 0xc1f5221c, 0x0d5f2282, 0x079a2b9b, 0xcb302b05, + 0x45bf2ce6, 0x89152c78, 0x50353ed4, 0x9c9f3e4a, 0x121039a9, + 0xdeba3937, 0xd47f302e, 0x18d530b0, 0x965a3753, 0x5af037cd, + 0xff6b144a, 0x33c114d4, 0xbd4e1337, 0x71e413a9, 0x7b211ab0, + 0xb78b1a2e, 0x39041dcd, 0xf5ae1d53, 0x2c8e0fff, 0xe0240f61, + 0x6eab0882, 0xa201081c, 0xa8c40105, 0x646e019b, 0xeae10678, + 0x264b06e6}, + {0x00000000, 0xa6770bb4, 0x979f1129, 0x31e81a9d, 0xf44f2413, + 0x52382fa7, 0x63d0353a, 0xc5a73e8e, 0x33ef4e67, 0x959845d3, + 0xa4705f4e, 0x020754fa, 0xc7a06a74, 0x61d761c0, 0x503f7b5d, + 0xf64870e9, 0x67de9cce, 0xc1a9977a, 0xf0418de7, 0x56368653, + 0x9391b8dd, 0x35e6b369, 0x040ea9f4, 0xa279a240, 0x5431d2a9, + 0xf246d91d, 0xc3aec380, 0x65d9c834, 0xa07ef6ba, 0x0609fd0e, + 0x37e1e793, 0x9196ec27, 0xcfbd399c, 0x69ca3228, 0x582228b5, + 0xfe552301, 0x3bf21d8f, 0x9d85163b, 0xac6d0ca6, 0x0a1a0712, + 0xfc5277fb, 0x5a257c4f, 0x6bcd66d2, 0xcdba6d66, 0x081d53e8, + 0xae6a585c, 0x9f8242c1, 0x39f54975, 0xa863a552, 0x0e14aee6, + 0x3ffcb47b, 0x998bbfcf, 0x5c2c8141, 0xfa5b8af5, 0xcbb39068, + 0x6dc49bdc, 0x9b8ceb35, 0x3dfbe081, 0x0c13fa1c, 0xaa64f1a8, + 0x6fc3cf26, 0xc9b4c492, 0xf85cde0f, 0x5e2bd5bb, 0x440b7579, + 0xe27c7ecd, 0xd3946450, 0x75e36fe4, 0xb044516a, 0x16335ade, + 0x27db4043, 0x81ac4bf7, 0x77e43b1e, 0xd19330aa, 0xe07b2a37, + 0x460c2183, 0x83ab1f0d, 0x25dc14b9, 0x14340e24, 0xb2430590, + 0x23d5e9b7, 0x85a2e203, 0xb44af89e, 0x123df32a, 0xd79acda4, + 0x71edc610, 0x4005dc8d, 0xe672d739, 0x103aa7d0, 0xb64dac64, + 0x87a5b6f9, 0x21d2bd4d, 0xe47583c3, 0x42028877, 0x73ea92ea, + 0xd59d995e, 0x8bb64ce5, 0x2dc14751, 0x1c295dcc, 0xba5e5678, + 0x7ff968f6, 0xd98e6342, 0xe86679df, 0x4e11726b, 0xb8590282, + 0x1e2e0936, 0x2fc613ab, 0x89b1181f, 0x4c162691, 0xea612d25, + 0xdb8937b8, 0x7dfe3c0c, 0xec68d02b, 0x4a1fdb9f, 0x7bf7c102, + 0xdd80cab6, 0x1827f438, 0xbe50ff8c, 0x8fb8e511, 0x29cfeea5, + 0xdf879e4c, 0x79f095f8, 0x48188f65, 0xee6f84d1, 0x2bc8ba5f, + 0x8dbfb1eb, 0xbc57ab76, 0x1a20a0c2, 0x8816eaf2, 0x2e61e146, + 0x1f89fbdb, 0xb9fef06f, 0x7c59cee1, 0xda2ec555, 0xebc6dfc8, + 0x4db1d47c, 0xbbf9a495, 0x1d8eaf21, 0x2c66b5bc, 0x8a11be08, + 0x4fb68086, 0xe9c18b32, 0xd82991af, 0x7e5e9a1b, 0xefc8763c, + 0x49bf7d88, 0x78576715, 0xde206ca1, 0x1b87522f, 0xbdf0599b, + 0x8c184306, 0x2a6f48b2, 0xdc27385b, 0x7a5033ef, 0x4bb82972, + 0xedcf22c6, 0x28681c48, 0x8e1f17fc, 0xbff70d61, 0x198006d5, + 0x47abd36e, 0xe1dcd8da, 0xd034c247, 0x7643c9f3, 0xb3e4f77d, + 0x1593fcc9, 0x247be654, 0x820cede0, 0x74449d09, 0xd23396bd, + 0xe3db8c20, 0x45ac8794, 0x800bb91a, 0x267cb2ae, 0x1794a833, + 0xb1e3a387, 0x20754fa0, 0x86024414, 0xb7ea5e89, 0x119d553d, + 0xd43a6bb3, 0x724d6007, 0x43a57a9a, 0xe5d2712e, 0x139a01c7, + 0xb5ed0a73, 0x840510ee, 0x22721b5a, 0xe7d525d4, 0x41a22e60, + 0x704a34fd, 0xd63d3f49, 0xcc1d9f8b, 0x6a6a943f, 0x5b828ea2, + 0xfdf58516, 0x3852bb98, 0x9e25b02c, 0xafcdaab1, 0x09baa105, + 0xfff2d1ec, 0x5985da58, 0x686dc0c5, 0xce1acb71, 0x0bbdf5ff, + 0xadcafe4b, 0x9c22e4d6, 0x3a55ef62, 0xabc30345, 0x0db408f1, + 0x3c5c126c, 0x9a2b19d8, 0x5f8c2756, 0xf9fb2ce2, 0xc813367f, + 0x6e643dcb, 0x982c4d22, 0x3e5b4696, 0x0fb35c0b, 0xa9c457bf, + 0x6c636931, 0xca146285, 0xfbfc7818, 0x5d8b73ac, 0x03a0a617, + 0xa5d7ada3, 0x943fb73e, 0x3248bc8a, 0xf7ef8204, 0x519889b0, + 0x6070932d, 0xc6079899, 0x304fe870, 0x9638e3c4, 0xa7d0f959, + 0x01a7f2ed, 0xc400cc63, 0x6277c7d7, 0x539fdd4a, 0xf5e8d6fe, + 0x647e3ad9, 0xc209316d, 0xf3e12bf0, 0x55962044, 0x90311eca, + 0x3646157e, 0x07ae0fe3, 0xa1d90457, 0x579174be, 0xf1e67f0a, + 0xc00e6597, 0x66796e23, 0xa3de50ad, 0x05a95b19, 0x34414184, + 0x92364a30}, + {0x00000000, 0xcb5cd3a5, 0x4dc8a10b, 0x869472ae, 0x9b914216, + 0x50cd91b3, 0xd659e31d, 0x1d0530b8, 0xec53826d, 0x270f51c8, + 0xa19b2366, 0x6ac7f0c3, 0x77c2c07b, 0xbc9e13de, 0x3a0a6170, + 0xf156b2d5, 0x03d6029b, 0xc88ad13e, 0x4e1ea390, 0x85427035, + 0x9847408d, 0x531b9328, 0xd58fe186, 0x1ed33223, 0xef8580f6, + 0x24d95353, 0xa24d21fd, 0x6911f258, 0x7414c2e0, 0xbf481145, + 0x39dc63eb, 0xf280b04e, 0x07ac0536, 0xccf0d693, 0x4a64a43d, + 0x81387798, 0x9c3d4720, 0x57619485, 0xd1f5e62b, 0x1aa9358e, + 0xebff875b, 0x20a354fe, 0xa6372650, 0x6d6bf5f5, 0x706ec54d, + 0xbb3216e8, 0x3da66446, 0xf6fab7e3, 0x047a07ad, 0xcf26d408, + 0x49b2a6a6, 0x82ee7503, 0x9feb45bb, 0x54b7961e, 0xd223e4b0, + 0x197f3715, 0xe82985c0, 0x23755665, 0xa5e124cb, 0x6ebdf76e, + 0x73b8c7d6, 0xb8e41473, 0x3e7066dd, 0xf52cb578, 0x0f580a6c, + 0xc404d9c9, 0x4290ab67, 0x89cc78c2, 0x94c9487a, 0x5f959bdf, + 0xd901e971, 0x125d3ad4, 0xe30b8801, 0x28575ba4, 0xaec3290a, + 0x659ffaaf, 0x789aca17, 0xb3c619b2, 0x35526b1c, 0xfe0eb8b9, + 0x0c8e08f7, 0xc7d2db52, 0x4146a9fc, 0x8a1a7a59, 0x971f4ae1, + 0x5c439944, 0xdad7ebea, 0x118b384f, 0xe0dd8a9a, 0x2b81593f, + 0xad152b91, 0x6649f834, 0x7b4cc88c, 0xb0101b29, 0x36846987, + 0xfdd8ba22, 0x08f40f5a, 0xc3a8dcff, 0x453cae51, 0x8e607df4, + 0x93654d4c, 0x58399ee9, 0xdeadec47, 0x15f13fe2, 0xe4a78d37, + 0x2ffb5e92, 0xa96f2c3c, 0x6233ff99, 0x7f36cf21, 0xb46a1c84, + 0x32fe6e2a, 0xf9a2bd8f, 0x0b220dc1, 0xc07ede64, 0x46eaacca, + 0x8db67f6f, 0x90b34fd7, 0x5bef9c72, 0xdd7beedc, 0x16273d79, + 0xe7718fac, 0x2c2d5c09, 0xaab92ea7, 0x61e5fd02, 0x7ce0cdba, + 0xb7bc1e1f, 0x31286cb1, 0xfa74bf14, 0x1eb014d8, 0xd5ecc77d, + 0x5378b5d3, 0x98246676, 0x852156ce, 0x4e7d856b, 0xc8e9f7c5, + 0x03b52460, 0xf2e396b5, 0x39bf4510, 0xbf2b37be, 0x7477e41b, + 0x6972d4a3, 0xa22e0706, 0x24ba75a8, 0xefe6a60d, 0x1d661643, + 0xd63ac5e6, 0x50aeb748, 0x9bf264ed, 0x86f75455, 0x4dab87f0, + 0xcb3ff55e, 0x006326fb, 0xf135942e, 0x3a69478b, 0xbcfd3525, + 0x77a1e680, 0x6aa4d638, 0xa1f8059d, 0x276c7733, 0xec30a496, + 0x191c11ee, 0xd240c24b, 0x54d4b0e5, 0x9f886340, 0x828d53f8, + 0x49d1805d, 0xcf45f2f3, 0x04192156, 0xf54f9383, 0x3e134026, + 0xb8873288, 0x73dbe12d, 0x6eded195, 0xa5820230, 0x2316709e, + 0xe84aa33b, 0x1aca1375, 0xd196c0d0, 0x5702b27e, 0x9c5e61db, + 0x815b5163, 0x4a0782c6, 0xcc93f068, 0x07cf23cd, 0xf6999118, + 0x3dc542bd, 0xbb513013, 0x700de3b6, 0x6d08d30e, 0xa65400ab, + 0x20c07205, 0xeb9ca1a0, 0x11e81eb4, 0xdab4cd11, 0x5c20bfbf, + 0x977c6c1a, 0x8a795ca2, 0x41258f07, 0xc7b1fda9, 0x0ced2e0c, + 0xfdbb9cd9, 0x36e74f7c, 0xb0733dd2, 0x7b2fee77, 0x662adecf, + 0xad760d6a, 0x2be27fc4, 0xe0beac61, 0x123e1c2f, 0xd962cf8a, + 0x5ff6bd24, 0x94aa6e81, 0x89af5e39, 0x42f38d9c, 0xc467ff32, + 0x0f3b2c97, 0xfe6d9e42, 0x35314de7, 0xb3a53f49, 0x78f9ecec, + 0x65fcdc54, 0xaea00ff1, 0x28347d5f, 0xe368aefa, 0x16441b82, + 0xdd18c827, 0x5b8cba89, 0x90d0692c, 0x8dd55994, 0x46898a31, + 0xc01df89f, 0x0b412b3a, 0xfa1799ef, 0x314b4a4a, 0xb7df38e4, + 0x7c83eb41, 0x6186dbf9, 0xaada085c, 0x2c4e7af2, 0xe712a957, + 0x15921919, 0xdececabc, 0x585ab812, 0x93066bb7, 0x8e035b0f, + 0x455f88aa, 0xc3cbfa04, 0x089729a1, 0xf9c19b74, 0x329d48d1, + 0xb4093a7f, 0x7f55e9da, 0x6250d962, 0xa90c0ac7, 0x2f987869, + 0xe4c4abcc}, + {0x00000000, 0x3d6029b0, 0x7ac05360, 0x47a07ad0, 0xf580a6c0, + 0xc8e08f70, 0x8f40f5a0, 0xb220dc10, 0x30704bc1, 0x0d106271, + 0x4ab018a1, 0x77d03111, 0xc5f0ed01, 0xf890c4b1, 0xbf30be61, + 0x825097d1, 0x60e09782, 0x5d80be32, 0x1a20c4e2, 0x2740ed52, + 0x95603142, 0xa80018f2, 0xefa06222, 0xd2c04b92, 0x5090dc43, + 0x6df0f5f3, 0x2a508f23, 0x1730a693, 0xa5107a83, 0x98705333, + 0xdfd029e3, 0xe2b00053, 0xc1c12f04, 0xfca106b4, 0xbb017c64, + 0x866155d4, 0x344189c4, 0x0921a074, 0x4e81daa4, 0x73e1f314, + 0xf1b164c5, 0xccd14d75, 0x8b7137a5, 0xb6111e15, 0x0431c205, + 0x3951ebb5, 0x7ef19165, 0x4391b8d5, 0xa121b886, 0x9c419136, + 0xdbe1ebe6, 0xe681c256, 0x54a11e46, 0x69c137f6, 0x2e614d26, + 0x13016496, 0x9151f347, 0xac31daf7, 0xeb91a027, 0xd6f18997, + 0x64d15587, 0x59b17c37, 0x1e1106e7, 0x23712f57, 0x58f35849, + 0x659371f9, 0x22330b29, 0x1f532299, 0xad73fe89, 0x9013d739, + 0xd7b3ade9, 0xead38459, 0x68831388, 0x55e33a38, 0x124340e8, + 0x2f236958, 0x9d03b548, 0xa0639cf8, 0xe7c3e628, 0xdaa3cf98, + 0x3813cfcb, 0x0573e67b, 0x42d39cab, 0x7fb3b51b, 0xcd93690b, + 0xf0f340bb, 0xb7533a6b, 0x8a3313db, 0x0863840a, 0x3503adba, + 0x72a3d76a, 0x4fc3feda, 0xfde322ca, 0xc0830b7a, 0x872371aa, + 0xba43581a, 0x9932774d, 0xa4525efd, 0xe3f2242d, 0xde920d9d, + 0x6cb2d18d, 0x51d2f83d, 0x167282ed, 0x2b12ab5d, 0xa9423c8c, + 0x9422153c, 0xd3826fec, 0xeee2465c, 0x5cc29a4c, 0x61a2b3fc, + 0x2602c92c, 0x1b62e09c, 0xf9d2e0cf, 0xc4b2c97f, 0x8312b3af, + 0xbe729a1f, 0x0c52460f, 0x31326fbf, 0x7692156f, 0x4bf23cdf, + 0xc9a2ab0e, 0xf4c282be, 0xb362f86e, 0x8e02d1de, 0x3c220dce, + 0x0142247e, 0x46e25eae, 0x7b82771e, 0xb1e6b092, 0x8c869922, + 0xcb26e3f2, 0xf646ca42, 0x44661652, 0x79063fe2, 0x3ea64532, + 0x03c66c82, 0x8196fb53, 0xbcf6d2e3, 0xfb56a833, 0xc6368183, + 0x74165d93, 0x49767423, 0x0ed60ef3, 0x33b62743, 0xd1062710, + 0xec660ea0, 0xabc67470, 0x96a65dc0, 0x248681d0, 0x19e6a860, + 0x5e46d2b0, 0x6326fb00, 0xe1766cd1, 0xdc164561, 0x9bb63fb1, + 0xa6d61601, 0x14f6ca11, 0x2996e3a1, 0x6e369971, 0x5356b0c1, + 0x70279f96, 0x4d47b626, 0x0ae7ccf6, 0x3787e546, 0x85a73956, + 0xb8c710e6, 0xff676a36, 0xc2074386, 0x4057d457, 0x7d37fde7, + 0x3a978737, 0x07f7ae87, 0xb5d77297, 0x88b75b27, 0xcf1721f7, + 0xf2770847, 0x10c70814, 0x2da721a4, 0x6a075b74, 0x576772c4, + 0xe547aed4, 0xd8278764, 0x9f87fdb4, 0xa2e7d404, 0x20b743d5, + 0x1dd76a65, 0x5a7710b5, 0x67173905, 0xd537e515, 0xe857cca5, + 0xaff7b675, 0x92979fc5, 0xe915e8db, 0xd475c16b, 0x93d5bbbb, + 0xaeb5920b, 0x1c954e1b, 0x21f567ab, 0x66551d7b, 0x5b3534cb, + 0xd965a31a, 0xe4058aaa, 0xa3a5f07a, 0x9ec5d9ca, 0x2ce505da, + 0x11852c6a, 0x562556ba, 0x6b457f0a, 0x89f57f59, 0xb49556e9, + 0xf3352c39, 0xce550589, 0x7c75d999, 0x4115f029, 0x06b58af9, + 0x3bd5a349, 0xb9853498, 0x84e51d28, 0xc34567f8, 0xfe254e48, + 0x4c059258, 0x7165bbe8, 0x36c5c138, 0x0ba5e888, 0x28d4c7df, + 0x15b4ee6f, 0x521494bf, 0x6f74bd0f, 0xdd54611f, 0xe03448af, + 0xa794327f, 0x9af41bcf, 0x18a48c1e, 0x25c4a5ae, 0x6264df7e, + 0x5f04f6ce, 0xed242ade, 0xd044036e, 0x97e479be, 0xaa84500e, + 0x4834505d, 0x755479ed, 0x32f4033d, 0x0f942a8d, 0xbdb4f69d, + 0x80d4df2d, 0xc774a5fd, 0xfa148c4d, 0x78441b9c, 0x4524322c, + 0x028448fc, 0x3fe4614c, 0x8dc4bd5c, 0xb0a494ec, 0xf704ee3c, + 0xca64c78c}, + {0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, 0x8f629757, + 0x37def032, 0x256b5fdc, 0x9dd738b9, 0xc5b428ef, 0x7d084f8a, + 0x6fbde064, 0xd7018701, 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, + 0x58631056, 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, + 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26, 0x95ad7f70, + 0x2d111815, 0x3fa4b7fb, 0x8718d09e, 0x1acfe827, 0xa2738f42, + 0xb0c620ac, 0x087a47c9, 0xa032af3e, 0x188ec85b, 0x0a3b67b5, + 0xb28700d0, 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, + 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f, 0xeae41086, + 0x525877e3, 0x40edd80d, 0xf851bf68, 0xf02bf8a1, 0x48979fc4, + 0x5a22302a, 0xe29e574f, 0x7f496ff6, 0xc7f50893, 0xd540a77d, + 0x6dfcc018, 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, + 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7, 0x9b14583d, + 0x23a83f58, 0x311d90b6, 0x89a1f7d3, 0x1476cf6a, 0xaccaa80f, + 0xbe7f07e1, 0x06c36084, 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, + 0x4c15df3c, 0xd1c2e785, 0x697e80e0, 0x7bcb2f0e, 0xc377486b, + 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c, 0x446f98f5, + 0xfcd3ff90, 0xee66507e, 0x56da371b, 0x0eb9274d, 0xb6054028, + 0xa4b0efc6, 0x1c0c88a3, 0x81dbb01a, 0x3967d77f, 0x2bd27891, + 0x936e1ff4, 0x3b26f703, 0x839a9066, 0x912f3f88, 0x299358ed, + 0xb4446054, 0x0cf80731, 0x1e4da8df, 0xa6f1cfba, 0xfe92dfec, + 0x462eb889, 0x549b1767, 0xec277002, 0x71f048bb, 0xc94c2fde, + 0xdbf98030, 0x6345e755, 0x6b3fa09c, 0xd383c7f9, 0xc1366817, + 0x798a0f72, 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825, + 0xae8b8873, 0x1637ef16, 0x048240f8, 0xbc3e279d, 0x21e91f24, + 0x99557841, 0x8be0d7af, 0x335cb0ca, 0xed59b63b, 0x55e5d15e, + 0x47507eb0, 0xffec19d5, 0x623b216c, 0xda874609, 0xc832e9e7, + 0x708e8e82, 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a, + 0xa78f0983, 0x1f336ee6, 0x0d86c108, 0xb53aa66d, 0xbd40e1a4, + 0x05fc86c1, 0x1749292f, 0xaff54e4a, 0x322276f3, 0x8a9e1196, + 0x982bbe78, 0x2097d91d, 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, + 0x6a4166a5, 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2, + 0x4d6b1905, 0xf5d77e60, 0xe762d18e, 0x5fdeb6eb, 0xc2098e52, + 0x7ab5e937, 0x680046d9, 0xd0bc21bc, 0x88df31ea, 0x3063568f, + 0x22d6f961, 0x9a6a9e04, 0x07bda6bd, 0xbf01c1d8, 0xadb46e36, + 0x15080953, 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0x0fc7e174, + 0x9210d9cd, 0x2aacbea8, 0x38191146, 0x80a57623, 0xd8c66675, + 0x607a0110, 0x72cfaefe, 0xca73c99b, 0x57a4f122, 0xef189647, + 0xfdad39a9, 0x45115ecc, 0x764dee06, 0xcef18963, 0xdc44268d, + 0x64f841e8, 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf, + 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907, 0x3c9b51be, + 0x842736db, 0x96929935, 0x2e2efe50, 0x2654b999, 0x9ee8defc, + 0x8c5d7112, 0x34e11677, 0xa9362ece, 0x118a49ab, 0x033fe645, + 0xbb838120, 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98, + 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf, 0xd67f4138, + 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, 0x591dd66f, 0xe1a1b10a, + 0xf3141ee4, 0x4ba87981, 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, + 0x017ec639, 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e, + 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, 0x090481f0, + 0xb1b8e695, 0xa30d497b, 0x1bb12e1e, 0x43d23e48, 0xfb6e592d, + 0xe9dbf6c3, 0x516791a6, 0xccb0a91f, 0x740cce7a, 0x66b96194, + 0xde0506f1}, + {0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59, 0x0709a8dc, + 0x06cbc2eb, 0x048d7cb2, 0x054f1685, 0x0e1351b8, 0x0fd13b8f, + 0x0d9785d6, 0x0c55efe1, 0x091af964, 0x08d89353, 0x0a9e2d0a, + 0x0b5c473d, 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29, + 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, 0x1235f2c8, + 0x13f798ff, 0x11b126a6, 0x10734c91, 0x153c5a14, 0x14fe3023, + 0x16b88e7a, 0x177ae44d, 0x384d46e0, 0x398f2cd7, 0x3bc9928e, + 0x3a0bf8b9, 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065, + 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, 0x3157bf84, + 0x3095d5b3, 0x32d36bea, 0x331101dd, 0x246be590, 0x25a98fa7, + 0x27ef31fe, 0x262d5bc9, 0x23624d4c, 0x22a0277b, 0x20e69922, + 0x2124f315, 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71, + 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad, 0x709a8dc0, + 0x7158e7f7, 0x731e59ae, 0x72dc3399, 0x7793251c, 0x76514f2b, + 0x7417f172, 0x75d59b45, 0x7e89dc78, 0x7f4bb64f, 0x7d0d0816, + 0x7ccf6221, 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd, + 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9, 0x6bb5866c, + 0x6a77ec5b, 0x68315202, 0x69f33835, 0x62af7f08, 0x636d153f, + 0x612bab66, 0x60e9c151, 0x65a6d7d4, 0x6464bde3, 0x662203ba, + 0x67e0698d, 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579, + 0x4fde63fc, 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5, 0x46c49a98, + 0x4706f0af, 0x45404ef6, 0x448224c1, 0x41cd3244, 0x400f5873, + 0x4249e62a, 0x438b8c1d, 0x54f16850, 0x55330267, 0x5775bc3e, + 0x56b7d609, 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5, + 0x5ae239e8, 0x5b2053df, 0x5966ed86, 0x58a487b1, 0x5deb9134, + 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d, 0xe1351b80, 0xe0f771b7, + 0xe2b1cfee, 0xe373a5d9, 0xe63cb35c, 0xe7fed96b, 0xe5b86732, + 0xe47a0d05, 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461, + 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, 0xea695cbd, 0xfd13b8f0, + 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9, 0xfa1a102c, 0xfbd87a1b, + 0xf99ec442, 0xf85cae75, 0xf300e948, 0xf2c2837f, 0xf0843d26, + 0xf1465711, 0xf4094194, 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd, + 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339, 0xde71f5bc, + 0xdfb39f8b, 0xddf521d2, 0xdc374be5, 0xd76b0cd8, 0xd6a966ef, + 0xd4efd8b6, 0xd52db281, 0xd062a404, 0xd1a0ce33, 0xd3e6706a, + 0xd2241a5d, 0xc55efe10, 0xc49c9427, 0xc6da2a7e, 0xc7184049, + 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895, 0xcb4dafa8, + 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1, 0xcc440774, 0xcd866d43, + 0xcfc0d31a, 0xce02b92d, 0x91af9640, 0x906dfc77, 0x922b422e, + 0x93e92819, 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5, + 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, 0x98b56f24, + 0x99770513, 0x9b31bb4a, 0x9af3d17d, 0x8d893530, 0x8c4b5f07, + 0x8e0de15e, 0x8fcf8b69, 0x8a809dec, 0x8b42f7db, 0x89044982, + 0x88c623b5, 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, + 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d, 0xa9e2d0a0, + 0xa820ba97, 0xaa6604ce, 0xaba46ef9, 0xaeeb787c, 0xaf29124b, + 0xad6fac12, 0xacadc625, 0xa7f18118, 0xa633eb2f, 0xa4755576, + 0xa5b73f41, 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d, + 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89, 0xb2cddb0c, + 0xb30fb13b, 0xb1490f62, 0xb08b6555, 0xbbd72268, 0xba15485f, + 0xb853f606, 0xb9919c31, 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, + 0xbe9834ed}, + {0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, 0x646cc504, + 0x7d77f445, 0x565aa786, 0x4f4196c7, 0xc8d98a08, 0xd1c2bb49, + 0xfaefe88a, 0xe3f4d9cb, 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, + 0x87981ccf, 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, + 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496, 0x821b9859, + 0x9b00a918, 0xb02dfadb, 0xa936cb9a, 0xe6775d5d, 0xff6c6c1c, + 0xd4413fdf, 0xcd5a0e9e, 0x958424a2, 0x8c9f15e3, 0xa7b24620, + 0xbea97761, 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, + 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69, 0x39316bae, + 0x202a5aef, 0x0b07092c, 0x121c386d, 0xdf4636f3, 0xc65d07b2, + 0xed705471, 0xf46b6530, 0xbb2af3f7, 0xa231c2b6, 0x891c9175, + 0x9007a034, 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38, + 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c, 0xf0794f05, + 0xe9627e44, 0xc24f2d87, 0xdb541cc6, 0x94158a01, 0x8d0ebb40, + 0xa623e883, 0xbf38d9c2, 0x38a0c50d, 0x21bbf44c, 0x0a96a78f, + 0x138d96ce, 0x5ccc0009, 0x45d73148, 0x6efa628b, 0x77e153ca, + 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97, 0xded79850, + 0xc7cca911, 0xece1fad2, 0xf5facb93, 0x7262d75c, 0x6b79e61d, + 0x4054b5de, 0x594f849f, 0x160e1258, 0x0f152319, 0x243870da, + 0x3d23419b, 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, 0x4ed03864, + 0x0191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60, 0xad24e1af, + 0xb43fd0ee, 0x9f12832d, 0x8609b26c, 0xc94824ab, 0xd05315ea, + 0xfb7e4629, 0xe2657768, 0x2f3f79f6, 0x362448b7, 0x1d091b74, + 0x04122a35, 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31, + 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d, 0x838a36fa, + 0x9a9107bb, 0xb1bc5478, 0xa8a76539, 0x3b83984b, 0x2298a90a, + 0x09b5fac9, 0x10aecb88, 0x5fef5d4f, 0x46f46c0e, 0x6dd93fcd, + 0x74c20e8c, 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180, + 0x9736d747, 0x8e2de606, 0xa500b5c5, 0xbc1b8484, 0x71418a1a, + 0x685abb5b, 0x4377e898, 0x5a6cd9d9, 0x152d4f1e, 0x0c367e5f, + 0x271b2d9c, 0x3e001cdd, 0xb9980012, 0xa0833153, 0x8bae6290, + 0x92b553d1, 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5, + 0xae07bce9, 0xb71c8da8, 0x9c31de6b, 0x852aef2a, 0xca6b79ed, + 0xd37048ac, 0xf85d1b6f, 0xe1462a2e, 0x66de36e1, 0x7fc507a0, + 0x54e85463, 0x4df36522, 0x02b2f3e5, 0x1ba9c2a4, 0x30849167, + 0x299fa026, 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b, + 0x80a96bbc, 0x99b25afd, 0xb29f093e, 0xab84387f, 0x2c1c24b0, + 0x350715f1, 0x1e2a4632, 0x07317773, 0x4870e1b4, 0x516bd0f5, + 0x7a468336, 0x635db277, 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, + 0xe0d7848d, 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189, + 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, 0x674f9842, + 0x7e54a903, 0x5579fac0, 0x4c62cb81, 0x8138c51f, 0x9823f45e, + 0xb30ea79d, 0xaa1596dc, 0xe554001b, 0xfc4f315a, 0xd7626299, + 0xce7953d8, 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4, + 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0, 0x5e7ef3ec, + 0x4765c2ad, 0x6c48916e, 0x7553a02f, 0x3a1236e8, 0x230907a9, + 0x0824546a, 0x113f652b, 0x96a779e4, 0x8fbc48a5, 0xa4911b66, + 0xbd8a2a27, 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23, + 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e, 0x70d024b9, + 0x69cb15f8, 0x42e6463b, 0x5bfd777a, 0xdc656bb5, 0xc57e5af4, + 0xee530937, 0xf7483876, 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, + 0x9324fd72}, + {0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x0000000000000000, 0x9630077700000000, 0x2c610eee00000000, + 0xba51099900000000, 0x19c46d0700000000, 0x8ff46a7000000000, + 0x35a563e900000000, 0xa395649e00000000, 0x3288db0e00000000, + 0xa4b8dc7900000000, 0x1ee9d5e000000000, 0x88d9d29700000000, + 0x2b4cb60900000000, 0xbd7cb17e00000000, 0x072db8e700000000, + 0x911dbf9000000000, 0x6410b71d00000000, 0xf220b06a00000000, + 0x4871b9f300000000, 0xde41be8400000000, 0x7dd4da1a00000000, + 0xebe4dd6d00000000, 0x51b5d4f400000000, 0xc785d38300000000, + 0x56986c1300000000, 0xc0a86b6400000000, 0x7af962fd00000000, + 0xecc9658a00000000, 0x4f5c011400000000, 0xd96c066300000000, + 0x633d0ffa00000000, 0xf50d088d00000000, 0xc8206e3b00000000, + 0x5e10694c00000000, 0xe44160d500000000, 0x727167a200000000, + 0xd1e4033c00000000, 0x47d4044b00000000, 0xfd850dd200000000, + 0x6bb50aa500000000, 0xfaa8b53500000000, 0x6c98b24200000000, + 0xd6c9bbdb00000000, 0x40f9bcac00000000, 0xe36cd83200000000, + 0x755cdf4500000000, 0xcf0dd6dc00000000, 0x593dd1ab00000000, + 0xac30d92600000000, 0x3a00de5100000000, 0x8051d7c800000000, + 0x1661d0bf00000000, 0xb5f4b42100000000, 0x23c4b35600000000, + 0x9995bacf00000000, 0x0fa5bdb800000000, 0x9eb8022800000000, + 0x0888055f00000000, 0xb2d90cc600000000, 0x24e90bb100000000, + 0x877c6f2f00000000, 0x114c685800000000, 0xab1d61c100000000, + 0x3d2d66b600000000, 0x9041dc7600000000, 0x0671db0100000000, + 0xbc20d29800000000, 0x2a10d5ef00000000, 0x8985b17100000000, + 0x1fb5b60600000000, 0xa5e4bf9f00000000, 0x33d4b8e800000000, + 0xa2c9077800000000, 0x34f9000f00000000, 0x8ea8099600000000, + 0x18980ee100000000, 0xbb0d6a7f00000000, 0x2d3d6d0800000000, + 0x976c649100000000, 0x015c63e600000000, 0xf4516b6b00000000, + 0x62616c1c00000000, 0xd830658500000000, 0x4e0062f200000000, + 0xed95066c00000000, 0x7ba5011b00000000, 0xc1f4088200000000, + 0x57c40ff500000000, 0xc6d9b06500000000, 0x50e9b71200000000, + 0xeab8be8b00000000, 0x7c88b9fc00000000, 0xdf1ddd6200000000, + 0x492dda1500000000, 0xf37cd38c00000000, 0x654cd4fb00000000, + 0x5861b24d00000000, 0xce51b53a00000000, 0x7400bca300000000, + 0xe230bbd400000000, 0x41a5df4a00000000, 0xd795d83d00000000, + 0x6dc4d1a400000000, 0xfbf4d6d300000000, 0x6ae9694300000000, + 0xfcd96e3400000000, 0x468867ad00000000, 0xd0b860da00000000, + 0x732d044400000000, 0xe51d033300000000, 0x5f4c0aaa00000000, + 0xc97c0ddd00000000, 0x3c71055000000000, 0xaa41022700000000, + 0x10100bbe00000000, 0x86200cc900000000, 0x25b5685700000000, + 0xb3856f2000000000, 0x09d466b900000000, 0x9fe461ce00000000, + 0x0ef9de5e00000000, 0x98c9d92900000000, 0x2298d0b000000000, + 0xb4a8d7c700000000, 0x173db35900000000, 0x810db42e00000000, + 0x3b5cbdb700000000, 0xad6cbac000000000, 0x2083b8ed00000000, + 0xb6b3bf9a00000000, 0x0ce2b60300000000, 0x9ad2b17400000000, + 0x3947d5ea00000000, 0xaf77d29d00000000, 0x1526db0400000000, + 0x8316dc7300000000, 0x120b63e300000000, 0x843b649400000000, + 0x3e6a6d0d00000000, 0xa85a6a7a00000000, 0x0bcf0ee400000000, + 0x9dff099300000000, 0x27ae000a00000000, 0xb19e077d00000000, + 0x44930ff000000000, 0xd2a3088700000000, 0x68f2011e00000000, + 0xfec2066900000000, 0x5d5762f700000000, 0xcb67658000000000, + 0x71366c1900000000, 0xe7066b6e00000000, 0x761bd4fe00000000, + 0xe02bd38900000000, 0x5a7ada1000000000, 0xcc4add6700000000, + 0x6fdfb9f900000000, 0xf9efbe8e00000000, 0x43beb71700000000, + 0xd58eb06000000000, 0xe8a3d6d600000000, 0x7e93d1a100000000, + 0xc4c2d83800000000, 0x52f2df4f00000000, 0xf167bbd100000000, + 0x6757bca600000000, 0xdd06b53f00000000, 0x4b36b24800000000, + 0xda2b0dd800000000, 0x4c1b0aaf00000000, 0xf64a033600000000, + 0x607a044100000000, 0xc3ef60df00000000, 0x55df67a800000000, + 0xef8e6e3100000000, 0x79be694600000000, 0x8cb361cb00000000, + 0x1a8366bc00000000, 0xa0d26f2500000000, 0x36e2685200000000, + 0x95770ccc00000000, 0x03470bbb00000000, 0xb916022200000000, + 0x2f26055500000000, 0xbe3bbac500000000, 0x280bbdb200000000, + 0x925ab42b00000000, 0x046ab35c00000000, 0xa7ffd7c200000000, + 0x31cfd0b500000000, 0x8b9ed92c00000000, 0x1daede5b00000000, + 0xb0c2649b00000000, 0x26f263ec00000000, 0x9ca36a7500000000, + 0x0a936d0200000000, 0xa906099c00000000, 0x3f360eeb00000000, + 0x8567077200000000, 0x1357000500000000, 0x824abf9500000000, + 0x147ab8e200000000, 0xae2bb17b00000000, 0x381bb60c00000000, + 0x9b8ed29200000000, 0x0dbed5e500000000, 0xb7efdc7c00000000, + 0x21dfdb0b00000000, 0xd4d2d38600000000, 0x42e2d4f100000000, + 0xf8b3dd6800000000, 0x6e83da1f00000000, 0xcd16be8100000000, + 0x5b26b9f600000000, 0xe177b06f00000000, 0x7747b71800000000, + 0xe65a088800000000, 0x706a0fff00000000, 0xca3b066600000000, + 0x5c0b011100000000, 0xff9e658f00000000, 0x69ae62f800000000, + 0xd3ff6b6100000000, 0x45cf6c1600000000, 0x78e20aa000000000, + 0xeed20dd700000000, 0x5483044e00000000, 0xc2b3033900000000, + 0x612667a700000000, 0xf71660d000000000, 0x4d47694900000000, + 0xdb776e3e00000000, 0x4a6ad1ae00000000, 0xdc5ad6d900000000, + 0x660bdf4000000000, 0xf03bd83700000000, 0x53aebca900000000, + 0xc59ebbde00000000, 0x7fcfb24700000000, 0xe9ffb53000000000, + 0x1cf2bdbd00000000, 0x8ac2baca00000000, 0x3093b35300000000, + 0xa6a3b42400000000, 0x0536d0ba00000000, 0x9306d7cd00000000, + 0x2957de5400000000, 0xbf67d92300000000, 0x2e7a66b300000000, + 0xb84a61c400000000, 0x021b685d00000000, 0x942b6f2a00000000, + 0x37be0bb400000000, 0xa18e0cc300000000, 0x1bdf055a00000000, + 0x8def022d00000000}, + {0x0000000000000000, 0x41311b1900000000, 0x8262363200000000, + 0xc3532d2b00000000, 0x04c56c6400000000, 0x45f4777d00000000, + 0x86a75a5600000000, 0xc796414f00000000, 0x088ad9c800000000, + 0x49bbc2d100000000, 0x8ae8effa00000000, 0xcbd9f4e300000000, + 0x0c4fb5ac00000000, 0x4d7eaeb500000000, 0x8e2d839e00000000, + 0xcf1c988700000000, 0x5112c24a00000000, 0x1023d95300000000, + 0xd370f47800000000, 0x9241ef6100000000, 0x55d7ae2e00000000, + 0x14e6b53700000000, 0xd7b5981c00000000, 0x9684830500000000, + 0x59981b8200000000, 0x18a9009b00000000, 0xdbfa2db000000000, + 0x9acb36a900000000, 0x5d5d77e600000000, 0x1c6c6cff00000000, + 0xdf3f41d400000000, 0x9e0e5acd00000000, 0xa224849500000000, + 0xe3159f8c00000000, 0x2046b2a700000000, 0x6177a9be00000000, + 0xa6e1e8f100000000, 0xe7d0f3e800000000, 0x2483dec300000000, + 0x65b2c5da00000000, 0xaaae5d5d00000000, 0xeb9f464400000000, + 0x28cc6b6f00000000, 0x69fd707600000000, 0xae6b313900000000, + 0xef5a2a2000000000, 0x2c09070b00000000, 0x6d381c1200000000, + 0xf33646df00000000, 0xb2075dc600000000, 0x715470ed00000000, + 0x30656bf400000000, 0xf7f32abb00000000, 0xb6c231a200000000, + 0x75911c8900000000, 0x34a0079000000000, 0xfbbc9f1700000000, + 0xba8d840e00000000, 0x79dea92500000000, 0x38efb23c00000000, + 0xff79f37300000000, 0xbe48e86a00000000, 0x7d1bc54100000000, + 0x3c2ade5800000000, 0x054f79f000000000, 0x447e62e900000000, + 0x872d4fc200000000, 0xc61c54db00000000, 0x018a159400000000, + 0x40bb0e8d00000000, 0x83e823a600000000, 0xc2d938bf00000000, + 0x0dc5a03800000000, 0x4cf4bb2100000000, 0x8fa7960a00000000, + 0xce968d1300000000, 0x0900cc5c00000000, 0x4831d74500000000, + 0x8b62fa6e00000000, 0xca53e17700000000, 0x545dbbba00000000, + 0x156ca0a300000000, 0xd63f8d8800000000, 0x970e969100000000, + 0x5098d7de00000000, 0x11a9ccc700000000, 0xd2fae1ec00000000, + 0x93cbfaf500000000, 0x5cd7627200000000, 0x1de6796b00000000, + 0xdeb5544000000000, 0x9f844f5900000000, 0x58120e1600000000, + 0x1923150f00000000, 0xda70382400000000, 0x9b41233d00000000, + 0xa76bfd6500000000, 0xe65ae67c00000000, 0x2509cb5700000000, + 0x6438d04e00000000, 0xa3ae910100000000, 0xe29f8a1800000000, + 0x21cca73300000000, 0x60fdbc2a00000000, 0xafe124ad00000000, + 0xeed03fb400000000, 0x2d83129f00000000, 0x6cb2098600000000, + 0xab2448c900000000, 0xea1553d000000000, 0x29467efb00000000, + 0x687765e200000000, 0xf6793f2f00000000, 0xb748243600000000, + 0x741b091d00000000, 0x352a120400000000, 0xf2bc534b00000000, + 0xb38d485200000000, 0x70de657900000000, 0x31ef7e6000000000, + 0xfef3e6e700000000, 0xbfc2fdfe00000000, 0x7c91d0d500000000, + 0x3da0cbcc00000000, 0xfa368a8300000000, 0xbb07919a00000000, + 0x7854bcb100000000, 0x3965a7a800000000, 0x4b98833b00000000, + 0x0aa9982200000000, 0xc9fab50900000000, 0x88cbae1000000000, + 0x4f5def5f00000000, 0x0e6cf44600000000, 0xcd3fd96d00000000, + 0x8c0ec27400000000, 0x43125af300000000, 0x022341ea00000000, + 0xc1706cc100000000, 0x804177d800000000, 0x47d7369700000000, + 0x06e62d8e00000000, 0xc5b500a500000000, 0x84841bbc00000000, + 0x1a8a417100000000, 0x5bbb5a6800000000, 0x98e8774300000000, + 0xd9d96c5a00000000, 0x1e4f2d1500000000, 0x5f7e360c00000000, + 0x9c2d1b2700000000, 0xdd1c003e00000000, 0x120098b900000000, + 0x533183a000000000, 0x9062ae8b00000000, 0xd153b59200000000, + 0x16c5f4dd00000000, 0x57f4efc400000000, 0x94a7c2ef00000000, + 0xd596d9f600000000, 0xe9bc07ae00000000, 0xa88d1cb700000000, + 0x6bde319c00000000, 0x2aef2a8500000000, 0xed796bca00000000, + 0xac4870d300000000, 0x6f1b5df800000000, 0x2e2a46e100000000, + 0xe136de6600000000, 0xa007c57f00000000, 0x6354e85400000000, + 0x2265f34d00000000, 0xe5f3b20200000000, 0xa4c2a91b00000000, + 0x6791843000000000, 0x26a09f2900000000, 0xb8aec5e400000000, + 0xf99fdefd00000000, 0x3accf3d600000000, 0x7bfde8cf00000000, + 0xbc6ba98000000000, 0xfd5ab29900000000, 0x3e099fb200000000, + 0x7f3884ab00000000, 0xb0241c2c00000000, 0xf115073500000000, + 0x32462a1e00000000, 0x7377310700000000, 0xb4e1704800000000, + 0xf5d06b5100000000, 0x3683467a00000000, 0x77b25d6300000000, + 0x4ed7facb00000000, 0x0fe6e1d200000000, 0xccb5ccf900000000, + 0x8d84d7e000000000, 0x4a1296af00000000, 0x0b238db600000000, + 0xc870a09d00000000, 0x8941bb8400000000, 0x465d230300000000, + 0x076c381a00000000, 0xc43f153100000000, 0x850e0e2800000000, + 0x42984f6700000000, 0x03a9547e00000000, 0xc0fa795500000000, + 0x81cb624c00000000, 0x1fc5388100000000, 0x5ef4239800000000, + 0x9da70eb300000000, 0xdc9615aa00000000, 0x1b0054e500000000, + 0x5a314ffc00000000, 0x996262d700000000, 0xd85379ce00000000, + 0x174fe14900000000, 0x567efa5000000000, 0x952dd77b00000000, + 0xd41ccc6200000000, 0x138a8d2d00000000, 0x52bb963400000000, + 0x91e8bb1f00000000, 0xd0d9a00600000000, 0xecf37e5e00000000, + 0xadc2654700000000, 0x6e91486c00000000, 0x2fa0537500000000, + 0xe836123a00000000, 0xa907092300000000, 0x6a54240800000000, + 0x2b653f1100000000, 0xe479a79600000000, 0xa548bc8f00000000, + 0x661b91a400000000, 0x272a8abd00000000, 0xe0bccbf200000000, + 0xa18dd0eb00000000, 0x62defdc000000000, 0x23efe6d900000000, + 0xbde1bc1400000000, 0xfcd0a70d00000000, 0x3f838a2600000000, + 0x7eb2913f00000000, 0xb924d07000000000, 0xf815cb6900000000, + 0x3b46e64200000000, 0x7a77fd5b00000000, 0xb56b65dc00000000, + 0xf45a7ec500000000, 0x370953ee00000000, 0x763848f700000000, + 0xb1ae09b800000000, 0xf09f12a100000000, 0x33cc3f8a00000000, + 0x72fd249300000000}, + {0x0000000000000000, 0x376ac20100000000, 0x6ed4840300000000, + 0x59be460200000000, 0xdca8090700000000, 0xebc2cb0600000000, + 0xb27c8d0400000000, 0x85164f0500000000, 0xb851130e00000000, + 0x8f3bd10f00000000, 0xd685970d00000000, 0xe1ef550c00000000, + 0x64f91a0900000000, 0x5393d80800000000, 0x0a2d9e0a00000000, + 0x3d475c0b00000000, 0x70a3261c00000000, 0x47c9e41d00000000, + 0x1e77a21f00000000, 0x291d601e00000000, 0xac0b2f1b00000000, + 0x9b61ed1a00000000, 0xc2dfab1800000000, 0xf5b5691900000000, + 0xc8f2351200000000, 0xff98f71300000000, 0xa626b11100000000, + 0x914c731000000000, 0x145a3c1500000000, 0x2330fe1400000000, + 0x7a8eb81600000000, 0x4de47a1700000000, 0xe0464d3800000000, + 0xd72c8f3900000000, 0x8e92c93b00000000, 0xb9f80b3a00000000, + 0x3cee443f00000000, 0x0b84863e00000000, 0x523ac03c00000000, + 0x6550023d00000000, 0x58175e3600000000, 0x6f7d9c3700000000, + 0x36c3da3500000000, 0x01a9183400000000, 0x84bf573100000000, + 0xb3d5953000000000, 0xea6bd33200000000, 0xdd01113300000000, + 0x90e56b2400000000, 0xa78fa92500000000, 0xfe31ef2700000000, + 0xc95b2d2600000000, 0x4c4d622300000000, 0x7b27a02200000000, + 0x2299e62000000000, 0x15f3242100000000, 0x28b4782a00000000, + 0x1fdeba2b00000000, 0x4660fc2900000000, 0x710a3e2800000000, + 0xf41c712d00000000, 0xc376b32c00000000, 0x9ac8f52e00000000, + 0xada2372f00000000, 0xc08d9a7000000000, 0xf7e7587100000000, + 0xae591e7300000000, 0x9933dc7200000000, 0x1c25937700000000, + 0x2b4f517600000000, 0x72f1177400000000, 0x459bd57500000000, + 0x78dc897e00000000, 0x4fb64b7f00000000, 0x16080d7d00000000, + 0x2162cf7c00000000, 0xa474807900000000, 0x931e427800000000, + 0xcaa0047a00000000, 0xfdcac67b00000000, 0xb02ebc6c00000000, + 0x87447e6d00000000, 0xdefa386f00000000, 0xe990fa6e00000000, + 0x6c86b56b00000000, 0x5bec776a00000000, 0x0252316800000000, + 0x3538f36900000000, 0x087faf6200000000, 0x3f156d6300000000, + 0x66ab2b6100000000, 0x51c1e96000000000, 0xd4d7a66500000000, + 0xe3bd646400000000, 0xba03226600000000, 0x8d69e06700000000, + 0x20cbd74800000000, 0x17a1154900000000, 0x4e1f534b00000000, + 0x7975914a00000000, 0xfc63de4f00000000, 0xcb091c4e00000000, + 0x92b75a4c00000000, 0xa5dd984d00000000, 0x989ac44600000000, + 0xaff0064700000000, 0xf64e404500000000, 0xc124824400000000, + 0x4432cd4100000000, 0x73580f4000000000, 0x2ae6494200000000, + 0x1d8c8b4300000000, 0x5068f15400000000, 0x6702335500000000, + 0x3ebc755700000000, 0x09d6b75600000000, 0x8cc0f85300000000, + 0xbbaa3a5200000000, 0xe2147c5000000000, 0xd57ebe5100000000, + 0xe839e25a00000000, 0xdf53205b00000000, 0x86ed665900000000, + 0xb187a45800000000, 0x3491eb5d00000000, 0x03fb295c00000000, + 0x5a456f5e00000000, 0x6d2fad5f00000000, 0x801b35e100000000, + 0xb771f7e000000000, 0xeecfb1e200000000, 0xd9a573e300000000, + 0x5cb33ce600000000, 0x6bd9fee700000000, 0x3267b8e500000000, + 0x050d7ae400000000, 0x384a26ef00000000, 0x0f20e4ee00000000, + 0x569ea2ec00000000, 0x61f460ed00000000, 0xe4e22fe800000000, + 0xd388ede900000000, 0x8a36abeb00000000, 0xbd5c69ea00000000, + 0xf0b813fd00000000, 0xc7d2d1fc00000000, 0x9e6c97fe00000000, + 0xa90655ff00000000, 0x2c101afa00000000, 0x1b7ad8fb00000000, + 0x42c49ef900000000, 0x75ae5cf800000000, 0x48e900f300000000, + 0x7f83c2f200000000, 0x263d84f000000000, 0x115746f100000000, + 0x944109f400000000, 0xa32bcbf500000000, 0xfa958df700000000, + 0xcdff4ff600000000, 0x605d78d900000000, 0x5737bad800000000, + 0x0e89fcda00000000, 0x39e33edb00000000, 0xbcf571de00000000, + 0x8b9fb3df00000000, 0xd221f5dd00000000, 0xe54b37dc00000000, + 0xd80c6bd700000000, 0xef66a9d600000000, 0xb6d8efd400000000, + 0x81b22dd500000000, 0x04a462d000000000, 0x33cea0d100000000, + 0x6a70e6d300000000, 0x5d1a24d200000000, 0x10fe5ec500000000, + 0x27949cc400000000, 0x7e2adac600000000, 0x494018c700000000, + 0xcc5657c200000000, 0xfb3c95c300000000, 0xa282d3c100000000, + 0x95e811c000000000, 0xa8af4dcb00000000, 0x9fc58fca00000000, + 0xc67bc9c800000000, 0xf1110bc900000000, 0x740744cc00000000, + 0x436d86cd00000000, 0x1ad3c0cf00000000, 0x2db902ce00000000, + 0x4096af9100000000, 0x77fc6d9000000000, 0x2e422b9200000000, + 0x1928e99300000000, 0x9c3ea69600000000, 0xab54649700000000, + 0xf2ea229500000000, 0xc580e09400000000, 0xf8c7bc9f00000000, + 0xcfad7e9e00000000, 0x9613389c00000000, 0xa179fa9d00000000, + 0x246fb59800000000, 0x1305779900000000, 0x4abb319b00000000, + 0x7dd1f39a00000000, 0x3035898d00000000, 0x075f4b8c00000000, + 0x5ee10d8e00000000, 0x698bcf8f00000000, 0xec9d808a00000000, + 0xdbf7428b00000000, 0x8249048900000000, 0xb523c68800000000, + 0x88649a8300000000, 0xbf0e588200000000, 0xe6b01e8000000000, + 0xd1dadc8100000000, 0x54cc938400000000, 0x63a6518500000000, + 0x3a18178700000000, 0x0d72d58600000000, 0xa0d0e2a900000000, + 0x97ba20a800000000, 0xce0466aa00000000, 0xf96ea4ab00000000, + 0x7c78ebae00000000, 0x4b1229af00000000, 0x12ac6fad00000000, + 0x25c6adac00000000, 0x1881f1a700000000, 0x2feb33a600000000, + 0x765575a400000000, 0x413fb7a500000000, 0xc429f8a000000000, + 0xf3433aa100000000, 0xaafd7ca300000000, 0x9d97bea200000000, + 0xd073c4b500000000, 0xe71906b400000000, 0xbea740b600000000, + 0x89cd82b700000000, 0x0cdbcdb200000000, 0x3bb10fb300000000, + 0x620f49b100000000, 0x55658bb000000000, 0x6822d7bb00000000, + 0x5f4815ba00000000, 0x06f653b800000000, 0x319c91b900000000, + 0xb48adebc00000000, 0x83e01cbd00000000, 0xda5e5abf00000000, + 0xed3498be00000000}, + {0x0000000000000000, 0x6567bcb800000000, 0x8bc809aa00000000, + 0xeeafb51200000000, 0x5797628f00000000, 0x32f0de3700000000, + 0xdc5f6b2500000000, 0xb938d79d00000000, 0xef28b4c500000000, + 0x8a4f087d00000000, 0x64e0bd6f00000000, 0x018701d700000000, + 0xb8bfd64a00000000, 0xddd86af200000000, 0x3377dfe000000000, + 0x5610635800000000, 0x9f57195000000000, 0xfa30a5e800000000, + 0x149f10fa00000000, 0x71f8ac4200000000, 0xc8c07bdf00000000, + 0xada7c76700000000, 0x4308727500000000, 0x266fcecd00000000, + 0x707fad9500000000, 0x1518112d00000000, 0xfbb7a43f00000000, + 0x9ed0188700000000, 0x27e8cf1a00000000, 0x428f73a200000000, + 0xac20c6b000000000, 0xc9477a0800000000, 0x3eaf32a000000000, + 0x5bc88e1800000000, 0xb5673b0a00000000, 0xd00087b200000000, + 0x6938502f00000000, 0x0c5fec9700000000, 0xe2f0598500000000, + 0x8797e53d00000000, 0xd187866500000000, 0xb4e03add00000000, + 0x5a4f8fcf00000000, 0x3f28337700000000, 0x8610e4ea00000000, + 0xe377585200000000, 0x0dd8ed4000000000, 0x68bf51f800000000, + 0xa1f82bf000000000, 0xc49f974800000000, 0x2a30225a00000000, + 0x4f579ee200000000, 0xf66f497f00000000, 0x9308f5c700000000, + 0x7da740d500000000, 0x18c0fc6d00000000, 0x4ed09f3500000000, + 0x2bb7238d00000000, 0xc518969f00000000, 0xa07f2a2700000000, + 0x1947fdba00000000, 0x7c20410200000000, 0x928ff41000000000, + 0xf7e848a800000000, 0x3d58149b00000000, 0x583fa82300000000, + 0xb6901d3100000000, 0xd3f7a18900000000, 0x6acf761400000000, + 0x0fa8caac00000000, 0xe1077fbe00000000, 0x8460c30600000000, + 0xd270a05e00000000, 0xb7171ce600000000, 0x59b8a9f400000000, + 0x3cdf154c00000000, 0x85e7c2d100000000, 0xe0807e6900000000, + 0x0e2fcb7b00000000, 0x6b4877c300000000, 0xa20f0dcb00000000, + 0xc768b17300000000, 0x29c7046100000000, 0x4ca0b8d900000000, + 0xf5986f4400000000, 0x90ffd3fc00000000, 0x7e5066ee00000000, + 0x1b37da5600000000, 0x4d27b90e00000000, 0x284005b600000000, + 0xc6efb0a400000000, 0xa3880c1c00000000, 0x1ab0db8100000000, + 0x7fd7673900000000, 0x9178d22b00000000, 0xf41f6e9300000000, + 0x03f7263b00000000, 0x66909a8300000000, 0x883f2f9100000000, + 0xed58932900000000, 0x546044b400000000, 0x3107f80c00000000, + 0xdfa84d1e00000000, 0xbacff1a600000000, 0xecdf92fe00000000, + 0x89b82e4600000000, 0x67179b5400000000, 0x027027ec00000000, + 0xbb48f07100000000, 0xde2f4cc900000000, 0x3080f9db00000000, + 0x55e7456300000000, 0x9ca03f6b00000000, 0xf9c783d300000000, + 0x176836c100000000, 0x720f8a7900000000, 0xcb375de400000000, + 0xae50e15c00000000, 0x40ff544e00000000, 0x2598e8f600000000, + 0x73888bae00000000, 0x16ef371600000000, 0xf840820400000000, + 0x9d273ebc00000000, 0x241fe92100000000, 0x4178559900000000, + 0xafd7e08b00000000, 0xcab05c3300000000, 0x3bb659ed00000000, + 0x5ed1e55500000000, 0xb07e504700000000, 0xd519ecff00000000, + 0x6c213b6200000000, 0x094687da00000000, 0xe7e932c800000000, + 0x828e8e7000000000, 0xd49eed2800000000, 0xb1f9519000000000, + 0x5f56e48200000000, 0x3a31583a00000000, 0x83098fa700000000, + 0xe66e331f00000000, 0x08c1860d00000000, 0x6da63ab500000000, + 0xa4e140bd00000000, 0xc186fc0500000000, 0x2f29491700000000, + 0x4a4ef5af00000000, 0xf376223200000000, 0x96119e8a00000000, + 0x78be2b9800000000, 0x1dd9972000000000, 0x4bc9f47800000000, + 0x2eae48c000000000, 0xc001fdd200000000, 0xa566416a00000000, + 0x1c5e96f700000000, 0x79392a4f00000000, 0x97969f5d00000000, + 0xf2f123e500000000, 0x05196b4d00000000, 0x607ed7f500000000, + 0x8ed162e700000000, 0xebb6de5f00000000, 0x528e09c200000000, + 0x37e9b57a00000000, 0xd946006800000000, 0xbc21bcd000000000, + 0xea31df8800000000, 0x8f56633000000000, 0x61f9d62200000000, + 0x049e6a9a00000000, 0xbda6bd0700000000, 0xd8c101bf00000000, + 0x366eb4ad00000000, 0x5309081500000000, 0x9a4e721d00000000, + 0xff29cea500000000, 0x11867bb700000000, 0x74e1c70f00000000, + 0xcdd9109200000000, 0xa8beac2a00000000, 0x4611193800000000, + 0x2376a58000000000, 0x7566c6d800000000, 0x10017a6000000000, + 0xfeaecf7200000000, 0x9bc973ca00000000, 0x22f1a45700000000, + 0x479618ef00000000, 0xa939adfd00000000, 0xcc5e114500000000, + 0x06ee4d7600000000, 0x6389f1ce00000000, 0x8d2644dc00000000, + 0xe841f86400000000, 0x51792ff900000000, 0x341e934100000000, + 0xdab1265300000000, 0xbfd69aeb00000000, 0xe9c6f9b300000000, + 0x8ca1450b00000000, 0x620ef01900000000, 0x07694ca100000000, + 0xbe519b3c00000000, 0xdb36278400000000, 0x3599929600000000, + 0x50fe2e2e00000000, 0x99b9542600000000, 0xfcdee89e00000000, + 0x12715d8c00000000, 0x7716e13400000000, 0xce2e36a900000000, + 0xab498a1100000000, 0x45e63f0300000000, 0x208183bb00000000, + 0x7691e0e300000000, 0x13f65c5b00000000, 0xfd59e94900000000, + 0x983e55f100000000, 0x2106826c00000000, 0x44613ed400000000, + 0xaace8bc600000000, 0xcfa9377e00000000, 0x38417fd600000000, + 0x5d26c36e00000000, 0xb389767c00000000, 0xd6eecac400000000, + 0x6fd61d5900000000, 0x0ab1a1e100000000, 0xe41e14f300000000, + 0x8179a84b00000000, 0xd769cb1300000000, 0xb20e77ab00000000, + 0x5ca1c2b900000000, 0x39c67e0100000000, 0x80fea99c00000000, + 0xe599152400000000, 0x0b36a03600000000, 0x6e511c8e00000000, + 0xa716668600000000, 0xc271da3e00000000, 0x2cde6f2c00000000, + 0x49b9d39400000000, 0xf081040900000000, 0x95e6b8b100000000, + 0x7b490da300000000, 0x1e2eb11b00000000, 0x483ed24300000000, + 0x2d596efb00000000, 0xc3f6dbe900000000, 0xa691675100000000, + 0x1fa9b0cc00000000, 0x7ace0c7400000000, 0x9461b96600000000, + 0xf10605de00000000}, + {0x0000000000000000, 0xb029603d00000000, 0x6053c07a00000000, + 0xd07aa04700000000, 0xc0a680f500000000, 0x708fe0c800000000, + 0xa0f5408f00000000, 0x10dc20b200000000, 0xc14b703000000000, + 0x7162100d00000000, 0xa118b04a00000000, 0x1131d07700000000, + 0x01edf0c500000000, 0xb1c490f800000000, 0x61be30bf00000000, + 0xd197508200000000, 0x8297e06000000000, 0x32be805d00000000, + 0xe2c4201a00000000, 0x52ed402700000000, 0x4231609500000000, + 0xf21800a800000000, 0x2262a0ef00000000, 0x924bc0d200000000, + 0x43dc905000000000, 0xf3f5f06d00000000, 0x238f502a00000000, + 0x93a6301700000000, 0x837a10a500000000, 0x3353709800000000, + 0xe329d0df00000000, 0x5300b0e200000000, 0x042fc1c100000000, + 0xb406a1fc00000000, 0x647c01bb00000000, 0xd455618600000000, + 0xc489413400000000, 0x74a0210900000000, 0xa4da814e00000000, + 0x14f3e17300000000, 0xc564b1f100000000, 0x754dd1cc00000000, + 0xa537718b00000000, 0x151e11b600000000, 0x05c2310400000000, + 0xb5eb513900000000, 0x6591f17e00000000, 0xd5b8914300000000, + 0x86b821a100000000, 0x3691419c00000000, 0xe6ebe1db00000000, + 0x56c281e600000000, 0x461ea15400000000, 0xf637c16900000000, + 0x264d612e00000000, 0x9664011300000000, 0x47f3519100000000, + 0xf7da31ac00000000, 0x27a091eb00000000, 0x9789f1d600000000, + 0x8755d16400000000, 0x377cb15900000000, 0xe706111e00000000, + 0x572f712300000000, 0x4958f35800000000, 0xf971936500000000, + 0x290b332200000000, 0x9922531f00000000, 0x89fe73ad00000000, + 0x39d7139000000000, 0xe9adb3d700000000, 0x5984d3ea00000000, + 0x8813836800000000, 0x383ae35500000000, 0xe840431200000000, + 0x5869232f00000000, 0x48b5039d00000000, 0xf89c63a000000000, + 0x28e6c3e700000000, 0x98cfa3da00000000, 0xcbcf133800000000, + 0x7be6730500000000, 0xab9cd34200000000, 0x1bb5b37f00000000, + 0x0b6993cd00000000, 0xbb40f3f000000000, 0x6b3a53b700000000, + 0xdb13338a00000000, 0x0a84630800000000, 0xbaad033500000000, + 0x6ad7a37200000000, 0xdafec34f00000000, 0xca22e3fd00000000, + 0x7a0b83c000000000, 0xaa71238700000000, 0x1a5843ba00000000, + 0x4d77329900000000, 0xfd5e52a400000000, 0x2d24f2e300000000, + 0x9d0d92de00000000, 0x8dd1b26c00000000, 0x3df8d25100000000, + 0xed82721600000000, 0x5dab122b00000000, 0x8c3c42a900000000, + 0x3c15229400000000, 0xec6f82d300000000, 0x5c46e2ee00000000, + 0x4c9ac25c00000000, 0xfcb3a26100000000, 0x2cc9022600000000, + 0x9ce0621b00000000, 0xcfe0d2f900000000, 0x7fc9b2c400000000, + 0xafb3128300000000, 0x1f9a72be00000000, 0x0f46520c00000000, + 0xbf6f323100000000, 0x6f15927600000000, 0xdf3cf24b00000000, + 0x0eaba2c900000000, 0xbe82c2f400000000, 0x6ef862b300000000, + 0xded1028e00000000, 0xce0d223c00000000, 0x7e24420100000000, + 0xae5ee24600000000, 0x1e77827b00000000, 0x92b0e6b100000000, + 0x2299868c00000000, 0xf2e326cb00000000, 0x42ca46f600000000, + 0x5216664400000000, 0xe23f067900000000, 0x3245a63e00000000, + 0x826cc60300000000, 0x53fb968100000000, 0xe3d2f6bc00000000, + 0x33a856fb00000000, 0x838136c600000000, 0x935d167400000000, + 0x2374764900000000, 0xf30ed60e00000000, 0x4327b63300000000, + 0x102706d100000000, 0xa00e66ec00000000, 0x7074c6ab00000000, + 0xc05da69600000000, 0xd081862400000000, 0x60a8e61900000000, + 0xb0d2465e00000000, 0x00fb266300000000, 0xd16c76e100000000, + 0x614516dc00000000, 0xb13fb69b00000000, 0x0116d6a600000000, + 0x11caf61400000000, 0xa1e3962900000000, 0x7199366e00000000, + 0xc1b0565300000000, 0x969f277000000000, 0x26b6474d00000000, + 0xf6cce70a00000000, 0x46e5873700000000, 0x5639a78500000000, + 0xe610c7b800000000, 0x366a67ff00000000, 0x864307c200000000, + 0x57d4574000000000, 0xe7fd377d00000000, 0x3787973a00000000, + 0x87aef70700000000, 0x9772d7b500000000, 0x275bb78800000000, + 0xf72117cf00000000, 0x470877f200000000, 0x1408c71000000000, + 0xa421a72d00000000, 0x745b076a00000000, 0xc472675700000000, + 0xd4ae47e500000000, 0x648727d800000000, 0xb4fd879f00000000, + 0x04d4e7a200000000, 0xd543b72000000000, 0x656ad71d00000000, + 0xb510775a00000000, 0x0539176700000000, 0x15e537d500000000, + 0xa5cc57e800000000, 0x75b6f7af00000000, 0xc59f979200000000, + 0xdbe815e900000000, 0x6bc175d400000000, 0xbbbbd59300000000, + 0x0b92b5ae00000000, 0x1b4e951c00000000, 0xab67f52100000000, + 0x7b1d556600000000, 0xcb34355b00000000, 0x1aa365d900000000, + 0xaa8a05e400000000, 0x7af0a5a300000000, 0xcad9c59e00000000, + 0xda05e52c00000000, 0x6a2c851100000000, 0xba56255600000000, + 0x0a7f456b00000000, 0x597ff58900000000, 0xe95695b400000000, + 0x392c35f300000000, 0x890555ce00000000, 0x99d9757c00000000, + 0x29f0154100000000, 0xf98ab50600000000, 0x49a3d53b00000000, + 0x983485b900000000, 0x281de58400000000, 0xf86745c300000000, + 0x484e25fe00000000, 0x5892054c00000000, 0xe8bb657100000000, + 0x38c1c53600000000, 0x88e8a50b00000000, 0xdfc7d42800000000, + 0x6feeb41500000000, 0xbf94145200000000, 0x0fbd746f00000000, + 0x1f6154dd00000000, 0xaf4834e000000000, 0x7f3294a700000000, + 0xcf1bf49a00000000, 0x1e8ca41800000000, 0xaea5c42500000000, + 0x7edf646200000000, 0xcef6045f00000000, 0xde2a24ed00000000, + 0x6e0344d000000000, 0xbe79e49700000000, 0x0e5084aa00000000, + 0x5d50344800000000, 0xed79547500000000, 0x3d03f43200000000, + 0x8d2a940f00000000, 0x9df6b4bd00000000, 0x2ddfd48000000000, + 0xfda574c700000000, 0x4d8c14fa00000000, 0x9c1b447800000000, + 0x2c32244500000000, 0xfc48840200000000, 0x4c61e43f00000000, + 0x5cbdc48d00000000, 0xec94a4b000000000, 0x3cee04f700000000, + 0x8cc764ca00000000}, + {0x0000000000000000, 0xa5d35ccb00000000, 0x0ba1c84d00000000, + 0xae72948600000000, 0x1642919b00000000, 0xb391cd5000000000, + 0x1de359d600000000, 0xb830051d00000000, 0x6d8253ec00000000, + 0xc8510f2700000000, 0x66239ba100000000, 0xc3f0c76a00000000, + 0x7bc0c27700000000, 0xde139ebc00000000, 0x70610a3a00000000, + 0xd5b256f100000000, 0x9b02d60300000000, 0x3ed18ac800000000, + 0x90a31e4e00000000, 0x3570428500000000, 0x8d40479800000000, + 0x28931b5300000000, 0x86e18fd500000000, 0x2332d31e00000000, + 0xf68085ef00000000, 0x5353d92400000000, 0xfd214da200000000, + 0x58f2116900000000, 0xe0c2147400000000, 0x451148bf00000000, + 0xeb63dc3900000000, 0x4eb080f200000000, 0x3605ac0700000000, + 0x93d6f0cc00000000, 0x3da4644a00000000, 0x9877388100000000, + 0x20473d9c00000000, 0x8594615700000000, 0x2be6f5d100000000, + 0x8e35a91a00000000, 0x5b87ffeb00000000, 0xfe54a32000000000, + 0x502637a600000000, 0xf5f56b6d00000000, 0x4dc56e7000000000, + 0xe81632bb00000000, 0x4664a63d00000000, 0xe3b7faf600000000, + 0xad077a0400000000, 0x08d426cf00000000, 0xa6a6b24900000000, + 0x0375ee8200000000, 0xbb45eb9f00000000, 0x1e96b75400000000, + 0xb0e423d200000000, 0x15377f1900000000, 0xc08529e800000000, + 0x6556752300000000, 0xcb24e1a500000000, 0x6ef7bd6e00000000, + 0xd6c7b87300000000, 0x7314e4b800000000, 0xdd66703e00000000, + 0x78b52cf500000000, 0x6c0a580f00000000, 0xc9d904c400000000, + 0x67ab904200000000, 0xc278cc8900000000, 0x7a48c99400000000, + 0xdf9b955f00000000, 0x71e901d900000000, 0xd43a5d1200000000, + 0x01880be300000000, 0xa45b572800000000, 0x0a29c3ae00000000, + 0xaffa9f6500000000, 0x17ca9a7800000000, 0xb219c6b300000000, + 0x1c6b523500000000, 0xb9b80efe00000000, 0xf7088e0c00000000, + 0x52dbd2c700000000, 0xfca9464100000000, 0x597a1a8a00000000, + 0xe14a1f9700000000, 0x4499435c00000000, 0xeaebd7da00000000, + 0x4f388b1100000000, 0x9a8adde000000000, 0x3f59812b00000000, + 0x912b15ad00000000, 0x34f8496600000000, 0x8cc84c7b00000000, + 0x291b10b000000000, 0x8769843600000000, 0x22bad8fd00000000, + 0x5a0ff40800000000, 0xffdca8c300000000, 0x51ae3c4500000000, + 0xf47d608e00000000, 0x4c4d659300000000, 0xe99e395800000000, + 0x47ecadde00000000, 0xe23ff11500000000, 0x378da7e400000000, + 0x925efb2f00000000, 0x3c2c6fa900000000, 0x99ff336200000000, + 0x21cf367f00000000, 0x841c6ab400000000, 0x2a6efe3200000000, + 0x8fbda2f900000000, 0xc10d220b00000000, 0x64de7ec000000000, + 0xcaacea4600000000, 0x6f7fb68d00000000, 0xd74fb39000000000, + 0x729cef5b00000000, 0xdcee7bdd00000000, 0x793d271600000000, + 0xac8f71e700000000, 0x095c2d2c00000000, 0xa72eb9aa00000000, + 0x02fde56100000000, 0xbacde07c00000000, 0x1f1ebcb700000000, + 0xb16c283100000000, 0x14bf74fa00000000, 0xd814b01e00000000, + 0x7dc7ecd500000000, 0xd3b5785300000000, 0x7666249800000000, + 0xce56218500000000, 0x6b857d4e00000000, 0xc5f7e9c800000000, + 0x6024b50300000000, 0xb596e3f200000000, 0x1045bf3900000000, + 0xbe372bbf00000000, 0x1be4777400000000, 0xa3d4726900000000, + 0x06072ea200000000, 0xa875ba2400000000, 0x0da6e6ef00000000, + 0x4316661d00000000, 0xe6c53ad600000000, 0x48b7ae5000000000, + 0xed64f29b00000000, 0x5554f78600000000, 0xf087ab4d00000000, + 0x5ef53fcb00000000, 0xfb26630000000000, 0x2e9435f100000000, + 0x8b47693a00000000, 0x2535fdbc00000000, 0x80e6a17700000000, + 0x38d6a46a00000000, 0x9d05f8a100000000, 0x33776c2700000000, + 0x96a430ec00000000, 0xee111c1900000000, 0x4bc240d200000000, + 0xe5b0d45400000000, 0x4063889f00000000, 0xf8538d8200000000, + 0x5d80d14900000000, 0xf3f245cf00000000, 0x5621190400000000, + 0x83934ff500000000, 0x2640133e00000000, 0x883287b800000000, + 0x2de1db7300000000, 0x95d1de6e00000000, 0x300282a500000000, + 0x9e70162300000000, 0x3ba34ae800000000, 0x7513ca1a00000000, + 0xd0c096d100000000, 0x7eb2025700000000, 0xdb615e9c00000000, + 0x63515b8100000000, 0xc682074a00000000, 0x68f093cc00000000, + 0xcd23cf0700000000, 0x189199f600000000, 0xbd42c53d00000000, + 0x133051bb00000000, 0xb6e30d7000000000, 0x0ed3086d00000000, + 0xab0054a600000000, 0x0572c02000000000, 0xa0a19ceb00000000, + 0xb41ee81100000000, 0x11cdb4da00000000, 0xbfbf205c00000000, + 0x1a6c7c9700000000, 0xa25c798a00000000, 0x078f254100000000, + 0xa9fdb1c700000000, 0x0c2eed0c00000000, 0xd99cbbfd00000000, + 0x7c4fe73600000000, 0xd23d73b000000000, 0x77ee2f7b00000000, + 0xcfde2a6600000000, 0x6a0d76ad00000000, 0xc47fe22b00000000, + 0x61acbee000000000, 0x2f1c3e1200000000, 0x8acf62d900000000, + 0x24bdf65f00000000, 0x816eaa9400000000, 0x395eaf8900000000, + 0x9c8df34200000000, 0x32ff67c400000000, 0x972c3b0f00000000, + 0x429e6dfe00000000, 0xe74d313500000000, 0x493fa5b300000000, + 0xececf97800000000, 0x54dcfc6500000000, 0xf10fa0ae00000000, + 0x5f7d342800000000, 0xfaae68e300000000, 0x821b441600000000, + 0x27c818dd00000000, 0x89ba8c5b00000000, 0x2c69d09000000000, + 0x9459d58d00000000, 0x318a894600000000, 0x9ff81dc000000000, + 0x3a2b410b00000000, 0xef9917fa00000000, 0x4a4a4b3100000000, + 0xe438dfb700000000, 0x41eb837c00000000, 0xf9db866100000000, + 0x5c08daaa00000000, 0xf27a4e2c00000000, 0x57a912e700000000, + 0x1919921500000000, 0xbccacede00000000, 0x12b85a5800000000, + 0xb76b069300000000, 0x0f5b038e00000000, 0xaa885f4500000000, + 0x04facbc300000000, 0xa129970800000000, 0x749bc1f900000000, + 0xd1489d3200000000, 0x7f3a09b400000000, 0xdae9557f00000000, + 0x62d9506200000000, 0xc70a0ca900000000, 0x6978982f00000000, + 0xccabc4e400000000}, + {0x0000000000000000, 0xb40b77a600000000, 0x29119f9700000000, + 0x9d1ae83100000000, 0x13244ff400000000, 0xa72f385200000000, + 0x3a35d06300000000, 0x8e3ea7c500000000, 0x674eef3300000000, + 0xd345989500000000, 0x4e5f70a400000000, 0xfa54070200000000, + 0x746aa0c700000000, 0xc061d76100000000, 0x5d7b3f5000000000, + 0xe97048f600000000, 0xce9cde6700000000, 0x7a97a9c100000000, + 0xe78d41f000000000, 0x5386365600000000, 0xddb8919300000000, + 0x69b3e63500000000, 0xf4a90e0400000000, 0x40a279a200000000, + 0xa9d2315400000000, 0x1dd946f200000000, 0x80c3aec300000000, + 0x34c8d96500000000, 0xbaf67ea000000000, 0x0efd090600000000, + 0x93e7e13700000000, 0x27ec969100000000, 0x9c39bdcf00000000, + 0x2832ca6900000000, 0xb528225800000000, 0x012355fe00000000, + 0x8f1df23b00000000, 0x3b16859d00000000, 0xa60c6dac00000000, + 0x12071a0a00000000, 0xfb7752fc00000000, 0x4f7c255a00000000, + 0xd266cd6b00000000, 0x666dbacd00000000, 0xe8531d0800000000, + 0x5c586aae00000000, 0xc142829f00000000, 0x7549f53900000000, + 0x52a563a800000000, 0xe6ae140e00000000, 0x7bb4fc3f00000000, + 0xcfbf8b9900000000, 0x41812c5c00000000, 0xf58a5bfa00000000, + 0x6890b3cb00000000, 0xdc9bc46d00000000, 0x35eb8c9b00000000, + 0x81e0fb3d00000000, 0x1cfa130c00000000, 0xa8f164aa00000000, + 0x26cfc36f00000000, 0x92c4b4c900000000, 0x0fde5cf800000000, + 0xbbd52b5e00000000, 0x79750b4400000000, 0xcd7e7ce200000000, + 0x506494d300000000, 0xe46fe37500000000, 0x6a5144b000000000, + 0xde5a331600000000, 0x4340db2700000000, 0xf74bac8100000000, + 0x1e3be47700000000, 0xaa3093d100000000, 0x372a7be000000000, + 0x83210c4600000000, 0x0d1fab8300000000, 0xb914dc2500000000, + 0x240e341400000000, 0x900543b200000000, 0xb7e9d52300000000, + 0x03e2a28500000000, 0x9ef84ab400000000, 0x2af33d1200000000, + 0xa4cd9ad700000000, 0x10c6ed7100000000, 0x8ddc054000000000, + 0x39d772e600000000, 0xd0a73a1000000000, 0x64ac4db600000000, + 0xf9b6a58700000000, 0x4dbdd22100000000, 0xc38375e400000000, + 0x7788024200000000, 0xea92ea7300000000, 0x5e999dd500000000, + 0xe54cb68b00000000, 0x5147c12d00000000, 0xcc5d291c00000000, + 0x78565eba00000000, 0xf668f97f00000000, 0x42638ed900000000, + 0xdf7966e800000000, 0x6b72114e00000000, 0x820259b800000000, + 0x36092e1e00000000, 0xab13c62f00000000, 0x1f18b18900000000, + 0x9126164c00000000, 0x252d61ea00000000, 0xb83789db00000000, + 0x0c3cfe7d00000000, 0x2bd068ec00000000, 0x9fdb1f4a00000000, + 0x02c1f77b00000000, 0xb6ca80dd00000000, 0x38f4271800000000, + 0x8cff50be00000000, 0x11e5b88f00000000, 0xa5eecf2900000000, + 0x4c9e87df00000000, 0xf895f07900000000, 0x658f184800000000, + 0xd1846fee00000000, 0x5fbac82b00000000, 0xebb1bf8d00000000, + 0x76ab57bc00000000, 0xc2a0201a00000000, 0xf2ea168800000000, + 0x46e1612e00000000, 0xdbfb891f00000000, 0x6ff0feb900000000, + 0xe1ce597c00000000, 0x55c52eda00000000, 0xc8dfc6eb00000000, + 0x7cd4b14d00000000, 0x95a4f9bb00000000, 0x21af8e1d00000000, + 0xbcb5662c00000000, 0x08be118a00000000, 0x8680b64f00000000, + 0x328bc1e900000000, 0xaf9129d800000000, 0x1b9a5e7e00000000, + 0x3c76c8ef00000000, 0x887dbf4900000000, 0x1567577800000000, + 0xa16c20de00000000, 0x2f52871b00000000, 0x9b59f0bd00000000, + 0x0643188c00000000, 0xb2486f2a00000000, 0x5b3827dc00000000, + 0xef33507a00000000, 0x7229b84b00000000, 0xc622cfed00000000, + 0x481c682800000000, 0xfc171f8e00000000, 0x610df7bf00000000, + 0xd506801900000000, 0x6ed3ab4700000000, 0xdad8dce100000000, + 0x47c234d000000000, 0xf3c9437600000000, 0x7df7e4b300000000, + 0xc9fc931500000000, 0x54e67b2400000000, 0xe0ed0c8200000000, + 0x099d447400000000, 0xbd9633d200000000, 0x208cdbe300000000, + 0x9487ac4500000000, 0x1ab90b8000000000, 0xaeb27c2600000000, + 0x33a8941700000000, 0x87a3e3b100000000, 0xa04f752000000000, + 0x1444028600000000, 0x895eeab700000000, 0x3d559d1100000000, + 0xb36b3ad400000000, 0x07604d7200000000, 0x9a7aa54300000000, + 0x2e71d2e500000000, 0xc7019a1300000000, 0x730aedb500000000, + 0xee10058400000000, 0x5a1b722200000000, 0xd425d5e700000000, + 0x602ea24100000000, 0xfd344a7000000000, 0x493f3dd600000000, + 0x8b9f1dcc00000000, 0x3f946a6a00000000, 0xa28e825b00000000, + 0x1685f5fd00000000, 0x98bb523800000000, 0x2cb0259e00000000, + 0xb1aacdaf00000000, 0x05a1ba0900000000, 0xecd1f2ff00000000, + 0x58da855900000000, 0xc5c06d6800000000, 0x71cb1ace00000000, + 0xfff5bd0b00000000, 0x4bfecaad00000000, 0xd6e4229c00000000, + 0x62ef553a00000000, 0x4503c3ab00000000, 0xf108b40d00000000, + 0x6c125c3c00000000, 0xd8192b9a00000000, 0x56278c5f00000000, + 0xe22cfbf900000000, 0x7f3613c800000000, 0xcb3d646e00000000, + 0x224d2c9800000000, 0x96465b3e00000000, 0x0b5cb30f00000000, + 0xbf57c4a900000000, 0x3169636c00000000, 0x856214ca00000000, + 0x1878fcfb00000000, 0xac738b5d00000000, 0x17a6a00300000000, + 0xa3add7a500000000, 0x3eb73f9400000000, 0x8abc483200000000, + 0x0482eff700000000, 0xb089985100000000, 0x2d93706000000000, + 0x999807c600000000, 0x70e84f3000000000, 0xc4e3389600000000, + 0x59f9d0a700000000, 0xedf2a70100000000, 0x63cc00c400000000, + 0xd7c7776200000000, 0x4add9f5300000000, 0xfed6e8f500000000, + 0xd93a7e6400000000, 0x6d3109c200000000, 0xf02be1f300000000, + 0x4420965500000000, 0xca1e319000000000, 0x7e15463600000000, + 0xe30fae0700000000, 0x5704d9a100000000, 0xbe74915700000000, + 0x0a7fe6f100000000, 0x97650ec000000000, 0x236e796600000000, + 0xad50dea300000000, 0x195ba90500000000, 0x8441413400000000, + 0x304a369200000000}, + {0x0000000000000000, 0x9e00aacc00000000, 0x7d07254200000000, + 0xe3078f8e00000000, 0xfa0e4a8400000000, 0x640ee04800000000, + 0x87096fc600000000, 0x1909c50a00000000, 0xb51be5d300000000, + 0x2b1b4f1f00000000, 0xc81cc09100000000, 0x561c6a5d00000000, + 0x4f15af5700000000, 0xd115059b00000000, 0x32128a1500000000, + 0xac1220d900000000, 0x2b31bb7c00000000, 0xb53111b000000000, + 0x56369e3e00000000, 0xc83634f200000000, 0xd13ff1f800000000, + 0x4f3f5b3400000000, 0xac38d4ba00000000, 0x32387e7600000000, + 0x9e2a5eaf00000000, 0x002af46300000000, 0xe32d7bed00000000, + 0x7d2dd12100000000, 0x6424142b00000000, 0xfa24bee700000000, + 0x1923316900000000, 0x87239ba500000000, 0x566276f900000000, + 0xc862dc3500000000, 0x2b6553bb00000000, 0xb565f97700000000, + 0xac6c3c7d00000000, 0x326c96b100000000, 0xd16b193f00000000, + 0x4f6bb3f300000000, 0xe379932a00000000, 0x7d7939e600000000, + 0x9e7eb66800000000, 0x007e1ca400000000, 0x1977d9ae00000000, + 0x8777736200000000, 0x6470fcec00000000, 0xfa70562000000000, + 0x7d53cd8500000000, 0xe353674900000000, 0x0054e8c700000000, + 0x9e54420b00000000, 0x875d870100000000, 0x195d2dcd00000000, + 0xfa5aa24300000000, 0x645a088f00000000, 0xc848285600000000, + 0x5648829a00000000, 0xb54f0d1400000000, 0x2b4fa7d800000000, + 0x324662d200000000, 0xac46c81e00000000, 0x4f41479000000000, + 0xd141ed5c00000000, 0xedc29d2900000000, 0x73c237e500000000, + 0x90c5b86b00000000, 0x0ec512a700000000, 0x17ccd7ad00000000, + 0x89cc7d6100000000, 0x6acbf2ef00000000, 0xf4cb582300000000, + 0x58d978fa00000000, 0xc6d9d23600000000, 0x25de5db800000000, + 0xbbdef77400000000, 0xa2d7327e00000000, 0x3cd798b200000000, + 0xdfd0173c00000000, 0x41d0bdf000000000, 0xc6f3265500000000, + 0x58f38c9900000000, 0xbbf4031700000000, 0x25f4a9db00000000, + 0x3cfd6cd100000000, 0xa2fdc61d00000000, 0x41fa499300000000, + 0xdffae35f00000000, 0x73e8c38600000000, 0xede8694a00000000, + 0x0eefe6c400000000, 0x90ef4c0800000000, 0x89e6890200000000, + 0x17e623ce00000000, 0xf4e1ac4000000000, 0x6ae1068c00000000, + 0xbba0ebd000000000, 0x25a0411c00000000, 0xc6a7ce9200000000, + 0x58a7645e00000000, 0x41aea15400000000, 0xdfae0b9800000000, + 0x3ca9841600000000, 0xa2a92eda00000000, 0x0ebb0e0300000000, + 0x90bba4cf00000000, 0x73bc2b4100000000, 0xedbc818d00000000, + 0xf4b5448700000000, 0x6ab5ee4b00000000, 0x89b261c500000000, + 0x17b2cb0900000000, 0x909150ac00000000, 0x0e91fa6000000000, + 0xed9675ee00000000, 0x7396df2200000000, 0x6a9f1a2800000000, + 0xf49fb0e400000000, 0x17983f6a00000000, 0x899895a600000000, + 0x258ab57f00000000, 0xbb8a1fb300000000, 0x588d903d00000000, + 0xc68d3af100000000, 0xdf84fffb00000000, 0x4184553700000000, + 0xa283dab900000000, 0x3c83707500000000, 0xda853b5300000000, + 0x4485919f00000000, 0xa7821e1100000000, 0x3982b4dd00000000, + 0x208b71d700000000, 0xbe8bdb1b00000000, 0x5d8c549500000000, + 0xc38cfe5900000000, 0x6f9ede8000000000, 0xf19e744c00000000, + 0x1299fbc200000000, 0x8c99510e00000000, 0x9590940400000000, + 0x0b903ec800000000, 0xe897b14600000000, 0x76971b8a00000000, + 0xf1b4802f00000000, 0x6fb42ae300000000, 0x8cb3a56d00000000, + 0x12b30fa100000000, 0x0bbacaab00000000, 0x95ba606700000000, + 0x76bdefe900000000, 0xe8bd452500000000, 0x44af65fc00000000, + 0xdaafcf3000000000, 0x39a840be00000000, 0xa7a8ea7200000000, + 0xbea12f7800000000, 0x20a185b400000000, 0xc3a60a3a00000000, + 0x5da6a0f600000000, 0x8ce74daa00000000, 0x12e7e76600000000, + 0xf1e068e800000000, 0x6fe0c22400000000, 0x76e9072e00000000, + 0xe8e9ade200000000, 0x0bee226c00000000, 0x95ee88a000000000, + 0x39fca87900000000, 0xa7fc02b500000000, 0x44fb8d3b00000000, + 0xdafb27f700000000, 0xc3f2e2fd00000000, 0x5df2483100000000, + 0xbef5c7bf00000000, 0x20f56d7300000000, 0xa7d6f6d600000000, + 0x39d65c1a00000000, 0xdad1d39400000000, 0x44d1795800000000, + 0x5dd8bc5200000000, 0xc3d8169e00000000, 0x20df991000000000, + 0xbedf33dc00000000, 0x12cd130500000000, 0x8ccdb9c900000000, + 0x6fca364700000000, 0xf1ca9c8b00000000, 0xe8c3598100000000, + 0x76c3f34d00000000, 0x95c47cc300000000, 0x0bc4d60f00000000, + 0x3747a67a00000000, 0xa9470cb600000000, 0x4a40833800000000, + 0xd44029f400000000, 0xcd49ecfe00000000, 0x5349463200000000, + 0xb04ec9bc00000000, 0x2e4e637000000000, 0x825c43a900000000, + 0x1c5ce96500000000, 0xff5b66eb00000000, 0x615bcc2700000000, + 0x7852092d00000000, 0xe652a3e100000000, 0x05552c6f00000000, + 0x9b5586a300000000, 0x1c761d0600000000, 0x8276b7ca00000000, + 0x6171384400000000, 0xff71928800000000, 0xe678578200000000, + 0x7878fd4e00000000, 0x9b7f72c000000000, 0x057fd80c00000000, + 0xa96df8d500000000, 0x376d521900000000, 0xd46add9700000000, + 0x4a6a775b00000000, 0x5363b25100000000, 0xcd63189d00000000, + 0x2e64971300000000, 0xb0643ddf00000000, 0x6125d08300000000, + 0xff257a4f00000000, 0x1c22f5c100000000, 0x82225f0d00000000, + 0x9b2b9a0700000000, 0x052b30cb00000000, 0xe62cbf4500000000, + 0x782c158900000000, 0xd43e355000000000, 0x4a3e9f9c00000000, + 0xa939101200000000, 0x3739bade00000000, 0x2e307fd400000000, + 0xb030d51800000000, 0x53375a9600000000, 0xcd37f05a00000000, + 0x4a146bff00000000, 0xd414c13300000000, 0x37134ebd00000000, + 0xa913e47100000000, 0xb01a217b00000000, 0x2e1a8bb700000000, + 0xcd1d043900000000, 0x531daef500000000, 0xff0f8e2c00000000, + 0x610f24e000000000, 0x8208ab6e00000000, 0x1c0801a200000000, + 0x0501c4a800000000, 0x9b016e6400000000, 0x7806e1ea00000000, + 0xe6064b2600000000}}; + +#else /* W == 4 */ + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, 0x8f629757, + 0x37def032, 0x256b5fdc, 0x9dd738b9, 0xc5b428ef, 0x7d084f8a, + 0x6fbde064, 0xd7018701, 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, + 0x58631056, 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, + 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26, 0x95ad7f70, + 0x2d111815, 0x3fa4b7fb, 0x8718d09e, 0x1acfe827, 0xa2738f42, + 0xb0c620ac, 0x087a47c9, 0xa032af3e, 0x188ec85b, 0x0a3b67b5, + 0xb28700d0, 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, + 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f, 0xeae41086, + 0x525877e3, 0x40edd80d, 0xf851bf68, 0xf02bf8a1, 0x48979fc4, + 0x5a22302a, 0xe29e574f, 0x7f496ff6, 0xc7f50893, 0xd540a77d, + 0x6dfcc018, 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, + 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7, 0x9b14583d, + 0x23a83f58, 0x311d90b6, 0x89a1f7d3, 0x1476cf6a, 0xaccaa80f, + 0xbe7f07e1, 0x06c36084, 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, + 0x4c15df3c, 0xd1c2e785, 0x697e80e0, 0x7bcb2f0e, 0xc377486b, + 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c, 0x446f98f5, + 0xfcd3ff90, 0xee66507e, 0x56da371b, 0x0eb9274d, 0xb6054028, + 0xa4b0efc6, 0x1c0c88a3, 0x81dbb01a, 0x3967d77f, 0x2bd27891, + 0x936e1ff4, 0x3b26f703, 0x839a9066, 0x912f3f88, 0x299358ed, + 0xb4446054, 0x0cf80731, 0x1e4da8df, 0xa6f1cfba, 0xfe92dfec, + 0x462eb889, 0x549b1767, 0xec277002, 0x71f048bb, 0xc94c2fde, + 0xdbf98030, 0x6345e755, 0x6b3fa09c, 0xd383c7f9, 0xc1366817, + 0x798a0f72, 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825, + 0xae8b8873, 0x1637ef16, 0x048240f8, 0xbc3e279d, 0x21e91f24, + 0x99557841, 0x8be0d7af, 0x335cb0ca, 0xed59b63b, 0x55e5d15e, + 0x47507eb0, 0xffec19d5, 0x623b216c, 0xda874609, 0xc832e9e7, + 0x708e8e82, 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a, + 0xa78f0983, 0x1f336ee6, 0x0d86c108, 0xb53aa66d, 0xbd40e1a4, + 0x05fc86c1, 0x1749292f, 0xaff54e4a, 0x322276f3, 0x8a9e1196, + 0x982bbe78, 0x2097d91d, 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, + 0x6a4166a5, 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2, + 0x4d6b1905, 0xf5d77e60, 0xe762d18e, 0x5fdeb6eb, 0xc2098e52, + 0x7ab5e937, 0x680046d9, 0xd0bc21bc, 0x88df31ea, 0x3063568f, + 0x22d6f961, 0x9a6a9e04, 0x07bda6bd, 0xbf01c1d8, 0xadb46e36, + 0x15080953, 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0x0fc7e174, + 0x9210d9cd, 0x2aacbea8, 0x38191146, 0x80a57623, 0xd8c66675, + 0x607a0110, 0x72cfaefe, 0xca73c99b, 0x57a4f122, 0xef189647, + 0xfdad39a9, 0x45115ecc, 0x764dee06, 0xcef18963, 0xdc44268d, + 0x64f841e8, 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf, + 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907, 0x3c9b51be, + 0x842736db, 0x96929935, 0x2e2efe50, 0x2654b999, 0x9ee8defc, + 0x8c5d7112, 0x34e11677, 0xa9362ece, 0x118a49ab, 0x033fe645, + 0xbb838120, 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98, + 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf, 0xd67f4138, + 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, 0x591dd66f, 0xe1a1b10a, + 0xf3141ee4, 0x4ba87981, 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, + 0x017ec639, 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e, + 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, 0x090481f0, + 0xb1b8e695, 0xa30d497b, 0x1bb12e1e, 0x43d23e48, 0xfb6e592d, + 0xe9dbf6c3, 0x516791a6, 0xccb0a91f, 0x740cce7a, 0x66b96194, + 0xde0506f1}, + {0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59, 0x0709a8dc, + 0x06cbc2eb, 0x048d7cb2, 0x054f1685, 0x0e1351b8, 0x0fd13b8f, + 0x0d9785d6, 0x0c55efe1, 0x091af964, 0x08d89353, 0x0a9e2d0a, + 0x0b5c473d, 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29, + 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, 0x1235f2c8, + 0x13f798ff, 0x11b126a6, 0x10734c91, 0x153c5a14, 0x14fe3023, + 0x16b88e7a, 0x177ae44d, 0x384d46e0, 0x398f2cd7, 0x3bc9928e, + 0x3a0bf8b9, 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065, + 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, 0x3157bf84, + 0x3095d5b3, 0x32d36bea, 0x331101dd, 0x246be590, 0x25a98fa7, + 0x27ef31fe, 0x262d5bc9, 0x23624d4c, 0x22a0277b, 0x20e69922, + 0x2124f315, 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71, + 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad, 0x709a8dc0, + 0x7158e7f7, 0x731e59ae, 0x72dc3399, 0x7793251c, 0x76514f2b, + 0x7417f172, 0x75d59b45, 0x7e89dc78, 0x7f4bb64f, 0x7d0d0816, + 0x7ccf6221, 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd, + 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9, 0x6bb5866c, + 0x6a77ec5b, 0x68315202, 0x69f33835, 0x62af7f08, 0x636d153f, + 0x612bab66, 0x60e9c151, 0x65a6d7d4, 0x6464bde3, 0x662203ba, + 0x67e0698d, 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579, + 0x4fde63fc, 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5, 0x46c49a98, + 0x4706f0af, 0x45404ef6, 0x448224c1, 0x41cd3244, 0x400f5873, + 0x4249e62a, 0x438b8c1d, 0x54f16850, 0x55330267, 0x5775bc3e, + 0x56b7d609, 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5, + 0x5ae239e8, 0x5b2053df, 0x5966ed86, 0x58a487b1, 0x5deb9134, + 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d, 0xe1351b80, 0xe0f771b7, + 0xe2b1cfee, 0xe373a5d9, 0xe63cb35c, 0xe7fed96b, 0xe5b86732, + 0xe47a0d05, 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461, + 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, 0xea695cbd, 0xfd13b8f0, + 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9, 0xfa1a102c, 0xfbd87a1b, + 0xf99ec442, 0xf85cae75, 0xf300e948, 0xf2c2837f, 0xf0843d26, + 0xf1465711, 0xf4094194, 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd, + 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339, 0xde71f5bc, + 0xdfb39f8b, 0xddf521d2, 0xdc374be5, 0xd76b0cd8, 0xd6a966ef, + 0xd4efd8b6, 0xd52db281, 0xd062a404, 0xd1a0ce33, 0xd3e6706a, + 0xd2241a5d, 0xc55efe10, 0xc49c9427, 0xc6da2a7e, 0xc7184049, + 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895, 0xcb4dafa8, + 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1, 0xcc440774, 0xcd866d43, + 0xcfc0d31a, 0xce02b92d, 0x91af9640, 0x906dfc77, 0x922b422e, + 0x93e92819, 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5, + 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, 0x98b56f24, + 0x99770513, 0x9b31bb4a, 0x9af3d17d, 0x8d893530, 0x8c4b5f07, + 0x8e0de15e, 0x8fcf8b69, 0x8a809dec, 0x8b42f7db, 0x89044982, + 0x88c623b5, 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, + 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d, 0xa9e2d0a0, + 0xa820ba97, 0xaa6604ce, 0xaba46ef9, 0xaeeb787c, 0xaf29124b, + 0xad6fac12, 0xacadc625, 0xa7f18118, 0xa633eb2f, 0xa4755576, + 0xa5b73f41, 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d, + 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89, 0xb2cddb0c, + 0xb30fb13b, 0xb1490f62, 0xb08b6555, 0xbbd72268, 0xba15485f, + 0xb853f606, 0xb9919c31, 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, + 0xbe9834ed}, + {0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, 0x646cc504, + 0x7d77f445, 0x565aa786, 0x4f4196c7, 0xc8d98a08, 0xd1c2bb49, + 0xfaefe88a, 0xe3f4d9cb, 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, + 0x87981ccf, 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, + 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496, 0x821b9859, + 0x9b00a918, 0xb02dfadb, 0xa936cb9a, 0xe6775d5d, 0xff6c6c1c, + 0xd4413fdf, 0xcd5a0e9e, 0x958424a2, 0x8c9f15e3, 0xa7b24620, + 0xbea97761, 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, + 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69, 0x39316bae, + 0x202a5aef, 0x0b07092c, 0x121c386d, 0xdf4636f3, 0xc65d07b2, + 0xed705471, 0xf46b6530, 0xbb2af3f7, 0xa231c2b6, 0x891c9175, + 0x9007a034, 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38, + 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c, 0xf0794f05, + 0xe9627e44, 0xc24f2d87, 0xdb541cc6, 0x94158a01, 0x8d0ebb40, + 0xa623e883, 0xbf38d9c2, 0x38a0c50d, 0x21bbf44c, 0x0a96a78f, + 0x138d96ce, 0x5ccc0009, 0x45d73148, 0x6efa628b, 0x77e153ca, + 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97, 0xded79850, + 0xc7cca911, 0xece1fad2, 0xf5facb93, 0x7262d75c, 0x6b79e61d, + 0x4054b5de, 0x594f849f, 0x160e1258, 0x0f152319, 0x243870da, + 0x3d23419b, 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, 0x4ed03864, + 0x0191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60, 0xad24e1af, + 0xb43fd0ee, 0x9f12832d, 0x8609b26c, 0xc94824ab, 0xd05315ea, + 0xfb7e4629, 0xe2657768, 0x2f3f79f6, 0x362448b7, 0x1d091b74, + 0x04122a35, 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31, + 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d, 0x838a36fa, + 0x9a9107bb, 0xb1bc5478, 0xa8a76539, 0x3b83984b, 0x2298a90a, + 0x09b5fac9, 0x10aecb88, 0x5fef5d4f, 0x46f46c0e, 0x6dd93fcd, + 0x74c20e8c, 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180, + 0x9736d747, 0x8e2de606, 0xa500b5c5, 0xbc1b8484, 0x71418a1a, + 0x685abb5b, 0x4377e898, 0x5a6cd9d9, 0x152d4f1e, 0x0c367e5f, + 0x271b2d9c, 0x3e001cdd, 0xb9980012, 0xa0833153, 0x8bae6290, + 0x92b553d1, 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5, + 0xae07bce9, 0xb71c8da8, 0x9c31de6b, 0x852aef2a, 0xca6b79ed, + 0xd37048ac, 0xf85d1b6f, 0xe1462a2e, 0x66de36e1, 0x7fc507a0, + 0x54e85463, 0x4df36522, 0x02b2f3e5, 0x1ba9c2a4, 0x30849167, + 0x299fa026, 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b, + 0x80a96bbc, 0x99b25afd, 0xb29f093e, 0xab84387f, 0x2c1c24b0, + 0x350715f1, 0x1e2a4632, 0x07317773, 0x4870e1b4, 0x516bd0f5, + 0x7a468336, 0x635db277, 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, + 0xe0d7848d, 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189, + 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, 0x674f9842, + 0x7e54a903, 0x5579fac0, 0x4c62cb81, 0x8138c51f, 0x9823f45e, + 0xb30ea79d, 0xaa1596dc, 0xe554001b, 0xfc4f315a, 0xd7626299, + 0xce7953d8, 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4, + 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0, 0x5e7ef3ec, + 0x4765c2ad, 0x6c48916e, 0x7553a02f, 0x3a1236e8, 0x230907a9, + 0x0824546a, 0x113f652b, 0x96a779e4, 0x8fbc48a5, 0xa4911b66, + 0xbd8a2a27, 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23, + 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e, 0x70d024b9, + 0x69cb15f8, 0x42e6463b, 0x5bfd777a, 0xdc656bb5, 0xc57e5af4, + 0xee530937, 0xf7483876, 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, + 0x9324fd72}, + {0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x00000000, 0x96300777, 0x2c610eee, 0xba510999, 0x19c46d07, + 0x8ff46a70, 0x35a563e9, 0xa395649e, 0x3288db0e, 0xa4b8dc79, + 0x1ee9d5e0, 0x88d9d297, 0x2b4cb609, 0xbd7cb17e, 0x072db8e7, + 0x911dbf90, 0x6410b71d, 0xf220b06a, 0x4871b9f3, 0xde41be84, + 0x7dd4da1a, 0xebe4dd6d, 0x51b5d4f4, 0xc785d383, 0x56986c13, + 0xc0a86b64, 0x7af962fd, 0xecc9658a, 0x4f5c0114, 0xd96c0663, + 0x633d0ffa, 0xf50d088d, 0xc8206e3b, 0x5e10694c, 0xe44160d5, + 0x727167a2, 0xd1e4033c, 0x47d4044b, 0xfd850dd2, 0x6bb50aa5, + 0xfaa8b535, 0x6c98b242, 0xd6c9bbdb, 0x40f9bcac, 0xe36cd832, + 0x755cdf45, 0xcf0dd6dc, 0x593dd1ab, 0xac30d926, 0x3a00de51, + 0x8051d7c8, 0x1661d0bf, 0xb5f4b421, 0x23c4b356, 0x9995bacf, + 0x0fa5bdb8, 0x9eb80228, 0x0888055f, 0xb2d90cc6, 0x24e90bb1, + 0x877c6f2f, 0x114c6858, 0xab1d61c1, 0x3d2d66b6, 0x9041dc76, + 0x0671db01, 0xbc20d298, 0x2a10d5ef, 0x8985b171, 0x1fb5b606, + 0xa5e4bf9f, 0x33d4b8e8, 0xa2c90778, 0x34f9000f, 0x8ea80996, + 0x18980ee1, 0xbb0d6a7f, 0x2d3d6d08, 0x976c6491, 0x015c63e6, + 0xf4516b6b, 0x62616c1c, 0xd8306585, 0x4e0062f2, 0xed95066c, + 0x7ba5011b, 0xc1f40882, 0x57c40ff5, 0xc6d9b065, 0x50e9b712, + 0xeab8be8b, 0x7c88b9fc, 0xdf1ddd62, 0x492dda15, 0xf37cd38c, + 0x654cd4fb, 0x5861b24d, 0xce51b53a, 0x7400bca3, 0xe230bbd4, + 0x41a5df4a, 0xd795d83d, 0x6dc4d1a4, 0xfbf4d6d3, 0x6ae96943, + 0xfcd96e34, 0x468867ad, 0xd0b860da, 0x732d0444, 0xe51d0333, + 0x5f4c0aaa, 0xc97c0ddd, 0x3c710550, 0xaa410227, 0x10100bbe, + 0x86200cc9, 0x25b56857, 0xb3856f20, 0x09d466b9, 0x9fe461ce, + 0x0ef9de5e, 0x98c9d929, 0x2298d0b0, 0xb4a8d7c7, 0x173db359, + 0x810db42e, 0x3b5cbdb7, 0xad6cbac0, 0x2083b8ed, 0xb6b3bf9a, + 0x0ce2b603, 0x9ad2b174, 0x3947d5ea, 0xaf77d29d, 0x1526db04, + 0x8316dc73, 0x120b63e3, 0x843b6494, 0x3e6a6d0d, 0xa85a6a7a, + 0x0bcf0ee4, 0x9dff0993, 0x27ae000a, 0xb19e077d, 0x44930ff0, + 0xd2a30887, 0x68f2011e, 0xfec20669, 0x5d5762f7, 0xcb676580, + 0x71366c19, 0xe7066b6e, 0x761bd4fe, 0xe02bd389, 0x5a7ada10, + 0xcc4add67, 0x6fdfb9f9, 0xf9efbe8e, 0x43beb717, 0xd58eb060, + 0xe8a3d6d6, 0x7e93d1a1, 0xc4c2d838, 0x52f2df4f, 0xf167bbd1, + 0x6757bca6, 0xdd06b53f, 0x4b36b248, 0xda2b0dd8, 0x4c1b0aaf, + 0xf64a0336, 0x607a0441, 0xc3ef60df, 0x55df67a8, 0xef8e6e31, + 0x79be6946, 0x8cb361cb, 0x1a8366bc, 0xa0d26f25, 0x36e26852, + 0x95770ccc, 0x03470bbb, 0xb9160222, 0x2f260555, 0xbe3bbac5, + 0x280bbdb2, 0x925ab42b, 0x046ab35c, 0xa7ffd7c2, 0x31cfd0b5, + 0x8b9ed92c, 0x1daede5b, 0xb0c2649b, 0x26f263ec, 0x9ca36a75, + 0x0a936d02, 0xa906099c, 0x3f360eeb, 0x85670772, 0x13570005, + 0x824abf95, 0x147ab8e2, 0xae2bb17b, 0x381bb60c, 0x9b8ed292, + 0x0dbed5e5, 0xb7efdc7c, 0x21dfdb0b, 0xd4d2d386, 0x42e2d4f1, + 0xf8b3dd68, 0x6e83da1f, 0xcd16be81, 0x5b26b9f6, 0xe177b06f, + 0x7747b718, 0xe65a0888, 0x706a0fff, 0xca3b0666, 0x5c0b0111, + 0xff9e658f, 0x69ae62f8, 0xd3ff6b61, 0x45cf6c16, 0x78e20aa0, + 0xeed20dd7, 0x5483044e, 0xc2b30339, 0x612667a7, 0xf71660d0, + 0x4d476949, 0xdb776e3e, 0x4a6ad1ae, 0xdc5ad6d9, 0x660bdf40, + 0xf03bd837, 0x53aebca9, 0xc59ebbde, 0x7fcfb247, 0xe9ffb530, + 0x1cf2bdbd, 0x8ac2baca, 0x3093b353, 0xa6a3b424, 0x0536d0ba, + 0x9306d7cd, 0x2957de54, 0xbf67d923, 0x2e7a66b3, 0xb84a61c4, + 0x021b685d, 0x942b6f2a, 0x37be0bb4, 0xa18e0cc3, 0x1bdf055a, + 0x8def022d}, + {0x00000000, 0x41311b19, 0x82623632, 0xc3532d2b, 0x04c56c64, + 0x45f4777d, 0x86a75a56, 0xc796414f, 0x088ad9c8, 0x49bbc2d1, + 0x8ae8effa, 0xcbd9f4e3, 0x0c4fb5ac, 0x4d7eaeb5, 0x8e2d839e, + 0xcf1c9887, 0x5112c24a, 0x1023d953, 0xd370f478, 0x9241ef61, + 0x55d7ae2e, 0x14e6b537, 0xd7b5981c, 0x96848305, 0x59981b82, + 0x18a9009b, 0xdbfa2db0, 0x9acb36a9, 0x5d5d77e6, 0x1c6c6cff, + 0xdf3f41d4, 0x9e0e5acd, 0xa2248495, 0xe3159f8c, 0x2046b2a7, + 0x6177a9be, 0xa6e1e8f1, 0xe7d0f3e8, 0x2483dec3, 0x65b2c5da, + 0xaaae5d5d, 0xeb9f4644, 0x28cc6b6f, 0x69fd7076, 0xae6b3139, + 0xef5a2a20, 0x2c09070b, 0x6d381c12, 0xf33646df, 0xb2075dc6, + 0x715470ed, 0x30656bf4, 0xf7f32abb, 0xb6c231a2, 0x75911c89, + 0x34a00790, 0xfbbc9f17, 0xba8d840e, 0x79dea925, 0x38efb23c, + 0xff79f373, 0xbe48e86a, 0x7d1bc541, 0x3c2ade58, 0x054f79f0, + 0x447e62e9, 0x872d4fc2, 0xc61c54db, 0x018a1594, 0x40bb0e8d, + 0x83e823a6, 0xc2d938bf, 0x0dc5a038, 0x4cf4bb21, 0x8fa7960a, + 0xce968d13, 0x0900cc5c, 0x4831d745, 0x8b62fa6e, 0xca53e177, + 0x545dbbba, 0x156ca0a3, 0xd63f8d88, 0x970e9691, 0x5098d7de, + 0x11a9ccc7, 0xd2fae1ec, 0x93cbfaf5, 0x5cd76272, 0x1de6796b, + 0xdeb55440, 0x9f844f59, 0x58120e16, 0x1923150f, 0xda703824, + 0x9b41233d, 0xa76bfd65, 0xe65ae67c, 0x2509cb57, 0x6438d04e, + 0xa3ae9101, 0xe29f8a18, 0x21cca733, 0x60fdbc2a, 0xafe124ad, + 0xeed03fb4, 0x2d83129f, 0x6cb20986, 0xab2448c9, 0xea1553d0, + 0x29467efb, 0x687765e2, 0xf6793f2f, 0xb7482436, 0x741b091d, + 0x352a1204, 0xf2bc534b, 0xb38d4852, 0x70de6579, 0x31ef7e60, + 0xfef3e6e7, 0xbfc2fdfe, 0x7c91d0d5, 0x3da0cbcc, 0xfa368a83, + 0xbb07919a, 0x7854bcb1, 0x3965a7a8, 0x4b98833b, 0x0aa99822, + 0xc9fab509, 0x88cbae10, 0x4f5def5f, 0x0e6cf446, 0xcd3fd96d, + 0x8c0ec274, 0x43125af3, 0x022341ea, 0xc1706cc1, 0x804177d8, + 0x47d73697, 0x06e62d8e, 0xc5b500a5, 0x84841bbc, 0x1a8a4171, + 0x5bbb5a68, 0x98e87743, 0xd9d96c5a, 0x1e4f2d15, 0x5f7e360c, + 0x9c2d1b27, 0xdd1c003e, 0x120098b9, 0x533183a0, 0x9062ae8b, + 0xd153b592, 0x16c5f4dd, 0x57f4efc4, 0x94a7c2ef, 0xd596d9f6, + 0xe9bc07ae, 0xa88d1cb7, 0x6bde319c, 0x2aef2a85, 0xed796bca, + 0xac4870d3, 0x6f1b5df8, 0x2e2a46e1, 0xe136de66, 0xa007c57f, + 0x6354e854, 0x2265f34d, 0xe5f3b202, 0xa4c2a91b, 0x67918430, + 0x26a09f29, 0xb8aec5e4, 0xf99fdefd, 0x3accf3d6, 0x7bfde8cf, + 0xbc6ba980, 0xfd5ab299, 0x3e099fb2, 0x7f3884ab, 0xb0241c2c, + 0xf1150735, 0x32462a1e, 0x73773107, 0xb4e17048, 0xf5d06b51, + 0x3683467a, 0x77b25d63, 0x4ed7facb, 0x0fe6e1d2, 0xccb5ccf9, + 0x8d84d7e0, 0x4a1296af, 0x0b238db6, 0xc870a09d, 0x8941bb84, + 0x465d2303, 0x076c381a, 0xc43f1531, 0x850e0e28, 0x42984f67, + 0x03a9547e, 0xc0fa7955, 0x81cb624c, 0x1fc53881, 0x5ef42398, + 0x9da70eb3, 0xdc9615aa, 0x1b0054e5, 0x5a314ffc, 0x996262d7, + 0xd85379ce, 0x174fe149, 0x567efa50, 0x952dd77b, 0xd41ccc62, + 0x138a8d2d, 0x52bb9634, 0x91e8bb1f, 0xd0d9a006, 0xecf37e5e, + 0xadc26547, 0x6e91486c, 0x2fa05375, 0xe836123a, 0xa9070923, + 0x6a542408, 0x2b653f11, 0xe479a796, 0xa548bc8f, 0x661b91a4, + 0x272a8abd, 0xe0bccbf2, 0xa18dd0eb, 0x62defdc0, 0x23efe6d9, + 0xbde1bc14, 0xfcd0a70d, 0x3f838a26, 0x7eb2913f, 0xb924d070, + 0xf815cb69, 0x3b46e642, 0x7a77fd5b, 0xb56b65dc, 0xf45a7ec5, + 0x370953ee, 0x763848f7, 0xb1ae09b8, 0xf09f12a1, 0x33cc3f8a, + 0x72fd2493}, + {0x00000000, 0x376ac201, 0x6ed48403, 0x59be4602, 0xdca80907, + 0xebc2cb06, 0xb27c8d04, 0x85164f05, 0xb851130e, 0x8f3bd10f, + 0xd685970d, 0xe1ef550c, 0x64f91a09, 0x5393d808, 0x0a2d9e0a, + 0x3d475c0b, 0x70a3261c, 0x47c9e41d, 0x1e77a21f, 0x291d601e, + 0xac0b2f1b, 0x9b61ed1a, 0xc2dfab18, 0xf5b56919, 0xc8f23512, + 0xff98f713, 0xa626b111, 0x914c7310, 0x145a3c15, 0x2330fe14, + 0x7a8eb816, 0x4de47a17, 0xe0464d38, 0xd72c8f39, 0x8e92c93b, + 0xb9f80b3a, 0x3cee443f, 0x0b84863e, 0x523ac03c, 0x6550023d, + 0x58175e36, 0x6f7d9c37, 0x36c3da35, 0x01a91834, 0x84bf5731, + 0xb3d59530, 0xea6bd332, 0xdd011133, 0x90e56b24, 0xa78fa925, + 0xfe31ef27, 0xc95b2d26, 0x4c4d6223, 0x7b27a022, 0x2299e620, + 0x15f32421, 0x28b4782a, 0x1fdeba2b, 0x4660fc29, 0x710a3e28, + 0xf41c712d, 0xc376b32c, 0x9ac8f52e, 0xada2372f, 0xc08d9a70, + 0xf7e75871, 0xae591e73, 0x9933dc72, 0x1c259377, 0x2b4f5176, + 0x72f11774, 0x459bd575, 0x78dc897e, 0x4fb64b7f, 0x16080d7d, + 0x2162cf7c, 0xa4748079, 0x931e4278, 0xcaa0047a, 0xfdcac67b, + 0xb02ebc6c, 0x87447e6d, 0xdefa386f, 0xe990fa6e, 0x6c86b56b, + 0x5bec776a, 0x02523168, 0x3538f369, 0x087faf62, 0x3f156d63, + 0x66ab2b61, 0x51c1e960, 0xd4d7a665, 0xe3bd6464, 0xba032266, + 0x8d69e067, 0x20cbd748, 0x17a11549, 0x4e1f534b, 0x7975914a, + 0xfc63de4f, 0xcb091c4e, 0x92b75a4c, 0xa5dd984d, 0x989ac446, + 0xaff00647, 0xf64e4045, 0xc1248244, 0x4432cd41, 0x73580f40, + 0x2ae64942, 0x1d8c8b43, 0x5068f154, 0x67023355, 0x3ebc7557, + 0x09d6b756, 0x8cc0f853, 0xbbaa3a52, 0xe2147c50, 0xd57ebe51, + 0xe839e25a, 0xdf53205b, 0x86ed6659, 0xb187a458, 0x3491eb5d, + 0x03fb295c, 0x5a456f5e, 0x6d2fad5f, 0x801b35e1, 0xb771f7e0, + 0xeecfb1e2, 0xd9a573e3, 0x5cb33ce6, 0x6bd9fee7, 0x3267b8e5, + 0x050d7ae4, 0x384a26ef, 0x0f20e4ee, 0x569ea2ec, 0x61f460ed, + 0xe4e22fe8, 0xd388ede9, 0x8a36abeb, 0xbd5c69ea, 0xf0b813fd, + 0xc7d2d1fc, 0x9e6c97fe, 0xa90655ff, 0x2c101afa, 0x1b7ad8fb, + 0x42c49ef9, 0x75ae5cf8, 0x48e900f3, 0x7f83c2f2, 0x263d84f0, + 0x115746f1, 0x944109f4, 0xa32bcbf5, 0xfa958df7, 0xcdff4ff6, + 0x605d78d9, 0x5737bad8, 0x0e89fcda, 0x39e33edb, 0xbcf571de, + 0x8b9fb3df, 0xd221f5dd, 0xe54b37dc, 0xd80c6bd7, 0xef66a9d6, + 0xb6d8efd4, 0x81b22dd5, 0x04a462d0, 0x33cea0d1, 0x6a70e6d3, + 0x5d1a24d2, 0x10fe5ec5, 0x27949cc4, 0x7e2adac6, 0x494018c7, + 0xcc5657c2, 0xfb3c95c3, 0xa282d3c1, 0x95e811c0, 0xa8af4dcb, + 0x9fc58fca, 0xc67bc9c8, 0xf1110bc9, 0x740744cc, 0x436d86cd, + 0x1ad3c0cf, 0x2db902ce, 0x4096af91, 0x77fc6d90, 0x2e422b92, + 0x1928e993, 0x9c3ea696, 0xab546497, 0xf2ea2295, 0xc580e094, + 0xf8c7bc9f, 0xcfad7e9e, 0x9613389c, 0xa179fa9d, 0x246fb598, + 0x13057799, 0x4abb319b, 0x7dd1f39a, 0x3035898d, 0x075f4b8c, + 0x5ee10d8e, 0x698bcf8f, 0xec9d808a, 0xdbf7428b, 0x82490489, + 0xb523c688, 0x88649a83, 0xbf0e5882, 0xe6b01e80, 0xd1dadc81, + 0x54cc9384, 0x63a65185, 0x3a181787, 0x0d72d586, 0xa0d0e2a9, + 0x97ba20a8, 0xce0466aa, 0xf96ea4ab, 0x7c78ebae, 0x4b1229af, + 0x12ac6fad, 0x25c6adac, 0x1881f1a7, 0x2feb33a6, 0x765575a4, + 0x413fb7a5, 0xc429f8a0, 0xf3433aa1, 0xaafd7ca3, 0x9d97bea2, + 0xd073c4b5, 0xe71906b4, 0xbea740b6, 0x89cd82b7, 0x0cdbcdb2, + 0x3bb10fb3, 0x620f49b1, 0x55658bb0, 0x6822d7bb, 0x5f4815ba, + 0x06f653b8, 0x319c91b9, 0xb48adebc, 0x83e01cbd, 0xda5e5abf, + 0xed3498be}, + {0x00000000, 0x6567bcb8, 0x8bc809aa, 0xeeafb512, 0x5797628f, + 0x32f0de37, 0xdc5f6b25, 0xb938d79d, 0xef28b4c5, 0x8a4f087d, + 0x64e0bd6f, 0x018701d7, 0xb8bfd64a, 0xddd86af2, 0x3377dfe0, + 0x56106358, 0x9f571950, 0xfa30a5e8, 0x149f10fa, 0x71f8ac42, + 0xc8c07bdf, 0xada7c767, 0x43087275, 0x266fcecd, 0x707fad95, + 0x1518112d, 0xfbb7a43f, 0x9ed01887, 0x27e8cf1a, 0x428f73a2, + 0xac20c6b0, 0xc9477a08, 0x3eaf32a0, 0x5bc88e18, 0xb5673b0a, + 0xd00087b2, 0x6938502f, 0x0c5fec97, 0xe2f05985, 0x8797e53d, + 0xd1878665, 0xb4e03add, 0x5a4f8fcf, 0x3f283377, 0x8610e4ea, + 0xe3775852, 0x0dd8ed40, 0x68bf51f8, 0xa1f82bf0, 0xc49f9748, + 0x2a30225a, 0x4f579ee2, 0xf66f497f, 0x9308f5c7, 0x7da740d5, + 0x18c0fc6d, 0x4ed09f35, 0x2bb7238d, 0xc518969f, 0xa07f2a27, + 0x1947fdba, 0x7c204102, 0x928ff410, 0xf7e848a8, 0x3d58149b, + 0x583fa823, 0xb6901d31, 0xd3f7a189, 0x6acf7614, 0x0fa8caac, + 0xe1077fbe, 0x8460c306, 0xd270a05e, 0xb7171ce6, 0x59b8a9f4, + 0x3cdf154c, 0x85e7c2d1, 0xe0807e69, 0x0e2fcb7b, 0x6b4877c3, + 0xa20f0dcb, 0xc768b173, 0x29c70461, 0x4ca0b8d9, 0xf5986f44, + 0x90ffd3fc, 0x7e5066ee, 0x1b37da56, 0x4d27b90e, 0x284005b6, + 0xc6efb0a4, 0xa3880c1c, 0x1ab0db81, 0x7fd76739, 0x9178d22b, + 0xf41f6e93, 0x03f7263b, 0x66909a83, 0x883f2f91, 0xed589329, + 0x546044b4, 0x3107f80c, 0xdfa84d1e, 0xbacff1a6, 0xecdf92fe, + 0x89b82e46, 0x67179b54, 0x027027ec, 0xbb48f071, 0xde2f4cc9, + 0x3080f9db, 0x55e74563, 0x9ca03f6b, 0xf9c783d3, 0x176836c1, + 0x720f8a79, 0xcb375de4, 0xae50e15c, 0x40ff544e, 0x2598e8f6, + 0x73888bae, 0x16ef3716, 0xf8408204, 0x9d273ebc, 0x241fe921, + 0x41785599, 0xafd7e08b, 0xcab05c33, 0x3bb659ed, 0x5ed1e555, + 0xb07e5047, 0xd519ecff, 0x6c213b62, 0x094687da, 0xe7e932c8, + 0x828e8e70, 0xd49eed28, 0xb1f95190, 0x5f56e482, 0x3a31583a, + 0x83098fa7, 0xe66e331f, 0x08c1860d, 0x6da63ab5, 0xa4e140bd, + 0xc186fc05, 0x2f294917, 0x4a4ef5af, 0xf3762232, 0x96119e8a, + 0x78be2b98, 0x1dd99720, 0x4bc9f478, 0x2eae48c0, 0xc001fdd2, + 0xa566416a, 0x1c5e96f7, 0x79392a4f, 0x97969f5d, 0xf2f123e5, + 0x05196b4d, 0x607ed7f5, 0x8ed162e7, 0xebb6de5f, 0x528e09c2, + 0x37e9b57a, 0xd9460068, 0xbc21bcd0, 0xea31df88, 0x8f566330, + 0x61f9d622, 0x049e6a9a, 0xbda6bd07, 0xd8c101bf, 0x366eb4ad, + 0x53090815, 0x9a4e721d, 0xff29cea5, 0x11867bb7, 0x74e1c70f, + 0xcdd91092, 0xa8beac2a, 0x46111938, 0x2376a580, 0x7566c6d8, + 0x10017a60, 0xfeaecf72, 0x9bc973ca, 0x22f1a457, 0x479618ef, + 0xa939adfd, 0xcc5e1145, 0x06ee4d76, 0x6389f1ce, 0x8d2644dc, + 0xe841f864, 0x51792ff9, 0x341e9341, 0xdab12653, 0xbfd69aeb, + 0xe9c6f9b3, 0x8ca1450b, 0x620ef019, 0x07694ca1, 0xbe519b3c, + 0xdb362784, 0x35999296, 0x50fe2e2e, 0x99b95426, 0xfcdee89e, + 0x12715d8c, 0x7716e134, 0xce2e36a9, 0xab498a11, 0x45e63f03, + 0x208183bb, 0x7691e0e3, 0x13f65c5b, 0xfd59e949, 0x983e55f1, + 0x2106826c, 0x44613ed4, 0xaace8bc6, 0xcfa9377e, 0x38417fd6, + 0x5d26c36e, 0xb389767c, 0xd6eecac4, 0x6fd61d59, 0x0ab1a1e1, + 0xe41e14f3, 0x8179a84b, 0xd769cb13, 0xb20e77ab, 0x5ca1c2b9, + 0x39c67e01, 0x80fea99c, 0xe5991524, 0x0b36a036, 0x6e511c8e, + 0xa7166686, 0xc271da3e, 0x2cde6f2c, 0x49b9d394, 0xf0810409, + 0x95e6b8b1, 0x7b490da3, 0x1e2eb11b, 0x483ed243, 0x2d596efb, + 0xc3f6dbe9, 0xa6916751, 0x1fa9b0cc, 0x7ace0c74, 0x9461b966, + 0xf10605de}}; + +#endif + +#endif + +#if N == 2 + +#if W == 8 + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xae689191, 0x87a02563, 0x29c8b4f2, 0xd4314c87, + 0x7a59dd16, 0x539169e4, 0xfdf9f875, 0x73139f4f, 0xdd7b0ede, + 0xf4b3ba2c, 0x5adb2bbd, 0xa722d3c8, 0x094a4259, 0x2082f6ab, + 0x8eea673a, 0xe6273e9e, 0x484faf0f, 0x61871bfd, 0xcfef8a6c, + 0x32167219, 0x9c7ee388, 0xb5b6577a, 0x1bdec6eb, 0x9534a1d1, + 0x3b5c3040, 0x129484b2, 0xbcfc1523, 0x4105ed56, 0xef6d7cc7, + 0xc6a5c835, 0x68cd59a4, 0x173f7b7d, 0xb957eaec, 0x909f5e1e, + 0x3ef7cf8f, 0xc30e37fa, 0x6d66a66b, 0x44ae1299, 0xeac68308, + 0x642ce432, 0xca4475a3, 0xe38cc151, 0x4de450c0, 0xb01da8b5, + 0x1e753924, 0x37bd8dd6, 0x99d51c47, 0xf11845e3, 0x5f70d472, + 0x76b86080, 0xd8d0f111, 0x25290964, 0x8b4198f5, 0xa2892c07, + 0x0ce1bd96, 0x820bdaac, 0x2c634b3d, 0x05abffcf, 0xabc36e5e, + 0x563a962b, 0xf85207ba, 0xd19ab348, 0x7ff222d9, 0x2e7ef6fa, + 0x8016676b, 0xa9ded399, 0x07b64208, 0xfa4fba7d, 0x54272bec, + 0x7def9f1e, 0xd3870e8f, 0x5d6d69b5, 0xf305f824, 0xdacd4cd6, + 0x74a5dd47, 0x895c2532, 0x2734b4a3, 0x0efc0051, 0xa09491c0, + 0xc859c864, 0x663159f5, 0x4ff9ed07, 0xe1917c96, 0x1c6884e3, + 0xb2001572, 0x9bc8a180, 0x35a03011, 0xbb4a572b, 0x1522c6ba, + 0x3cea7248, 0x9282e3d9, 0x6f7b1bac, 0xc1138a3d, 0xe8db3ecf, + 0x46b3af5e, 0x39418d87, 0x97291c16, 0xbee1a8e4, 0x10893975, + 0xed70c100, 0x43185091, 0x6ad0e463, 0xc4b875f2, 0x4a5212c8, + 0xe43a8359, 0xcdf237ab, 0x639aa63a, 0x9e635e4f, 0x300bcfde, + 0x19c37b2c, 0xb7abeabd, 0xdf66b319, 0x710e2288, 0x58c6967a, + 0xf6ae07eb, 0x0b57ff9e, 0xa53f6e0f, 0x8cf7dafd, 0x229f4b6c, + 0xac752c56, 0x021dbdc7, 0x2bd50935, 0x85bd98a4, 0x784460d1, + 0xd62cf140, 0xffe445b2, 0x518cd423, 0x5cfdedf4, 0xf2957c65, + 0xdb5dc897, 0x75355906, 0x88cca173, 0x26a430e2, 0x0f6c8410, + 0xa1041581, 0x2fee72bb, 0x8186e32a, 0xa84e57d8, 0x0626c649, + 0xfbdf3e3c, 0x55b7afad, 0x7c7f1b5f, 0xd2178ace, 0xbadad36a, + 0x14b242fb, 0x3d7af609, 0x93126798, 0x6eeb9fed, 0xc0830e7c, + 0xe94bba8e, 0x47232b1f, 0xc9c94c25, 0x67a1ddb4, 0x4e696946, + 0xe001f8d7, 0x1df800a2, 0xb3909133, 0x9a5825c1, 0x3430b450, + 0x4bc29689, 0xe5aa0718, 0xcc62b3ea, 0x620a227b, 0x9ff3da0e, + 0x319b4b9f, 0x1853ff6d, 0xb63b6efc, 0x38d109c6, 0x96b99857, + 0xbf712ca5, 0x1119bd34, 0xece04541, 0x4288d4d0, 0x6b406022, + 0xc528f1b3, 0xade5a817, 0x038d3986, 0x2a458d74, 0x842d1ce5, + 0x79d4e490, 0xd7bc7501, 0xfe74c1f3, 0x501c5062, 0xdef63758, + 0x709ea6c9, 0x5956123b, 0xf73e83aa, 0x0ac77bdf, 0xa4afea4e, + 0x8d675ebc, 0x230fcf2d, 0x72831b0e, 0xdceb8a9f, 0xf5233e6d, + 0x5b4baffc, 0xa6b25789, 0x08dac618, 0x211272ea, 0x8f7ae37b, + 0x01908441, 0xaff815d0, 0x8630a122, 0x285830b3, 0xd5a1c8c6, + 0x7bc95957, 0x5201eda5, 0xfc697c34, 0x94a42590, 0x3accb401, + 0x130400f3, 0xbd6c9162, 0x40956917, 0xeefdf886, 0xc7354c74, + 0x695ddde5, 0xe7b7badf, 0x49df2b4e, 0x60179fbc, 0xce7f0e2d, + 0x3386f658, 0x9dee67c9, 0xb426d33b, 0x1a4e42aa, 0x65bc6073, + 0xcbd4f1e2, 0xe21c4510, 0x4c74d481, 0xb18d2cf4, 0x1fe5bd65, + 0x362d0997, 0x98459806, 0x16afff3c, 0xb8c76ead, 0x910fda5f, + 0x3f674bce, 0xc29eb3bb, 0x6cf6222a, 0x453e96d8, 0xeb560749, + 0x839b5eed, 0x2df3cf7c, 0x043b7b8e, 0xaa53ea1f, 0x57aa126a, + 0xf9c283fb, 0xd00a3709, 0x7e62a698, 0xf088c1a2, 0x5ee05033, + 0x7728e4c1, 0xd9407550, 0x24b98d25, 0x8ad11cb4, 0xa319a846, + 0x0d7139d7}, + {0x00000000, 0xb9fbdbe8, 0xa886b191, 0x117d6a79, 0x8a7c6563, + 0x3387be8b, 0x22fad4f2, 0x9b010f1a, 0xcf89cc87, 0x7672176f, + 0x670f7d16, 0xdef4a6fe, 0x45f5a9e4, 0xfc0e720c, 0xed731875, + 0x5488c39d, 0x44629f4f, 0xfd9944a7, 0xece42ede, 0x551ff536, + 0xce1efa2c, 0x77e521c4, 0x66984bbd, 0xdf639055, 0x8beb53c8, + 0x32108820, 0x236de259, 0x9a9639b1, 0x019736ab, 0xb86ced43, + 0xa911873a, 0x10ea5cd2, 0x88c53e9e, 0x313ee576, 0x20438f0f, + 0x99b854e7, 0x02b95bfd, 0xbb428015, 0xaa3fea6c, 0x13c43184, + 0x474cf219, 0xfeb729f1, 0xefca4388, 0x56319860, 0xcd30977a, + 0x74cb4c92, 0x65b626eb, 0xdc4dfd03, 0xcca7a1d1, 0x755c7a39, + 0x64211040, 0xdddacba8, 0x46dbc4b2, 0xff201f5a, 0xee5d7523, + 0x57a6aecb, 0x032e6d56, 0xbad5b6be, 0xaba8dcc7, 0x1253072f, + 0x89520835, 0x30a9d3dd, 0x21d4b9a4, 0x982f624c, 0xcafb7b7d, + 0x7300a095, 0x627dcaec, 0xdb861104, 0x40871e1e, 0xf97cc5f6, + 0xe801af8f, 0x51fa7467, 0x0572b7fa, 0xbc896c12, 0xadf4066b, + 0x140fdd83, 0x8f0ed299, 0x36f50971, 0x27886308, 0x9e73b8e0, + 0x8e99e432, 0x37623fda, 0x261f55a3, 0x9fe48e4b, 0x04e58151, + 0xbd1e5ab9, 0xac6330c0, 0x1598eb28, 0x411028b5, 0xf8ebf35d, + 0xe9969924, 0x506d42cc, 0xcb6c4dd6, 0x7297963e, 0x63eafc47, + 0xda1127af, 0x423e45e3, 0xfbc59e0b, 0xeab8f472, 0x53432f9a, + 0xc8422080, 0x71b9fb68, 0x60c49111, 0xd93f4af9, 0x8db78964, + 0x344c528c, 0x253138f5, 0x9ccae31d, 0x07cbec07, 0xbe3037ef, + 0xaf4d5d96, 0x16b6867e, 0x065cdaac, 0xbfa70144, 0xaeda6b3d, + 0x1721b0d5, 0x8c20bfcf, 0x35db6427, 0x24a60e5e, 0x9d5dd5b6, + 0xc9d5162b, 0x702ecdc3, 0x6153a7ba, 0xd8a87c52, 0x43a97348, + 0xfa52a8a0, 0xeb2fc2d9, 0x52d41931, 0x4e87f0bb, 0xf77c2b53, + 0xe601412a, 0x5ffa9ac2, 0xc4fb95d8, 0x7d004e30, 0x6c7d2449, + 0xd586ffa1, 0x810e3c3c, 0x38f5e7d4, 0x29888dad, 0x90735645, + 0x0b72595f, 0xb28982b7, 0xa3f4e8ce, 0x1a0f3326, 0x0ae56ff4, + 0xb31eb41c, 0xa263de65, 0x1b98058d, 0x80990a97, 0x3962d17f, + 0x281fbb06, 0x91e460ee, 0xc56ca373, 0x7c97789b, 0x6dea12e2, + 0xd411c90a, 0x4f10c610, 0xf6eb1df8, 0xe7967781, 0x5e6dac69, + 0xc642ce25, 0x7fb915cd, 0x6ec47fb4, 0xd73fa45c, 0x4c3eab46, + 0xf5c570ae, 0xe4b81ad7, 0x5d43c13f, 0x09cb02a2, 0xb030d94a, + 0xa14db333, 0x18b668db, 0x83b767c1, 0x3a4cbc29, 0x2b31d650, + 0x92ca0db8, 0x8220516a, 0x3bdb8a82, 0x2aa6e0fb, 0x935d3b13, + 0x085c3409, 0xb1a7efe1, 0xa0da8598, 0x19215e70, 0x4da99ded, + 0xf4524605, 0xe52f2c7c, 0x5cd4f794, 0xc7d5f88e, 0x7e2e2366, + 0x6f53491f, 0xd6a892f7, 0x847c8bc6, 0x3d87502e, 0x2cfa3a57, + 0x9501e1bf, 0x0e00eea5, 0xb7fb354d, 0xa6865f34, 0x1f7d84dc, + 0x4bf54741, 0xf20e9ca9, 0xe373f6d0, 0x5a882d38, 0xc1892222, + 0x7872f9ca, 0x690f93b3, 0xd0f4485b, 0xc01e1489, 0x79e5cf61, + 0x6898a518, 0xd1637ef0, 0x4a6271ea, 0xf399aa02, 0xe2e4c07b, + 0x5b1f1b93, 0x0f97d80e, 0xb66c03e6, 0xa711699f, 0x1eeab277, + 0x85ebbd6d, 0x3c106685, 0x2d6d0cfc, 0x9496d714, 0x0cb9b558, + 0xb5426eb0, 0xa43f04c9, 0x1dc4df21, 0x86c5d03b, 0x3f3e0bd3, + 0x2e4361aa, 0x97b8ba42, 0xc33079df, 0x7acba237, 0x6bb6c84e, + 0xd24d13a6, 0x494c1cbc, 0xf0b7c754, 0xe1caad2d, 0x583176c5, + 0x48db2a17, 0xf120f1ff, 0xe05d9b86, 0x59a6406e, 0xc2a74f74, + 0x7b5c949c, 0x6a21fee5, 0xd3da250d, 0x8752e690, 0x3ea93d78, + 0x2fd45701, 0x962f8ce9, 0x0d2e83f3, 0xb4d5581b, 0xa5a83262, + 0x1c53e98a}, + {0x00000000, 0x9d0fe176, 0xe16ec4ad, 0x7c6125db, 0x19ac8f1b, + 0x84a36e6d, 0xf8c24bb6, 0x65cdaac0, 0x33591e36, 0xae56ff40, + 0xd237da9b, 0x4f383bed, 0x2af5912d, 0xb7fa705b, 0xcb9b5580, + 0x5694b4f6, 0x66b23c6c, 0xfbbddd1a, 0x87dcf8c1, 0x1ad319b7, + 0x7f1eb377, 0xe2115201, 0x9e7077da, 0x037f96ac, 0x55eb225a, + 0xc8e4c32c, 0xb485e6f7, 0x298a0781, 0x4c47ad41, 0xd1484c37, + 0xad2969ec, 0x3026889a, 0xcd6478d8, 0x506b99ae, 0x2c0abc75, + 0xb1055d03, 0xd4c8f7c3, 0x49c716b5, 0x35a6336e, 0xa8a9d218, + 0xfe3d66ee, 0x63328798, 0x1f53a243, 0x825c4335, 0xe791e9f5, + 0x7a9e0883, 0x06ff2d58, 0x9bf0cc2e, 0xabd644b4, 0x36d9a5c2, + 0x4ab88019, 0xd7b7616f, 0xb27acbaf, 0x2f752ad9, 0x53140f02, + 0xce1bee74, 0x988f5a82, 0x0580bbf4, 0x79e19e2f, 0xe4ee7f59, + 0x8123d599, 0x1c2c34ef, 0x604d1134, 0xfd42f042, 0x41b9f7f1, + 0xdcb61687, 0xa0d7335c, 0x3dd8d22a, 0x581578ea, 0xc51a999c, + 0xb97bbc47, 0x24745d31, 0x72e0e9c7, 0xefef08b1, 0x938e2d6a, + 0x0e81cc1c, 0x6b4c66dc, 0xf64387aa, 0x8a22a271, 0x172d4307, + 0x270bcb9d, 0xba042aeb, 0xc6650f30, 0x5b6aee46, 0x3ea74486, + 0xa3a8a5f0, 0xdfc9802b, 0x42c6615d, 0x1452d5ab, 0x895d34dd, + 0xf53c1106, 0x6833f070, 0x0dfe5ab0, 0x90f1bbc6, 0xec909e1d, + 0x719f7f6b, 0x8cdd8f29, 0x11d26e5f, 0x6db34b84, 0xf0bcaaf2, + 0x95710032, 0x087ee144, 0x741fc49f, 0xe91025e9, 0xbf84911f, + 0x228b7069, 0x5eea55b2, 0xc3e5b4c4, 0xa6281e04, 0x3b27ff72, + 0x4746daa9, 0xda493bdf, 0xea6fb345, 0x77605233, 0x0b0177e8, + 0x960e969e, 0xf3c33c5e, 0x6eccdd28, 0x12adf8f3, 0x8fa21985, + 0xd936ad73, 0x44394c05, 0x385869de, 0xa55788a8, 0xc09a2268, + 0x5d95c31e, 0x21f4e6c5, 0xbcfb07b3, 0x8373efe2, 0x1e7c0e94, + 0x621d2b4f, 0xff12ca39, 0x9adf60f9, 0x07d0818f, 0x7bb1a454, + 0xe6be4522, 0xb02af1d4, 0x2d2510a2, 0x51443579, 0xcc4bd40f, + 0xa9867ecf, 0x34899fb9, 0x48e8ba62, 0xd5e75b14, 0xe5c1d38e, + 0x78ce32f8, 0x04af1723, 0x99a0f655, 0xfc6d5c95, 0x6162bde3, + 0x1d039838, 0x800c794e, 0xd698cdb8, 0x4b972cce, 0x37f60915, + 0xaaf9e863, 0xcf3442a3, 0x523ba3d5, 0x2e5a860e, 0xb3556778, + 0x4e17973a, 0xd318764c, 0xaf795397, 0x3276b2e1, 0x57bb1821, + 0xcab4f957, 0xb6d5dc8c, 0x2bda3dfa, 0x7d4e890c, 0xe041687a, + 0x9c204da1, 0x012facd7, 0x64e20617, 0xf9ede761, 0x858cc2ba, + 0x188323cc, 0x28a5ab56, 0xb5aa4a20, 0xc9cb6ffb, 0x54c48e8d, + 0x3109244d, 0xac06c53b, 0xd067e0e0, 0x4d680196, 0x1bfcb560, + 0x86f35416, 0xfa9271cd, 0x679d90bb, 0x02503a7b, 0x9f5fdb0d, + 0xe33efed6, 0x7e311fa0, 0xc2ca1813, 0x5fc5f965, 0x23a4dcbe, + 0xbeab3dc8, 0xdb669708, 0x4669767e, 0x3a0853a5, 0xa707b2d3, + 0xf1930625, 0x6c9ce753, 0x10fdc288, 0x8df223fe, 0xe83f893e, + 0x75306848, 0x09514d93, 0x945eace5, 0xa478247f, 0x3977c509, + 0x4516e0d2, 0xd81901a4, 0xbdd4ab64, 0x20db4a12, 0x5cba6fc9, + 0xc1b58ebf, 0x97213a49, 0x0a2edb3f, 0x764ffee4, 0xeb401f92, + 0x8e8db552, 0x13825424, 0x6fe371ff, 0xf2ec9089, 0x0fae60cb, + 0x92a181bd, 0xeec0a466, 0x73cf4510, 0x1602efd0, 0x8b0d0ea6, + 0xf76c2b7d, 0x6a63ca0b, 0x3cf77efd, 0xa1f89f8b, 0xdd99ba50, + 0x40965b26, 0x255bf1e6, 0xb8541090, 0xc435354b, 0x593ad43d, + 0x691c5ca7, 0xf413bdd1, 0x8872980a, 0x157d797c, 0x70b0d3bc, + 0xedbf32ca, 0x91de1711, 0x0cd1f667, 0x5a454291, 0xc74aa3e7, + 0xbb2b863c, 0x2624674a, 0x43e9cd8a, 0xdee62cfc, 0xa2870927, + 0x3f88e851}, + {0x00000000, 0xdd96d985, 0x605cb54b, 0xbdca6cce, 0xc0b96a96, + 0x1d2fb313, 0xa0e5dfdd, 0x7d730658, 0x5a03d36d, 0x87950ae8, + 0x3a5f6626, 0xe7c9bfa3, 0x9abab9fb, 0x472c607e, 0xfae60cb0, + 0x2770d535, 0xb407a6da, 0x69917f5f, 0xd45b1391, 0x09cdca14, + 0x74becc4c, 0xa92815c9, 0x14e27907, 0xc974a082, 0xee0475b7, + 0x3392ac32, 0x8e58c0fc, 0x53ce1979, 0x2ebd1f21, 0xf32bc6a4, + 0x4ee1aa6a, 0x937773ef, 0xb37e4bf5, 0x6ee89270, 0xd322febe, + 0x0eb4273b, 0x73c72163, 0xae51f8e6, 0x139b9428, 0xce0d4dad, + 0xe97d9898, 0x34eb411d, 0x89212dd3, 0x54b7f456, 0x29c4f20e, + 0xf4522b8b, 0x49984745, 0x940e9ec0, 0x0779ed2f, 0xdaef34aa, + 0x67255864, 0xbab381e1, 0xc7c087b9, 0x1a565e3c, 0xa79c32f2, + 0x7a0aeb77, 0x5d7a3e42, 0x80ece7c7, 0x3d268b09, 0xe0b0528c, + 0x9dc354d4, 0x40558d51, 0xfd9fe19f, 0x2009381a, 0xbd8d91ab, + 0x601b482e, 0xddd124e0, 0x0047fd65, 0x7d34fb3d, 0xa0a222b8, + 0x1d684e76, 0xc0fe97f3, 0xe78e42c6, 0x3a189b43, 0x87d2f78d, + 0x5a442e08, 0x27372850, 0xfaa1f1d5, 0x476b9d1b, 0x9afd449e, + 0x098a3771, 0xd41ceef4, 0x69d6823a, 0xb4405bbf, 0xc9335de7, + 0x14a58462, 0xa96fe8ac, 0x74f93129, 0x5389e41c, 0x8e1f3d99, + 0x33d55157, 0xee4388d2, 0x93308e8a, 0x4ea6570f, 0xf36c3bc1, + 0x2efae244, 0x0ef3da5e, 0xd36503db, 0x6eaf6f15, 0xb339b690, + 0xce4ab0c8, 0x13dc694d, 0xae160583, 0x7380dc06, 0x54f00933, + 0x8966d0b6, 0x34acbc78, 0xe93a65fd, 0x944963a5, 0x49dfba20, + 0xf415d6ee, 0x29830f6b, 0xbaf47c84, 0x6762a501, 0xdaa8c9cf, + 0x073e104a, 0x7a4d1612, 0xa7dbcf97, 0x1a11a359, 0xc7877adc, + 0xe0f7afe9, 0x3d61766c, 0x80ab1aa2, 0x5d3dc327, 0x204ec57f, + 0xfdd81cfa, 0x40127034, 0x9d84a9b1, 0xa06a2517, 0x7dfcfc92, + 0xc036905c, 0x1da049d9, 0x60d34f81, 0xbd459604, 0x008ffaca, + 0xdd19234f, 0xfa69f67a, 0x27ff2fff, 0x9a354331, 0x47a39ab4, + 0x3ad09cec, 0xe7464569, 0x5a8c29a7, 0x871af022, 0x146d83cd, + 0xc9fb5a48, 0x74313686, 0xa9a7ef03, 0xd4d4e95b, 0x094230de, + 0xb4885c10, 0x691e8595, 0x4e6e50a0, 0x93f88925, 0x2e32e5eb, + 0xf3a43c6e, 0x8ed73a36, 0x5341e3b3, 0xee8b8f7d, 0x331d56f8, + 0x13146ee2, 0xce82b767, 0x7348dba9, 0xaede022c, 0xd3ad0474, + 0x0e3bddf1, 0xb3f1b13f, 0x6e6768ba, 0x4917bd8f, 0x9481640a, + 0x294b08c4, 0xf4ddd141, 0x89aed719, 0x54380e9c, 0xe9f26252, + 0x3464bbd7, 0xa713c838, 0x7a8511bd, 0xc74f7d73, 0x1ad9a4f6, + 0x67aaa2ae, 0xba3c7b2b, 0x07f617e5, 0xda60ce60, 0xfd101b55, + 0x2086c2d0, 0x9d4cae1e, 0x40da779b, 0x3da971c3, 0xe03fa846, + 0x5df5c488, 0x80631d0d, 0x1de7b4bc, 0xc0716d39, 0x7dbb01f7, + 0xa02dd872, 0xdd5ede2a, 0x00c807af, 0xbd026b61, 0x6094b2e4, + 0x47e467d1, 0x9a72be54, 0x27b8d29a, 0xfa2e0b1f, 0x875d0d47, + 0x5acbd4c2, 0xe701b80c, 0x3a976189, 0xa9e01266, 0x7476cbe3, + 0xc9bca72d, 0x142a7ea8, 0x695978f0, 0xb4cfa175, 0x0905cdbb, + 0xd493143e, 0xf3e3c10b, 0x2e75188e, 0x93bf7440, 0x4e29adc5, + 0x335aab9d, 0xeecc7218, 0x53061ed6, 0x8e90c753, 0xae99ff49, + 0x730f26cc, 0xcec54a02, 0x13539387, 0x6e2095df, 0xb3b64c5a, + 0x0e7c2094, 0xd3eaf911, 0xf49a2c24, 0x290cf5a1, 0x94c6996f, + 0x495040ea, 0x342346b2, 0xe9b59f37, 0x547ff3f9, 0x89e92a7c, + 0x1a9e5993, 0xc7088016, 0x7ac2ecd8, 0xa754355d, 0xda273305, + 0x07b1ea80, 0xba7b864e, 0x67ed5fcb, 0x409d8afe, 0x9d0b537b, + 0x20c13fb5, 0xfd57e630, 0x8024e068, 0x5db239ed, 0xe0785523, + 0x3dee8ca6}, + {0x00000000, 0x9ba54c6f, 0xec3b9e9f, 0x779ed2f0, 0x03063b7f, + 0x98a37710, 0xef3da5e0, 0x7498e98f, 0x060c76fe, 0x9da93a91, + 0xea37e861, 0x7192a40e, 0x050a4d81, 0x9eaf01ee, 0xe931d31e, + 0x72949f71, 0x0c18edfc, 0x97bda193, 0xe0237363, 0x7b863f0c, + 0x0f1ed683, 0x94bb9aec, 0xe325481c, 0x78800473, 0x0a149b02, + 0x91b1d76d, 0xe62f059d, 0x7d8a49f2, 0x0912a07d, 0x92b7ec12, + 0xe5293ee2, 0x7e8c728d, 0x1831dbf8, 0x83949797, 0xf40a4567, + 0x6faf0908, 0x1b37e087, 0x8092ace8, 0xf70c7e18, 0x6ca93277, + 0x1e3dad06, 0x8598e169, 0xf2063399, 0x69a37ff6, 0x1d3b9679, + 0x869eda16, 0xf10008e6, 0x6aa54489, 0x14293604, 0x8f8c7a6b, + 0xf812a89b, 0x63b7e4f4, 0x172f0d7b, 0x8c8a4114, 0xfb1493e4, + 0x60b1df8b, 0x122540fa, 0x89800c95, 0xfe1ede65, 0x65bb920a, + 0x11237b85, 0x8a8637ea, 0xfd18e51a, 0x66bda975, 0x3063b7f0, + 0xabc6fb9f, 0xdc58296f, 0x47fd6500, 0x33658c8f, 0xa8c0c0e0, + 0xdf5e1210, 0x44fb5e7f, 0x366fc10e, 0xadca8d61, 0xda545f91, + 0x41f113fe, 0x3569fa71, 0xaeccb61e, 0xd95264ee, 0x42f72881, + 0x3c7b5a0c, 0xa7de1663, 0xd040c493, 0x4be588fc, 0x3f7d6173, + 0xa4d82d1c, 0xd346ffec, 0x48e3b383, 0x3a772cf2, 0xa1d2609d, + 0xd64cb26d, 0x4de9fe02, 0x3971178d, 0xa2d45be2, 0xd54a8912, + 0x4eefc57d, 0x28526c08, 0xb3f72067, 0xc469f297, 0x5fccbef8, + 0x2b545777, 0xb0f11b18, 0xc76fc9e8, 0x5cca8587, 0x2e5e1af6, + 0xb5fb5699, 0xc2658469, 0x59c0c806, 0x2d582189, 0xb6fd6de6, + 0xc163bf16, 0x5ac6f379, 0x244a81f4, 0xbfefcd9b, 0xc8711f6b, + 0x53d45304, 0x274cba8b, 0xbce9f6e4, 0xcb772414, 0x50d2687b, + 0x2246f70a, 0xb9e3bb65, 0xce7d6995, 0x55d825fa, 0x2140cc75, + 0xbae5801a, 0xcd7b52ea, 0x56de1e85, 0x60c76fe0, 0xfb62238f, + 0x8cfcf17f, 0x1759bd10, 0x63c1549f, 0xf86418f0, 0x8ffaca00, + 0x145f866f, 0x66cb191e, 0xfd6e5571, 0x8af08781, 0x1155cbee, + 0x65cd2261, 0xfe686e0e, 0x89f6bcfe, 0x1253f091, 0x6cdf821c, + 0xf77ace73, 0x80e41c83, 0x1b4150ec, 0x6fd9b963, 0xf47cf50c, + 0x83e227fc, 0x18476b93, 0x6ad3f4e2, 0xf176b88d, 0x86e86a7d, + 0x1d4d2612, 0x69d5cf9d, 0xf27083f2, 0x85ee5102, 0x1e4b1d6d, + 0x78f6b418, 0xe353f877, 0x94cd2a87, 0x0f6866e8, 0x7bf08f67, + 0xe055c308, 0x97cb11f8, 0x0c6e5d97, 0x7efac2e6, 0xe55f8e89, + 0x92c15c79, 0x09641016, 0x7dfcf999, 0xe659b5f6, 0x91c76706, + 0x0a622b69, 0x74ee59e4, 0xef4b158b, 0x98d5c77b, 0x03708b14, + 0x77e8629b, 0xec4d2ef4, 0x9bd3fc04, 0x0076b06b, 0x72e22f1a, + 0xe9476375, 0x9ed9b185, 0x057cfdea, 0x71e41465, 0xea41580a, + 0x9ddf8afa, 0x067ac695, 0x50a4d810, 0xcb01947f, 0xbc9f468f, + 0x273a0ae0, 0x53a2e36f, 0xc807af00, 0xbf997df0, 0x243c319f, + 0x56a8aeee, 0xcd0de281, 0xba933071, 0x21367c1e, 0x55ae9591, + 0xce0bd9fe, 0xb9950b0e, 0x22304761, 0x5cbc35ec, 0xc7197983, + 0xb087ab73, 0x2b22e71c, 0x5fba0e93, 0xc41f42fc, 0xb381900c, + 0x2824dc63, 0x5ab04312, 0xc1150f7d, 0xb68bdd8d, 0x2d2e91e2, + 0x59b6786d, 0xc2133402, 0xb58de6f2, 0x2e28aa9d, 0x489503e8, + 0xd3304f87, 0xa4ae9d77, 0x3f0bd118, 0x4b933897, 0xd03674f8, + 0xa7a8a608, 0x3c0dea67, 0x4e997516, 0xd53c3979, 0xa2a2eb89, + 0x3907a7e6, 0x4d9f4e69, 0xd63a0206, 0xa1a4d0f6, 0x3a019c99, + 0x448dee14, 0xdf28a27b, 0xa8b6708b, 0x33133ce4, 0x478bd56b, + 0xdc2e9904, 0xabb04bf4, 0x3015079b, 0x428198ea, 0xd924d485, + 0xaeba0675, 0x351f4a1a, 0x4187a395, 0xda22effa, 0xadbc3d0a, + 0x36197165}, + {0x00000000, 0xc18edfc0, 0x586cb9c1, 0x99e26601, 0xb0d97382, + 0x7157ac42, 0xe8b5ca43, 0x293b1583, 0xbac3e145, 0x7b4d3e85, + 0xe2af5884, 0x23218744, 0x0a1a92c7, 0xcb944d07, 0x52762b06, + 0x93f8f4c6, 0xaef6c4cb, 0x6f781b0b, 0xf69a7d0a, 0x3714a2ca, + 0x1e2fb749, 0xdfa16889, 0x46430e88, 0x87cdd148, 0x1435258e, + 0xd5bbfa4e, 0x4c599c4f, 0x8dd7438f, 0xa4ec560c, 0x656289cc, + 0xfc80efcd, 0x3d0e300d, 0x869c8fd7, 0x47125017, 0xdef03616, + 0x1f7ee9d6, 0x3645fc55, 0xf7cb2395, 0x6e294594, 0xafa79a54, + 0x3c5f6e92, 0xfdd1b152, 0x6433d753, 0xa5bd0893, 0x8c861d10, + 0x4d08c2d0, 0xd4eaa4d1, 0x15647b11, 0x286a4b1c, 0xe9e494dc, + 0x7006f2dd, 0xb1882d1d, 0x98b3389e, 0x593de75e, 0xc0df815f, + 0x01515e9f, 0x92a9aa59, 0x53277599, 0xcac51398, 0x0b4bcc58, + 0x2270d9db, 0xe3fe061b, 0x7a1c601a, 0xbb92bfda, 0xd64819ef, + 0x17c6c62f, 0x8e24a02e, 0x4faa7fee, 0x66916a6d, 0xa71fb5ad, + 0x3efdd3ac, 0xff730c6c, 0x6c8bf8aa, 0xad05276a, 0x34e7416b, + 0xf5699eab, 0xdc528b28, 0x1ddc54e8, 0x843e32e9, 0x45b0ed29, + 0x78bedd24, 0xb93002e4, 0x20d264e5, 0xe15cbb25, 0xc867aea6, + 0x09e97166, 0x900b1767, 0x5185c8a7, 0xc27d3c61, 0x03f3e3a1, + 0x9a1185a0, 0x5b9f5a60, 0x72a44fe3, 0xb32a9023, 0x2ac8f622, + 0xeb4629e2, 0x50d49638, 0x915a49f8, 0x08b82ff9, 0xc936f039, + 0xe00de5ba, 0x21833a7a, 0xb8615c7b, 0x79ef83bb, 0xea17777d, + 0x2b99a8bd, 0xb27bcebc, 0x73f5117c, 0x5ace04ff, 0x9b40db3f, + 0x02a2bd3e, 0xc32c62fe, 0xfe2252f3, 0x3fac8d33, 0xa64eeb32, + 0x67c034f2, 0x4efb2171, 0x8f75feb1, 0x169798b0, 0xd7194770, + 0x44e1b3b6, 0x856f6c76, 0x1c8d0a77, 0xdd03d5b7, 0xf438c034, + 0x35b61ff4, 0xac5479f5, 0x6ddaa635, 0x77e1359f, 0xb66fea5f, + 0x2f8d8c5e, 0xee03539e, 0xc738461d, 0x06b699dd, 0x9f54ffdc, + 0x5eda201c, 0xcd22d4da, 0x0cac0b1a, 0x954e6d1b, 0x54c0b2db, + 0x7dfba758, 0xbc757898, 0x25971e99, 0xe419c159, 0xd917f154, + 0x18992e94, 0x817b4895, 0x40f59755, 0x69ce82d6, 0xa8405d16, + 0x31a23b17, 0xf02ce4d7, 0x63d41011, 0xa25acfd1, 0x3bb8a9d0, + 0xfa367610, 0xd30d6393, 0x1283bc53, 0x8b61da52, 0x4aef0592, + 0xf17dba48, 0x30f36588, 0xa9110389, 0x689fdc49, 0x41a4c9ca, + 0x802a160a, 0x19c8700b, 0xd846afcb, 0x4bbe5b0d, 0x8a3084cd, + 0x13d2e2cc, 0xd25c3d0c, 0xfb67288f, 0x3ae9f74f, 0xa30b914e, + 0x62854e8e, 0x5f8b7e83, 0x9e05a143, 0x07e7c742, 0xc6691882, + 0xef520d01, 0x2edcd2c1, 0xb73eb4c0, 0x76b06b00, 0xe5489fc6, + 0x24c64006, 0xbd242607, 0x7caaf9c7, 0x5591ec44, 0x941f3384, + 0x0dfd5585, 0xcc738a45, 0xa1a92c70, 0x6027f3b0, 0xf9c595b1, + 0x384b4a71, 0x11705ff2, 0xd0fe8032, 0x491ce633, 0x889239f3, + 0x1b6acd35, 0xdae412f5, 0x430674f4, 0x8288ab34, 0xabb3beb7, + 0x6a3d6177, 0xf3df0776, 0x3251d8b6, 0x0f5fe8bb, 0xced1377b, + 0x5733517a, 0x96bd8eba, 0xbf869b39, 0x7e0844f9, 0xe7ea22f8, + 0x2664fd38, 0xb59c09fe, 0x7412d63e, 0xedf0b03f, 0x2c7e6fff, + 0x05457a7c, 0xc4cba5bc, 0x5d29c3bd, 0x9ca71c7d, 0x2735a3a7, + 0xe6bb7c67, 0x7f591a66, 0xbed7c5a6, 0x97ecd025, 0x56620fe5, + 0xcf8069e4, 0x0e0eb624, 0x9df642e2, 0x5c789d22, 0xc59afb23, + 0x041424e3, 0x2d2f3160, 0xeca1eea0, 0x754388a1, 0xb4cd5761, + 0x89c3676c, 0x484db8ac, 0xd1afdead, 0x1021016d, 0x391a14ee, + 0xf894cb2e, 0x6176ad2f, 0xa0f872ef, 0x33008629, 0xf28e59e9, + 0x6b6c3fe8, 0xaae2e028, 0x83d9f5ab, 0x42572a6b, 0xdbb54c6a, + 0x1a3b93aa}, + {0x00000000, 0xefc26b3e, 0x04f5d03d, 0xeb37bb03, 0x09eba07a, + 0xe629cb44, 0x0d1e7047, 0xe2dc1b79, 0x13d740f4, 0xfc152bca, + 0x172290c9, 0xf8e0fbf7, 0x1a3ce08e, 0xf5fe8bb0, 0x1ec930b3, + 0xf10b5b8d, 0x27ae81e8, 0xc86cead6, 0x235b51d5, 0xcc993aeb, + 0x2e452192, 0xc1874aac, 0x2ab0f1af, 0xc5729a91, 0x3479c11c, + 0xdbbbaa22, 0x308c1121, 0xdf4e7a1f, 0x3d926166, 0xd2500a58, + 0x3967b15b, 0xd6a5da65, 0x4f5d03d0, 0xa09f68ee, 0x4ba8d3ed, + 0xa46ab8d3, 0x46b6a3aa, 0xa974c894, 0x42437397, 0xad8118a9, + 0x5c8a4324, 0xb348281a, 0x587f9319, 0xb7bdf827, 0x5561e35e, + 0xbaa38860, 0x51943363, 0xbe56585d, 0x68f38238, 0x8731e906, + 0x6c065205, 0x83c4393b, 0x61182242, 0x8eda497c, 0x65edf27f, + 0x8a2f9941, 0x7b24c2cc, 0x94e6a9f2, 0x7fd112f1, 0x901379cf, + 0x72cf62b6, 0x9d0d0988, 0x763ab28b, 0x99f8d9b5, 0x9eba07a0, + 0x71786c9e, 0x9a4fd79d, 0x758dbca3, 0x9751a7da, 0x7893cce4, + 0x93a477e7, 0x7c661cd9, 0x8d6d4754, 0x62af2c6a, 0x89989769, + 0x665afc57, 0x8486e72e, 0x6b448c10, 0x80733713, 0x6fb15c2d, + 0xb9148648, 0x56d6ed76, 0xbde15675, 0x52233d4b, 0xb0ff2632, + 0x5f3d4d0c, 0xb40af60f, 0x5bc89d31, 0xaac3c6bc, 0x4501ad82, + 0xae361681, 0x41f47dbf, 0xa32866c6, 0x4cea0df8, 0xa7ddb6fb, + 0x481fddc5, 0xd1e70470, 0x3e256f4e, 0xd512d44d, 0x3ad0bf73, + 0xd80ca40a, 0x37cecf34, 0xdcf97437, 0x333b1f09, 0xc2304484, + 0x2df22fba, 0xc6c594b9, 0x2907ff87, 0xcbdbe4fe, 0x24198fc0, + 0xcf2e34c3, 0x20ec5ffd, 0xf6498598, 0x198beea6, 0xf2bc55a5, + 0x1d7e3e9b, 0xffa225e2, 0x10604edc, 0xfb57f5df, 0x14959ee1, + 0xe59ec56c, 0x0a5cae52, 0xe16b1551, 0x0ea97e6f, 0xec756516, + 0x03b70e28, 0xe880b52b, 0x0742de15, 0xe6050901, 0x09c7623f, + 0xe2f0d93c, 0x0d32b202, 0xefeea97b, 0x002cc245, 0xeb1b7946, + 0x04d91278, 0xf5d249f5, 0x1a1022cb, 0xf12799c8, 0x1ee5f2f6, + 0xfc39e98f, 0x13fb82b1, 0xf8cc39b2, 0x170e528c, 0xc1ab88e9, + 0x2e69e3d7, 0xc55e58d4, 0x2a9c33ea, 0xc8402893, 0x278243ad, + 0xccb5f8ae, 0x23779390, 0xd27cc81d, 0x3dbea323, 0xd6891820, + 0x394b731e, 0xdb976867, 0x34550359, 0xdf62b85a, 0x30a0d364, + 0xa9580ad1, 0x469a61ef, 0xadaddaec, 0x426fb1d2, 0xa0b3aaab, + 0x4f71c195, 0xa4467a96, 0x4b8411a8, 0xba8f4a25, 0x554d211b, + 0xbe7a9a18, 0x51b8f126, 0xb364ea5f, 0x5ca68161, 0xb7913a62, + 0x5853515c, 0x8ef68b39, 0x6134e007, 0x8a035b04, 0x65c1303a, + 0x871d2b43, 0x68df407d, 0x83e8fb7e, 0x6c2a9040, 0x9d21cbcd, + 0x72e3a0f3, 0x99d41bf0, 0x761670ce, 0x94ca6bb7, 0x7b080089, + 0x903fbb8a, 0x7ffdd0b4, 0x78bf0ea1, 0x977d659f, 0x7c4ade9c, + 0x9388b5a2, 0x7154aedb, 0x9e96c5e5, 0x75a17ee6, 0x9a6315d8, + 0x6b684e55, 0x84aa256b, 0x6f9d9e68, 0x805ff556, 0x6283ee2f, + 0x8d418511, 0x66763e12, 0x89b4552c, 0x5f118f49, 0xb0d3e477, + 0x5be45f74, 0xb426344a, 0x56fa2f33, 0xb938440d, 0x520fff0e, + 0xbdcd9430, 0x4cc6cfbd, 0xa304a483, 0x48331f80, 0xa7f174be, + 0x452d6fc7, 0xaaef04f9, 0x41d8bffa, 0xae1ad4c4, 0x37e20d71, + 0xd820664f, 0x3317dd4c, 0xdcd5b672, 0x3e09ad0b, 0xd1cbc635, + 0x3afc7d36, 0xd53e1608, 0x24354d85, 0xcbf726bb, 0x20c09db8, + 0xcf02f686, 0x2ddeedff, 0xc21c86c1, 0x292b3dc2, 0xc6e956fc, + 0x104c8c99, 0xff8ee7a7, 0x14b95ca4, 0xfb7b379a, 0x19a72ce3, + 0xf66547dd, 0x1d52fcde, 0xf29097e0, 0x039bcc6d, 0xec59a753, + 0x076e1c50, 0xe8ac776e, 0x0a706c17, 0xe5b20729, 0x0e85bc2a, + 0xe147d714}, + {0x00000000, 0x177b1443, 0x2ef62886, 0x398d3cc5, 0x5dec510c, + 0x4a97454f, 0x731a798a, 0x64616dc9, 0xbbd8a218, 0xaca3b65b, + 0x952e8a9e, 0x82559edd, 0xe634f314, 0xf14fe757, 0xc8c2db92, + 0xdfb9cfd1, 0xacc04271, 0xbbbb5632, 0x82366af7, 0x954d7eb4, + 0xf12c137d, 0xe657073e, 0xdfda3bfb, 0xc8a12fb8, 0x1718e069, + 0x0063f42a, 0x39eec8ef, 0x2e95dcac, 0x4af4b165, 0x5d8fa526, + 0x640299e3, 0x73798da0, 0x82f182a3, 0x958a96e0, 0xac07aa25, + 0xbb7cbe66, 0xdf1dd3af, 0xc866c7ec, 0xf1ebfb29, 0xe690ef6a, + 0x392920bb, 0x2e5234f8, 0x17df083d, 0x00a41c7e, 0x64c571b7, + 0x73be65f4, 0x4a335931, 0x5d484d72, 0x2e31c0d2, 0x394ad491, + 0x00c7e854, 0x17bcfc17, 0x73dd91de, 0x64a6859d, 0x5d2bb958, + 0x4a50ad1b, 0x95e962ca, 0x82927689, 0xbb1f4a4c, 0xac645e0f, + 0xc80533c6, 0xdf7e2785, 0xe6f31b40, 0xf1880f03, 0xde920307, + 0xc9e91744, 0xf0642b81, 0xe71f3fc2, 0x837e520b, 0x94054648, + 0xad887a8d, 0xbaf36ece, 0x654aa11f, 0x7231b55c, 0x4bbc8999, + 0x5cc79dda, 0x38a6f013, 0x2fdde450, 0x1650d895, 0x012bccd6, + 0x72524176, 0x65295535, 0x5ca469f0, 0x4bdf7db3, 0x2fbe107a, + 0x38c50439, 0x014838fc, 0x16332cbf, 0xc98ae36e, 0xdef1f72d, + 0xe77ccbe8, 0xf007dfab, 0x9466b262, 0x831da621, 0xba909ae4, + 0xadeb8ea7, 0x5c6381a4, 0x4b1895e7, 0x7295a922, 0x65eebd61, + 0x018fd0a8, 0x16f4c4eb, 0x2f79f82e, 0x3802ec6d, 0xe7bb23bc, + 0xf0c037ff, 0xc94d0b3a, 0xde361f79, 0xba5772b0, 0xad2c66f3, + 0x94a15a36, 0x83da4e75, 0xf0a3c3d5, 0xe7d8d796, 0xde55eb53, + 0xc92eff10, 0xad4f92d9, 0xba34869a, 0x83b9ba5f, 0x94c2ae1c, + 0x4b7b61cd, 0x5c00758e, 0x658d494b, 0x72f65d08, 0x169730c1, + 0x01ec2482, 0x38611847, 0x2f1a0c04, 0x6655004f, 0x712e140c, + 0x48a328c9, 0x5fd83c8a, 0x3bb95143, 0x2cc24500, 0x154f79c5, + 0x02346d86, 0xdd8da257, 0xcaf6b614, 0xf37b8ad1, 0xe4009e92, + 0x8061f35b, 0x971ae718, 0xae97dbdd, 0xb9eccf9e, 0xca95423e, + 0xddee567d, 0xe4636ab8, 0xf3187efb, 0x97791332, 0x80020771, + 0xb98f3bb4, 0xaef42ff7, 0x714de026, 0x6636f465, 0x5fbbc8a0, + 0x48c0dce3, 0x2ca1b12a, 0x3bdaa569, 0x025799ac, 0x152c8def, + 0xe4a482ec, 0xf3df96af, 0xca52aa6a, 0xdd29be29, 0xb948d3e0, + 0xae33c7a3, 0x97befb66, 0x80c5ef25, 0x5f7c20f4, 0x480734b7, + 0x718a0872, 0x66f11c31, 0x029071f8, 0x15eb65bb, 0x2c66597e, + 0x3b1d4d3d, 0x4864c09d, 0x5f1fd4de, 0x6692e81b, 0x71e9fc58, + 0x15889191, 0x02f385d2, 0x3b7eb917, 0x2c05ad54, 0xf3bc6285, + 0xe4c776c6, 0xdd4a4a03, 0xca315e40, 0xae503389, 0xb92b27ca, + 0x80a61b0f, 0x97dd0f4c, 0xb8c70348, 0xafbc170b, 0x96312bce, + 0x814a3f8d, 0xe52b5244, 0xf2504607, 0xcbdd7ac2, 0xdca66e81, + 0x031fa150, 0x1464b513, 0x2de989d6, 0x3a929d95, 0x5ef3f05c, + 0x4988e41f, 0x7005d8da, 0x677ecc99, 0x14074139, 0x037c557a, + 0x3af169bf, 0x2d8a7dfc, 0x49eb1035, 0x5e900476, 0x671d38b3, + 0x70662cf0, 0xafdfe321, 0xb8a4f762, 0x8129cba7, 0x9652dfe4, + 0xf233b22d, 0xe548a66e, 0xdcc59aab, 0xcbbe8ee8, 0x3a3681eb, + 0x2d4d95a8, 0x14c0a96d, 0x03bbbd2e, 0x67dad0e7, 0x70a1c4a4, + 0x492cf861, 0x5e57ec22, 0x81ee23f3, 0x969537b0, 0xaf180b75, + 0xb8631f36, 0xdc0272ff, 0xcb7966bc, 0xf2f45a79, 0xe58f4e3a, + 0x96f6c39a, 0x818dd7d9, 0xb800eb1c, 0xaf7bff5f, 0xcb1a9296, + 0xdc6186d5, 0xe5ecba10, 0xf297ae53, 0x2d2e6182, 0x3a5575c1, + 0x03d84904, 0x14a35d47, 0x70c2308e, 0x67b924cd, 0x5e341808, + 0x494f0c4b}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x0000000000000000, 0x43147b1700000000, 0x8628f62e00000000, + 0xc53c8d3900000000, 0x0c51ec5d00000000, 0x4f45974a00000000, + 0x8a791a7300000000, 0xc96d616400000000, 0x18a2d8bb00000000, + 0x5bb6a3ac00000000, 0x9e8a2e9500000000, 0xdd9e558200000000, + 0x14f334e600000000, 0x57e74ff100000000, 0x92dbc2c800000000, + 0xd1cfb9df00000000, 0x7142c0ac00000000, 0x3256bbbb00000000, + 0xf76a368200000000, 0xb47e4d9500000000, 0x7d132cf100000000, + 0x3e0757e600000000, 0xfb3bdadf00000000, 0xb82fa1c800000000, + 0x69e0181700000000, 0x2af4630000000000, 0xefc8ee3900000000, + 0xacdc952e00000000, 0x65b1f44a00000000, 0x26a58f5d00000000, + 0xe399026400000000, 0xa08d797300000000, 0xa382f18200000000, + 0xe0968a9500000000, 0x25aa07ac00000000, 0x66be7cbb00000000, + 0xafd31ddf00000000, 0xecc766c800000000, 0x29fbebf100000000, + 0x6aef90e600000000, 0xbb20293900000000, 0xf834522e00000000, + 0x3d08df1700000000, 0x7e1ca40000000000, 0xb771c56400000000, + 0xf465be7300000000, 0x3159334a00000000, 0x724d485d00000000, + 0xd2c0312e00000000, 0x91d44a3900000000, 0x54e8c70000000000, + 0x17fcbc1700000000, 0xde91dd7300000000, 0x9d85a66400000000, + 0x58b92b5d00000000, 0x1bad504a00000000, 0xca62e99500000000, + 0x8976928200000000, 0x4c4a1fbb00000000, 0x0f5e64ac00000000, + 0xc63305c800000000, 0x85277edf00000000, 0x401bf3e600000000, + 0x030f88f100000000, 0x070392de00000000, 0x4417e9c900000000, + 0x812b64f000000000, 0xc23f1fe700000000, 0x0b527e8300000000, + 0x4846059400000000, 0x8d7a88ad00000000, 0xce6ef3ba00000000, + 0x1fa14a6500000000, 0x5cb5317200000000, 0x9989bc4b00000000, + 0xda9dc75c00000000, 0x13f0a63800000000, 0x50e4dd2f00000000, + 0x95d8501600000000, 0xd6cc2b0100000000, 0x7641527200000000, + 0x3555296500000000, 0xf069a45c00000000, 0xb37ddf4b00000000, + 0x7a10be2f00000000, 0x3904c53800000000, 0xfc38480100000000, + 0xbf2c331600000000, 0x6ee38ac900000000, 0x2df7f1de00000000, + 0xe8cb7ce700000000, 0xabdf07f000000000, 0x62b2669400000000, + 0x21a61d8300000000, 0xe49a90ba00000000, 0xa78eebad00000000, + 0xa481635c00000000, 0xe795184b00000000, 0x22a9957200000000, + 0x61bdee6500000000, 0xa8d08f0100000000, 0xebc4f41600000000, + 0x2ef8792f00000000, 0x6dec023800000000, 0xbc23bbe700000000, + 0xff37c0f000000000, 0x3a0b4dc900000000, 0x791f36de00000000, + 0xb07257ba00000000, 0xf3662cad00000000, 0x365aa19400000000, + 0x754eda8300000000, 0xd5c3a3f000000000, 0x96d7d8e700000000, + 0x53eb55de00000000, 0x10ff2ec900000000, 0xd9924fad00000000, + 0x9a8634ba00000000, 0x5fbab98300000000, 0x1caec29400000000, + 0xcd617b4b00000000, 0x8e75005c00000000, 0x4b498d6500000000, + 0x085df67200000000, 0xc130971600000000, 0x8224ec0100000000, + 0x4718613800000000, 0x040c1a2f00000000, 0x4f00556600000000, + 0x0c142e7100000000, 0xc928a34800000000, 0x8a3cd85f00000000, + 0x4351b93b00000000, 0x0045c22c00000000, 0xc5794f1500000000, + 0x866d340200000000, 0x57a28ddd00000000, 0x14b6f6ca00000000, + 0xd18a7bf300000000, 0x929e00e400000000, 0x5bf3618000000000, + 0x18e71a9700000000, 0xdddb97ae00000000, 0x9ecfecb900000000, + 0x3e4295ca00000000, 0x7d56eedd00000000, 0xb86a63e400000000, + 0xfb7e18f300000000, 0x3213799700000000, 0x7107028000000000, + 0xb43b8fb900000000, 0xf72ff4ae00000000, 0x26e04d7100000000, + 0x65f4366600000000, 0xa0c8bb5f00000000, 0xe3dcc04800000000, + 0x2ab1a12c00000000, 0x69a5da3b00000000, 0xac99570200000000, + 0xef8d2c1500000000, 0xec82a4e400000000, 0xaf96dff300000000, + 0x6aaa52ca00000000, 0x29be29dd00000000, 0xe0d348b900000000, + 0xa3c733ae00000000, 0x66fbbe9700000000, 0x25efc58000000000, + 0xf4207c5f00000000, 0xb734074800000000, 0x72088a7100000000, + 0x311cf16600000000, 0xf871900200000000, 0xbb65eb1500000000, + 0x7e59662c00000000, 0x3d4d1d3b00000000, 0x9dc0644800000000, + 0xded41f5f00000000, 0x1be8926600000000, 0x58fce97100000000, + 0x9191881500000000, 0xd285f30200000000, 0x17b97e3b00000000, + 0x54ad052c00000000, 0x8562bcf300000000, 0xc676c7e400000000, + 0x034a4add00000000, 0x405e31ca00000000, 0x893350ae00000000, + 0xca272bb900000000, 0x0f1ba68000000000, 0x4c0fdd9700000000, + 0x4803c7b800000000, 0x0b17bcaf00000000, 0xce2b319600000000, + 0x8d3f4a8100000000, 0x44522be500000000, 0x074650f200000000, + 0xc27addcb00000000, 0x816ea6dc00000000, 0x50a11f0300000000, + 0x13b5641400000000, 0xd689e92d00000000, 0x959d923a00000000, + 0x5cf0f35e00000000, 0x1fe4884900000000, 0xdad8057000000000, + 0x99cc7e6700000000, 0x3941071400000000, 0x7a557c0300000000, + 0xbf69f13a00000000, 0xfc7d8a2d00000000, 0x3510eb4900000000, + 0x7604905e00000000, 0xb3381d6700000000, 0xf02c667000000000, + 0x21e3dfaf00000000, 0x62f7a4b800000000, 0xa7cb298100000000, + 0xe4df529600000000, 0x2db233f200000000, 0x6ea648e500000000, + 0xab9ac5dc00000000, 0xe88ebecb00000000, 0xeb81363a00000000, + 0xa8954d2d00000000, 0x6da9c01400000000, 0x2ebdbb0300000000, + 0xe7d0da6700000000, 0xa4c4a17000000000, 0x61f82c4900000000, + 0x22ec575e00000000, 0xf323ee8100000000, 0xb037959600000000, + 0x750b18af00000000, 0x361f63b800000000, 0xff7202dc00000000, + 0xbc6679cb00000000, 0x795af4f200000000, 0x3a4e8fe500000000, + 0x9ac3f69600000000, 0xd9d78d8100000000, 0x1ceb00b800000000, + 0x5fff7baf00000000, 0x96921acb00000000, 0xd58661dc00000000, + 0x10baece500000000, 0x53ae97f200000000, 0x82612e2d00000000, + 0xc175553a00000000, 0x0449d80300000000, 0x475da31400000000, + 0x8e30c27000000000, 0xcd24b96700000000, 0x0818345e00000000, + 0x4b0c4f4900000000}, + {0x0000000000000000, 0x3e6bc2ef00000000, 0x3dd0f50400000000, + 0x03bb37eb00000000, 0x7aa0eb0900000000, 0x44cb29e600000000, + 0x47701e0d00000000, 0x791bdce200000000, 0xf440d71300000000, + 0xca2b15fc00000000, 0xc990221700000000, 0xf7fbe0f800000000, + 0x8ee03c1a00000000, 0xb08bfef500000000, 0xb330c91e00000000, + 0x8d5b0bf100000000, 0xe881ae2700000000, 0xd6ea6cc800000000, + 0xd5515b2300000000, 0xeb3a99cc00000000, 0x9221452e00000000, + 0xac4a87c100000000, 0xaff1b02a00000000, 0x919a72c500000000, + 0x1cc1793400000000, 0x22aabbdb00000000, 0x21118c3000000000, + 0x1f7a4edf00000000, 0x6661923d00000000, 0x580a50d200000000, + 0x5bb1673900000000, 0x65daa5d600000000, 0xd0035d4f00000000, + 0xee689fa000000000, 0xedd3a84b00000000, 0xd3b86aa400000000, + 0xaaa3b64600000000, 0x94c874a900000000, 0x9773434200000000, + 0xa91881ad00000000, 0x24438a5c00000000, 0x1a2848b300000000, + 0x19937f5800000000, 0x27f8bdb700000000, 0x5ee3615500000000, + 0x6088a3ba00000000, 0x6333945100000000, 0x5d5856be00000000, + 0x3882f36800000000, 0x06e9318700000000, 0x0552066c00000000, + 0x3b39c48300000000, 0x4222186100000000, 0x7c49da8e00000000, + 0x7ff2ed6500000000, 0x41992f8a00000000, 0xccc2247b00000000, + 0xf2a9e69400000000, 0xf112d17f00000000, 0xcf79139000000000, + 0xb662cf7200000000, 0x88090d9d00000000, 0x8bb23a7600000000, + 0xb5d9f89900000000, 0xa007ba9e00000000, 0x9e6c787100000000, + 0x9dd74f9a00000000, 0xa3bc8d7500000000, 0xdaa7519700000000, + 0xe4cc937800000000, 0xe777a49300000000, 0xd91c667c00000000, + 0x54476d8d00000000, 0x6a2caf6200000000, 0x6997988900000000, + 0x57fc5a6600000000, 0x2ee7868400000000, 0x108c446b00000000, + 0x1337738000000000, 0x2d5cb16f00000000, 0x488614b900000000, + 0x76edd65600000000, 0x7556e1bd00000000, 0x4b3d235200000000, + 0x3226ffb000000000, 0x0c4d3d5f00000000, 0x0ff60ab400000000, + 0x319dc85b00000000, 0xbcc6c3aa00000000, 0x82ad014500000000, + 0x811636ae00000000, 0xbf7df44100000000, 0xc66628a300000000, + 0xf80dea4c00000000, 0xfbb6dda700000000, 0xc5dd1f4800000000, + 0x7004e7d100000000, 0x4e6f253e00000000, 0x4dd412d500000000, + 0x73bfd03a00000000, 0x0aa40cd800000000, 0x34cfce3700000000, + 0x3774f9dc00000000, 0x091f3b3300000000, 0x844430c200000000, + 0xba2ff22d00000000, 0xb994c5c600000000, 0x87ff072900000000, + 0xfee4dbcb00000000, 0xc08f192400000000, 0xc3342ecf00000000, + 0xfd5fec2000000000, 0x988549f600000000, 0xa6ee8b1900000000, + 0xa555bcf200000000, 0x9b3e7e1d00000000, 0xe225a2ff00000000, + 0xdc4e601000000000, 0xdff557fb00000000, 0xe19e951400000000, + 0x6cc59ee500000000, 0x52ae5c0a00000000, 0x51156be100000000, + 0x6f7ea90e00000000, 0x166575ec00000000, 0x280eb70300000000, + 0x2bb580e800000000, 0x15de420700000000, 0x010905e600000000, + 0x3f62c70900000000, 0x3cd9f0e200000000, 0x02b2320d00000000, + 0x7ba9eeef00000000, 0x45c22c0000000000, 0x46791beb00000000, + 0x7812d90400000000, 0xf549d2f500000000, 0xcb22101a00000000, + 0xc89927f100000000, 0xf6f2e51e00000000, 0x8fe939fc00000000, + 0xb182fb1300000000, 0xb239ccf800000000, 0x8c520e1700000000, + 0xe988abc100000000, 0xd7e3692e00000000, 0xd4585ec500000000, + 0xea339c2a00000000, 0x932840c800000000, 0xad43822700000000, + 0xaef8b5cc00000000, 0x9093772300000000, 0x1dc87cd200000000, + 0x23a3be3d00000000, 0x201889d600000000, 0x1e734b3900000000, + 0x676897db00000000, 0x5903553400000000, 0x5ab862df00000000, + 0x64d3a03000000000, 0xd10a58a900000000, 0xef619a4600000000, + 0xecdaadad00000000, 0xd2b16f4200000000, 0xabaab3a000000000, + 0x95c1714f00000000, 0x967a46a400000000, 0xa811844b00000000, + 0x254a8fba00000000, 0x1b214d5500000000, 0x189a7abe00000000, + 0x26f1b85100000000, 0x5fea64b300000000, 0x6181a65c00000000, + 0x623a91b700000000, 0x5c51535800000000, 0x398bf68e00000000, + 0x07e0346100000000, 0x045b038a00000000, 0x3a30c16500000000, + 0x432b1d8700000000, 0x7d40df6800000000, 0x7efbe88300000000, + 0x40902a6c00000000, 0xcdcb219d00000000, 0xf3a0e37200000000, + 0xf01bd49900000000, 0xce70167600000000, 0xb76bca9400000000, + 0x8900087b00000000, 0x8abb3f9000000000, 0xb4d0fd7f00000000, + 0xa10ebf7800000000, 0x9f657d9700000000, 0x9cde4a7c00000000, + 0xa2b5889300000000, 0xdbae547100000000, 0xe5c5969e00000000, + 0xe67ea17500000000, 0xd815639a00000000, 0x554e686b00000000, + 0x6b25aa8400000000, 0x689e9d6f00000000, 0x56f55f8000000000, + 0x2fee836200000000, 0x1185418d00000000, 0x123e766600000000, + 0x2c55b48900000000, 0x498f115f00000000, 0x77e4d3b000000000, + 0x745fe45b00000000, 0x4a3426b400000000, 0x332ffa5600000000, + 0x0d4438b900000000, 0x0eff0f5200000000, 0x3094cdbd00000000, + 0xbdcfc64c00000000, 0x83a404a300000000, 0x801f334800000000, + 0xbe74f1a700000000, 0xc76f2d4500000000, 0xf904efaa00000000, + 0xfabfd84100000000, 0xc4d41aae00000000, 0x710de23700000000, + 0x4f6620d800000000, 0x4cdd173300000000, 0x72b6d5dc00000000, + 0x0bad093e00000000, 0x35c6cbd100000000, 0x367dfc3a00000000, + 0x08163ed500000000, 0x854d352400000000, 0xbb26f7cb00000000, + 0xb89dc02000000000, 0x86f602cf00000000, 0xffedde2d00000000, + 0xc1861cc200000000, 0xc23d2b2900000000, 0xfc56e9c600000000, + 0x998c4c1000000000, 0xa7e78eff00000000, 0xa45cb91400000000, + 0x9a377bfb00000000, 0xe32ca71900000000, 0xdd4765f600000000, + 0xdefc521d00000000, 0xe09790f200000000, 0x6dcc9b0300000000, + 0x53a759ec00000000, 0x501c6e0700000000, 0x6e77ace800000000, + 0x176c700a00000000, 0x2907b2e500000000, 0x2abc850e00000000, + 0x14d747e100000000}, + {0x0000000000000000, 0xc0df8ec100000000, 0xc1b96c5800000000, + 0x0166e29900000000, 0x8273d9b000000000, 0x42ac577100000000, + 0x43cab5e800000000, 0x83153b2900000000, 0x45e1c3ba00000000, + 0x853e4d7b00000000, 0x8458afe200000000, 0x4487212300000000, + 0xc7921a0a00000000, 0x074d94cb00000000, 0x062b765200000000, + 0xc6f4f89300000000, 0xcbc4f6ae00000000, 0x0b1b786f00000000, + 0x0a7d9af600000000, 0xcaa2143700000000, 0x49b72f1e00000000, + 0x8968a1df00000000, 0x880e434600000000, 0x48d1cd8700000000, + 0x8e25351400000000, 0x4efabbd500000000, 0x4f9c594c00000000, + 0x8f43d78d00000000, 0x0c56eca400000000, 0xcc89626500000000, + 0xcdef80fc00000000, 0x0d300e3d00000000, 0xd78f9c8600000000, + 0x1750124700000000, 0x1636f0de00000000, 0xd6e97e1f00000000, + 0x55fc453600000000, 0x9523cbf700000000, 0x9445296e00000000, + 0x549aa7af00000000, 0x926e5f3c00000000, 0x52b1d1fd00000000, + 0x53d7336400000000, 0x9308bda500000000, 0x101d868c00000000, + 0xd0c2084d00000000, 0xd1a4ead400000000, 0x117b641500000000, + 0x1c4b6a2800000000, 0xdc94e4e900000000, 0xddf2067000000000, + 0x1d2d88b100000000, 0x9e38b39800000000, 0x5ee73d5900000000, + 0x5f81dfc000000000, 0x9f5e510100000000, 0x59aaa99200000000, + 0x9975275300000000, 0x9813c5ca00000000, 0x58cc4b0b00000000, + 0xdbd9702200000000, 0x1b06fee300000000, 0x1a601c7a00000000, + 0xdabf92bb00000000, 0xef1948d600000000, 0x2fc6c61700000000, + 0x2ea0248e00000000, 0xee7faa4f00000000, 0x6d6a916600000000, + 0xadb51fa700000000, 0xacd3fd3e00000000, 0x6c0c73ff00000000, + 0xaaf88b6c00000000, 0x6a2705ad00000000, 0x6b41e73400000000, + 0xab9e69f500000000, 0x288b52dc00000000, 0xe854dc1d00000000, + 0xe9323e8400000000, 0x29edb04500000000, 0x24ddbe7800000000, + 0xe40230b900000000, 0xe564d22000000000, 0x25bb5ce100000000, + 0xa6ae67c800000000, 0x6671e90900000000, 0x67170b9000000000, + 0xa7c8855100000000, 0x613c7dc200000000, 0xa1e3f30300000000, + 0xa085119a00000000, 0x605a9f5b00000000, 0xe34fa47200000000, + 0x23902ab300000000, 0x22f6c82a00000000, 0xe22946eb00000000, + 0x3896d45000000000, 0xf8495a9100000000, 0xf92fb80800000000, + 0x39f036c900000000, 0xbae50de000000000, 0x7a3a832100000000, + 0x7b5c61b800000000, 0xbb83ef7900000000, 0x7d7717ea00000000, + 0xbda8992b00000000, 0xbcce7bb200000000, 0x7c11f57300000000, + 0xff04ce5a00000000, 0x3fdb409b00000000, 0x3ebda20200000000, + 0xfe622cc300000000, 0xf35222fe00000000, 0x338dac3f00000000, + 0x32eb4ea600000000, 0xf234c06700000000, 0x7121fb4e00000000, + 0xb1fe758f00000000, 0xb098971600000000, 0x704719d700000000, + 0xb6b3e14400000000, 0x766c6f8500000000, 0x770a8d1c00000000, + 0xb7d503dd00000000, 0x34c038f400000000, 0xf41fb63500000000, + 0xf57954ac00000000, 0x35a6da6d00000000, 0x9f35e17700000000, + 0x5fea6fb600000000, 0x5e8c8d2f00000000, 0x9e5303ee00000000, + 0x1d4638c700000000, 0xdd99b60600000000, 0xdcff549f00000000, + 0x1c20da5e00000000, 0xdad422cd00000000, 0x1a0bac0c00000000, + 0x1b6d4e9500000000, 0xdbb2c05400000000, 0x58a7fb7d00000000, + 0x987875bc00000000, 0x991e972500000000, 0x59c119e400000000, + 0x54f117d900000000, 0x942e991800000000, 0x95487b8100000000, + 0x5597f54000000000, 0xd682ce6900000000, 0x165d40a800000000, + 0x173ba23100000000, 0xd7e42cf000000000, 0x1110d46300000000, + 0xd1cf5aa200000000, 0xd0a9b83b00000000, 0x107636fa00000000, + 0x93630dd300000000, 0x53bc831200000000, 0x52da618b00000000, + 0x9205ef4a00000000, 0x48ba7df100000000, 0x8865f33000000000, + 0x890311a900000000, 0x49dc9f6800000000, 0xcac9a44100000000, + 0x0a162a8000000000, 0x0b70c81900000000, 0xcbaf46d800000000, + 0x0d5bbe4b00000000, 0xcd84308a00000000, 0xcce2d21300000000, + 0x0c3d5cd200000000, 0x8f2867fb00000000, 0x4ff7e93a00000000, + 0x4e910ba300000000, 0x8e4e856200000000, 0x837e8b5f00000000, + 0x43a1059e00000000, 0x42c7e70700000000, 0x821869c600000000, + 0x010d52ef00000000, 0xc1d2dc2e00000000, 0xc0b43eb700000000, + 0x006bb07600000000, 0xc69f48e500000000, 0x0640c62400000000, + 0x072624bd00000000, 0xc7f9aa7c00000000, 0x44ec915500000000, + 0x84331f9400000000, 0x8555fd0d00000000, 0x458a73cc00000000, + 0x702ca9a100000000, 0xb0f3276000000000, 0xb195c5f900000000, + 0x714a4b3800000000, 0xf25f701100000000, 0x3280fed000000000, + 0x33e61c4900000000, 0xf339928800000000, 0x35cd6a1b00000000, + 0xf512e4da00000000, 0xf474064300000000, 0x34ab888200000000, + 0xb7beb3ab00000000, 0x77613d6a00000000, 0x7607dff300000000, + 0xb6d8513200000000, 0xbbe85f0f00000000, 0x7b37d1ce00000000, + 0x7a51335700000000, 0xba8ebd9600000000, 0x399b86bf00000000, + 0xf944087e00000000, 0xf822eae700000000, 0x38fd642600000000, + 0xfe099cb500000000, 0x3ed6127400000000, 0x3fb0f0ed00000000, + 0xff6f7e2c00000000, 0x7c7a450500000000, 0xbca5cbc400000000, + 0xbdc3295d00000000, 0x7d1ca79c00000000, 0xa7a3352700000000, + 0x677cbbe600000000, 0x661a597f00000000, 0xa6c5d7be00000000, + 0x25d0ec9700000000, 0xe50f625600000000, 0xe46980cf00000000, + 0x24b60e0e00000000, 0xe242f69d00000000, 0x229d785c00000000, + 0x23fb9ac500000000, 0xe324140400000000, 0x60312f2d00000000, + 0xa0eea1ec00000000, 0xa188437500000000, 0x6157cdb400000000, + 0x6c67c38900000000, 0xacb84d4800000000, 0xaddeafd100000000, + 0x6d01211000000000, 0xee141a3900000000, 0x2ecb94f800000000, + 0x2fad766100000000, 0xef72f8a000000000, 0x2986003300000000, + 0xe9598ef200000000, 0xe83f6c6b00000000, 0x28e0e2aa00000000, + 0xabf5d98300000000, 0x6b2a574200000000, 0x6a4cb5db00000000, + 0xaa933b1a00000000}, + {0x0000000000000000, 0x6f4ca59b00000000, 0x9f9e3bec00000000, + 0xf0d29e7700000000, 0x7f3b060300000000, 0x1077a39800000000, + 0xe0a53def00000000, 0x8fe9987400000000, 0xfe760c0600000000, + 0x913aa99d00000000, 0x61e837ea00000000, 0x0ea4927100000000, + 0x814d0a0500000000, 0xee01af9e00000000, 0x1ed331e900000000, + 0x719f947200000000, 0xfced180c00000000, 0x93a1bd9700000000, + 0x637323e000000000, 0x0c3f867b00000000, 0x83d61e0f00000000, + 0xec9abb9400000000, 0x1c4825e300000000, 0x7304807800000000, + 0x029b140a00000000, 0x6dd7b19100000000, 0x9d052fe600000000, + 0xf2498a7d00000000, 0x7da0120900000000, 0x12ecb79200000000, + 0xe23e29e500000000, 0x8d728c7e00000000, 0xf8db311800000000, + 0x9797948300000000, 0x67450af400000000, 0x0809af6f00000000, + 0x87e0371b00000000, 0xe8ac928000000000, 0x187e0cf700000000, + 0x7732a96c00000000, 0x06ad3d1e00000000, 0x69e1988500000000, + 0x993306f200000000, 0xf67fa36900000000, 0x79963b1d00000000, + 0x16da9e8600000000, 0xe60800f100000000, 0x8944a56a00000000, + 0x0436291400000000, 0x6b7a8c8f00000000, 0x9ba812f800000000, + 0xf4e4b76300000000, 0x7b0d2f1700000000, 0x14418a8c00000000, + 0xe49314fb00000000, 0x8bdfb16000000000, 0xfa40251200000000, + 0x950c808900000000, 0x65de1efe00000000, 0x0a92bb6500000000, + 0x857b231100000000, 0xea37868a00000000, 0x1ae518fd00000000, + 0x75a9bd6600000000, 0xf0b7633000000000, 0x9ffbc6ab00000000, + 0x6f2958dc00000000, 0x0065fd4700000000, 0x8f8c653300000000, + 0xe0c0c0a800000000, 0x10125edf00000000, 0x7f5efb4400000000, + 0x0ec16f3600000000, 0x618dcaad00000000, 0x915f54da00000000, + 0xfe13f14100000000, 0x71fa693500000000, 0x1eb6ccae00000000, + 0xee6452d900000000, 0x8128f74200000000, 0x0c5a7b3c00000000, + 0x6316dea700000000, 0x93c440d000000000, 0xfc88e54b00000000, + 0x73617d3f00000000, 0x1c2dd8a400000000, 0xecff46d300000000, + 0x83b3e34800000000, 0xf22c773a00000000, 0x9d60d2a100000000, + 0x6db24cd600000000, 0x02fee94d00000000, 0x8d17713900000000, + 0xe25bd4a200000000, 0x12894ad500000000, 0x7dc5ef4e00000000, + 0x086c522800000000, 0x6720f7b300000000, 0x97f269c400000000, + 0xf8becc5f00000000, 0x7757542b00000000, 0x181bf1b000000000, + 0xe8c96fc700000000, 0x8785ca5c00000000, 0xf61a5e2e00000000, + 0x9956fbb500000000, 0x698465c200000000, 0x06c8c05900000000, + 0x8921582d00000000, 0xe66dfdb600000000, 0x16bf63c100000000, + 0x79f3c65a00000000, 0xf4814a2400000000, 0x9bcdefbf00000000, + 0x6b1f71c800000000, 0x0453d45300000000, 0x8bba4c2700000000, + 0xe4f6e9bc00000000, 0x142477cb00000000, 0x7b68d25000000000, + 0x0af7462200000000, 0x65bbe3b900000000, 0x95697dce00000000, + 0xfa25d85500000000, 0x75cc402100000000, 0x1a80e5ba00000000, + 0xea527bcd00000000, 0x851ede5600000000, 0xe06fc76000000000, + 0x8f2362fb00000000, 0x7ff1fc8c00000000, 0x10bd591700000000, + 0x9f54c16300000000, 0xf01864f800000000, 0x00cafa8f00000000, + 0x6f865f1400000000, 0x1e19cb6600000000, 0x71556efd00000000, + 0x8187f08a00000000, 0xeecb551100000000, 0x6122cd6500000000, + 0x0e6e68fe00000000, 0xfebcf68900000000, 0x91f0531200000000, + 0x1c82df6c00000000, 0x73ce7af700000000, 0x831ce48000000000, + 0xec50411b00000000, 0x63b9d96f00000000, 0x0cf57cf400000000, + 0xfc27e28300000000, 0x936b471800000000, 0xe2f4d36a00000000, + 0x8db876f100000000, 0x7d6ae88600000000, 0x12264d1d00000000, + 0x9dcfd56900000000, 0xf28370f200000000, 0x0251ee8500000000, + 0x6d1d4b1e00000000, 0x18b4f67800000000, 0x77f853e300000000, + 0x872acd9400000000, 0xe866680f00000000, 0x678ff07b00000000, + 0x08c355e000000000, 0xf811cb9700000000, 0x975d6e0c00000000, + 0xe6c2fa7e00000000, 0x898e5fe500000000, 0x795cc19200000000, + 0x1610640900000000, 0x99f9fc7d00000000, 0xf6b559e600000000, + 0x0667c79100000000, 0x692b620a00000000, 0xe459ee7400000000, + 0x8b154bef00000000, 0x7bc7d59800000000, 0x148b700300000000, + 0x9b62e87700000000, 0xf42e4dec00000000, 0x04fcd39b00000000, + 0x6bb0760000000000, 0x1a2fe27200000000, 0x756347e900000000, + 0x85b1d99e00000000, 0xeafd7c0500000000, 0x6514e47100000000, + 0x0a5841ea00000000, 0xfa8adf9d00000000, 0x95c67a0600000000, + 0x10d8a45000000000, 0x7f9401cb00000000, 0x8f469fbc00000000, + 0xe00a3a2700000000, 0x6fe3a25300000000, 0x00af07c800000000, + 0xf07d99bf00000000, 0x9f313c2400000000, 0xeeaea85600000000, + 0x81e20dcd00000000, 0x713093ba00000000, 0x1e7c362100000000, + 0x9195ae5500000000, 0xfed90bce00000000, 0x0e0b95b900000000, + 0x6147302200000000, 0xec35bc5c00000000, 0x837919c700000000, + 0x73ab87b000000000, 0x1ce7222b00000000, 0x930eba5f00000000, + 0xfc421fc400000000, 0x0c9081b300000000, 0x63dc242800000000, + 0x1243b05a00000000, 0x7d0f15c100000000, 0x8ddd8bb600000000, + 0xe2912e2d00000000, 0x6d78b65900000000, 0x023413c200000000, + 0xf2e68db500000000, 0x9daa282e00000000, 0xe803954800000000, + 0x874f30d300000000, 0x779daea400000000, 0x18d10b3f00000000, + 0x9738934b00000000, 0xf87436d000000000, 0x08a6a8a700000000, + 0x67ea0d3c00000000, 0x1675994e00000000, 0x79393cd500000000, + 0x89eba2a200000000, 0xe6a7073900000000, 0x694e9f4d00000000, + 0x06023ad600000000, 0xf6d0a4a100000000, 0x999c013a00000000, + 0x14ee8d4400000000, 0x7ba228df00000000, 0x8b70b6a800000000, + 0xe43c133300000000, 0x6bd58b4700000000, 0x04992edc00000000, + 0xf44bb0ab00000000, 0x9b07153000000000, 0xea98814200000000, + 0x85d424d900000000, 0x7506baae00000000, 0x1a4a1f3500000000, + 0x95a3874100000000, 0xfaef22da00000000, 0x0a3dbcad00000000, + 0x6571193600000000}, + {0x0000000000000000, 0x85d996dd00000000, 0x4bb55c6000000000, + 0xce6ccabd00000000, 0x966ab9c000000000, 0x13b32f1d00000000, + 0xdddfe5a000000000, 0x5806737d00000000, 0x6dd3035a00000000, + 0xe80a958700000000, 0x26665f3a00000000, 0xa3bfc9e700000000, + 0xfbb9ba9a00000000, 0x7e602c4700000000, 0xb00ce6fa00000000, + 0x35d5702700000000, 0xdaa607b400000000, 0x5f7f916900000000, + 0x91135bd400000000, 0x14cacd0900000000, 0x4cccbe7400000000, + 0xc91528a900000000, 0x0779e21400000000, 0x82a074c900000000, + 0xb77504ee00000000, 0x32ac923300000000, 0xfcc0588e00000000, + 0x7919ce5300000000, 0x211fbd2e00000000, 0xa4c62bf300000000, + 0x6aaae14e00000000, 0xef73779300000000, 0xf54b7eb300000000, + 0x7092e86e00000000, 0xbefe22d300000000, 0x3b27b40e00000000, + 0x6321c77300000000, 0xe6f851ae00000000, 0x28949b1300000000, + 0xad4d0dce00000000, 0x98987de900000000, 0x1d41eb3400000000, + 0xd32d218900000000, 0x56f4b75400000000, 0x0ef2c42900000000, + 0x8b2b52f400000000, 0x4547984900000000, 0xc09e0e9400000000, + 0x2fed790700000000, 0xaa34efda00000000, 0x6458256700000000, + 0xe181b3ba00000000, 0xb987c0c700000000, 0x3c5e561a00000000, + 0xf2329ca700000000, 0x77eb0a7a00000000, 0x423e7a5d00000000, + 0xc7e7ec8000000000, 0x098b263d00000000, 0x8c52b0e000000000, + 0xd454c39d00000000, 0x518d554000000000, 0x9fe19ffd00000000, + 0x1a38092000000000, 0xab918dbd00000000, 0x2e481b6000000000, + 0xe024d1dd00000000, 0x65fd470000000000, 0x3dfb347d00000000, + 0xb822a2a000000000, 0x764e681d00000000, 0xf397fec000000000, + 0xc6428ee700000000, 0x439b183a00000000, 0x8df7d28700000000, + 0x082e445a00000000, 0x5028372700000000, 0xd5f1a1fa00000000, + 0x1b9d6b4700000000, 0x9e44fd9a00000000, 0x71378a0900000000, + 0xf4ee1cd400000000, 0x3a82d66900000000, 0xbf5b40b400000000, + 0xe75d33c900000000, 0x6284a51400000000, 0xace86fa900000000, + 0x2931f97400000000, 0x1ce4895300000000, 0x993d1f8e00000000, + 0x5751d53300000000, 0xd28843ee00000000, 0x8a8e309300000000, + 0x0f57a64e00000000, 0xc13b6cf300000000, 0x44e2fa2e00000000, + 0x5edaf30e00000000, 0xdb0365d300000000, 0x156faf6e00000000, + 0x90b639b300000000, 0xc8b04ace00000000, 0x4d69dc1300000000, + 0x830516ae00000000, 0x06dc807300000000, 0x3309f05400000000, + 0xb6d0668900000000, 0x78bcac3400000000, 0xfd653ae900000000, + 0xa563499400000000, 0x20badf4900000000, 0xeed615f400000000, + 0x6b0f832900000000, 0x847cf4ba00000000, 0x01a5626700000000, + 0xcfc9a8da00000000, 0x4a103e0700000000, 0x12164d7a00000000, + 0x97cfdba700000000, 0x59a3111a00000000, 0xdc7a87c700000000, + 0xe9aff7e000000000, 0x6c76613d00000000, 0xa21aab8000000000, + 0x27c33d5d00000000, 0x7fc54e2000000000, 0xfa1cd8fd00000000, + 0x3470124000000000, 0xb1a9849d00000000, 0x17256aa000000000, + 0x92fcfc7d00000000, 0x5c9036c000000000, 0xd949a01d00000000, + 0x814fd36000000000, 0x049645bd00000000, 0xcafa8f0000000000, + 0x4f2319dd00000000, 0x7af669fa00000000, 0xff2fff2700000000, + 0x3143359a00000000, 0xb49aa34700000000, 0xec9cd03a00000000, + 0x694546e700000000, 0xa7298c5a00000000, 0x22f01a8700000000, + 0xcd836d1400000000, 0x485afbc900000000, 0x8636317400000000, + 0x03efa7a900000000, 0x5be9d4d400000000, 0xde30420900000000, + 0x105c88b400000000, 0x95851e6900000000, 0xa0506e4e00000000, + 0x2589f89300000000, 0xebe5322e00000000, 0x6e3ca4f300000000, + 0x363ad78e00000000, 0xb3e3415300000000, 0x7d8f8bee00000000, + 0xf8561d3300000000, 0xe26e141300000000, 0x67b782ce00000000, + 0xa9db487300000000, 0x2c02deae00000000, 0x7404add300000000, + 0xf1dd3b0e00000000, 0x3fb1f1b300000000, 0xba68676e00000000, + 0x8fbd174900000000, 0x0a64819400000000, 0xc4084b2900000000, + 0x41d1ddf400000000, 0x19d7ae8900000000, 0x9c0e385400000000, + 0x5262f2e900000000, 0xd7bb643400000000, 0x38c813a700000000, + 0xbd11857a00000000, 0x737d4fc700000000, 0xf6a4d91a00000000, + 0xaea2aa6700000000, 0x2b7b3cba00000000, 0xe517f60700000000, + 0x60ce60da00000000, 0x551b10fd00000000, 0xd0c2862000000000, + 0x1eae4c9d00000000, 0x9b77da4000000000, 0xc371a93d00000000, + 0x46a83fe000000000, 0x88c4f55d00000000, 0x0d1d638000000000, + 0xbcb4e71d00000000, 0x396d71c000000000, 0xf701bb7d00000000, + 0x72d82da000000000, 0x2ade5edd00000000, 0xaf07c80000000000, + 0x616b02bd00000000, 0xe4b2946000000000, 0xd167e44700000000, + 0x54be729a00000000, 0x9ad2b82700000000, 0x1f0b2efa00000000, + 0x470d5d8700000000, 0xc2d4cb5a00000000, 0x0cb801e700000000, + 0x8961973a00000000, 0x6612e0a900000000, 0xe3cb767400000000, + 0x2da7bcc900000000, 0xa87e2a1400000000, 0xf078596900000000, + 0x75a1cfb400000000, 0xbbcd050900000000, 0x3e1493d400000000, + 0x0bc1e3f300000000, 0x8e18752e00000000, 0x4074bf9300000000, + 0xc5ad294e00000000, 0x9dab5a3300000000, 0x1872ccee00000000, + 0xd61e065300000000, 0x53c7908e00000000, 0x49ff99ae00000000, + 0xcc260f7300000000, 0x024ac5ce00000000, 0x8793531300000000, + 0xdf95206e00000000, 0x5a4cb6b300000000, 0x94207c0e00000000, + 0x11f9ead300000000, 0x242c9af400000000, 0xa1f50c2900000000, + 0x6f99c69400000000, 0xea40504900000000, 0xb246233400000000, + 0x379fb5e900000000, 0xf9f37f5400000000, 0x7c2ae98900000000, + 0x93599e1a00000000, 0x168008c700000000, 0xd8ecc27a00000000, + 0x5d3554a700000000, 0x053327da00000000, 0x80eab10700000000, + 0x4e867bba00000000, 0xcb5fed6700000000, 0xfe8a9d4000000000, + 0x7b530b9d00000000, 0xb53fc12000000000, 0x30e657fd00000000, + 0x68e0248000000000, 0xed39b25d00000000, 0x235578e000000000, + 0xa68cee3d00000000}, + {0x0000000000000000, 0x76e10f9d00000000, 0xadc46ee100000000, + 0xdb25617c00000000, 0x1b8fac1900000000, 0x6d6ea38400000000, + 0xb64bc2f800000000, 0xc0aacd6500000000, 0x361e593300000000, + 0x40ff56ae00000000, 0x9bda37d200000000, 0xed3b384f00000000, + 0x2d91f52a00000000, 0x5b70fab700000000, 0x80559bcb00000000, + 0xf6b4945600000000, 0x6c3cb26600000000, 0x1addbdfb00000000, + 0xc1f8dc8700000000, 0xb719d31a00000000, 0x77b31e7f00000000, + 0x015211e200000000, 0xda77709e00000000, 0xac967f0300000000, + 0x5a22eb5500000000, 0x2cc3e4c800000000, 0xf7e685b400000000, + 0x81078a2900000000, 0x41ad474c00000000, 0x374c48d100000000, + 0xec6929ad00000000, 0x9a88263000000000, 0xd87864cd00000000, + 0xae996b5000000000, 0x75bc0a2c00000000, 0x035d05b100000000, + 0xc3f7c8d400000000, 0xb516c74900000000, 0x6e33a63500000000, + 0x18d2a9a800000000, 0xee663dfe00000000, 0x9887326300000000, + 0x43a2531f00000000, 0x35435c8200000000, 0xf5e991e700000000, + 0x83089e7a00000000, 0x582dff0600000000, 0x2eccf09b00000000, + 0xb444d6ab00000000, 0xc2a5d93600000000, 0x1980b84a00000000, + 0x6f61b7d700000000, 0xafcb7ab200000000, 0xd92a752f00000000, + 0x020f145300000000, 0x74ee1bce00000000, 0x825a8f9800000000, + 0xf4bb800500000000, 0x2f9ee17900000000, 0x597feee400000000, + 0x99d5238100000000, 0xef342c1c00000000, 0x34114d6000000000, + 0x42f042fd00000000, 0xf1f7b94100000000, 0x8716b6dc00000000, + 0x5c33d7a000000000, 0x2ad2d83d00000000, 0xea78155800000000, + 0x9c991ac500000000, 0x47bc7bb900000000, 0x315d742400000000, + 0xc7e9e07200000000, 0xb108efef00000000, 0x6a2d8e9300000000, + 0x1ccc810e00000000, 0xdc664c6b00000000, 0xaa8743f600000000, + 0x71a2228a00000000, 0x07432d1700000000, 0x9dcb0b2700000000, + 0xeb2a04ba00000000, 0x300f65c600000000, 0x46ee6a5b00000000, + 0x8644a73e00000000, 0xf0a5a8a300000000, 0x2b80c9df00000000, + 0x5d61c64200000000, 0xabd5521400000000, 0xdd345d8900000000, + 0x06113cf500000000, 0x70f0336800000000, 0xb05afe0d00000000, + 0xc6bbf19000000000, 0x1d9e90ec00000000, 0x6b7f9f7100000000, + 0x298fdd8c00000000, 0x5f6ed21100000000, 0x844bb36d00000000, + 0xf2aabcf000000000, 0x3200719500000000, 0x44e17e0800000000, + 0x9fc41f7400000000, 0xe92510e900000000, 0x1f9184bf00000000, + 0x69708b2200000000, 0xb255ea5e00000000, 0xc4b4e5c300000000, + 0x041e28a600000000, 0x72ff273b00000000, 0xa9da464700000000, + 0xdf3b49da00000000, 0x45b36fea00000000, 0x3352607700000000, + 0xe877010b00000000, 0x9e960e9600000000, 0x5e3cc3f300000000, + 0x28ddcc6e00000000, 0xf3f8ad1200000000, 0x8519a28f00000000, + 0x73ad36d900000000, 0x054c394400000000, 0xde69583800000000, + 0xa88857a500000000, 0x68229ac000000000, 0x1ec3955d00000000, + 0xc5e6f42100000000, 0xb307fbbc00000000, 0xe2ef738300000000, + 0x940e7c1e00000000, 0x4f2b1d6200000000, 0x39ca12ff00000000, + 0xf960df9a00000000, 0x8f81d00700000000, 0x54a4b17b00000000, + 0x2245bee600000000, 0xd4f12ab000000000, 0xa210252d00000000, + 0x7935445100000000, 0x0fd44bcc00000000, 0xcf7e86a900000000, + 0xb99f893400000000, 0x62bae84800000000, 0x145be7d500000000, + 0x8ed3c1e500000000, 0xf832ce7800000000, 0x2317af0400000000, + 0x55f6a09900000000, 0x955c6dfc00000000, 0xe3bd626100000000, + 0x3898031d00000000, 0x4e790c8000000000, 0xb8cd98d600000000, + 0xce2c974b00000000, 0x1509f63700000000, 0x63e8f9aa00000000, + 0xa34234cf00000000, 0xd5a33b5200000000, 0x0e865a2e00000000, + 0x786755b300000000, 0x3a97174e00000000, 0x4c7618d300000000, + 0x975379af00000000, 0xe1b2763200000000, 0x2118bb5700000000, + 0x57f9b4ca00000000, 0x8cdcd5b600000000, 0xfa3dda2b00000000, + 0x0c894e7d00000000, 0x7a6841e000000000, 0xa14d209c00000000, + 0xd7ac2f0100000000, 0x1706e26400000000, 0x61e7edf900000000, + 0xbac28c8500000000, 0xcc23831800000000, 0x56aba52800000000, + 0x204aaab500000000, 0xfb6fcbc900000000, 0x8d8ec45400000000, + 0x4d24093100000000, 0x3bc506ac00000000, 0xe0e067d000000000, + 0x9601684d00000000, 0x60b5fc1b00000000, 0x1654f38600000000, + 0xcd7192fa00000000, 0xbb909d6700000000, 0x7b3a500200000000, + 0x0ddb5f9f00000000, 0xd6fe3ee300000000, 0xa01f317e00000000, + 0x1318cac200000000, 0x65f9c55f00000000, 0xbedca42300000000, + 0xc83dabbe00000000, 0x089766db00000000, 0x7e76694600000000, + 0xa553083a00000000, 0xd3b207a700000000, 0x250693f100000000, + 0x53e79c6c00000000, 0x88c2fd1000000000, 0xfe23f28d00000000, + 0x3e893fe800000000, 0x4868307500000000, 0x934d510900000000, + 0xe5ac5e9400000000, 0x7f2478a400000000, 0x09c5773900000000, + 0xd2e0164500000000, 0xa40119d800000000, 0x64abd4bd00000000, + 0x124adb2000000000, 0xc96fba5c00000000, 0xbf8eb5c100000000, + 0x493a219700000000, 0x3fdb2e0a00000000, 0xe4fe4f7600000000, + 0x921f40eb00000000, 0x52b58d8e00000000, 0x2454821300000000, + 0xff71e36f00000000, 0x8990ecf200000000, 0xcb60ae0f00000000, + 0xbd81a19200000000, 0x66a4c0ee00000000, 0x1045cf7300000000, + 0xd0ef021600000000, 0xa60e0d8b00000000, 0x7d2b6cf700000000, + 0x0bca636a00000000, 0xfd7ef73c00000000, 0x8b9ff8a100000000, + 0x50ba99dd00000000, 0x265b964000000000, 0xe6f15b2500000000, + 0x901054b800000000, 0x4b3535c400000000, 0x3dd43a5900000000, + 0xa75c1c6900000000, 0xd1bd13f400000000, 0x0a98728800000000, + 0x7c797d1500000000, 0xbcd3b07000000000, 0xca32bfed00000000, + 0x1117de9100000000, 0x67f6d10c00000000, 0x9142455a00000000, + 0xe7a34ac700000000, 0x3c862bbb00000000, 0x4a67242600000000, + 0x8acde94300000000, 0xfc2ce6de00000000, 0x270987a200000000, + 0x51e8883f00000000}, + {0x0000000000000000, 0xe8dbfbb900000000, 0x91b186a800000000, + 0x796a7d1100000000, 0x63657c8a00000000, 0x8bbe873300000000, + 0xf2d4fa2200000000, 0x1a0f019b00000000, 0x87cc89cf00000000, + 0x6f17727600000000, 0x167d0f6700000000, 0xfea6f4de00000000, + 0xe4a9f54500000000, 0x0c720efc00000000, 0x751873ed00000000, + 0x9dc3885400000000, 0x4f9f624400000000, 0xa74499fd00000000, + 0xde2ee4ec00000000, 0x36f51f5500000000, 0x2cfa1ece00000000, + 0xc421e57700000000, 0xbd4b986600000000, 0x559063df00000000, + 0xc853eb8b00000000, 0x2088103200000000, 0x59e26d2300000000, + 0xb139969a00000000, 0xab36970100000000, 0x43ed6cb800000000, + 0x3a8711a900000000, 0xd25cea1000000000, 0x9e3ec58800000000, + 0x76e53e3100000000, 0x0f8f432000000000, 0xe754b89900000000, + 0xfd5bb90200000000, 0x158042bb00000000, 0x6cea3faa00000000, + 0x8431c41300000000, 0x19f24c4700000000, 0xf129b7fe00000000, + 0x8843caef00000000, 0x6098315600000000, 0x7a9730cd00000000, + 0x924ccb7400000000, 0xeb26b66500000000, 0x03fd4ddc00000000, + 0xd1a1a7cc00000000, 0x397a5c7500000000, 0x4010216400000000, + 0xa8cbdadd00000000, 0xb2c4db4600000000, 0x5a1f20ff00000000, + 0x23755dee00000000, 0xcbaea65700000000, 0x566d2e0300000000, + 0xbeb6d5ba00000000, 0xc7dca8ab00000000, 0x2f07531200000000, + 0x3508528900000000, 0xddd3a93000000000, 0xa4b9d42100000000, + 0x4c622f9800000000, 0x7d7bfbca00000000, 0x95a0007300000000, + 0xecca7d6200000000, 0x041186db00000000, 0x1e1e874000000000, + 0xf6c57cf900000000, 0x8faf01e800000000, 0x6774fa5100000000, + 0xfab7720500000000, 0x126c89bc00000000, 0x6b06f4ad00000000, + 0x83dd0f1400000000, 0x99d20e8f00000000, 0x7109f53600000000, + 0x0863882700000000, 0xe0b8739e00000000, 0x32e4998e00000000, + 0xda3f623700000000, 0xa3551f2600000000, 0x4b8ee49f00000000, + 0x5181e50400000000, 0xb95a1ebd00000000, 0xc03063ac00000000, + 0x28eb981500000000, 0xb528104100000000, 0x5df3ebf800000000, + 0x249996e900000000, 0xcc426d5000000000, 0xd64d6ccb00000000, + 0x3e96977200000000, 0x47fcea6300000000, 0xaf2711da00000000, + 0xe3453e4200000000, 0x0b9ec5fb00000000, 0x72f4b8ea00000000, + 0x9a2f435300000000, 0x802042c800000000, 0x68fbb97100000000, + 0x1191c46000000000, 0xf94a3fd900000000, 0x6489b78d00000000, + 0x8c524c3400000000, 0xf538312500000000, 0x1de3ca9c00000000, + 0x07eccb0700000000, 0xef3730be00000000, 0x965d4daf00000000, + 0x7e86b61600000000, 0xacda5c0600000000, 0x4401a7bf00000000, + 0x3d6bdaae00000000, 0xd5b0211700000000, 0xcfbf208c00000000, + 0x2764db3500000000, 0x5e0ea62400000000, 0xb6d55d9d00000000, + 0x2b16d5c900000000, 0xc3cd2e7000000000, 0xbaa7536100000000, + 0x527ca8d800000000, 0x4873a94300000000, 0xa0a852fa00000000, + 0xd9c22feb00000000, 0x3119d45200000000, 0xbbf0874e00000000, + 0x532b7cf700000000, 0x2a4101e600000000, 0xc29afa5f00000000, + 0xd895fbc400000000, 0x304e007d00000000, 0x49247d6c00000000, + 0xa1ff86d500000000, 0x3c3c0e8100000000, 0xd4e7f53800000000, + 0xad8d882900000000, 0x4556739000000000, 0x5f59720b00000000, + 0xb78289b200000000, 0xcee8f4a300000000, 0x26330f1a00000000, + 0xf46fe50a00000000, 0x1cb41eb300000000, 0x65de63a200000000, + 0x8d05981b00000000, 0x970a998000000000, 0x7fd1623900000000, + 0x06bb1f2800000000, 0xee60e49100000000, 0x73a36cc500000000, + 0x9b78977c00000000, 0xe212ea6d00000000, 0x0ac911d400000000, + 0x10c6104f00000000, 0xf81debf600000000, 0x817796e700000000, + 0x69ac6d5e00000000, 0x25ce42c600000000, 0xcd15b97f00000000, + 0xb47fc46e00000000, 0x5ca43fd700000000, 0x46ab3e4c00000000, + 0xae70c5f500000000, 0xd71ab8e400000000, 0x3fc1435d00000000, + 0xa202cb0900000000, 0x4ad930b000000000, 0x33b34da100000000, + 0xdb68b61800000000, 0xc167b78300000000, 0x29bc4c3a00000000, + 0x50d6312b00000000, 0xb80dca9200000000, 0x6a51208200000000, + 0x828adb3b00000000, 0xfbe0a62a00000000, 0x133b5d9300000000, + 0x09345c0800000000, 0xe1efa7b100000000, 0x9885daa000000000, + 0x705e211900000000, 0xed9da94d00000000, 0x054652f400000000, + 0x7c2c2fe500000000, 0x94f7d45c00000000, 0x8ef8d5c700000000, + 0x66232e7e00000000, 0x1f49536f00000000, 0xf792a8d600000000, + 0xc68b7c8400000000, 0x2e50873d00000000, 0x573afa2c00000000, + 0xbfe1019500000000, 0xa5ee000e00000000, 0x4d35fbb700000000, + 0x345f86a600000000, 0xdc847d1f00000000, 0x4147f54b00000000, + 0xa99c0ef200000000, 0xd0f673e300000000, 0x382d885a00000000, + 0x222289c100000000, 0xcaf9727800000000, 0xb3930f6900000000, + 0x5b48f4d000000000, 0x89141ec000000000, 0x61cfe57900000000, + 0x18a5986800000000, 0xf07e63d100000000, 0xea71624a00000000, + 0x02aa99f300000000, 0x7bc0e4e200000000, 0x931b1f5b00000000, + 0x0ed8970f00000000, 0xe6036cb600000000, 0x9f6911a700000000, + 0x77b2ea1e00000000, 0x6dbdeb8500000000, 0x8566103c00000000, + 0xfc0c6d2d00000000, 0x14d7969400000000, 0x58b5b90c00000000, + 0xb06e42b500000000, 0xc9043fa400000000, 0x21dfc41d00000000, + 0x3bd0c58600000000, 0xd30b3e3f00000000, 0xaa61432e00000000, + 0x42bab89700000000, 0xdf7930c300000000, 0x37a2cb7a00000000, + 0x4ec8b66b00000000, 0xa6134dd200000000, 0xbc1c4c4900000000, + 0x54c7b7f000000000, 0x2dadcae100000000, 0xc576315800000000, + 0x172adb4800000000, 0xfff120f100000000, 0x869b5de000000000, + 0x6e40a65900000000, 0x744fa7c200000000, 0x9c945c7b00000000, + 0xe5fe216a00000000, 0x0d25dad300000000, 0x90e6528700000000, + 0x783da93e00000000, 0x0157d42f00000000, 0xe98c2f9600000000, + 0xf3832e0d00000000, 0x1b58d5b400000000, 0x6232a8a500000000, + 0x8ae9531c00000000}, + {0x0000000000000000, 0x919168ae00000000, 0x6325a08700000000, + 0xf2b4c82900000000, 0x874c31d400000000, 0x16dd597a00000000, + 0xe469915300000000, 0x75f8f9fd00000000, 0x4f9f137300000000, + 0xde0e7bdd00000000, 0x2cbab3f400000000, 0xbd2bdb5a00000000, + 0xc8d322a700000000, 0x59424a0900000000, 0xabf6822000000000, + 0x3a67ea8e00000000, 0x9e3e27e600000000, 0x0faf4f4800000000, + 0xfd1b876100000000, 0x6c8aefcf00000000, 0x1972163200000000, + 0x88e37e9c00000000, 0x7a57b6b500000000, 0xebc6de1b00000000, + 0xd1a1349500000000, 0x40305c3b00000000, 0xb284941200000000, + 0x2315fcbc00000000, 0x56ed054100000000, 0xc77c6def00000000, + 0x35c8a5c600000000, 0xa459cd6800000000, 0x7d7b3f1700000000, + 0xecea57b900000000, 0x1e5e9f9000000000, 0x8fcff73e00000000, + 0xfa370ec300000000, 0x6ba6666d00000000, 0x9912ae4400000000, + 0x0883c6ea00000000, 0x32e42c6400000000, 0xa37544ca00000000, + 0x51c18ce300000000, 0xc050e44d00000000, 0xb5a81db000000000, + 0x2439751e00000000, 0xd68dbd3700000000, 0x471cd59900000000, + 0xe34518f100000000, 0x72d4705f00000000, 0x8060b87600000000, + 0x11f1d0d800000000, 0x6409292500000000, 0xf598418b00000000, + 0x072c89a200000000, 0x96bde10c00000000, 0xacda0b8200000000, + 0x3d4b632c00000000, 0xcfffab0500000000, 0x5e6ec3ab00000000, + 0x2b963a5600000000, 0xba0752f800000000, 0x48b39ad100000000, + 0xd922f27f00000000, 0xfaf67e2e00000000, 0x6b67168000000000, + 0x99d3dea900000000, 0x0842b60700000000, 0x7dba4ffa00000000, + 0xec2b275400000000, 0x1e9fef7d00000000, 0x8f0e87d300000000, + 0xb5696d5d00000000, 0x24f805f300000000, 0xd64ccdda00000000, + 0x47dda57400000000, 0x32255c8900000000, 0xa3b4342700000000, + 0x5100fc0e00000000, 0xc09194a000000000, 0x64c859c800000000, + 0xf559316600000000, 0x07edf94f00000000, 0x967c91e100000000, + 0xe384681c00000000, 0x721500b200000000, 0x80a1c89b00000000, + 0x1130a03500000000, 0x2b574abb00000000, 0xbac6221500000000, + 0x4872ea3c00000000, 0xd9e3829200000000, 0xac1b7b6f00000000, + 0x3d8a13c100000000, 0xcf3edbe800000000, 0x5eafb34600000000, + 0x878d413900000000, 0x161c299700000000, 0xe4a8e1be00000000, + 0x7539891000000000, 0x00c170ed00000000, 0x9150184300000000, + 0x63e4d06a00000000, 0xf275b8c400000000, 0xc812524a00000000, + 0x59833ae400000000, 0xab37f2cd00000000, 0x3aa69a6300000000, + 0x4f5e639e00000000, 0xdecf0b3000000000, 0x2c7bc31900000000, + 0xbdeaabb700000000, 0x19b366df00000000, 0x88220e7100000000, + 0x7a96c65800000000, 0xeb07aef600000000, 0x9eff570b00000000, + 0x0f6e3fa500000000, 0xfddaf78c00000000, 0x6c4b9f2200000000, + 0x562c75ac00000000, 0xc7bd1d0200000000, 0x3509d52b00000000, + 0xa498bd8500000000, 0xd160447800000000, 0x40f12cd600000000, + 0xb245e4ff00000000, 0x23d48c5100000000, 0xf4edfd5c00000000, + 0x657c95f200000000, 0x97c85ddb00000000, 0x0659357500000000, + 0x73a1cc8800000000, 0xe230a42600000000, 0x10846c0f00000000, + 0x811504a100000000, 0xbb72ee2f00000000, 0x2ae3868100000000, + 0xd8574ea800000000, 0x49c6260600000000, 0x3c3edffb00000000, + 0xadafb75500000000, 0x5f1b7f7c00000000, 0xce8a17d200000000, + 0x6ad3daba00000000, 0xfb42b21400000000, 0x09f67a3d00000000, + 0x9867129300000000, 0xed9feb6e00000000, 0x7c0e83c000000000, + 0x8eba4be900000000, 0x1f2b234700000000, 0x254cc9c900000000, + 0xb4dda16700000000, 0x4669694e00000000, 0xd7f801e000000000, + 0xa200f81d00000000, 0x339190b300000000, 0xc125589a00000000, + 0x50b4303400000000, 0x8996c24b00000000, 0x1807aae500000000, + 0xeab362cc00000000, 0x7b220a6200000000, 0x0edaf39f00000000, + 0x9f4b9b3100000000, 0x6dff531800000000, 0xfc6e3bb600000000, + 0xc609d13800000000, 0x5798b99600000000, 0xa52c71bf00000000, + 0x34bd191100000000, 0x4145e0ec00000000, 0xd0d4884200000000, + 0x2260406b00000000, 0xb3f128c500000000, 0x17a8e5ad00000000, + 0x86398d0300000000, 0x748d452a00000000, 0xe51c2d8400000000, + 0x90e4d47900000000, 0x0175bcd700000000, 0xf3c174fe00000000, + 0x62501c5000000000, 0x5837f6de00000000, 0xc9a69e7000000000, + 0x3b12565900000000, 0xaa833ef700000000, 0xdf7bc70a00000000, + 0x4eeaafa400000000, 0xbc5e678d00000000, 0x2dcf0f2300000000, + 0x0e1b837200000000, 0x9f8aebdc00000000, 0x6d3e23f500000000, + 0xfcaf4b5b00000000, 0x8957b2a600000000, 0x18c6da0800000000, + 0xea72122100000000, 0x7be37a8f00000000, 0x4184900100000000, + 0xd015f8af00000000, 0x22a1308600000000, 0xb330582800000000, + 0xc6c8a1d500000000, 0x5759c97b00000000, 0xa5ed015200000000, + 0x347c69fc00000000, 0x9025a49400000000, 0x01b4cc3a00000000, + 0xf300041300000000, 0x62916cbd00000000, 0x1769954000000000, + 0x86f8fdee00000000, 0x744c35c700000000, 0xe5dd5d6900000000, + 0xdfbab7e700000000, 0x4e2bdf4900000000, 0xbc9f176000000000, + 0x2d0e7fce00000000, 0x58f6863300000000, 0xc967ee9d00000000, + 0x3bd326b400000000, 0xaa424e1a00000000, 0x7360bc6500000000, + 0xe2f1d4cb00000000, 0x10451ce200000000, 0x81d4744c00000000, + 0xf42c8db100000000, 0x65bde51f00000000, 0x97092d3600000000, + 0x0698459800000000, 0x3cffaf1600000000, 0xad6ec7b800000000, + 0x5fda0f9100000000, 0xce4b673f00000000, 0xbbb39ec200000000, + 0x2a22f66c00000000, 0xd8963e4500000000, 0x490756eb00000000, + 0xed5e9b8300000000, 0x7ccff32d00000000, 0x8e7b3b0400000000, + 0x1fea53aa00000000, 0x6a12aa5700000000, 0xfb83c2f900000000, + 0x09370ad000000000, 0x98a6627e00000000, 0xa2c188f000000000, + 0x3350e05e00000000, 0xc1e4287700000000, 0x507540d900000000, + 0x258db92400000000, 0xb41cd18a00000000, 0x46a819a300000000, + 0xd739710d00000000}}; + +#else /* W == 4 */ + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xccaa009e, 0x4225077d, 0x8e8f07e3, 0x844a0efa, + 0x48e00e64, 0xc66f0987, 0x0ac50919, 0xd3e51bb5, 0x1f4f1b2b, + 0x91c01cc8, 0x5d6a1c56, 0x57af154f, 0x9b0515d1, 0x158a1232, + 0xd92012ac, 0x7cbb312b, 0xb01131b5, 0x3e9e3656, 0xf23436c8, + 0xf8f13fd1, 0x345b3f4f, 0xbad438ac, 0x767e3832, 0xaf5e2a9e, + 0x63f42a00, 0xed7b2de3, 0x21d12d7d, 0x2b142464, 0xe7be24fa, + 0x69312319, 0xa59b2387, 0xf9766256, 0x35dc62c8, 0xbb53652b, + 0x77f965b5, 0x7d3c6cac, 0xb1966c32, 0x3f196bd1, 0xf3b36b4f, + 0x2a9379e3, 0xe639797d, 0x68b67e9e, 0xa41c7e00, 0xaed97719, + 0x62737787, 0xecfc7064, 0x205670fa, 0x85cd537d, 0x496753e3, + 0xc7e85400, 0x0b42549e, 0x01875d87, 0xcd2d5d19, 0x43a25afa, + 0x8f085a64, 0x562848c8, 0x9a824856, 0x140d4fb5, 0xd8a74f2b, + 0xd2624632, 0x1ec846ac, 0x9047414f, 0x5ced41d1, 0x299dc2ed, + 0xe537c273, 0x6bb8c590, 0xa712c50e, 0xadd7cc17, 0x617dcc89, + 0xeff2cb6a, 0x2358cbf4, 0xfa78d958, 0x36d2d9c6, 0xb85dde25, + 0x74f7debb, 0x7e32d7a2, 0xb298d73c, 0x3c17d0df, 0xf0bdd041, + 0x5526f3c6, 0x998cf358, 0x1703f4bb, 0xdba9f425, 0xd16cfd3c, + 0x1dc6fda2, 0x9349fa41, 0x5fe3fadf, 0x86c3e873, 0x4a69e8ed, + 0xc4e6ef0e, 0x084cef90, 0x0289e689, 0xce23e617, 0x40ace1f4, + 0x8c06e16a, 0xd0eba0bb, 0x1c41a025, 0x92cea7c6, 0x5e64a758, + 0x54a1ae41, 0x980baedf, 0x1684a93c, 0xda2ea9a2, 0x030ebb0e, + 0xcfa4bb90, 0x412bbc73, 0x8d81bced, 0x8744b5f4, 0x4beeb56a, + 0xc561b289, 0x09cbb217, 0xac509190, 0x60fa910e, 0xee7596ed, + 0x22df9673, 0x281a9f6a, 0xe4b09ff4, 0x6a3f9817, 0xa6959889, + 0x7fb58a25, 0xb31f8abb, 0x3d908d58, 0xf13a8dc6, 0xfbff84df, + 0x37558441, 0xb9da83a2, 0x7570833c, 0x533b85da, 0x9f918544, + 0x111e82a7, 0xddb48239, 0xd7718b20, 0x1bdb8bbe, 0x95548c5d, + 0x59fe8cc3, 0x80de9e6f, 0x4c749ef1, 0xc2fb9912, 0x0e51998c, + 0x04949095, 0xc83e900b, 0x46b197e8, 0x8a1b9776, 0x2f80b4f1, + 0xe32ab46f, 0x6da5b38c, 0xa10fb312, 0xabcaba0b, 0x6760ba95, + 0xe9efbd76, 0x2545bde8, 0xfc65af44, 0x30cfafda, 0xbe40a839, + 0x72eaa8a7, 0x782fa1be, 0xb485a120, 0x3a0aa6c3, 0xf6a0a65d, + 0xaa4de78c, 0x66e7e712, 0xe868e0f1, 0x24c2e06f, 0x2e07e976, + 0xe2ade9e8, 0x6c22ee0b, 0xa088ee95, 0x79a8fc39, 0xb502fca7, + 0x3b8dfb44, 0xf727fbda, 0xfde2f2c3, 0x3148f25d, 0xbfc7f5be, + 0x736df520, 0xd6f6d6a7, 0x1a5cd639, 0x94d3d1da, 0x5879d144, + 0x52bcd85d, 0x9e16d8c3, 0x1099df20, 0xdc33dfbe, 0x0513cd12, + 0xc9b9cd8c, 0x4736ca6f, 0x8b9ccaf1, 0x8159c3e8, 0x4df3c376, + 0xc37cc495, 0x0fd6c40b, 0x7aa64737, 0xb60c47a9, 0x3883404a, + 0xf42940d4, 0xfeec49cd, 0x32464953, 0xbcc94eb0, 0x70634e2e, + 0xa9435c82, 0x65e95c1c, 0xeb665bff, 0x27cc5b61, 0x2d095278, + 0xe1a352e6, 0x6f2c5505, 0xa386559b, 0x061d761c, 0xcab77682, + 0x44387161, 0x889271ff, 0x825778e6, 0x4efd7878, 0xc0727f9b, + 0x0cd87f05, 0xd5f86da9, 0x19526d37, 0x97dd6ad4, 0x5b776a4a, + 0x51b26353, 0x9d1863cd, 0x1397642e, 0xdf3d64b0, 0x83d02561, + 0x4f7a25ff, 0xc1f5221c, 0x0d5f2282, 0x079a2b9b, 0xcb302b05, + 0x45bf2ce6, 0x89152c78, 0x50353ed4, 0x9c9f3e4a, 0x121039a9, + 0xdeba3937, 0xd47f302e, 0x18d530b0, 0x965a3753, 0x5af037cd, + 0xff6b144a, 0x33c114d4, 0xbd4e1337, 0x71e413a9, 0x7b211ab0, + 0xb78b1a2e, 0x39041dcd, 0xf5ae1d53, 0x2c8e0fff, 0xe0240f61, + 0x6eab0882, 0xa201081c, 0xa8c40105, 0x646e019b, 0xeae10678, + 0x264b06e6}, + {0x00000000, 0xa6770bb4, 0x979f1129, 0x31e81a9d, 0xf44f2413, + 0x52382fa7, 0x63d0353a, 0xc5a73e8e, 0x33ef4e67, 0x959845d3, + 0xa4705f4e, 0x020754fa, 0xc7a06a74, 0x61d761c0, 0x503f7b5d, + 0xf64870e9, 0x67de9cce, 0xc1a9977a, 0xf0418de7, 0x56368653, + 0x9391b8dd, 0x35e6b369, 0x040ea9f4, 0xa279a240, 0x5431d2a9, + 0xf246d91d, 0xc3aec380, 0x65d9c834, 0xa07ef6ba, 0x0609fd0e, + 0x37e1e793, 0x9196ec27, 0xcfbd399c, 0x69ca3228, 0x582228b5, + 0xfe552301, 0x3bf21d8f, 0x9d85163b, 0xac6d0ca6, 0x0a1a0712, + 0xfc5277fb, 0x5a257c4f, 0x6bcd66d2, 0xcdba6d66, 0x081d53e8, + 0xae6a585c, 0x9f8242c1, 0x39f54975, 0xa863a552, 0x0e14aee6, + 0x3ffcb47b, 0x998bbfcf, 0x5c2c8141, 0xfa5b8af5, 0xcbb39068, + 0x6dc49bdc, 0x9b8ceb35, 0x3dfbe081, 0x0c13fa1c, 0xaa64f1a8, + 0x6fc3cf26, 0xc9b4c492, 0xf85cde0f, 0x5e2bd5bb, 0x440b7579, + 0xe27c7ecd, 0xd3946450, 0x75e36fe4, 0xb044516a, 0x16335ade, + 0x27db4043, 0x81ac4bf7, 0x77e43b1e, 0xd19330aa, 0xe07b2a37, + 0x460c2183, 0x83ab1f0d, 0x25dc14b9, 0x14340e24, 0xb2430590, + 0x23d5e9b7, 0x85a2e203, 0xb44af89e, 0x123df32a, 0xd79acda4, + 0x71edc610, 0x4005dc8d, 0xe672d739, 0x103aa7d0, 0xb64dac64, + 0x87a5b6f9, 0x21d2bd4d, 0xe47583c3, 0x42028877, 0x73ea92ea, + 0xd59d995e, 0x8bb64ce5, 0x2dc14751, 0x1c295dcc, 0xba5e5678, + 0x7ff968f6, 0xd98e6342, 0xe86679df, 0x4e11726b, 0xb8590282, + 0x1e2e0936, 0x2fc613ab, 0x89b1181f, 0x4c162691, 0xea612d25, + 0xdb8937b8, 0x7dfe3c0c, 0xec68d02b, 0x4a1fdb9f, 0x7bf7c102, + 0xdd80cab6, 0x1827f438, 0xbe50ff8c, 0x8fb8e511, 0x29cfeea5, + 0xdf879e4c, 0x79f095f8, 0x48188f65, 0xee6f84d1, 0x2bc8ba5f, + 0x8dbfb1eb, 0xbc57ab76, 0x1a20a0c2, 0x8816eaf2, 0x2e61e146, + 0x1f89fbdb, 0xb9fef06f, 0x7c59cee1, 0xda2ec555, 0xebc6dfc8, + 0x4db1d47c, 0xbbf9a495, 0x1d8eaf21, 0x2c66b5bc, 0x8a11be08, + 0x4fb68086, 0xe9c18b32, 0xd82991af, 0x7e5e9a1b, 0xefc8763c, + 0x49bf7d88, 0x78576715, 0xde206ca1, 0x1b87522f, 0xbdf0599b, + 0x8c184306, 0x2a6f48b2, 0xdc27385b, 0x7a5033ef, 0x4bb82972, + 0xedcf22c6, 0x28681c48, 0x8e1f17fc, 0xbff70d61, 0x198006d5, + 0x47abd36e, 0xe1dcd8da, 0xd034c247, 0x7643c9f3, 0xb3e4f77d, + 0x1593fcc9, 0x247be654, 0x820cede0, 0x74449d09, 0xd23396bd, + 0xe3db8c20, 0x45ac8794, 0x800bb91a, 0x267cb2ae, 0x1794a833, + 0xb1e3a387, 0x20754fa0, 0x86024414, 0xb7ea5e89, 0x119d553d, + 0xd43a6bb3, 0x724d6007, 0x43a57a9a, 0xe5d2712e, 0x139a01c7, + 0xb5ed0a73, 0x840510ee, 0x22721b5a, 0xe7d525d4, 0x41a22e60, + 0x704a34fd, 0xd63d3f49, 0xcc1d9f8b, 0x6a6a943f, 0x5b828ea2, + 0xfdf58516, 0x3852bb98, 0x9e25b02c, 0xafcdaab1, 0x09baa105, + 0xfff2d1ec, 0x5985da58, 0x686dc0c5, 0xce1acb71, 0x0bbdf5ff, + 0xadcafe4b, 0x9c22e4d6, 0x3a55ef62, 0xabc30345, 0x0db408f1, + 0x3c5c126c, 0x9a2b19d8, 0x5f8c2756, 0xf9fb2ce2, 0xc813367f, + 0x6e643dcb, 0x982c4d22, 0x3e5b4696, 0x0fb35c0b, 0xa9c457bf, + 0x6c636931, 0xca146285, 0xfbfc7818, 0x5d8b73ac, 0x03a0a617, + 0xa5d7ada3, 0x943fb73e, 0x3248bc8a, 0xf7ef8204, 0x519889b0, + 0x6070932d, 0xc6079899, 0x304fe870, 0x9638e3c4, 0xa7d0f959, + 0x01a7f2ed, 0xc400cc63, 0x6277c7d7, 0x539fdd4a, 0xf5e8d6fe, + 0x647e3ad9, 0xc209316d, 0xf3e12bf0, 0x55962044, 0x90311eca, + 0x3646157e, 0x07ae0fe3, 0xa1d90457, 0x579174be, 0xf1e67f0a, + 0xc00e6597, 0x66796e23, 0xa3de50ad, 0x05a95b19, 0x34414184, + 0x92364a30}, + {0x00000000, 0xcb5cd3a5, 0x4dc8a10b, 0x869472ae, 0x9b914216, + 0x50cd91b3, 0xd659e31d, 0x1d0530b8, 0xec53826d, 0x270f51c8, + 0xa19b2366, 0x6ac7f0c3, 0x77c2c07b, 0xbc9e13de, 0x3a0a6170, + 0xf156b2d5, 0x03d6029b, 0xc88ad13e, 0x4e1ea390, 0x85427035, + 0x9847408d, 0x531b9328, 0xd58fe186, 0x1ed33223, 0xef8580f6, + 0x24d95353, 0xa24d21fd, 0x6911f258, 0x7414c2e0, 0xbf481145, + 0x39dc63eb, 0xf280b04e, 0x07ac0536, 0xccf0d693, 0x4a64a43d, + 0x81387798, 0x9c3d4720, 0x57619485, 0xd1f5e62b, 0x1aa9358e, + 0xebff875b, 0x20a354fe, 0xa6372650, 0x6d6bf5f5, 0x706ec54d, + 0xbb3216e8, 0x3da66446, 0xf6fab7e3, 0x047a07ad, 0xcf26d408, + 0x49b2a6a6, 0x82ee7503, 0x9feb45bb, 0x54b7961e, 0xd223e4b0, + 0x197f3715, 0xe82985c0, 0x23755665, 0xa5e124cb, 0x6ebdf76e, + 0x73b8c7d6, 0xb8e41473, 0x3e7066dd, 0xf52cb578, 0x0f580a6c, + 0xc404d9c9, 0x4290ab67, 0x89cc78c2, 0x94c9487a, 0x5f959bdf, + 0xd901e971, 0x125d3ad4, 0xe30b8801, 0x28575ba4, 0xaec3290a, + 0x659ffaaf, 0x789aca17, 0xb3c619b2, 0x35526b1c, 0xfe0eb8b9, + 0x0c8e08f7, 0xc7d2db52, 0x4146a9fc, 0x8a1a7a59, 0x971f4ae1, + 0x5c439944, 0xdad7ebea, 0x118b384f, 0xe0dd8a9a, 0x2b81593f, + 0xad152b91, 0x6649f834, 0x7b4cc88c, 0xb0101b29, 0x36846987, + 0xfdd8ba22, 0x08f40f5a, 0xc3a8dcff, 0x453cae51, 0x8e607df4, + 0x93654d4c, 0x58399ee9, 0xdeadec47, 0x15f13fe2, 0xe4a78d37, + 0x2ffb5e92, 0xa96f2c3c, 0x6233ff99, 0x7f36cf21, 0xb46a1c84, + 0x32fe6e2a, 0xf9a2bd8f, 0x0b220dc1, 0xc07ede64, 0x46eaacca, + 0x8db67f6f, 0x90b34fd7, 0x5bef9c72, 0xdd7beedc, 0x16273d79, + 0xe7718fac, 0x2c2d5c09, 0xaab92ea7, 0x61e5fd02, 0x7ce0cdba, + 0xb7bc1e1f, 0x31286cb1, 0xfa74bf14, 0x1eb014d8, 0xd5ecc77d, + 0x5378b5d3, 0x98246676, 0x852156ce, 0x4e7d856b, 0xc8e9f7c5, + 0x03b52460, 0xf2e396b5, 0x39bf4510, 0xbf2b37be, 0x7477e41b, + 0x6972d4a3, 0xa22e0706, 0x24ba75a8, 0xefe6a60d, 0x1d661643, + 0xd63ac5e6, 0x50aeb748, 0x9bf264ed, 0x86f75455, 0x4dab87f0, + 0xcb3ff55e, 0x006326fb, 0xf135942e, 0x3a69478b, 0xbcfd3525, + 0x77a1e680, 0x6aa4d638, 0xa1f8059d, 0x276c7733, 0xec30a496, + 0x191c11ee, 0xd240c24b, 0x54d4b0e5, 0x9f886340, 0x828d53f8, + 0x49d1805d, 0xcf45f2f3, 0x04192156, 0xf54f9383, 0x3e134026, + 0xb8873288, 0x73dbe12d, 0x6eded195, 0xa5820230, 0x2316709e, + 0xe84aa33b, 0x1aca1375, 0xd196c0d0, 0x5702b27e, 0x9c5e61db, + 0x815b5163, 0x4a0782c6, 0xcc93f068, 0x07cf23cd, 0xf6999118, + 0x3dc542bd, 0xbb513013, 0x700de3b6, 0x6d08d30e, 0xa65400ab, + 0x20c07205, 0xeb9ca1a0, 0x11e81eb4, 0xdab4cd11, 0x5c20bfbf, + 0x977c6c1a, 0x8a795ca2, 0x41258f07, 0xc7b1fda9, 0x0ced2e0c, + 0xfdbb9cd9, 0x36e74f7c, 0xb0733dd2, 0x7b2fee77, 0x662adecf, + 0xad760d6a, 0x2be27fc4, 0xe0beac61, 0x123e1c2f, 0xd962cf8a, + 0x5ff6bd24, 0x94aa6e81, 0x89af5e39, 0x42f38d9c, 0xc467ff32, + 0x0f3b2c97, 0xfe6d9e42, 0x35314de7, 0xb3a53f49, 0x78f9ecec, + 0x65fcdc54, 0xaea00ff1, 0x28347d5f, 0xe368aefa, 0x16441b82, + 0xdd18c827, 0x5b8cba89, 0x90d0692c, 0x8dd55994, 0x46898a31, + 0xc01df89f, 0x0b412b3a, 0xfa1799ef, 0x314b4a4a, 0xb7df38e4, + 0x7c83eb41, 0x6186dbf9, 0xaada085c, 0x2c4e7af2, 0xe712a957, + 0x15921919, 0xdececabc, 0x585ab812, 0x93066bb7, 0x8e035b0f, + 0x455f88aa, 0xc3cbfa04, 0x089729a1, 0xf9c19b74, 0x329d48d1, + 0xb4093a7f, 0x7f55e9da, 0x6250d962, 0xa90c0ac7, 0x2f987869, + 0xe4c4abcc}, + {0x00000000, 0x3d6029b0, 0x7ac05360, 0x47a07ad0, 0xf580a6c0, + 0xc8e08f70, 0x8f40f5a0, 0xb220dc10, 0x30704bc1, 0x0d106271, + 0x4ab018a1, 0x77d03111, 0xc5f0ed01, 0xf890c4b1, 0xbf30be61, + 0x825097d1, 0x60e09782, 0x5d80be32, 0x1a20c4e2, 0x2740ed52, + 0x95603142, 0xa80018f2, 0xefa06222, 0xd2c04b92, 0x5090dc43, + 0x6df0f5f3, 0x2a508f23, 0x1730a693, 0xa5107a83, 0x98705333, + 0xdfd029e3, 0xe2b00053, 0xc1c12f04, 0xfca106b4, 0xbb017c64, + 0x866155d4, 0x344189c4, 0x0921a074, 0x4e81daa4, 0x73e1f314, + 0xf1b164c5, 0xccd14d75, 0x8b7137a5, 0xb6111e15, 0x0431c205, + 0x3951ebb5, 0x7ef19165, 0x4391b8d5, 0xa121b886, 0x9c419136, + 0xdbe1ebe6, 0xe681c256, 0x54a11e46, 0x69c137f6, 0x2e614d26, + 0x13016496, 0x9151f347, 0xac31daf7, 0xeb91a027, 0xd6f18997, + 0x64d15587, 0x59b17c37, 0x1e1106e7, 0x23712f57, 0x58f35849, + 0x659371f9, 0x22330b29, 0x1f532299, 0xad73fe89, 0x9013d739, + 0xd7b3ade9, 0xead38459, 0x68831388, 0x55e33a38, 0x124340e8, + 0x2f236958, 0x9d03b548, 0xa0639cf8, 0xe7c3e628, 0xdaa3cf98, + 0x3813cfcb, 0x0573e67b, 0x42d39cab, 0x7fb3b51b, 0xcd93690b, + 0xf0f340bb, 0xb7533a6b, 0x8a3313db, 0x0863840a, 0x3503adba, + 0x72a3d76a, 0x4fc3feda, 0xfde322ca, 0xc0830b7a, 0x872371aa, + 0xba43581a, 0x9932774d, 0xa4525efd, 0xe3f2242d, 0xde920d9d, + 0x6cb2d18d, 0x51d2f83d, 0x167282ed, 0x2b12ab5d, 0xa9423c8c, + 0x9422153c, 0xd3826fec, 0xeee2465c, 0x5cc29a4c, 0x61a2b3fc, + 0x2602c92c, 0x1b62e09c, 0xf9d2e0cf, 0xc4b2c97f, 0x8312b3af, + 0xbe729a1f, 0x0c52460f, 0x31326fbf, 0x7692156f, 0x4bf23cdf, + 0xc9a2ab0e, 0xf4c282be, 0xb362f86e, 0x8e02d1de, 0x3c220dce, + 0x0142247e, 0x46e25eae, 0x7b82771e, 0xb1e6b092, 0x8c869922, + 0xcb26e3f2, 0xf646ca42, 0x44661652, 0x79063fe2, 0x3ea64532, + 0x03c66c82, 0x8196fb53, 0xbcf6d2e3, 0xfb56a833, 0xc6368183, + 0x74165d93, 0x49767423, 0x0ed60ef3, 0x33b62743, 0xd1062710, + 0xec660ea0, 0xabc67470, 0x96a65dc0, 0x248681d0, 0x19e6a860, + 0x5e46d2b0, 0x6326fb00, 0xe1766cd1, 0xdc164561, 0x9bb63fb1, + 0xa6d61601, 0x14f6ca11, 0x2996e3a1, 0x6e369971, 0x5356b0c1, + 0x70279f96, 0x4d47b626, 0x0ae7ccf6, 0x3787e546, 0x85a73956, + 0xb8c710e6, 0xff676a36, 0xc2074386, 0x4057d457, 0x7d37fde7, + 0x3a978737, 0x07f7ae87, 0xb5d77297, 0x88b75b27, 0xcf1721f7, + 0xf2770847, 0x10c70814, 0x2da721a4, 0x6a075b74, 0x576772c4, + 0xe547aed4, 0xd8278764, 0x9f87fdb4, 0xa2e7d404, 0x20b743d5, + 0x1dd76a65, 0x5a7710b5, 0x67173905, 0xd537e515, 0xe857cca5, + 0xaff7b675, 0x92979fc5, 0xe915e8db, 0xd475c16b, 0x93d5bbbb, + 0xaeb5920b, 0x1c954e1b, 0x21f567ab, 0x66551d7b, 0x5b3534cb, + 0xd965a31a, 0xe4058aaa, 0xa3a5f07a, 0x9ec5d9ca, 0x2ce505da, + 0x11852c6a, 0x562556ba, 0x6b457f0a, 0x89f57f59, 0xb49556e9, + 0xf3352c39, 0xce550589, 0x7c75d999, 0x4115f029, 0x06b58af9, + 0x3bd5a349, 0xb9853498, 0x84e51d28, 0xc34567f8, 0xfe254e48, + 0x4c059258, 0x7165bbe8, 0x36c5c138, 0x0ba5e888, 0x28d4c7df, + 0x15b4ee6f, 0x521494bf, 0x6f74bd0f, 0xdd54611f, 0xe03448af, + 0xa794327f, 0x9af41bcf, 0x18a48c1e, 0x25c4a5ae, 0x6264df7e, + 0x5f04f6ce, 0xed242ade, 0xd044036e, 0x97e479be, 0xaa84500e, + 0x4834505d, 0x755479ed, 0x32f4033d, 0x0f942a8d, 0xbdb4f69d, + 0x80d4df2d, 0xc774a5fd, 0xfa148c4d, 0x78441b9c, 0x4524322c, + 0x028448fc, 0x3fe4614c, 0x8dc4bd5c, 0xb0a494ec, 0xf704ee3c, + 0xca64c78c}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x00000000, 0xb029603d, 0x6053c07a, 0xd07aa047, 0xc0a680f5, + 0x708fe0c8, 0xa0f5408f, 0x10dc20b2, 0xc14b7030, 0x7162100d, + 0xa118b04a, 0x1131d077, 0x01edf0c5, 0xb1c490f8, 0x61be30bf, + 0xd1975082, 0x8297e060, 0x32be805d, 0xe2c4201a, 0x52ed4027, + 0x42316095, 0xf21800a8, 0x2262a0ef, 0x924bc0d2, 0x43dc9050, + 0xf3f5f06d, 0x238f502a, 0x93a63017, 0x837a10a5, 0x33537098, + 0xe329d0df, 0x5300b0e2, 0x042fc1c1, 0xb406a1fc, 0x647c01bb, + 0xd4556186, 0xc4894134, 0x74a02109, 0xa4da814e, 0x14f3e173, + 0xc564b1f1, 0x754dd1cc, 0xa537718b, 0x151e11b6, 0x05c23104, + 0xb5eb5139, 0x6591f17e, 0xd5b89143, 0x86b821a1, 0x3691419c, + 0xe6ebe1db, 0x56c281e6, 0x461ea154, 0xf637c169, 0x264d612e, + 0x96640113, 0x47f35191, 0xf7da31ac, 0x27a091eb, 0x9789f1d6, + 0x8755d164, 0x377cb159, 0xe706111e, 0x572f7123, 0x4958f358, + 0xf9719365, 0x290b3322, 0x9922531f, 0x89fe73ad, 0x39d71390, + 0xe9adb3d7, 0x5984d3ea, 0x88138368, 0x383ae355, 0xe8404312, + 0x5869232f, 0x48b5039d, 0xf89c63a0, 0x28e6c3e7, 0x98cfa3da, + 0xcbcf1338, 0x7be67305, 0xab9cd342, 0x1bb5b37f, 0x0b6993cd, + 0xbb40f3f0, 0x6b3a53b7, 0xdb13338a, 0x0a846308, 0xbaad0335, + 0x6ad7a372, 0xdafec34f, 0xca22e3fd, 0x7a0b83c0, 0xaa712387, + 0x1a5843ba, 0x4d773299, 0xfd5e52a4, 0x2d24f2e3, 0x9d0d92de, + 0x8dd1b26c, 0x3df8d251, 0xed827216, 0x5dab122b, 0x8c3c42a9, + 0x3c152294, 0xec6f82d3, 0x5c46e2ee, 0x4c9ac25c, 0xfcb3a261, + 0x2cc90226, 0x9ce0621b, 0xcfe0d2f9, 0x7fc9b2c4, 0xafb31283, + 0x1f9a72be, 0x0f46520c, 0xbf6f3231, 0x6f159276, 0xdf3cf24b, + 0x0eaba2c9, 0xbe82c2f4, 0x6ef862b3, 0xded1028e, 0xce0d223c, + 0x7e244201, 0xae5ee246, 0x1e77827b, 0x92b0e6b1, 0x2299868c, + 0xf2e326cb, 0x42ca46f6, 0x52166644, 0xe23f0679, 0x3245a63e, + 0x826cc603, 0x53fb9681, 0xe3d2f6bc, 0x33a856fb, 0x838136c6, + 0x935d1674, 0x23747649, 0xf30ed60e, 0x4327b633, 0x102706d1, + 0xa00e66ec, 0x7074c6ab, 0xc05da696, 0xd0818624, 0x60a8e619, + 0xb0d2465e, 0x00fb2663, 0xd16c76e1, 0x614516dc, 0xb13fb69b, + 0x0116d6a6, 0x11caf614, 0xa1e39629, 0x7199366e, 0xc1b05653, + 0x969f2770, 0x26b6474d, 0xf6cce70a, 0x46e58737, 0x5639a785, + 0xe610c7b8, 0x366a67ff, 0x864307c2, 0x57d45740, 0xe7fd377d, + 0x3787973a, 0x87aef707, 0x9772d7b5, 0x275bb788, 0xf72117cf, + 0x470877f2, 0x1408c710, 0xa421a72d, 0x745b076a, 0xc4726757, + 0xd4ae47e5, 0x648727d8, 0xb4fd879f, 0x04d4e7a2, 0xd543b720, + 0x656ad71d, 0xb510775a, 0x05391767, 0x15e537d5, 0xa5cc57e8, + 0x75b6f7af, 0xc59f9792, 0xdbe815e9, 0x6bc175d4, 0xbbbbd593, + 0x0b92b5ae, 0x1b4e951c, 0xab67f521, 0x7b1d5566, 0xcb34355b, + 0x1aa365d9, 0xaa8a05e4, 0x7af0a5a3, 0xcad9c59e, 0xda05e52c, + 0x6a2c8511, 0xba562556, 0x0a7f456b, 0x597ff589, 0xe95695b4, + 0x392c35f3, 0x890555ce, 0x99d9757c, 0x29f01541, 0xf98ab506, + 0x49a3d53b, 0x983485b9, 0x281de584, 0xf86745c3, 0x484e25fe, + 0x5892054c, 0xe8bb6571, 0x38c1c536, 0x88e8a50b, 0xdfc7d428, + 0x6feeb415, 0xbf941452, 0x0fbd746f, 0x1f6154dd, 0xaf4834e0, + 0x7f3294a7, 0xcf1bf49a, 0x1e8ca418, 0xaea5c425, 0x7edf6462, + 0xcef6045f, 0xde2a24ed, 0x6e0344d0, 0xbe79e497, 0x0e5084aa, + 0x5d503448, 0xed795475, 0x3d03f432, 0x8d2a940f, 0x9df6b4bd, + 0x2ddfd480, 0xfda574c7, 0x4d8c14fa, 0x9c1b4478, 0x2c322445, + 0xfc488402, 0x4c61e43f, 0x5cbdc48d, 0xec94a4b0, 0x3cee04f7, + 0x8cc764ca}, + {0x00000000, 0xa5d35ccb, 0x0ba1c84d, 0xae729486, 0x1642919b, + 0xb391cd50, 0x1de359d6, 0xb830051d, 0x6d8253ec, 0xc8510f27, + 0x66239ba1, 0xc3f0c76a, 0x7bc0c277, 0xde139ebc, 0x70610a3a, + 0xd5b256f1, 0x9b02d603, 0x3ed18ac8, 0x90a31e4e, 0x35704285, + 0x8d404798, 0x28931b53, 0x86e18fd5, 0x2332d31e, 0xf68085ef, + 0x5353d924, 0xfd214da2, 0x58f21169, 0xe0c21474, 0x451148bf, + 0xeb63dc39, 0x4eb080f2, 0x3605ac07, 0x93d6f0cc, 0x3da4644a, + 0x98773881, 0x20473d9c, 0x85946157, 0x2be6f5d1, 0x8e35a91a, + 0x5b87ffeb, 0xfe54a320, 0x502637a6, 0xf5f56b6d, 0x4dc56e70, + 0xe81632bb, 0x4664a63d, 0xe3b7faf6, 0xad077a04, 0x08d426cf, + 0xa6a6b249, 0x0375ee82, 0xbb45eb9f, 0x1e96b754, 0xb0e423d2, + 0x15377f19, 0xc08529e8, 0x65567523, 0xcb24e1a5, 0x6ef7bd6e, + 0xd6c7b873, 0x7314e4b8, 0xdd66703e, 0x78b52cf5, 0x6c0a580f, + 0xc9d904c4, 0x67ab9042, 0xc278cc89, 0x7a48c994, 0xdf9b955f, + 0x71e901d9, 0xd43a5d12, 0x01880be3, 0xa45b5728, 0x0a29c3ae, + 0xaffa9f65, 0x17ca9a78, 0xb219c6b3, 0x1c6b5235, 0xb9b80efe, + 0xf7088e0c, 0x52dbd2c7, 0xfca94641, 0x597a1a8a, 0xe14a1f97, + 0x4499435c, 0xeaebd7da, 0x4f388b11, 0x9a8adde0, 0x3f59812b, + 0x912b15ad, 0x34f84966, 0x8cc84c7b, 0x291b10b0, 0x87698436, + 0x22bad8fd, 0x5a0ff408, 0xffdca8c3, 0x51ae3c45, 0xf47d608e, + 0x4c4d6593, 0xe99e3958, 0x47ecadde, 0xe23ff115, 0x378da7e4, + 0x925efb2f, 0x3c2c6fa9, 0x99ff3362, 0x21cf367f, 0x841c6ab4, + 0x2a6efe32, 0x8fbda2f9, 0xc10d220b, 0x64de7ec0, 0xcaacea46, + 0x6f7fb68d, 0xd74fb390, 0x729cef5b, 0xdcee7bdd, 0x793d2716, + 0xac8f71e7, 0x095c2d2c, 0xa72eb9aa, 0x02fde561, 0xbacde07c, + 0x1f1ebcb7, 0xb16c2831, 0x14bf74fa, 0xd814b01e, 0x7dc7ecd5, + 0xd3b57853, 0x76662498, 0xce562185, 0x6b857d4e, 0xc5f7e9c8, + 0x6024b503, 0xb596e3f2, 0x1045bf39, 0xbe372bbf, 0x1be47774, + 0xa3d47269, 0x06072ea2, 0xa875ba24, 0x0da6e6ef, 0x4316661d, + 0xe6c53ad6, 0x48b7ae50, 0xed64f29b, 0x5554f786, 0xf087ab4d, + 0x5ef53fcb, 0xfb266300, 0x2e9435f1, 0x8b47693a, 0x2535fdbc, + 0x80e6a177, 0x38d6a46a, 0x9d05f8a1, 0x33776c27, 0x96a430ec, + 0xee111c19, 0x4bc240d2, 0xe5b0d454, 0x4063889f, 0xf8538d82, + 0x5d80d149, 0xf3f245cf, 0x56211904, 0x83934ff5, 0x2640133e, + 0x883287b8, 0x2de1db73, 0x95d1de6e, 0x300282a5, 0x9e701623, + 0x3ba34ae8, 0x7513ca1a, 0xd0c096d1, 0x7eb20257, 0xdb615e9c, + 0x63515b81, 0xc682074a, 0x68f093cc, 0xcd23cf07, 0x189199f6, + 0xbd42c53d, 0x133051bb, 0xb6e30d70, 0x0ed3086d, 0xab0054a6, + 0x0572c020, 0xa0a19ceb, 0xb41ee811, 0x11cdb4da, 0xbfbf205c, + 0x1a6c7c97, 0xa25c798a, 0x078f2541, 0xa9fdb1c7, 0x0c2eed0c, + 0xd99cbbfd, 0x7c4fe736, 0xd23d73b0, 0x77ee2f7b, 0xcfde2a66, + 0x6a0d76ad, 0xc47fe22b, 0x61acbee0, 0x2f1c3e12, 0x8acf62d9, + 0x24bdf65f, 0x816eaa94, 0x395eaf89, 0x9c8df342, 0x32ff67c4, + 0x972c3b0f, 0x429e6dfe, 0xe74d3135, 0x493fa5b3, 0xececf978, + 0x54dcfc65, 0xf10fa0ae, 0x5f7d3428, 0xfaae68e3, 0x821b4416, + 0x27c818dd, 0x89ba8c5b, 0x2c69d090, 0x9459d58d, 0x318a8946, + 0x9ff81dc0, 0x3a2b410b, 0xef9917fa, 0x4a4a4b31, 0xe438dfb7, + 0x41eb837c, 0xf9db8661, 0x5c08daaa, 0xf27a4e2c, 0x57a912e7, + 0x19199215, 0xbccacede, 0x12b85a58, 0xb76b0693, 0x0f5b038e, + 0xaa885f45, 0x04facbc3, 0xa1299708, 0x749bc1f9, 0xd1489d32, + 0x7f3a09b4, 0xdae9557f, 0x62d95062, 0xc70a0ca9, 0x6978982f, + 0xccabc4e4}, + {0x00000000, 0xb40b77a6, 0x29119f97, 0x9d1ae831, 0x13244ff4, + 0xa72f3852, 0x3a35d063, 0x8e3ea7c5, 0x674eef33, 0xd3459895, + 0x4e5f70a4, 0xfa540702, 0x746aa0c7, 0xc061d761, 0x5d7b3f50, + 0xe97048f6, 0xce9cde67, 0x7a97a9c1, 0xe78d41f0, 0x53863656, + 0xddb89193, 0x69b3e635, 0xf4a90e04, 0x40a279a2, 0xa9d23154, + 0x1dd946f2, 0x80c3aec3, 0x34c8d965, 0xbaf67ea0, 0x0efd0906, + 0x93e7e137, 0x27ec9691, 0x9c39bdcf, 0x2832ca69, 0xb5282258, + 0x012355fe, 0x8f1df23b, 0x3b16859d, 0xa60c6dac, 0x12071a0a, + 0xfb7752fc, 0x4f7c255a, 0xd266cd6b, 0x666dbacd, 0xe8531d08, + 0x5c586aae, 0xc142829f, 0x7549f539, 0x52a563a8, 0xe6ae140e, + 0x7bb4fc3f, 0xcfbf8b99, 0x41812c5c, 0xf58a5bfa, 0x6890b3cb, + 0xdc9bc46d, 0x35eb8c9b, 0x81e0fb3d, 0x1cfa130c, 0xa8f164aa, + 0x26cfc36f, 0x92c4b4c9, 0x0fde5cf8, 0xbbd52b5e, 0x79750b44, + 0xcd7e7ce2, 0x506494d3, 0xe46fe375, 0x6a5144b0, 0xde5a3316, + 0x4340db27, 0xf74bac81, 0x1e3be477, 0xaa3093d1, 0x372a7be0, + 0x83210c46, 0x0d1fab83, 0xb914dc25, 0x240e3414, 0x900543b2, + 0xb7e9d523, 0x03e2a285, 0x9ef84ab4, 0x2af33d12, 0xa4cd9ad7, + 0x10c6ed71, 0x8ddc0540, 0x39d772e6, 0xd0a73a10, 0x64ac4db6, + 0xf9b6a587, 0x4dbdd221, 0xc38375e4, 0x77880242, 0xea92ea73, + 0x5e999dd5, 0xe54cb68b, 0x5147c12d, 0xcc5d291c, 0x78565eba, + 0xf668f97f, 0x42638ed9, 0xdf7966e8, 0x6b72114e, 0x820259b8, + 0x36092e1e, 0xab13c62f, 0x1f18b189, 0x9126164c, 0x252d61ea, + 0xb83789db, 0x0c3cfe7d, 0x2bd068ec, 0x9fdb1f4a, 0x02c1f77b, + 0xb6ca80dd, 0x38f42718, 0x8cff50be, 0x11e5b88f, 0xa5eecf29, + 0x4c9e87df, 0xf895f079, 0x658f1848, 0xd1846fee, 0x5fbac82b, + 0xebb1bf8d, 0x76ab57bc, 0xc2a0201a, 0xf2ea1688, 0x46e1612e, + 0xdbfb891f, 0x6ff0feb9, 0xe1ce597c, 0x55c52eda, 0xc8dfc6eb, + 0x7cd4b14d, 0x95a4f9bb, 0x21af8e1d, 0xbcb5662c, 0x08be118a, + 0x8680b64f, 0x328bc1e9, 0xaf9129d8, 0x1b9a5e7e, 0x3c76c8ef, + 0x887dbf49, 0x15675778, 0xa16c20de, 0x2f52871b, 0x9b59f0bd, + 0x0643188c, 0xb2486f2a, 0x5b3827dc, 0xef33507a, 0x7229b84b, + 0xc622cfed, 0x481c6828, 0xfc171f8e, 0x610df7bf, 0xd5068019, + 0x6ed3ab47, 0xdad8dce1, 0x47c234d0, 0xf3c94376, 0x7df7e4b3, + 0xc9fc9315, 0x54e67b24, 0xe0ed0c82, 0x099d4474, 0xbd9633d2, + 0x208cdbe3, 0x9487ac45, 0x1ab90b80, 0xaeb27c26, 0x33a89417, + 0x87a3e3b1, 0xa04f7520, 0x14440286, 0x895eeab7, 0x3d559d11, + 0xb36b3ad4, 0x07604d72, 0x9a7aa543, 0x2e71d2e5, 0xc7019a13, + 0x730aedb5, 0xee100584, 0x5a1b7222, 0xd425d5e7, 0x602ea241, + 0xfd344a70, 0x493f3dd6, 0x8b9f1dcc, 0x3f946a6a, 0xa28e825b, + 0x1685f5fd, 0x98bb5238, 0x2cb0259e, 0xb1aacdaf, 0x05a1ba09, + 0xecd1f2ff, 0x58da8559, 0xc5c06d68, 0x71cb1ace, 0xfff5bd0b, + 0x4bfecaad, 0xd6e4229c, 0x62ef553a, 0x4503c3ab, 0xf108b40d, + 0x6c125c3c, 0xd8192b9a, 0x56278c5f, 0xe22cfbf9, 0x7f3613c8, + 0xcb3d646e, 0x224d2c98, 0x96465b3e, 0x0b5cb30f, 0xbf57c4a9, + 0x3169636c, 0x856214ca, 0x1878fcfb, 0xac738b5d, 0x17a6a003, + 0xa3add7a5, 0x3eb73f94, 0x8abc4832, 0x0482eff7, 0xb0899851, + 0x2d937060, 0x999807c6, 0x70e84f30, 0xc4e33896, 0x59f9d0a7, + 0xedf2a701, 0x63cc00c4, 0xd7c77762, 0x4add9f53, 0xfed6e8f5, + 0xd93a7e64, 0x6d3109c2, 0xf02be1f3, 0x44209655, 0xca1e3190, + 0x7e154636, 0xe30fae07, 0x5704d9a1, 0xbe749157, 0x0a7fe6f1, + 0x97650ec0, 0x236e7966, 0xad50dea3, 0x195ba905, 0x84414134, + 0x304a3692}, + {0x00000000, 0x9e00aacc, 0x7d072542, 0xe3078f8e, 0xfa0e4a84, + 0x640ee048, 0x87096fc6, 0x1909c50a, 0xb51be5d3, 0x2b1b4f1f, + 0xc81cc091, 0x561c6a5d, 0x4f15af57, 0xd115059b, 0x32128a15, + 0xac1220d9, 0x2b31bb7c, 0xb53111b0, 0x56369e3e, 0xc83634f2, + 0xd13ff1f8, 0x4f3f5b34, 0xac38d4ba, 0x32387e76, 0x9e2a5eaf, + 0x002af463, 0xe32d7bed, 0x7d2dd121, 0x6424142b, 0xfa24bee7, + 0x19233169, 0x87239ba5, 0x566276f9, 0xc862dc35, 0x2b6553bb, + 0xb565f977, 0xac6c3c7d, 0x326c96b1, 0xd16b193f, 0x4f6bb3f3, + 0xe379932a, 0x7d7939e6, 0x9e7eb668, 0x007e1ca4, 0x1977d9ae, + 0x87777362, 0x6470fcec, 0xfa705620, 0x7d53cd85, 0xe3536749, + 0x0054e8c7, 0x9e54420b, 0x875d8701, 0x195d2dcd, 0xfa5aa243, + 0x645a088f, 0xc8482856, 0x5648829a, 0xb54f0d14, 0x2b4fa7d8, + 0x324662d2, 0xac46c81e, 0x4f414790, 0xd141ed5c, 0xedc29d29, + 0x73c237e5, 0x90c5b86b, 0x0ec512a7, 0x17ccd7ad, 0x89cc7d61, + 0x6acbf2ef, 0xf4cb5823, 0x58d978fa, 0xc6d9d236, 0x25de5db8, + 0xbbdef774, 0xa2d7327e, 0x3cd798b2, 0xdfd0173c, 0x41d0bdf0, + 0xc6f32655, 0x58f38c99, 0xbbf40317, 0x25f4a9db, 0x3cfd6cd1, + 0xa2fdc61d, 0x41fa4993, 0xdffae35f, 0x73e8c386, 0xede8694a, + 0x0eefe6c4, 0x90ef4c08, 0x89e68902, 0x17e623ce, 0xf4e1ac40, + 0x6ae1068c, 0xbba0ebd0, 0x25a0411c, 0xc6a7ce92, 0x58a7645e, + 0x41aea154, 0xdfae0b98, 0x3ca98416, 0xa2a92eda, 0x0ebb0e03, + 0x90bba4cf, 0x73bc2b41, 0xedbc818d, 0xf4b54487, 0x6ab5ee4b, + 0x89b261c5, 0x17b2cb09, 0x909150ac, 0x0e91fa60, 0xed9675ee, + 0x7396df22, 0x6a9f1a28, 0xf49fb0e4, 0x17983f6a, 0x899895a6, + 0x258ab57f, 0xbb8a1fb3, 0x588d903d, 0xc68d3af1, 0xdf84fffb, + 0x41845537, 0xa283dab9, 0x3c837075, 0xda853b53, 0x4485919f, + 0xa7821e11, 0x3982b4dd, 0x208b71d7, 0xbe8bdb1b, 0x5d8c5495, + 0xc38cfe59, 0x6f9ede80, 0xf19e744c, 0x1299fbc2, 0x8c99510e, + 0x95909404, 0x0b903ec8, 0xe897b146, 0x76971b8a, 0xf1b4802f, + 0x6fb42ae3, 0x8cb3a56d, 0x12b30fa1, 0x0bbacaab, 0x95ba6067, + 0x76bdefe9, 0xe8bd4525, 0x44af65fc, 0xdaafcf30, 0x39a840be, + 0xa7a8ea72, 0xbea12f78, 0x20a185b4, 0xc3a60a3a, 0x5da6a0f6, + 0x8ce74daa, 0x12e7e766, 0xf1e068e8, 0x6fe0c224, 0x76e9072e, + 0xe8e9ade2, 0x0bee226c, 0x95ee88a0, 0x39fca879, 0xa7fc02b5, + 0x44fb8d3b, 0xdafb27f7, 0xc3f2e2fd, 0x5df24831, 0xbef5c7bf, + 0x20f56d73, 0xa7d6f6d6, 0x39d65c1a, 0xdad1d394, 0x44d17958, + 0x5dd8bc52, 0xc3d8169e, 0x20df9910, 0xbedf33dc, 0x12cd1305, + 0x8ccdb9c9, 0x6fca3647, 0xf1ca9c8b, 0xe8c35981, 0x76c3f34d, + 0x95c47cc3, 0x0bc4d60f, 0x3747a67a, 0xa9470cb6, 0x4a408338, + 0xd44029f4, 0xcd49ecfe, 0x53494632, 0xb04ec9bc, 0x2e4e6370, + 0x825c43a9, 0x1c5ce965, 0xff5b66eb, 0x615bcc27, 0x7852092d, + 0xe652a3e1, 0x05552c6f, 0x9b5586a3, 0x1c761d06, 0x8276b7ca, + 0x61713844, 0xff719288, 0xe6785782, 0x7878fd4e, 0x9b7f72c0, + 0x057fd80c, 0xa96df8d5, 0x376d5219, 0xd46add97, 0x4a6a775b, + 0x5363b251, 0xcd63189d, 0x2e649713, 0xb0643ddf, 0x6125d083, + 0xff257a4f, 0x1c22f5c1, 0x82225f0d, 0x9b2b9a07, 0x052b30cb, + 0xe62cbf45, 0x782c1589, 0xd43e3550, 0x4a3e9f9c, 0xa9391012, + 0x3739bade, 0x2e307fd4, 0xb030d518, 0x53375a96, 0xcd37f05a, + 0x4a146bff, 0xd414c133, 0x37134ebd, 0xa913e471, 0xb01a217b, + 0x2e1a8bb7, 0xcd1d0439, 0x531daef5, 0xff0f8e2c, 0x610f24e0, + 0x8208ab6e, 0x1c0801a2, 0x0501c4a8, 0x9b016e64, 0x7806e1ea, + 0xe6064b26}}; + +#endif + +#endif + +#if N == 3 + +#if W == 8 + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0x81256527, 0xd93bcc0f, 0x581ea928, 0x69069e5f, + 0xe823fb78, 0xb03d5250, 0x31183777, 0xd20d3cbe, 0x53285999, + 0x0b36f0b1, 0x8a139596, 0xbb0ba2e1, 0x3a2ec7c6, 0x62306eee, + 0xe3150bc9, 0x7f6b7f3d, 0xfe4e1a1a, 0xa650b332, 0x2775d615, + 0x166de162, 0x97488445, 0xcf562d6d, 0x4e73484a, 0xad664383, + 0x2c4326a4, 0x745d8f8c, 0xf578eaab, 0xc460dddc, 0x4545b8fb, + 0x1d5b11d3, 0x9c7e74f4, 0xfed6fe7a, 0x7ff39b5d, 0x27ed3275, + 0xa6c85752, 0x97d06025, 0x16f50502, 0x4eebac2a, 0xcfcec90d, + 0x2cdbc2c4, 0xadfea7e3, 0xf5e00ecb, 0x74c56bec, 0x45dd5c9b, + 0xc4f839bc, 0x9ce69094, 0x1dc3f5b3, 0x81bd8147, 0x0098e460, + 0x58864d48, 0xd9a3286f, 0xe8bb1f18, 0x699e7a3f, 0x3180d317, + 0xb0a5b630, 0x53b0bdf9, 0xd295d8de, 0x8a8b71f6, 0x0bae14d1, + 0x3ab623a6, 0xbb934681, 0xe38defa9, 0x62a88a8e, 0x26dcfab5, + 0xa7f99f92, 0xffe736ba, 0x7ec2539d, 0x4fda64ea, 0xceff01cd, + 0x96e1a8e5, 0x17c4cdc2, 0xf4d1c60b, 0x75f4a32c, 0x2dea0a04, + 0xaccf6f23, 0x9dd75854, 0x1cf23d73, 0x44ec945b, 0xc5c9f17c, + 0x59b78588, 0xd892e0af, 0x808c4987, 0x01a92ca0, 0x30b11bd7, + 0xb1947ef0, 0xe98ad7d8, 0x68afb2ff, 0x8bbab936, 0x0a9fdc11, + 0x52817539, 0xd3a4101e, 0xe2bc2769, 0x6399424e, 0x3b87eb66, + 0xbaa28e41, 0xd80a04cf, 0x592f61e8, 0x0131c8c0, 0x8014ade7, + 0xb10c9a90, 0x3029ffb7, 0x6837569f, 0xe91233b8, 0x0a073871, + 0x8b225d56, 0xd33cf47e, 0x52199159, 0x6301a62e, 0xe224c309, + 0xba3a6a21, 0x3b1f0f06, 0xa7617bf2, 0x26441ed5, 0x7e5ab7fd, + 0xff7fd2da, 0xce67e5ad, 0x4f42808a, 0x175c29a2, 0x96794c85, + 0x756c474c, 0xf449226b, 0xac578b43, 0x2d72ee64, 0x1c6ad913, + 0x9d4fbc34, 0xc551151c, 0x4474703b, 0x4db9f56a, 0xcc9c904d, + 0x94823965, 0x15a75c42, 0x24bf6b35, 0xa59a0e12, 0xfd84a73a, + 0x7ca1c21d, 0x9fb4c9d4, 0x1e91acf3, 0x468f05db, 0xc7aa60fc, + 0xf6b2578b, 0x779732ac, 0x2f899b84, 0xaeacfea3, 0x32d28a57, + 0xb3f7ef70, 0xebe94658, 0x6acc237f, 0x5bd41408, 0xdaf1712f, + 0x82efd807, 0x03cabd20, 0xe0dfb6e9, 0x61fad3ce, 0x39e47ae6, + 0xb8c11fc1, 0x89d928b6, 0x08fc4d91, 0x50e2e4b9, 0xd1c7819e, + 0xb36f0b10, 0x324a6e37, 0x6a54c71f, 0xeb71a238, 0xda69954f, + 0x5b4cf068, 0x03525940, 0x82773c67, 0x616237ae, 0xe0475289, + 0xb859fba1, 0x397c9e86, 0x0864a9f1, 0x8941ccd6, 0xd15f65fe, + 0x507a00d9, 0xcc04742d, 0x4d21110a, 0x153fb822, 0x941add05, + 0xa502ea72, 0x24278f55, 0x7c39267d, 0xfd1c435a, 0x1e094893, + 0x9f2c2db4, 0xc732849c, 0x4617e1bb, 0x770fd6cc, 0xf62ab3eb, + 0xae341ac3, 0x2f117fe4, 0x6b650fdf, 0xea406af8, 0xb25ec3d0, + 0x337ba6f7, 0x02639180, 0x8346f4a7, 0xdb585d8f, 0x5a7d38a8, + 0xb9683361, 0x384d5646, 0x6053ff6e, 0xe1769a49, 0xd06ead3e, + 0x514bc819, 0x09556131, 0x88700416, 0x140e70e2, 0x952b15c5, + 0xcd35bced, 0x4c10d9ca, 0x7d08eebd, 0xfc2d8b9a, 0xa43322b2, + 0x25164795, 0xc6034c5c, 0x4726297b, 0x1f388053, 0x9e1de574, + 0xaf05d203, 0x2e20b724, 0x763e1e0c, 0xf71b7b2b, 0x95b3f1a5, + 0x14969482, 0x4c883daa, 0xcdad588d, 0xfcb56ffa, 0x7d900add, + 0x258ea3f5, 0xa4abc6d2, 0x47becd1b, 0xc69ba83c, 0x9e850114, + 0x1fa06433, 0x2eb85344, 0xaf9d3663, 0xf7839f4b, 0x76a6fa6c, + 0xead88e98, 0x6bfdebbf, 0x33e34297, 0xb2c627b0, 0x83de10c7, + 0x02fb75e0, 0x5ae5dcc8, 0xdbc0b9ef, 0x38d5b226, 0xb9f0d701, + 0xe1ee7e29, 0x60cb1b0e, 0x51d32c79, 0xd0f6495e, 0x88e8e076, + 0x09cd8551}, + {0x00000000, 0x9b73ead4, 0xed96d3e9, 0x76e5393d, 0x005ca193, + 0x9b2f4b47, 0xedca727a, 0x76b998ae, 0x00b94326, 0x9bcaa9f2, + 0xed2f90cf, 0x765c7a1b, 0x00e5e2b5, 0x9b960861, 0xed73315c, + 0x7600db88, 0x0172864c, 0x9a016c98, 0xece455a5, 0x7797bf71, + 0x012e27df, 0x9a5dcd0b, 0xecb8f436, 0x77cb1ee2, 0x01cbc56a, + 0x9ab82fbe, 0xec5d1683, 0x772efc57, 0x019764f9, 0x9ae48e2d, + 0xec01b710, 0x77725dc4, 0x02e50c98, 0x9996e64c, 0xef73df71, + 0x740035a5, 0x02b9ad0b, 0x99ca47df, 0xef2f7ee2, 0x745c9436, + 0x025c4fbe, 0x992fa56a, 0xefca9c57, 0x74b97683, 0x0200ee2d, + 0x997304f9, 0xef963dc4, 0x74e5d710, 0x03978ad4, 0x98e46000, + 0xee01593d, 0x7572b3e9, 0x03cb2b47, 0x98b8c193, 0xee5df8ae, + 0x752e127a, 0x032ec9f2, 0x985d2326, 0xeeb81a1b, 0x75cbf0cf, + 0x03726861, 0x980182b5, 0xeee4bb88, 0x7597515c, 0x05ca1930, + 0x9eb9f3e4, 0xe85ccad9, 0x732f200d, 0x0596b8a3, 0x9ee55277, + 0xe8006b4a, 0x7373819e, 0x05735a16, 0x9e00b0c2, 0xe8e589ff, + 0x7396632b, 0x052ffb85, 0x9e5c1151, 0xe8b9286c, 0x73cac2b8, + 0x04b89f7c, 0x9fcb75a8, 0xe92e4c95, 0x725da641, 0x04e43eef, + 0x9f97d43b, 0xe972ed06, 0x720107d2, 0x0401dc5a, 0x9f72368e, + 0xe9970fb3, 0x72e4e567, 0x045d7dc9, 0x9f2e971d, 0xe9cbae20, + 0x72b844f4, 0x072f15a8, 0x9c5cff7c, 0xeab9c641, 0x71ca2c95, + 0x0773b43b, 0x9c005eef, 0xeae567d2, 0x71968d06, 0x0796568e, + 0x9ce5bc5a, 0xea008567, 0x71736fb3, 0x07caf71d, 0x9cb91dc9, + 0xea5c24f4, 0x712fce20, 0x065d93e4, 0x9d2e7930, 0xebcb400d, + 0x70b8aad9, 0x06013277, 0x9d72d8a3, 0xeb97e19e, 0x70e40b4a, + 0x06e4d0c2, 0x9d973a16, 0xeb72032b, 0x7001e9ff, 0x06b87151, + 0x9dcb9b85, 0xeb2ea2b8, 0x705d486c, 0x0b943260, 0x90e7d8b4, + 0xe602e189, 0x7d710b5d, 0x0bc893f3, 0x90bb7927, 0xe65e401a, + 0x7d2daace, 0x0b2d7146, 0x905e9b92, 0xe6bba2af, 0x7dc8487b, + 0x0b71d0d5, 0x90023a01, 0xe6e7033c, 0x7d94e9e8, 0x0ae6b42c, + 0x91955ef8, 0xe77067c5, 0x7c038d11, 0x0aba15bf, 0x91c9ff6b, + 0xe72cc656, 0x7c5f2c82, 0x0a5ff70a, 0x912c1dde, 0xe7c924e3, + 0x7cbace37, 0x0a035699, 0x9170bc4d, 0xe7958570, 0x7ce66fa4, + 0x09713ef8, 0x9202d42c, 0xe4e7ed11, 0x7f9407c5, 0x092d9f6b, + 0x925e75bf, 0xe4bb4c82, 0x7fc8a656, 0x09c87dde, 0x92bb970a, + 0xe45eae37, 0x7f2d44e3, 0x0994dc4d, 0x92e73699, 0xe4020fa4, + 0x7f71e570, 0x0803b8b4, 0x93705260, 0xe5956b5d, 0x7ee68189, + 0x085f1927, 0x932cf3f3, 0xe5c9cace, 0x7eba201a, 0x08bafb92, + 0x93c91146, 0xe52c287b, 0x7e5fc2af, 0x08e65a01, 0x9395b0d5, + 0xe57089e8, 0x7e03633c, 0x0e5e2b50, 0x952dc184, 0xe3c8f8b9, + 0x78bb126d, 0x0e028ac3, 0x95716017, 0xe394592a, 0x78e7b3fe, + 0x0ee76876, 0x959482a2, 0xe371bb9f, 0x7802514b, 0x0ebbc9e5, + 0x95c82331, 0xe32d1a0c, 0x785ef0d8, 0x0f2cad1c, 0x945f47c8, + 0xe2ba7ef5, 0x79c99421, 0x0f700c8f, 0x9403e65b, 0xe2e6df66, + 0x799535b2, 0x0f95ee3a, 0x94e604ee, 0xe2033dd3, 0x7970d707, + 0x0fc94fa9, 0x94baa57d, 0xe25f9c40, 0x792c7694, 0x0cbb27c8, + 0x97c8cd1c, 0xe12df421, 0x7a5e1ef5, 0x0ce7865b, 0x97946c8f, + 0xe17155b2, 0x7a02bf66, 0x0c0264ee, 0x97718e3a, 0xe194b707, + 0x7ae75dd3, 0x0c5ec57d, 0x972d2fa9, 0xe1c81694, 0x7abbfc40, + 0x0dc9a184, 0x96ba4b50, 0xe05f726d, 0x7b2c98b9, 0x0d950017, + 0x96e6eac3, 0xe003d3fe, 0x7b70392a, 0x0d70e2a2, 0x96030876, + 0xe0e6314b, 0x7b95db9f, 0x0d2c4331, 0x965fa9e5, 0xe0ba90d8, + 0x7bc97a0c}, + {0x00000000, 0x172864c0, 0x2e50c980, 0x3978ad40, 0x5ca19300, + 0x4b89f7c0, 0x72f15a80, 0x65d93e40, 0xb9432600, 0xae6b42c0, + 0x9713ef80, 0x803b8b40, 0xe5e2b500, 0xf2cad1c0, 0xcbb27c80, + 0xdc9a1840, 0xa9f74a41, 0xbedf2e81, 0x87a783c1, 0x908fe701, + 0xf556d941, 0xe27ebd81, 0xdb0610c1, 0xcc2e7401, 0x10b46c41, + 0x079c0881, 0x3ee4a5c1, 0x29ccc101, 0x4c15ff41, 0x5b3d9b81, + 0x624536c1, 0x756d5201, 0x889f92c3, 0x9fb7f603, 0xa6cf5b43, + 0xb1e73f83, 0xd43e01c3, 0xc3166503, 0xfa6ec843, 0xed46ac83, + 0x31dcb4c3, 0x26f4d003, 0x1f8c7d43, 0x08a41983, 0x6d7d27c3, + 0x7a554303, 0x432dee43, 0x54058a83, 0x2168d882, 0x3640bc42, + 0x0f381102, 0x181075c2, 0x7dc94b82, 0x6ae12f42, 0x53998202, + 0x44b1e6c2, 0x982bfe82, 0x8f039a42, 0xb67b3702, 0xa15353c2, + 0xc48a6d82, 0xd3a20942, 0xeadaa402, 0xfdf2c0c2, 0xca4e23c7, + 0xdd664707, 0xe41eea47, 0xf3368e87, 0x96efb0c7, 0x81c7d407, + 0xb8bf7947, 0xaf971d87, 0x730d05c7, 0x64256107, 0x5d5dcc47, + 0x4a75a887, 0x2fac96c7, 0x3884f207, 0x01fc5f47, 0x16d43b87, + 0x63b96986, 0x74910d46, 0x4de9a006, 0x5ac1c4c6, 0x3f18fa86, + 0x28309e46, 0x11483306, 0x066057c6, 0xdafa4f86, 0xcdd22b46, + 0xf4aa8606, 0xe382e2c6, 0x865bdc86, 0x9173b846, 0xa80b1506, + 0xbf2371c6, 0x42d1b104, 0x55f9d5c4, 0x6c817884, 0x7ba91c44, + 0x1e702204, 0x095846c4, 0x3020eb84, 0x27088f44, 0xfb929704, + 0xecbaf3c4, 0xd5c25e84, 0xc2ea3a44, 0xa7330404, 0xb01b60c4, + 0x8963cd84, 0x9e4ba944, 0xeb26fb45, 0xfc0e9f85, 0xc57632c5, + 0xd25e5605, 0xb7876845, 0xa0af0c85, 0x99d7a1c5, 0x8effc505, + 0x5265dd45, 0x454db985, 0x7c3514c5, 0x6b1d7005, 0x0ec44e45, + 0x19ec2a85, 0x209487c5, 0x37bce305, 0x4fed41cf, 0x58c5250f, + 0x61bd884f, 0x7695ec8f, 0x134cd2cf, 0x0464b60f, 0x3d1c1b4f, + 0x2a347f8f, 0xf6ae67cf, 0xe186030f, 0xd8feae4f, 0xcfd6ca8f, + 0xaa0ff4cf, 0xbd27900f, 0x845f3d4f, 0x9377598f, 0xe61a0b8e, + 0xf1326f4e, 0xc84ac20e, 0xdf62a6ce, 0xbabb988e, 0xad93fc4e, + 0x94eb510e, 0x83c335ce, 0x5f592d8e, 0x4871494e, 0x7109e40e, + 0x662180ce, 0x03f8be8e, 0x14d0da4e, 0x2da8770e, 0x3a8013ce, + 0xc772d30c, 0xd05ab7cc, 0xe9221a8c, 0xfe0a7e4c, 0x9bd3400c, + 0x8cfb24cc, 0xb583898c, 0xa2abed4c, 0x7e31f50c, 0x691991cc, + 0x50613c8c, 0x4749584c, 0x2290660c, 0x35b802cc, 0x0cc0af8c, + 0x1be8cb4c, 0x6e85994d, 0x79adfd8d, 0x40d550cd, 0x57fd340d, + 0x32240a4d, 0x250c6e8d, 0x1c74c3cd, 0x0b5ca70d, 0xd7c6bf4d, + 0xc0eedb8d, 0xf99676cd, 0xeebe120d, 0x8b672c4d, 0x9c4f488d, + 0xa537e5cd, 0xb21f810d, 0x85a36208, 0x928b06c8, 0xabf3ab88, + 0xbcdbcf48, 0xd902f108, 0xce2a95c8, 0xf7523888, 0xe07a5c48, + 0x3ce04408, 0x2bc820c8, 0x12b08d88, 0x0598e948, 0x6041d708, + 0x7769b3c8, 0x4e111e88, 0x59397a48, 0x2c542849, 0x3b7c4c89, + 0x0204e1c9, 0x152c8509, 0x70f5bb49, 0x67dddf89, 0x5ea572c9, + 0x498d1609, 0x95170e49, 0x823f6a89, 0xbb47c7c9, 0xac6fa309, + 0xc9b69d49, 0xde9ef989, 0xe7e654c9, 0xf0ce3009, 0x0d3cf0cb, + 0x1a14940b, 0x236c394b, 0x34445d8b, 0x519d63cb, 0x46b5070b, + 0x7fcdaa4b, 0x68e5ce8b, 0xb47fd6cb, 0xa357b20b, 0x9a2f1f4b, + 0x8d077b8b, 0xe8de45cb, 0xfff6210b, 0xc68e8c4b, 0xd1a6e88b, + 0xa4cbba8a, 0xb3e3de4a, 0x8a9b730a, 0x9db317ca, 0xf86a298a, + 0xef424d4a, 0xd63ae00a, 0xc11284ca, 0x1d889c8a, 0x0aa0f84a, + 0x33d8550a, 0x24f031ca, 0x41290f8a, 0x56016b4a, 0x6f79c60a, + 0x7851a2ca}, + {0x00000000, 0x9fda839e, 0xe4c4017d, 0x7b1e82e3, 0x12f904bb, + 0x8d238725, 0xf63d05c6, 0x69e78658, 0x25f20976, 0xba288ae8, + 0xc136080b, 0x5eec8b95, 0x370b0dcd, 0xa8d18e53, 0xd3cf0cb0, + 0x4c158f2e, 0x4be412ec, 0xd43e9172, 0xaf201391, 0x30fa900f, + 0x591d1657, 0xc6c795c9, 0xbdd9172a, 0x220394b4, 0x6e161b9a, + 0xf1cc9804, 0x8ad21ae7, 0x15089979, 0x7cef1f21, 0xe3359cbf, + 0x982b1e5c, 0x07f19dc2, 0x97c825d8, 0x0812a646, 0x730c24a5, + 0xecd6a73b, 0x85312163, 0x1aeba2fd, 0x61f5201e, 0xfe2fa380, + 0xb23a2cae, 0x2de0af30, 0x56fe2dd3, 0xc924ae4d, 0xa0c32815, + 0x3f19ab8b, 0x44072968, 0xdbddaaf6, 0xdc2c3734, 0x43f6b4aa, + 0x38e83649, 0xa732b5d7, 0xced5338f, 0x510fb011, 0x2a1132f2, + 0xb5cbb16c, 0xf9de3e42, 0x6604bddc, 0x1d1a3f3f, 0x82c0bca1, + 0xeb273af9, 0x74fdb967, 0x0fe33b84, 0x9039b81a, 0xf4e14df1, + 0x6b3bce6f, 0x10254c8c, 0x8fffcf12, 0xe618494a, 0x79c2cad4, + 0x02dc4837, 0x9d06cba9, 0xd1134487, 0x4ec9c719, 0x35d745fa, + 0xaa0dc664, 0xc3ea403c, 0x5c30c3a2, 0x272e4141, 0xb8f4c2df, + 0xbf055f1d, 0x20dfdc83, 0x5bc15e60, 0xc41bddfe, 0xadfc5ba6, + 0x3226d838, 0x49385adb, 0xd6e2d945, 0x9af7566b, 0x052dd5f5, + 0x7e335716, 0xe1e9d488, 0x880e52d0, 0x17d4d14e, 0x6cca53ad, + 0xf310d033, 0x63296829, 0xfcf3ebb7, 0x87ed6954, 0x1837eaca, + 0x71d06c92, 0xee0aef0c, 0x95146def, 0x0aceee71, 0x46db615f, + 0xd901e2c1, 0xa21f6022, 0x3dc5e3bc, 0x542265e4, 0xcbf8e67a, + 0xb0e66499, 0x2f3ce707, 0x28cd7ac5, 0xb717f95b, 0xcc097bb8, + 0x53d3f826, 0x3a347e7e, 0xa5eefde0, 0xdef07f03, 0x412afc9d, + 0x0d3f73b3, 0x92e5f02d, 0xe9fb72ce, 0x7621f150, 0x1fc67708, + 0x801cf496, 0xfb027675, 0x64d8f5eb, 0x32b39da3, 0xad691e3d, + 0xd6779cde, 0x49ad1f40, 0x204a9918, 0xbf901a86, 0xc48e9865, + 0x5b541bfb, 0x174194d5, 0x889b174b, 0xf38595a8, 0x6c5f1636, + 0x05b8906e, 0x9a6213f0, 0xe17c9113, 0x7ea6128d, 0x79578f4f, + 0xe68d0cd1, 0x9d938e32, 0x02490dac, 0x6bae8bf4, 0xf474086a, + 0x8f6a8a89, 0x10b00917, 0x5ca58639, 0xc37f05a7, 0xb8618744, + 0x27bb04da, 0x4e5c8282, 0xd186011c, 0xaa9883ff, 0x35420061, + 0xa57bb87b, 0x3aa13be5, 0x41bfb906, 0xde653a98, 0xb782bcc0, + 0x28583f5e, 0x5346bdbd, 0xcc9c3e23, 0x8089b10d, 0x1f533293, + 0x644db070, 0xfb9733ee, 0x9270b5b6, 0x0daa3628, 0x76b4b4cb, + 0xe96e3755, 0xee9faa97, 0x71452909, 0x0a5babea, 0x95812874, + 0xfc66ae2c, 0x63bc2db2, 0x18a2af51, 0x87782ccf, 0xcb6da3e1, + 0x54b7207f, 0x2fa9a29c, 0xb0732102, 0xd994a75a, 0x464e24c4, + 0x3d50a627, 0xa28a25b9, 0xc652d052, 0x598853cc, 0x2296d12f, + 0xbd4c52b1, 0xd4abd4e9, 0x4b715777, 0x306fd594, 0xafb5560a, + 0xe3a0d924, 0x7c7a5aba, 0x0764d859, 0x98be5bc7, 0xf159dd9f, + 0x6e835e01, 0x159ddce2, 0x8a475f7c, 0x8db6c2be, 0x126c4120, + 0x6972c3c3, 0xf6a8405d, 0x9f4fc605, 0x0095459b, 0x7b8bc778, + 0xe45144e6, 0xa844cbc8, 0x379e4856, 0x4c80cab5, 0xd35a492b, + 0xbabdcf73, 0x25674ced, 0x5e79ce0e, 0xc1a34d90, 0x519af58a, + 0xce407614, 0xb55ef4f7, 0x2a847769, 0x4363f131, 0xdcb972af, + 0xa7a7f04c, 0x387d73d2, 0x7468fcfc, 0xebb27f62, 0x90acfd81, + 0x0f767e1f, 0x6691f847, 0xf94b7bd9, 0x8255f93a, 0x1d8f7aa4, + 0x1a7ee766, 0x85a464f8, 0xfebae61b, 0x61606585, 0x0887e3dd, + 0x975d6043, 0xec43e2a0, 0x7399613e, 0x3f8cee10, 0xa0566d8e, + 0xdb48ef6d, 0x44926cf3, 0x2d75eaab, 0xb2af6935, 0xc9b1ebd6, + 0x566b6848}, + {0x00000000, 0x65673b46, 0xcace768c, 0xafa94dca, 0x4eedeb59, + 0x2b8ad01f, 0x84239dd5, 0xe144a693, 0x9ddbd6b2, 0xf8bcedf4, + 0x5715a03e, 0x32729b78, 0xd3363deb, 0xb65106ad, 0x19f84b67, + 0x7c9f7021, 0xe0c6ab25, 0x85a19063, 0x2a08dda9, 0x4f6fe6ef, + 0xae2b407c, 0xcb4c7b3a, 0x64e536f0, 0x01820db6, 0x7d1d7d97, + 0x187a46d1, 0xb7d30b1b, 0xd2b4305d, 0x33f096ce, 0x5697ad88, + 0xf93ee042, 0x9c59db04, 0x1afc500b, 0x7f9b6b4d, 0xd0322687, + 0xb5551dc1, 0x5411bb52, 0x31768014, 0x9edfcdde, 0xfbb8f698, + 0x872786b9, 0xe240bdff, 0x4de9f035, 0x288ecb73, 0xc9ca6de0, + 0xacad56a6, 0x03041b6c, 0x6663202a, 0xfa3afb2e, 0x9f5dc068, + 0x30f48da2, 0x5593b6e4, 0xb4d71077, 0xd1b02b31, 0x7e1966fb, + 0x1b7e5dbd, 0x67e12d9c, 0x028616da, 0xad2f5b10, 0xc8486056, + 0x290cc6c5, 0x4c6bfd83, 0xe3c2b049, 0x86a58b0f, 0x35f8a016, + 0x509f9b50, 0xff36d69a, 0x9a51eddc, 0x7b154b4f, 0x1e727009, + 0xb1db3dc3, 0xd4bc0685, 0xa82376a4, 0xcd444de2, 0x62ed0028, + 0x078a3b6e, 0xe6ce9dfd, 0x83a9a6bb, 0x2c00eb71, 0x4967d037, + 0xd53e0b33, 0xb0593075, 0x1ff07dbf, 0x7a9746f9, 0x9bd3e06a, + 0xfeb4db2c, 0x511d96e6, 0x347aada0, 0x48e5dd81, 0x2d82e6c7, + 0x822bab0d, 0xe74c904b, 0x060836d8, 0x636f0d9e, 0xccc64054, + 0xa9a17b12, 0x2f04f01d, 0x4a63cb5b, 0xe5ca8691, 0x80adbdd7, + 0x61e91b44, 0x048e2002, 0xab276dc8, 0xce40568e, 0xb2df26af, + 0xd7b81de9, 0x78115023, 0x1d766b65, 0xfc32cdf6, 0x9955f6b0, + 0x36fcbb7a, 0x539b803c, 0xcfc25b38, 0xaaa5607e, 0x050c2db4, + 0x606b16f2, 0x812fb061, 0xe4488b27, 0x4be1c6ed, 0x2e86fdab, + 0x52198d8a, 0x377eb6cc, 0x98d7fb06, 0xfdb0c040, 0x1cf466d3, + 0x79935d95, 0xd63a105f, 0xb35d2b19, 0x6bf1402c, 0x0e967b6a, + 0xa13f36a0, 0xc4580de6, 0x251cab75, 0x407b9033, 0xefd2ddf9, + 0x8ab5e6bf, 0xf62a969e, 0x934dadd8, 0x3ce4e012, 0x5983db54, + 0xb8c77dc7, 0xdda04681, 0x72090b4b, 0x176e300d, 0x8b37eb09, + 0xee50d04f, 0x41f99d85, 0x249ea6c3, 0xc5da0050, 0xa0bd3b16, + 0x0f1476dc, 0x6a734d9a, 0x16ec3dbb, 0x738b06fd, 0xdc224b37, + 0xb9457071, 0x5801d6e2, 0x3d66eda4, 0x92cfa06e, 0xf7a89b28, + 0x710d1027, 0x146a2b61, 0xbbc366ab, 0xdea45ded, 0x3fe0fb7e, + 0x5a87c038, 0xf52e8df2, 0x9049b6b4, 0xecd6c695, 0x89b1fdd3, + 0x2618b019, 0x437f8b5f, 0xa23b2dcc, 0xc75c168a, 0x68f55b40, + 0x0d926006, 0x91cbbb02, 0xf4ac8044, 0x5b05cd8e, 0x3e62f6c8, + 0xdf26505b, 0xba416b1d, 0x15e826d7, 0x708f1d91, 0x0c106db0, + 0x697756f6, 0xc6de1b3c, 0xa3b9207a, 0x42fd86e9, 0x279abdaf, + 0x8833f065, 0xed54cb23, 0x5e09e03a, 0x3b6edb7c, 0x94c796b6, + 0xf1a0adf0, 0x10e40b63, 0x75833025, 0xda2a7def, 0xbf4d46a9, + 0xc3d23688, 0xa6b50dce, 0x091c4004, 0x6c7b7b42, 0x8d3fddd1, + 0xe858e697, 0x47f1ab5d, 0x2296901b, 0xbecf4b1f, 0xdba87059, + 0x74013d93, 0x116606d5, 0xf022a046, 0x95459b00, 0x3aecd6ca, + 0x5f8bed8c, 0x23149dad, 0x4673a6eb, 0xe9daeb21, 0x8cbdd067, + 0x6df976f4, 0x089e4db2, 0xa7370078, 0xc2503b3e, 0x44f5b031, + 0x21928b77, 0x8e3bc6bd, 0xeb5cfdfb, 0x0a185b68, 0x6f7f602e, + 0xc0d62de4, 0xa5b116a2, 0xd92e6683, 0xbc495dc5, 0x13e0100f, + 0x76872b49, 0x97c38dda, 0xf2a4b69c, 0x5d0dfb56, 0x386ac010, + 0xa4331b14, 0xc1542052, 0x6efd6d98, 0x0b9a56de, 0xeadef04d, + 0x8fb9cb0b, 0x201086c1, 0x4577bd87, 0x39e8cda6, 0x5c8ff6e0, + 0xf326bb2a, 0x9641806c, 0x770526ff, 0x12621db9, 0xbdcb5073, + 0xd8ac6b35}, + {0x00000000, 0xd7e28058, 0x74b406f1, 0xa35686a9, 0xe9680de2, + 0x3e8a8dba, 0x9ddc0b13, 0x4a3e8b4b, 0x09a11d85, 0xde439ddd, + 0x7d151b74, 0xaaf79b2c, 0xe0c91067, 0x372b903f, 0x947d1696, + 0x439f96ce, 0x13423b0a, 0xc4a0bb52, 0x67f63dfb, 0xb014bda3, + 0xfa2a36e8, 0x2dc8b6b0, 0x8e9e3019, 0x597cb041, 0x1ae3268f, + 0xcd01a6d7, 0x6e57207e, 0xb9b5a026, 0xf38b2b6d, 0x2469ab35, + 0x873f2d9c, 0x50ddadc4, 0x26847614, 0xf166f64c, 0x523070e5, + 0x85d2f0bd, 0xcfec7bf6, 0x180efbae, 0xbb587d07, 0x6cbafd5f, + 0x2f256b91, 0xf8c7ebc9, 0x5b916d60, 0x8c73ed38, 0xc64d6673, + 0x11afe62b, 0xb2f96082, 0x651be0da, 0x35c64d1e, 0xe224cd46, + 0x41724bef, 0x9690cbb7, 0xdcae40fc, 0x0b4cc0a4, 0xa81a460d, + 0x7ff8c655, 0x3c67509b, 0xeb85d0c3, 0x48d3566a, 0x9f31d632, + 0xd50f5d79, 0x02eddd21, 0xa1bb5b88, 0x7659dbd0, 0x4d08ec28, + 0x9aea6c70, 0x39bcead9, 0xee5e6a81, 0xa460e1ca, 0x73826192, + 0xd0d4e73b, 0x07366763, 0x44a9f1ad, 0x934b71f5, 0x301df75c, + 0xe7ff7704, 0xadc1fc4f, 0x7a237c17, 0xd975fabe, 0x0e977ae6, + 0x5e4ad722, 0x89a8577a, 0x2afed1d3, 0xfd1c518b, 0xb722dac0, + 0x60c05a98, 0xc396dc31, 0x14745c69, 0x57ebcaa7, 0x80094aff, + 0x235fcc56, 0xf4bd4c0e, 0xbe83c745, 0x6961471d, 0xca37c1b4, + 0x1dd541ec, 0x6b8c9a3c, 0xbc6e1a64, 0x1f389ccd, 0xc8da1c95, + 0x82e497de, 0x55061786, 0xf650912f, 0x21b21177, 0x622d87b9, + 0xb5cf07e1, 0x16998148, 0xc17b0110, 0x8b458a5b, 0x5ca70a03, + 0xfff18caa, 0x28130cf2, 0x78cea136, 0xaf2c216e, 0x0c7aa7c7, + 0xdb98279f, 0x91a6acd4, 0x46442c8c, 0xe512aa25, 0x32f02a7d, + 0x716fbcb3, 0xa68d3ceb, 0x05dbba42, 0xd2393a1a, 0x9807b151, + 0x4fe53109, 0xecb3b7a0, 0x3b5137f8, 0x9a11d850, 0x4df35808, + 0xeea5dea1, 0x39475ef9, 0x7379d5b2, 0xa49b55ea, 0x07cdd343, + 0xd02f531b, 0x93b0c5d5, 0x4452458d, 0xe704c324, 0x30e6437c, + 0x7ad8c837, 0xad3a486f, 0x0e6ccec6, 0xd98e4e9e, 0x8953e35a, + 0x5eb16302, 0xfde7e5ab, 0x2a0565f3, 0x603beeb8, 0xb7d96ee0, + 0x148fe849, 0xc36d6811, 0x80f2fedf, 0x57107e87, 0xf446f82e, + 0x23a47876, 0x699af33d, 0xbe787365, 0x1d2ef5cc, 0xcacc7594, + 0xbc95ae44, 0x6b772e1c, 0xc821a8b5, 0x1fc328ed, 0x55fda3a6, + 0x821f23fe, 0x2149a557, 0xf6ab250f, 0xb534b3c1, 0x62d63399, + 0xc180b530, 0x16623568, 0x5c5cbe23, 0x8bbe3e7b, 0x28e8b8d2, + 0xff0a388a, 0xafd7954e, 0x78351516, 0xdb6393bf, 0x0c8113e7, + 0x46bf98ac, 0x915d18f4, 0x320b9e5d, 0xe5e91e05, 0xa67688cb, + 0x71940893, 0xd2c28e3a, 0x05200e62, 0x4f1e8529, 0x98fc0571, + 0x3baa83d8, 0xec480380, 0xd7193478, 0x00fbb420, 0xa3ad3289, + 0x744fb2d1, 0x3e71399a, 0xe993b9c2, 0x4ac53f6b, 0x9d27bf33, + 0xdeb829fd, 0x095aa9a5, 0xaa0c2f0c, 0x7deeaf54, 0x37d0241f, + 0xe032a447, 0x436422ee, 0x9486a2b6, 0xc45b0f72, 0x13b98f2a, + 0xb0ef0983, 0x670d89db, 0x2d330290, 0xfad182c8, 0x59870461, + 0x8e658439, 0xcdfa12f7, 0x1a1892af, 0xb94e1406, 0x6eac945e, + 0x24921f15, 0xf3709f4d, 0x502619e4, 0x87c499bc, 0xf19d426c, + 0x267fc234, 0x8529449d, 0x52cbc4c5, 0x18f54f8e, 0xcf17cfd6, + 0x6c41497f, 0xbba3c927, 0xf83c5fe9, 0x2fdedfb1, 0x8c885918, + 0x5b6ad940, 0x1154520b, 0xc6b6d253, 0x65e054fa, 0xb202d4a2, + 0xe2df7966, 0x353df93e, 0x966b7f97, 0x4189ffcf, 0x0bb77484, + 0xdc55f4dc, 0x7f037275, 0xa8e1f22d, 0xeb7e64e3, 0x3c9ce4bb, + 0x9fca6212, 0x4828e24a, 0x02166901, 0xd5f4e959, 0x76a26ff0, + 0xa140efa8}, + {0x00000000, 0xef52b6e1, 0x05d46b83, 0xea86dd62, 0x0ba8d706, + 0xe4fa61e7, 0x0e7cbc85, 0xe12e0a64, 0x1751ae0c, 0xf80318ed, + 0x1285c58f, 0xfdd7736e, 0x1cf9790a, 0xf3abcfeb, 0x192d1289, + 0xf67fa468, 0x2ea35c18, 0xc1f1eaf9, 0x2b77379b, 0xc425817a, + 0x250b8b1e, 0xca593dff, 0x20dfe09d, 0xcf8d567c, 0x39f2f214, + 0xd6a044f5, 0x3c269997, 0xd3742f76, 0x325a2512, 0xdd0893f3, + 0x378e4e91, 0xd8dcf870, 0x5d46b830, 0xb2140ed1, 0x5892d3b3, + 0xb7c06552, 0x56ee6f36, 0xb9bcd9d7, 0x533a04b5, 0xbc68b254, + 0x4a17163c, 0xa545a0dd, 0x4fc37dbf, 0xa091cb5e, 0x41bfc13a, + 0xaeed77db, 0x446baab9, 0xab391c58, 0x73e5e428, 0x9cb752c9, + 0x76318fab, 0x9963394a, 0x784d332e, 0x971f85cf, 0x7d9958ad, + 0x92cbee4c, 0x64b44a24, 0x8be6fcc5, 0x616021a7, 0x8e329746, + 0x6f1c9d22, 0x804e2bc3, 0x6ac8f6a1, 0x859a4040, 0xba8d7060, + 0x55dfc681, 0xbf591be3, 0x500bad02, 0xb125a766, 0x5e771187, + 0xb4f1cce5, 0x5ba37a04, 0xaddcde6c, 0x428e688d, 0xa808b5ef, + 0x475a030e, 0xa674096a, 0x4926bf8b, 0xa3a062e9, 0x4cf2d408, + 0x942e2c78, 0x7b7c9a99, 0x91fa47fb, 0x7ea8f11a, 0x9f86fb7e, + 0x70d44d9f, 0x9a5290fd, 0x7500261c, 0x837f8274, 0x6c2d3495, + 0x86abe9f7, 0x69f95f16, 0x88d75572, 0x6785e393, 0x8d033ef1, + 0x62518810, 0xe7cbc850, 0x08997eb1, 0xe21fa3d3, 0x0d4d1532, + 0xec631f56, 0x0331a9b7, 0xe9b774d5, 0x06e5c234, 0xf09a665c, + 0x1fc8d0bd, 0xf54e0ddf, 0x1a1cbb3e, 0xfb32b15a, 0x146007bb, + 0xfee6dad9, 0x11b46c38, 0xc9689448, 0x263a22a9, 0xccbcffcb, + 0x23ee492a, 0xc2c0434e, 0x2d92f5af, 0xc71428cd, 0x28469e2c, + 0xde393a44, 0x316b8ca5, 0xdbed51c7, 0x34bfe726, 0xd591ed42, + 0x3ac35ba3, 0xd04586c1, 0x3f173020, 0xae6be681, 0x41395060, + 0xabbf8d02, 0x44ed3be3, 0xa5c33187, 0x4a918766, 0xa0175a04, + 0x4f45ece5, 0xb93a488d, 0x5668fe6c, 0xbcee230e, 0x53bc95ef, + 0xb2929f8b, 0x5dc0296a, 0xb746f408, 0x581442e9, 0x80c8ba99, + 0x6f9a0c78, 0x851cd11a, 0x6a4e67fb, 0x8b606d9f, 0x6432db7e, + 0x8eb4061c, 0x61e6b0fd, 0x97991495, 0x78cba274, 0x924d7f16, + 0x7d1fc9f7, 0x9c31c393, 0x73637572, 0x99e5a810, 0x76b71ef1, + 0xf32d5eb1, 0x1c7fe850, 0xf6f93532, 0x19ab83d3, 0xf88589b7, + 0x17d73f56, 0xfd51e234, 0x120354d5, 0xe47cf0bd, 0x0b2e465c, + 0xe1a89b3e, 0x0efa2ddf, 0xefd427bb, 0x0086915a, 0xea004c38, + 0x0552fad9, 0xdd8e02a9, 0x32dcb448, 0xd85a692a, 0x3708dfcb, + 0xd626d5af, 0x3974634e, 0xd3f2be2c, 0x3ca008cd, 0xcadfaca5, + 0x258d1a44, 0xcf0bc726, 0x205971c7, 0xc1777ba3, 0x2e25cd42, + 0xc4a31020, 0x2bf1a6c1, 0x14e696e1, 0xfbb42000, 0x1132fd62, + 0xfe604b83, 0x1f4e41e7, 0xf01cf706, 0x1a9a2a64, 0xf5c89c85, + 0x03b738ed, 0xece58e0c, 0x0663536e, 0xe931e58f, 0x081fefeb, + 0xe74d590a, 0x0dcb8468, 0xe2993289, 0x3a45caf9, 0xd5177c18, + 0x3f91a17a, 0xd0c3179b, 0x31ed1dff, 0xdebfab1e, 0x3439767c, + 0xdb6bc09d, 0x2d1464f5, 0xc246d214, 0x28c00f76, 0xc792b997, + 0x26bcb3f3, 0xc9ee0512, 0x2368d870, 0xcc3a6e91, 0x49a02ed1, + 0xa6f29830, 0x4c744552, 0xa326f3b3, 0x4208f9d7, 0xad5a4f36, + 0x47dc9254, 0xa88e24b5, 0x5ef180dd, 0xb1a3363c, 0x5b25eb5e, + 0xb4775dbf, 0x555957db, 0xba0be13a, 0x508d3c58, 0xbfdf8ab9, + 0x670372c9, 0x8851c428, 0x62d7194a, 0x8d85afab, 0x6caba5cf, + 0x83f9132e, 0x697fce4c, 0x862d78ad, 0x7052dcc5, 0x9f006a24, + 0x7586b746, 0x9ad401a7, 0x7bfa0bc3, 0x94a8bd22, 0x7e2e6040, + 0x917cd6a1}, + {0x00000000, 0x87a6cb43, 0xd43c90c7, 0x539a5b84, 0x730827cf, + 0xf4aeec8c, 0xa734b708, 0x20927c4b, 0xe6104f9e, 0x61b684dd, + 0x322cdf59, 0xb58a141a, 0x95186851, 0x12bea312, 0x4124f896, + 0xc68233d5, 0x1751997d, 0x90f7523e, 0xc36d09ba, 0x44cbc2f9, + 0x6459beb2, 0xe3ff75f1, 0xb0652e75, 0x37c3e536, 0xf141d6e3, + 0x76e71da0, 0x257d4624, 0xa2db8d67, 0x8249f12c, 0x05ef3a6f, + 0x567561eb, 0xd1d3aaa8, 0x2ea332fa, 0xa905f9b9, 0xfa9fa23d, + 0x7d39697e, 0x5dab1535, 0xda0dde76, 0x899785f2, 0x0e314eb1, + 0xc8b37d64, 0x4f15b627, 0x1c8feda3, 0x9b2926e0, 0xbbbb5aab, + 0x3c1d91e8, 0x6f87ca6c, 0xe821012f, 0x39f2ab87, 0xbe5460c4, + 0xedce3b40, 0x6a68f003, 0x4afa8c48, 0xcd5c470b, 0x9ec61c8f, + 0x1960d7cc, 0xdfe2e419, 0x58442f5a, 0x0bde74de, 0x8c78bf9d, + 0xaceac3d6, 0x2b4c0895, 0x78d65311, 0xff709852, 0x5d4665f4, + 0xdae0aeb7, 0x897af533, 0x0edc3e70, 0x2e4e423b, 0xa9e88978, + 0xfa72d2fc, 0x7dd419bf, 0xbb562a6a, 0x3cf0e129, 0x6f6abaad, + 0xe8cc71ee, 0xc85e0da5, 0x4ff8c6e6, 0x1c629d62, 0x9bc45621, + 0x4a17fc89, 0xcdb137ca, 0x9e2b6c4e, 0x198da70d, 0x391fdb46, + 0xbeb91005, 0xed234b81, 0x6a8580c2, 0xac07b317, 0x2ba17854, + 0x783b23d0, 0xff9de893, 0xdf0f94d8, 0x58a95f9b, 0x0b33041f, + 0x8c95cf5c, 0x73e5570e, 0xf4439c4d, 0xa7d9c7c9, 0x207f0c8a, + 0x00ed70c1, 0x874bbb82, 0xd4d1e006, 0x53772b45, 0x95f51890, + 0x1253d3d3, 0x41c98857, 0xc66f4314, 0xe6fd3f5f, 0x615bf41c, + 0x32c1af98, 0xb56764db, 0x64b4ce73, 0xe3120530, 0xb0885eb4, + 0x372e95f7, 0x17bce9bc, 0x901a22ff, 0xc380797b, 0x4426b238, + 0x82a481ed, 0x05024aae, 0x5698112a, 0xd13eda69, 0xf1aca622, + 0x760a6d61, 0x259036e5, 0xa236fda6, 0xba8ccbe8, 0x3d2a00ab, + 0x6eb05b2f, 0xe916906c, 0xc984ec27, 0x4e222764, 0x1db87ce0, + 0x9a1eb7a3, 0x5c9c8476, 0xdb3a4f35, 0x88a014b1, 0x0f06dff2, + 0x2f94a3b9, 0xa83268fa, 0xfba8337e, 0x7c0ef83d, 0xaddd5295, + 0x2a7b99d6, 0x79e1c252, 0xfe470911, 0xded5755a, 0x5973be19, + 0x0ae9e59d, 0x8d4f2ede, 0x4bcd1d0b, 0xcc6bd648, 0x9ff18dcc, + 0x1857468f, 0x38c53ac4, 0xbf63f187, 0xecf9aa03, 0x6b5f6140, + 0x942ff912, 0x13893251, 0x401369d5, 0xc7b5a296, 0xe727dedd, + 0x6081159e, 0x331b4e1a, 0xb4bd8559, 0x723fb68c, 0xf5997dcf, + 0xa603264b, 0x21a5ed08, 0x01379143, 0x86915a00, 0xd50b0184, + 0x52adcac7, 0x837e606f, 0x04d8ab2c, 0x5742f0a8, 0xd0e43beb, + 0xf07647a0, 0x77d08ce3, 0x244ad767, 0xa3ec1c24, 0x656e2ff1, + 0xe2c8e4b2, 0xb152bf36, 0x36f47475, 0x1666083e, 0x91c0c37d, + 0xc25a98f9, 0x45fc53ba, 0xe7caae1c, 0x606c655f, 0x33f63edb, + 0xb450f598, 0x94c289d3, 0x13644290, 0x40fe1914, 0xc758d257, + 0x01dae182, 0x867c2ac1, 0xd5e67145, 0x5240ba06, 0x72d2c64d, + 0xf5740d0e, 0xa6ee568a, 0x21489dc9, 0xf09b3761, 0x773dfc22, + 0x24a7a7a6, 0xa3016ce5, 0x839310ae, 0x0435dbed, 0x57af8069, + 0xd0094b2a, 0x168b78ff, 0x912db3bc, 0xc2b7e838, 0x4511237b, + 0x65835f30, 0xe2259473, 0xb1bfcff7, 0x361904b4, 0xc9699ce6, + 0x4ecf57a5, 0x1d550c21, 0x9af3c762, 0xba61bb29, 0x3dc7706a, + 0x6e5d2bee, 0xe9fbe0ad, 0x2f79d378, 0xa8df183b, 0xfb4543bf, + 0x7ce388fc, 0x5c71f4b7, 0xdbd73ff4, 0x884d6470, 0x0febaf33, + 0xde38059b, 0x599eced8, 0x0a04955c, 0x8da25e1f, 0xad302254, + 0x2a96e917, 0x790cb293, 0xfeaa79d0, 0x38284a05, 0xbf8e8146, + 0xec14dac2, 0x6bb21181, 0x4b206dca, 0xcc86a689, 0x9f1cfd0d, + 0x18ba364e}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x0000000000000000, 0x43cba68700000000, 0xc7903cd400000000, + 0x845b9a5300000000, 0xcf27087300000000, 0x8cecaef400000000, + 0x08b734a700000000, 0x4b7c922000000000, 0x9e4f10e600000000, + 0xdd84b66100000000, 0x59df2c3200000000, 0x1a148ab500000000, + 0x5168189500000000, 0x12a3be1200000000, 0x96f8244100000000, + 0xd53382c600000000, 0x7d99511700000000, 0x3e52f79000000000, + 0xba096dc300000000, 0xf9c2cb4400000000, 0xb2be596400000000, + 0xf175ffe300000000, 0x752e65b000000000, 0x36e5c33700000000, + 0xe3d641f100000000, 0xa01de77600000000, 0x24467d2500000000, + 0x678ddba200000000, 0x2cf1498200000000, 0x6f3aef0500000000, + 0xeb61755600000000, 0xa8aad3d100000000, 0xfa32a32e00000000, + 0xb9f905a900000000, 0x3da29ffa00000000, 0x7e69397d00000000, + 0x3515ab5d00000000, 0x76de0dda00000000, 0xf285978900000000, + 0xb14e310e00000000, 0x647db3c800000000, 0x27b6154f00000000, + 0xa3ed8f1c00000000, 0xe026299b00000000, 0xab5abbbb00000000, + 0xe8911d3c00000000, 0x6cca876f00000000, 0x2f0121e800000000, + 0x87abf23900000000, 0xc46054be00000000, 0x403bceed00000000, + 0x03f0686a00000000, 0x488cfa4a00000000, 0x0b475ccd00000000, + 0x8f1cc69e00000000, 0xccd7601900000000, 0x19e4e2df00000000, + 0x5a2f445800000000, 0xde74de0b00000000, 0x9dbf788c00000000, + 0xd6c3eaac00000000, 0x95084c2b00000000, 0x1153d67800000000, + 0x529870ff00000000, 0xf465465d00000000, 0xb7aee0da00000000, + 0x33f57a8900000000, 0x703edc0e00000000, 0x3b424e2e00000000, + 0x7889e8a900000000, 0xfcd272fa00000000, 0xbf19d47d00000000, + 0x6a2a56bb00000000, 0x29e1f03c00000000, 0xadba6a6f00000000, + 0xee71cce800000000, 0xa50d5ec800000000, 0xe6c6f84f00000000, + 0x629d621c00000000, 0x2156c49b00000000, 0x89fc174a00000000, + 0xca37b1cd00000000, 0x4e6c2b9e00000000, 0x0da78d1900000000, + 0x46db1f3900000000, 0x0510b9be00000000, 0x814b23ed00000000, + 0xc280856a00000000, 0x17b307ac00000000, 0x5478a12b00000000, + 0xd0233b7800000000, 0x93e89dff00000000, 0xd8940fdf00000000, + 0x9b5fa95800000000, 0x1f04330b00000000, 0x5ccf958c00000000, + 0x0e57e57300000000, 0x4d9c43f400000000, 0xc9c7d9a700000000, + 0x8a0c7f2000000000, 0xc170ed0000000000, 0x82bb4b8700000000, + 0x06e0d1d400000000, 0x452b775300000000, 0x9018f59500000000, + 0xd3d3531200000000, 0x5788c94100000000, 0x14436fc600000000, + 0x5f3ffde600000000, 0x1cf45b6100000000, 0x98afc13200000000, + 0xdb6467b500000000, 0x73ceb46400000000, 0x300512e300000000, + 0xb45e88b000000000, 0xf7952e3700000000, 0xbce9bc1700000000, + 0xff221a9000000000, 0x7b7980c300000000, 0x38b2264400000000, + 0xed81a48200000000, 0xae4a020500000000, 0x2a11985600000000, + 0x69da3ed100000000, 0x22a6acf100000000, 0x616d0a7600000000, + 0xe536902500000000, 0xa6fd36a200000000, 0xe8cb8cba00000000, + 0xab002a3d00000000, 0x2f5bb06e00000000, 0x6c9016e900000000, + 0x27ec84c900000000, 0x6427224e00000000, 0xe07cb81d00000000, + 0xa3b71e9a00000000, 0x76849c5c00000000, 0x354f3adb00000000, + 0xb114a08800000000, 0xf2df060f00000000, 0xb9a3942f00000000, + 0xfa6832a800000000, 0x7e33a8fb00000000, 0x3df80e7c00000000, + 0x9552ddad00000000, 0xd6997b2a00000000, 0x52c2e17900000000, + 0x110947fe00000000, 0x5a75d5de00000000, 0x19be735900000000, + 0x9de5e90a00000000, 0xde2e4f8d00000000, 0x0b1dcd4b00000000, + 0x48d66bcc00000000, 0xcc8df19f00000000, 0x8f46571800000000, + 0xc43ac53800000000, 0x87f163bf00000000, 0x03aaf9ec00000000, + 0x40615f6b00000000, 0x12f92f9400000000, 0x5132891300000000, + 0xd569134000000000, 0x96a2b5c700000000, 0xddde27e700000000, + 0x9e15816000000000, 0x1a4e1b3300000000, 0x5985bdb400000000, + 0x8cb63f7200000000, 0xcf7d99f500000000, 0x4b2603a600000000, + 0x08eda52100000000, 0x4391370100000000, 0x005a918600000000, + 0x84010bd500000000, 0xc7caad5200000000, 0x6f607e8300000000, + 0x2cabd80400000000, 0xa8f0425700000000, 0xeb3be4d000000000, + 0xa04776f000000000, 0xe38cd07700000000, 0x67d74a2400000000, + 0x241ceca300000000, 0xf12f6e6500000000, 0xb2e4c8e200000000, + 0x36bf52b100000000, 0x7574f43600000000, 0x3e08661600000000, + 0x7dc3c09100000000, 0xf9985ac200000000, 0xba53fc4500000000, + 0x1caecae700000000, 0x5f656c6000000000, 0xdb3ef63300000000, + 0x98f550b400000000, 0xd389c29400000000, 0x9042641300000000, + 0x1419fe4000000000, 0x57d258c700000000, 0x82e1da0100000000, + 0xc12a7c8600000000, 0x4571e6d500000000, 0x06ba405200000000, + 0x4dc6d27200000000, 0x0e0d74f500000000, 0x8a56eea600000000, + 0xc99d482100000000, 0x61379bf000000000, 0x22fc3d7700000000, + 0xa6a7a72400000000, 0xe56c01a300000000, 0xae10938300000000, + 0xeddb350400000000, 0x6980af5700000000, 0x2a4b09d000000000, + 0xff788b1600000000, 0xbcb32d9100000000, 0x38e8b7c200000000, + 0x7b23114500000000, 0x305f836500000000, 0x739425e200000000, + 0xf7cfbfb100000000, 0xb404193600000000, 0xe69c69c900000000, + 0xa557cf4e00000000, 0x210c551d00000000, 0x62c7f39a00000000, + 0x29bb61ba00000000, 0x6a70c73d00000000, 0xee2b5d6e00000000, + 0xade0fbe900000000, 0x78d3792f00000000, 0x3b18dfa800000000, + 0xbf4345fb00000000, 0xfc88e37c00000000, 0xb7f4715c00000000, + 0xf43fd7db00000000, 0x70644d8800000000, 0x33afeb0f00000000, + 0x9b0538de00000000, 0xd8ce9e5900000000, 0x5c95040a00000000, + 0x1f5ea28d00000000, 0x542230ad00000000, 0x17e9962a00000000, + 0x93b20c7900000000, 0xd079aafe00000000, 0x054a283800000000, + 0x46818ebf00000000, 0xc2da14ec00000000, 0x8111b26b00000000, + 0xca6d204b00000000, 0x89a686cc00000000, 0x0dfd1c9f00000000, + 0x4e36ba1800000000}, + {0x0000000000000000, 0xe1b652ef00000000, 0x836bd40500000000, + 0x62dd86ea00000000, 0x06d7a80b00000000, 0xe761fae400000000, + 0x85bc7c0e00000000, 0x640a2ee100000000, 0x0cae511700000000, + 0xed1803f800000000, 0x8fc5851200000000, 0x6e73d7fd00000000, + 0x0a79f91c00000000, 0xebcfabf300000000, 0x89122d1900000000, + 0x68a47ff600000000, 0x185ca32e00000000, 0xf9eaf1c100000000, + 0x9b37772b00000000, 0x7a8125c400000000, 0x1e8b0b2500000000, + 0xff3d59ca00000000, 0x9de0df2000000000, 0x7c568dcf00000000, + 0x14f2f23900000000, 0xf544a0d600000000, 0x9799263c00000000, + 0x762f74d300000000, 0x12255a3200000000, 0xf39308dd00000000, + 0x914e8e3700000000, 0x70f8dcd800000000, 0x30b8465d00000000, + 0xd10e14b200000000, 0xb3d3925800000000, 0x5265c0b700000000, + 0x366fee5600000000, 0xd7d9bcb900000000, 0xb5043a5300000000, + 0x54b268bc00000000, 0x3c16174a00000000, 0xdda045a500000000, + 0xbf7dc34f00000000, 0x5ecb91a000000000, 0x3ac1bf4100000000, + 0xdb77edae00000000, 0xb9aa6b4400000000, 0x581c39ab00000000, + 0x28e4e57300000000, 0xc952b79c00000000, 0xab8f317600000000, + 0x4a39639900000000, 0x2e334d7800000000, 0xcf851f9700000000, + 0xad58997d00000000, 0x4ceecb9200000000, 0x244ab46400000000, + 0xc5fce68b00000000, 0xa721606100000000, 0x4697328e00000000, + 0x229d1c6f00000000, 0xc32b4e8000000000, 0xa1f6c86a00000000, + 0x40409a8500000000, 0x60708dba00000000, 0x81c6df5500000000, + 0xe31b59bf00000000, 0x02ad0b5000000000, 0x66a725b100000000, + 0x8711775e00000000, 0xe5ccf1b400000000, 0x047aa35b00000000, + 0x6cdedcad00000000, 0x8d688e4200000000, 0xefb508a800000000, + 0x0e035a4700000000, 0x6a0974a600000000, 0x8bbf264900000000, + 0xe962a0a300000000, 0x08d4f24c00000000, 0x782c2e9400000000, + 0x999a7c7b00000000, 0xfb47fa9100000000, 0x1af1a87e00000000, + 0x7efb869f00000000, 0x9f4dd47000000000, 0xfd90529a00000000, + 0x1c26007500000000, 0x74827f8300000000, 0x95342d6c00000000, + 0xf7e9ab8600000000, 0x165ff96900000000, 0x7255d78800000000, + 0x93e3856700000000, 0xf13e038d00000000, 0x1088516200000000, + 0x50c8cbe700000000, 0xb17e990800000000, 0xd3a31fe200000000, + 0x32154d0d00000000, 0x561f63ec00000000, 0xb7a9310300000000, + 0xd574b7e900000000, 0x34c2e50600000000, 0x5c669af000000000, + 0xbdd0c81f00000000, 0xdf0d4ef500000000, 0x3ebb1c1a00000000, + 0x5ab132fb00000000, 0xbb07601400000000, 0xd9dae6fe00000000, + 0x386cb41100000000, 0x489468c900000000, 0xa9223a2600000000, + 0xcbffbccc00000000, 0x2a49ee2300000000, 0x4e43c0c200000000, + 0xaff5922d00000000, 0xcd2814c700000000, 0x2c9e462800000000, + 0x443a39de00000000, 0xa58c6b3100000000, 0xc751eddb00000000, + 0x26e7bf3400000000, 0x42ed91d500000000, 0xa35bc33a00000000, + 0xc18645d000000000, 0x2030173f00000000, 0x81e66bae00000000, + 0x6050394100000000, 0x028dbfab00000000, 0xe33bed4400000000, + 0x8731c3a500000000, 0x6687914a00000000, 0x045a17a000000000, + 0xe5ec454f00000000, 0x8d483ab900000000, 0x6cfe685600000000, + 0x0e23eebc00000000, 0xef95bc5300000000, 0x8b9f92b200000000, + 0x6a29c05d00000000, 0x08f446b700000000, 0xe942145800000000, + 0x99bac88000000000, 0x780c9a6f00000000, 0x1ad11c8500000000, + 0xfb674e6a00000000, 0x9f6d608b00000000, 0x7edb326400000000, + 0x1c06b48e00000000, 0xfdb0e66100000000, 0x9514999700000000, + 0x74a2cb7800000000, 0x167f4d9200000000, 0xf7c91f7d00000000, + 0x93c3319c00000000, 0x7275637300000000, 0x10a8e59900000000, + 0xf11eb77600000000, 0xb15e2df300000000, 0x50e87f1c00000000, + 0x3235f9f600000000, 0xd383ab1900000000, 0xb78985f800000000, + 0x563fd71700000000, 0x34e251fd00000000, 0xd554031200000000, + 0xbdf07ce400000000, 0x5c462e0b00000000, 0x3e9ba8e100000000, + 0xdf2dfa0e00000000, 0xbb27d4ef00000000, 0x5a91860000000000, + 0x384c00ea00000000, 0xd9fa520500000000, 0xa9028edd00000000, + 0x48b4dc3200000000, 0x2a695ad800000000, 0xcbdf083700000000, + 0xafd526d600000000, 0x4e63743900000000, 0x2cbef2d300000000, + 0xcd08a03c00000000, 0xa5acdfca00000000, 0x441a8d2500000000, + 0x26c70bcf00000000, 0xc771592000000000, 0xa37b77c100000000, + 0x42cd252e00000000, 0x2010a3c400000000, 0xc1a6f12b00000000, + 0xe196e61400000000, 0x0020b4fb00000000, 0x62fd321100000000, + 0x834b60fe00000000, 0xe7414e1f00000000, 0x06f71cf000000000, + 0x642a9a1a00000000, 0x859cc8f500000000, 0xed38b70300000000, + 0x0c8ee5ec00000000, 0x6e53630600000000, 0x8fe531e900000000, + 0xebef1f0800000000, 0x0a594de700000000, 0x6884cb0d00000000, + 0x893299e200000000, 0xf9ca453a00000000, 0x187c17d500000000, + 0x7aa1913f00000000, 0x9b17c3d000000000, 0xff1ded3100000000, + 0x1eabbfde00000000, 0x7c76393400000000, 0x9dc06bdb00000000, + 0xf564142d00000000, 0x14d246c200000000, 0x760fc02800000000, + 0x97b992c700000000, 0xf3b3bc2600000000, 0x1205eec900000000, + 0x70d8682300000000, 0x916e3acc00000000, 0xd12ea04900000000, + 0x3098f2a600000000, 0x5245744c00000000, 0xb3f326a300000000, + 0xd7f9084200000000, 0x364f5aad00000000, 0x5492dc4700000000, + 0xb5248ea800000000, 0xdd80f15e00000000, 0x3c36a3b100000000, + 0x5eeb255b00000000, 0xbf5d77b400000000, 0xdb57595500000000, + 0x3ae10bba00000000, 0x583c8d5000000000, 0xb98adfbf00000000, + 0xc972036700000000, 0x28c4518800000000, 0x4a19d76200000000, + 0xabaf858d00000000, 0xcfa5ab6c00000000, 0x2e13f98300000000, + 0x4cce7f6900000000, 0xad782d8600000000, 0xc5dc527000000000, + 0x246a009f00000000, 0x46b7867500000000, 0xa701d49a00000000, + 0xc30bfa7b00000000, 0x22bda89400000000, 0x40602e7e00000000, + 0xa1d67c9100000000}, + {0x0000000000000000, 0x5880e2d700000000, 0xf106b47400000000, + 0xa98656a300000000, 0xe20d68e900000000, 0xba8d8a3e00000000, + 0x130bdc9d00000000, 0x4b8b3e4a00000000, 0x851da10900000000, + 0xdd9d43de00000000, 0x741b157d00000000, 0x2c9bf7aa00000000, + 0x6710c9e000000000, 0x3f902b3700000000, 0x96167d9400000000, + 0xce969f4300000000, 0x0a3b421300000000, 0x52bba0c400000000, + 0xfb3df66700000000, 0xa3bd14b000000000, 0xe8362afa00000000, + 0xb0b6c82d00000000, 0x19309e8e00000000, 0x41b07c5900000000, + 0x8f26e31a00000000, 0xd7a601cd00000000, 0x7e20576e00000000, + 0x26a0b5b900000000, 0x6d2b8bf300000000, 0x35ab692400000000, + 0x9c2d3f8700000000, 0xc4addd5000000000, 0x1476842600000000, + 0x4cf666f100000000, 0xe570305200000000, 0xbdf0d28500000000, + 0xf67beccf00000000, 0xaefb0e1800000000, 0x077d58bb00000000, + 0x5ffdba6c00000000, 0x916b252f00000000, 0xc9ebc7f800000000, + 0x606d915b00000000, 0x38ed738c00000000, 0x73664dc600000000, + 0x2be6af1100000000, 0x8260f9b200000000, 0xdae01b6500000000, + 0x1e4dc63500000000, 0x46cd24e200000000, 0xef4b724100000000, + 0xb7cb909600000000, 0xfc40aedc00000000, 0xa4c04c0b00000000, + 0x0d461aa800000000, 0x55c6f87f00000000, 0x9b50673c00000000, + 0xc3d085eb00000000, 0x6a56d34800000000, 0x32d6319f00000000, + 0x795d0fd500000000, 0x21dded0200000000, 0x885bbba100000000, + 0xd0db597600000000, 0x28ec084d00000000, 0x706cea9a00000000, + 0xd9eabc3900000000, 0x816a5eee00000000, 0xcae160a400000000, + 0x9261827300000000, 0x3be7d4d000000000, 0x6367360700000000, + 0xadf1a94400000000, 0xf5714b9300000000, 0x5cf71d3000000000, + 0x0477ffe700000000, 0x4ffcc1ad00000000, 0x177c237a00000000, + 0xbefa75d900000000, 0xe67a970e00000000, 0x22d74a5e00000000, + 0x7a57a88900000000, 0xd3d1fe2a00000000, 0x8b511cfd00000000, + 0xc0da22b700000000, 0x985ac06000000000, 0x31dc96c300000000, + 0x695c741400000000, 0xa7caeb5700000000, 0xff4a098000000000, + 0x56cc5f2300000000, 0x0e4cbdf400000000, 0x45c783be00000000, + 0x1d47616900000000, 0xb4c137ca00000000, 0xec41d51d00000000, + 0x3c9a8c6b00000000, 0x641a6ebc00000000, 0xcd9c381f00000000, + 0x951cdac800000000, 0xde97e48200000000, 0x8617065500000000, + 0x2f9150f600000000, 0x7711b22100000000, 0xb9872d6200000000, + 0xe107cfb500000000, 0x4881991600000000, 0x10017bc100000000, + 0x5b8a458b00000000, 0x030aa75c00000000, 0xaa8cf1ff00000000, + 0xf20c132800000000, 0x36a1ce7800000000, 0x6e212caf00000000, + 0xc7a77a0c00000000, 0x9f2798db00000000, 0xd4aca69100000000, + 0x8c2c444600000000, 0x25aa12e500000000, 0x7d2af03200000000, + 0xb3bc6f7100000000, 0xeb3c8da600000000, 0x42badb0500000000, + 0x1a3a39d200000000, 0x51b1079800000000, 0x0931e54f00000000, + 0xa0b7b3ec00000000, 0xf837513b00000000, 0x50d8119a00000000, + 0x0858f34d00000000, 0xa1dea5ee00000000, 0xf95e473900000000, + 0xb2d5797300000000, 0xea559ba400000000, 0x43d3cd0700000000, + 0x1b532fd000000000, 0xd5c5b09300000000, 0x8d45524400000000, + 0x24c304e700000000, 0x7c43e63000000000, 0x37c8d87a00000000, + 0x6f483aad00000000, 0xc6ce6c0e00000000, 0x9e4e8ed900000000, + 0x5ae3538900000000, 0x0263b15e00000000, 0xabe5e7fd00000000, + 0xf365052a00000000, 0xb8ee3b6000000000, 0xe06ed9b700000000, + 0x49e88f1400000000, 0x11686dc300000000, 0xdffef28000000000, + 0x877e105700000000, 0x2ef846f400000000, 0x7678a42300000000, + 0x3df39a6900000000, 0x657378be00000000, 0xccf52e1d00000000, + 0x9475ccca00000000, 0x44ae95bc00000000, 0x1c2e776b00000000, + 0xb5a821c800000000, 0xed28c31f00000000, 0xa6a3fd5500000000, + 0xfe231f8200000000, 0x57a5492100000000, 0x0f25abf600000000, + 0xc1b334b500000000, 0x9933d66200000000, 0x30b580c100000000, + 0x6835621600000000, 0x23be5c5c00000000, 0x7b3ebe8b00000000, + 0xd2b8e82800000000, 0x8a380aff00000000, 0x4e95d7af00000000, + 0x1615357800000000, 0xbf9363db00000000, 0xe713810c00000000, + 0xac98bf4600000000, 0xf4185d9100000000, 0x5d9e0b3200000000, + 0x051ee9e500000000, 0xcb8876a600000000, 0x9308947100000000, + 0x3a8ec2d200000000, 0x620e200500000000, 0x29851e4f00000000, + 0x7105fc9800000000, 0xd883aa3b00000000, 0x800348ec00000000, + 0x783419d700000000, 0x20b4fb0000000000, 0x8932ada300000000, + 0xd1b24f7400000000, 0x9a39713e00000000, 0xc2b993e900000000, + 0x6b3fc54a00000000, 0x33bf279d00000000, 0xfd29b8de00000000, + 0xa5a95a0900000000, 0x0c2f0caa00000000, 0x54afee7d00000000, + 0x1f24d03700000000, 0x47a432e000000000, 0xee22644300000000, + 0xb6a2869400000000, 0x720f5bc400000000, 0x2a8fb91300000000, + 0x8309efb000000000, 0xdb890d6700000000, 0x9002332d00000000, + 0xc882d1fa00000000, 0x6104875900000000, 0x3984658e00000000, + 0xf712facd00000000, 0xaf92181a00000000, 0x06144eb900000000, + 0x5e94ac6e00000000, 0x151f922400000000, 0x4d9f70f300000000, + 0xe419265000000000, 0xbc99c48700000000, 0x6c429df100000000, + 0x34c27f2600000000, 0x9d44298500000000, 0xc5c4cb5200000000, + 0x8e4ff51800000000, 0xd6cf17cf00000000, 0x7f49416c00000000, + 0x27c9a3bb00000000, 0xe95f3cf800000000, 0xb1dfde2f00000000, + 0x1859888c00000000, 0x40d96a5b00000000, 0x0b52541100000000, + 0x53d2b6c600000000, 0xfa54e06500000000, 0xa2d402b200000000, + 0x6679dfe200000000, 0x3ef93d3500000000, 0x977f6b9600000000, + 0xcfff894100000000, 0x8474b70b00000000, 0xdcf455dc00000000, + 0x7572037f00000000, 0x2df2e1a800000000, 0xe3647eeb00000000, + 0xbbe49c3c00000000, 0x1262ca9f00000000, 0x4ae2284800000000, + 0x0169160200000000, 0x59e9f4d500000000, 0xf06fa27600000000, + 0xa8ef40a100000000}, + {0x0000000000000000, 0x463b676500000000, 0x8c76ceca00000000, + 0xca4da9af00000000, 0x59ebed4e00000000, 0x1fd08a2b00000000, + 0xd59d238400000000, 0x93a644e100000000, 0xb2d6db9d00000000, + 0xf4edbcf800000000, 0x3ea0155700000000, 0x789b723200000000, + 0xeb3d36d300000000, 0xad0651b600000000, 0x674bf81900000000, + 0x21709f7c00000000, 0x25abc6e000000000, 0x6390a18500000000, + 0xa9dd082a00000000, 0xefe66f4f00000000, 0x7c402bae00000000, + 0x3a7b4ccb00000000, 0xf036e56400000000, 0xb60d820100000000, + 0x977d1d7d00000000, 0xd1467a1800000000, 0x1b0bd3b700000000, + 0x5d30b4d200000000, 0xce96f03300000000, 0x88ad975600000000, + 0x42e03ef900000000, 0x04db599c00000000, 0x0b50fc1a00000000, + 0x4d6b9b7f00000000, 0x872632d000000000, 0xc11d55b500000000, + 0x52bb115400000000, 0x1480763100000000, 0xdecddf9e00000000, + 0x98f6b8fb00000000, 0xb986278700000000, 0xffbd40e200000000, + 0x35f0e94d00000000, 0x73cb8e2800000000, 0xe06dcac900000000, + 0xa656adac00000000, 0x6c1b040300000000, 0x2a20636600000000, + 0x2efb3afa00000000, 0x68c05d9f00000000, 0xa28df43000000000, + 0xe4b6935500000000, 0x7710d7b400000000, 0x312bb0d100000000, + 0xfb66197e00000000, 0xbd5d7e1b00000000, 0x9c2de16700000000, + 0xda16860200000000, 0x105b2fad00000000, 0x566048c800000000, + 0xc5c60c2900000000, 0x83fd6b4c00000000, 0x49b0c2e300000000, + 0x0f8ba58600000000, 0x16a0f83500000000, 0x509b9f5000000000, + 0x9ad636ff00000000, 0xdced519a00000000, 0x4f4b157b00000000, + 0x0970721e00000000, 0xc33ddbb100000000, 0x8506bcd400000000, + 0xa47623a800000000, 0xe24d44cd00000000, 0x2800ed6200000000, + 0x6e3b8a0700000000, 0xfd9dcee600000000, 0xbba6a98300000000, + 0x71eb002c00000000, 0x37d0674900000000, 0x330b3ed500000000, + 0x753059b000000000, 0xbf7df01f00000000, 0xf946977a00000000, + 0x6ae0d39b00000000, 0x2cdbb4fe00000000, 0xe6961d5100000000, + 0xa0ad7a3400000000, 0x81dde54800000000, 0xc7e6822d00000000, + 0x0dab2b8200000000, 0x4b904ce700000000, 0xd836080600000000, + 0x9e0d6f6300000000, 0x5440c6cc00000000, 0x127ba1a900000000, + 0x1df0042f00000000, 0x5bcb634a00000000, 0x9186cae500000000, + 0xd7bdad8000000000, 0x441be96100000000, 0x02208e0400000000, + 0xc86d27ab00000000, 0x8e5640ce00000000, 0xaf26dfb200000000, + 0xe91db8d700000000, 0x2350117800000000, 0x656b761d00000000, + 0xf6cd32fc00000000, 0xb0f6559900000000, 0x7abbfc3600000000, + 0x3c809b5300000000, 0x385bc2cf00000000, 0x7e60a5aa00000000, + 0xb42d0c0500000000, 0xf2166b6000000000, 0x61b02f8100000000, + 0x278b48e400000000, 0xedc6e14b00000000, 0xabfd862e00000000, + 0x8a8d195200000000, 0xccb67e3700000000, 0x06fbd79800000000, + 0x40c0b0fd00000000, 0xd366f41c00000000, 0x955d937900000000, + 0x5f103ad600000000, 0x192b5db300000000, 0x2c40f16b00000000, + 0x6a7b960e00000000, 0xa0363fa100000000, 0xe60d58c400000000, + 0x75ab1c2500000000, 0x33907b4000000000, 0xf9ddd2ef00000000, + 0xbfe6b58a00000000, 0x9e962af600000000, 0xd8ad4d9300000000, + 0x12e0e43c00000000, 0x54db835900000000, 0xc77dc7b800000000, + 0x8146a0dd00000000, 0x4b0b097200000000, 0x0d306e1700000000, + 0x09eb378b00000000, 0x4fd050ee00000000, 0x859df94100000000, + 0xc3a69e2400000000, 0x5000dac500000000, 0x163bbda000000000, + 0xdc76140f00000000, 0x9a4d736a00000000, 0xbb3dec1600000000, + 0xfd068b7300000000, 0x374b22dc00000000, 0x717045b900000000, + 0xe2d6015800000000, 0xa4ed663d00000000, 0x6ea0cf9200000000, + 0x289ba8f700000000, 0x27100d7100000000, 0x612b6a1400000000, + 0xab66c3bb00000000, 0xed5da4de00000000, 0x7efbe03f00000000, + 0x38c0875a00000000, 0xf28d2ef500000000, 0xb4b6499000000000, + 0x95c6d6ec00000000, 0xd3fdb18900000000, 0x19b0182600000000, + 0x5f8b7f4300000000, 0xcc2d3ba200000000, 0x8a165cc700000000, + 0x405bf56800000000, 0x0660920d00000000, 0x02bbcb9100000000, + 0x4480acf400000000, 0x8ecd055b00000000, 0xc8f6623e00000000, + 0x5b5026df00000000, 0x1d6b41ba00000000, 0xd726e81500000000, + 0x911d8f7000000000, 0xb06d100c00000000, 0xf656776900000000, + 0x3c1bdec600000000, 0x7a20b9a300000000, 0xe986fd4200000000, + 0xafbd9a2700000000, 0x65f0338800000000, 0x23cb54ed00000000, + 0x3ae0095e00000000, 0x7cdb6e3b00000000, 0xb696c79400000000, + 0xf0ada0f100000000, 0x630be41000000000, 0x2530837500000000, + 0xef7d2ada00000000, 0xa9464dbf00000000, 0x8836d2c300000000, + 0xce0db5a600000000, 0x04401c0900000000, 0x427b7b6c00000000, + 0xd1dd3f8d00000000, 0x97e658e800000000, 0x5dabf14700000000, + 0x1b90962200000000, 0x1f4bcfbe00000000, 0x5970a8db00000000, + 0x933d017400000000, 0xd506661100000000, 0x46a022f000000000, + 0x009b459500000000, 0xcad6ec3a00000000, 0x8ced8b5f00000000, + 0xad9d142300000000, 0xeba6734600000000, 0x21ebdae900000000, + 0x67d0bd8c00000000, 0xf476f96d00000000, 0xb24d9e0800000000, + 0x780037a700000000, 0x3e3b50c200000000, 0x31b0f54400000000, + 0x778b922100000000, 0xbdc63b8e00000000, 0xfbfd5ceb00000000, + 0x685b180a00000000, 0x2e607f6f00000000, 0xe42dd6c000000000, + 0xa216b1a500000000, 0x83662ed900000000, 0xc55d49bc00000000, + 0x0f10e01300000000, 0x492b877600000000, 0xda8dc39700000000, + 0x9cb6a4f200000000, 0x56fb0d5d00000000, 0x10c06a3800000000, + 0x141b33a400000000, 0x522054c100000000, 0x986dfd6e00000000, + 0xde569a0b00000000, 0x4df0deea00000000, 0x0bcbb98f00000000, + 0xc186102000000000, 0x87bd774500000000, 0xa6cde83900000000, + 0xe0f68f5c00000000, 0x2abb26f300000000, 0x6c80419600000000, + 0xff26057700000000, 0xb91d621200000000, 0x7350cbbd00000000, + 0x356bacd800000000}, + {0x0000000000000000, 0x9e83da9f00000000, 0x7d01c4e400000000, + 0xe3821e7b00000000, 0xbb04f91200000000, 0x2587238d00000000, + 0xc6053df600000000, 0x5886e76900000000, 0x7609f22500000000, + 0xe88a28ba00000000, 0x0b0836c100000000, 0x958bec5e00000000, + 0xcd0d0b3700000000, 0x538ed1a800000000, 0xb00ccfd300000000, + 0x2e8f154c00000000, 0xec12e44b00000000, 0x72913ed400000000, + 0x911320af00000000, 0x0f90fa3000000000, 0x57161d5900000000, + 0xc995c7c600000000, 0x2a17d9bd00000000, 0xb494032200000000, + 0x9a1b166e00000000, 0x0498ccf100000000, 0xe71ad28a00000000, + 0x7999081500000000, 0x211fef7c00000000, 0xbf9c35e300000000, + 0x5c1e2b9800000000, 0xc29df10700000000, 0xd825c89700000000, + 0x46a6120800000000, 0xa5240c7300000000, 0x3ba7d6ec00000000, + 0x6321318500000000, 0xfda2eb1a00000000, 0x1e20f56100000000, + 0x80a32ffe00000000, 0xae2c3ab200000000, 0x30afe02d00000000, + 0xd32dfe5600000000, 0x4dae24c900000000, 0x1528c3a000000000, + 0x8bab193f00000000, 0x6829074400000000, 0xf6aadddb00000000, + 0x34372cdc00000000, 0xaab4f64300000000, 0x4936e83800000000, + 0xd7b532a700000000, 0x8f33d5ce00000000, 0x11b00f5100000000, + 0xf232112a00000000, 0x6cb1cbb500000000, 0x423edef900000000, + 0xdcbd046600000000, 0x3f3f1a1d00000000, 0xa1bcc08200000000, + 0xf93a27eb00000000, 0x67b9fd7400000000, 0x843be30f00000000, + 0x1ab8399000000000, 0xf14de1f400000000, 0x6fce3b6b00000000, + 0x8c4c251000000000, 0x12cfff8f00000000, 0x4a4918e600000000, + 0xd4cac27900000000, 0x3748dc0200000000, 0xa9cb069d00000000, + 0x874413d100000000, 0x19c7c94e00000000, 0xfa45d73500000000, + 0x64c60daa00000000, 0x3c40eac300000000, 0xa2c3305c00000000, + 0x41412e2700000000, 0xdfc2f4b800000000, 0x1d5f05bf00000000, + 0x83dcdf2000000000, 0x605ec15b00000000, 0xfedd1bc400000000, + 0xa65bfcad00000000, 0x38d8263200000000, 0xdb5a384900000000, + 0x45d9e2d600000000, 0x6b56f79a00000000, 0xf5d52d0500000000, + 0x1657337e00000000, 0x88d4e9e100000000, 0xd0520e8800000000, + 0x4ed1d41700000000, 0xad53ca6c00000000, 0x33d010f300000000, + 0x2968296300000000, 0xb7ebf3fc00000000, 0x5469ed8700000000, + 0xcaea371800000000, 0x926cd07100000000, 0x0cef0aee00000000, + 0xef6d149500000000, 0x71eece0a00000000, 0x5f61db4600000000, + 0xc1e201d900000000, 0x22601fa200000000, 0xbce3c53d00000000, + 0xe465225400000000, 0x7ae6f8cb00000000, 0x9964e6b000000000, + 0x07e73c2f00000000, 0xc57acd2800000000, 0x5bf917b700000000, + 0xb87b09cc00000000, 0x26f8d35300000000, 0x7e7e343a00000000, + 0xe0fdeea500000000, 0x037ff0de00000000, 0x9dfc2a4100000000, + 0xb3733f0d00000000, 0x2df0e59200000000, 0xce72fbe900000000, + 0x50f1217600000000, 0x0877c61f00000000, 0x96f41c8000000000, + 0x757602fb00000000, 0xebf5d86400000000, 0xa39db33200000000, + 0x3d1e69ad00000000, 0xde9c77d600000000, 0x401fad4900000000, + 0x18994a2000000000, 0x861a90bf00000000, 0x65988ec400000000, + 0xfb1b545b00000000, 0xd594411700000000, 0x4b179b8800000000, + 0xa89585f300000000, 0x36165f6c00000000, 0x6e90b80500000000, + 0xf013629a00000000, 0x13917ce100000000, 0x8d12a67e00000000, + 0x4f8f577900000000, 0xd10c8de600000000, 0x328e939d00000000, + 0xac0d490200000000, 0xf48bae6b00000000, 0x6a0874f400000000, + 0x898a6a8f00000000, 0x1709b01000000000, 0x3986a55c00000000, + 0xa7057fc300000000, 0x448761b800000000, 0xda04bb2700000000, + 0x82825c4e00000000, 0x1c0186d100000000, 0xff8398aa00000000, + 0x6100423500000000, 0x7bb87ba500000000, 0xe53ba13a00000000, + 0x06b9bf4100000000, 0x983a65de00000000, 0xc0bc82b700000000, + 0x5e3f582800000000, 0xbdbd465300000000, 0x233e9ccc00000000, + 0x0db1898000000000, 0x9332531f00000000, 0x70b04d6400000000, + 0xee3397fb00000000, 0xb6b5709200000000, 0x2836aa0d00000000, + 0xcbb4b47600000000, 0x55376ee900000000, 0x97aa9fee00000000, + 0x0929457100000000, 0xeaab5b0a00000000, 0x7428819500000000, + 0x2cae66fc00000000, 0xb22dbc6300000000, 0x51afa21800000000, + 0xcf2c788700000000, 0xe1a36dcb00000000, 0x7f20b75400000000, + 0x9ca2a92f00000000, 0x022173b000000000, 0x5aa794d900000000, + 0xc4244e4600000000, 0x27a6503d00000000, 0xb9258aa200000000, + 0x52d052c600000000, 0xcc53885900000000, 0x2fd1962200000000, + 0xb1524cbd00000000, 0xe9d4abd400000000, 0x7757714b00000000, + 0x94d56f3000000000, 0x0a56b5af00000000, 0x24d9a0e300000000, + 0xba5a7a7c00000000, 0x59d8640700000000, 0xc75bbe9800000000, + 0x9fdd59f100000000, 0x015e836e00000000, 0xe2dc9d1500000000, + 0x7c5f478a00000000, 0xbec2b68d00000000, 0x20416c1200000000, + 0xc3c3726900000000, 0x5d40a8f600000000, 0x05c64f9f00000000, + 0x9b45950000000000, 0x78c78b7b00000000, 0xe64451e400000000, + 0xc8cb44a800000000, 0x56489e3700000000, 0xb5ca804c00000000, + 0x2b495ad300000000, 0x73cfbdba00000000, 0xed4c672500000000, + 0x0ece795e00000000, 0x904da3c100000000, 0x8af59a5100000000, + 0x147640ce00000000, 0xf7f45eb500000000, 0x6977842a00000000, + 0x31f1634300000000, 0xaf72b9dc00000000, 0x4cf0a7a700000000, + 0xd2737d3800000000, 0xfcfc687400000000, 0x627fb2eb00000000, + 0x81fdac9000000000, 0x1f7e760f00000000, 0x47f8916600000000, + 0xd97b4bf900000000, 0x3af9558200000000, 0xa47a8f1d00000000, + 0x66e77e1a00000000, 0xf864a48500000000, 0x1be6bafe00000000, + 0x8565606100000000, 0xdde3870800000000, 0x43605d9700000000, + 0xa0e243ec00000000, 0x3e61997300000000, 0x10ee8c3f00000000, + 0x8e6d56a000000000, 0x6def48db00000000, 0xf36c924400000000, + 0xabea752d00000000, 0x3569afb200000000, 0xd6ebb1c900000000, + 0x48686b5600000000}, + {0x0000000000000000, 0xc064281700000000, 0x80c9502e00000000, + 0x40ad783900000000, 0x0093a15c00000000, 0xc0f7894b00000000, + 0x805af17200000000, 0x403ed96500000000, 0x002643b900000000, + 0xc0426bae00000000, 0x80ef139700000000, 0x408b3b8000000000, + 0x00b5e2e500000000, 0xc0d1caf200000000, 0x807cb2cb00000000, + 0x40189adc00000000, 0x414af7a900000000, 0x812edfbe00000000, + 0xc183a78700000000, 0x01e78f9000000000, 0x41d956f500000000, + 0x81bd7ee200000000, 0xc11006db00000000, 0x01742ecc00000000, + 0x416cb41000000000, 0x81089c0700000000, 0xc1a5e43e00000000, + 0x01c1cc2900000000, 0x41ff154c00000000, 0x819b3d5b00000000, + 0xc136456200000000, 0x01526d7500000000, 0xc3929f8800000000, + 0x03f6b79f00000000, 0x435bcfa600000000, 0x833fe7b100000000, + 0xc3013ed400000000, 0x036516c300000000, 0x43c86efa00000000, + 0x83ac46ed00000000, 0xc3b4dc3100000000, 0x03d0f42600000000, + 0x437d8c1f00000000, 0x8319a40800000000, 0xc3277d6d00000000, + 0x0343557a00000000, 0x43ee2d4300000000, 0x838a055400000000, + 0x82d8682100000000, 0x42bc403600000000, 0x0211380f00000000, + 0xc275101800000000, 0x824bc97d00000000, 0x422fe16a00000000, + 0x0282995300000000, 0xc2e6b14400000000, 0x82fe2b9800000000, + 0x429a038f00000000, 0x02377bb600000000, 0xc25353a100000000, + 0x826d8ac400000000, 0x4209a2d300000000, 0x02a4daea00000000, + 0xc2c0f2fd00000000, 0xc7234eca00000000, 0x074766dd00000000, + 0x47ea1ee400000000, 0x878e36f300000000, 0xc7b0ef9600000000, + 0x07d4c78100000000, 0x4779bfb800000000, 0x871d97af00000000, + 0xc7050d7300000000, 0x0761256400000000, 0x47cc5d5d00000000, + 0x87a8754a00000000, 0xc796ac2f00000000, 0x07f2843800000000, + 0x475ffc0100000000, 0x873bd41600000000, 0x8669b96300000000, + 0x460d917400000000, 0x06a0e94d00000000, 0xc6c4c15a00000000, + 0x86fa183f00000000, 0x469e302800000000, 0x0633481100000000, + 0xc657600600000000, 0x864ffada00000000, 0x462bd2cd00000000, + 0x0686aaf400000000, 0xc6e282e300000000, 0x86dc5b8600000000, + 0x46b8739100000000, 0x06150ba800000000, 0xc67123bf00000000, + 0x04b1d14200000000, 0xc4d5f95500000000, 0x8478816c00000000, + 0x441ca97b00000000, 0x0422701e00000000, 0xc446580900000000, + 0x84eb203000000000, 0x448f082700000000, 0x049792fb00000000, + 0xc4f3baec00000000, 0x845ec2d500000000, 0x443aeac200000000, + 0x040433a700000000, 0xc4601bb000000000, 0x84cd638900000000, + 0x44a94b9e00000000, 0x45fb26eb00000000, 0x859f0efc00000000, + 0xc53276c500000000, 0x05565ed200000000, 0x456887b700000000, + 0x850cafa000000000, 0xc5a1d79900000000, 0x05c5ff8e00000000, + 0x45dd655200000000, 0x85b94d4500000000, 0xc514357c00000000, + 0x05701d6b00000000, 0x454ec40e00000000, 0x852aec1900000000, + 0xc587942000000000, 0x05e3bc3700000000, 0xcf41ed4f00000000, + 0x0f25c55800000000, 0x4f88bd6100000000, 0x8fec957600000000, + 0xcfd24c1300000000, 0x0fb6640400000000, 0x4f1b1c3d00000000, + 0x8f7f342a00000000, 0xcf67aef600000000, 0x0f0386e100000000, + 0x4faefed800000000, 0x8fcad6cf00000000, 0xcff40faa00000000, + 0x0f9027bd00000000, 0x4f3d5f8400000000, 0x8f59779300000000, + 0x8e0b1ae600000000, 0x4e6f32f100000000, 0x0ec24ac800000000, + 0xcea662df00000000, 0x8e98bbba00000000, 0x4efc93ad00000000, + 0x0e51eb9400000000, 0xce35c38300000000, 0x8e2d595f00000000, + 0x4e49714800000000, 0x0ee4097100000000, 0xce80216600000000, + 0x8ebef80300000000, 0x4edad01400000000, 0x0e77a82d00000000, + 0xce13803a00000000, 0x0cd372c700000000, 0xccb75ad000000000, + 0x8c1a22e900000000, 0x4c7e0afe00000000, 0x0c40d39b00000000, + 0xcc24fb8c00000000, 0x8c8983b500000000, 0x4cedaba200000000, + 0x0cf5317e00000000, 0xcc91196900000000, 0x8c3c615000000000, + 0x4c58494700000000, 0x0c66902200000000, 0xcc02b83500000000, + 0x8cafc00c00000000, 0x4ccbe81b00000000, 0x4d99856e00000000, + 0x8dfdad7900000000, 0xcd50d54000000000, 0x0d34fd5700000000, + 0x4d0a243200000000, 0x8d6e0c2500000000, 0xcdc3741c00000000, + 0x0da75c0b00000000, 0x4dbfc6d700000000, 0x8ddbeec000000000, + 0xcd7696f900000000, 0x0d12beee00000000, 0x4d2c678b00000000, + 0x8d484f9c00000000, 0xcde537a500000000, 0x0d811fb200000000, + 0x0862a38500000000, 0xc8068b9200000000, 0x88abf3ab00000000, + 0x48cfdbbc00000000, 0x08f102d900000000, 0xc8952ace00000000, + 0x883852f700000000, 0x485c7ae000000000, 0x0844e03c00000000, + 0xc820c82b00000000, 0x888db01200000000, 0x48e9980500000000, + 0x08d7416000000000, 0xc8b3697700000000, 0x881e114e00000000, + 0x487a395900000000, 0x4928542c00000000, 0x894c7c3b00000000, + 0xc9e1040200000000, 0x09852c1500000000, 0x49bbf57000000000, + 0x89dfdd6700000000, 0xc972a55e00000000, 0x09168d4900000000, + 0x490e179500000000, 0x896a3f8200000000, 0xc9c747bb00000000, + 0x09a36fac00000000, 0x499db6c900000000, 0x89f99ede00000000, + 0xc954e6e700000000, 0x0930cef000000000, 0xcbf03c0d00000000, + 0x0b94141a00000000, 0x4b396c2300000000, 0x8b5d443400000000, + 0xcb639d5100000000, 0x0b07b54600000000, 0x4baacd7f00000000, + 0x8bcee56800000000, 0xcbd67fb400000000, 0x0bb257a300000000, + 0x4b1f2f9a00000000, 0x8b7b078d00000000, 0xcb45dee800000000, + 0x0b21f6ff00000000, 0x4b8c8ec600000000, 0x8be8a6d100000000, + 0x8abacba400000000, 0x4adee3b300000000, 0x0a739b8a00000000, + 0xca17b39d00000000, 0x8a296af800000000, 0x4a4d42ef00000000, + 0x0ae03ad600000000, 0xca8412c100000000, 0x8a9c881d00000000, + 0x4af8a00a00000000, 0x0a55d83300000000, 0xca31f02400000000, + 0x8a0f294100000000, 0x4a6b015600000000, 0x0ac6796f00000000, + 0xcaa2517800000000}, + {0x0000000000000000, 0xd4ea739b00000000, 0xe9d396ed00000000, + 0x3d39e57600000000, 0x93a15c0000000000, 0x474b2f9b00000000, + 0x7a72caed00000000, 0xae98b97600000000, 0x2643b90000000000, + 0xf2a9ca9b00000000, 0xcf902fed00000000, 0x1b7a5c7600000000, + 0xb5e2e50000000000, 0x6108969b00000000, 0x5c3173ed00000000, + 0x88db007600000000, 0x4c86720100000000, 0x986c019a00000000, + 0xa555e4ec00000000, 0x71bf977700000000, 0xdf272e0100000000, + 0x0bcd5d9a00000000, 0x36f4b8ec00000000, 0xe21ecb7700000000, + 0x6ac5cb0100000000, 0xbe2fb89a00000000, 0x83165dec00000000, + 0x57fc2e7700000000, 0xf964970100000000, 0x2d8ee49a00000000, + 0x10b701ec00000000, 0xc45d727700000000, 0x980ce50200000000, + 0x4ce6969900000000, 0x71df73ef00000000, 0xa535007400000000, + 0x0badb90200000000, 0xdf47ca9900000000, 0xe27e2fef00000000, + 0x36945c7400000000, 0xbe4f5c0200000000, 0x6aa52f9900000000, + 0x579ccaef00000000, 0x8376b97400000000, 0x2dee000200000000, + 0xf904739900000000, 0xc43d96ef00000000, 0x10d7e57400000000, + 0xd48a970300000000, 0x0060e49800000000, 0x3d5901ee00000000, + 0xe9b3727500000000, 0x472bcb0300000000, 0x93c1b89800000000, + 0xaef85dee00000000, 0x7a122e7500000000, 0xf2c92e0300000000, + 0x26235d9800000000, 0x1b1ab8ee00000000, 0xcff0cb7500000000, + 0x6168720300000000, 0xb582019800000000, 0x88bbe4ee00000000, + 0x5c51977500000000, 0x3019ca0500000000, 0xe4f3b99e00000000, + 0xd9ca5ce800000000, 0x0d202f7300000000, 0xa3b8960500000000, + 0x7752e59e00000000, 0x4a6b00e800000000, 0x9e81737300000000, + 0x165a730500000000, 0xc2b0009e00000000, 0xff89e5e800000000, + 0x2b63967300000000, 0x85fb2f0500000000, 0x51115c9e00000000, + 0x6c28b9e800000000, 0xb8c2ca7300000000, 0x7c9fb80400000000, + 0xa875cb9f00000000, 0x954c2ee900000000, 0x41a65d7200000000, + 0xef3ee40400000000, 0x3bd4979f00000000, 0x06ed72e900000000, + 0xd207017200000000, 0x5adc010400000000, 0x8e36729f00000000, + 0xb30f97e900000000, 0x67e5e47200000000, 0xc97d5d0400000000, + 0x1d972e9f00000000, 0x20aecbe900000000, 0xf444b87200000000, + 0xa8152f0700000000, 0x7cff5c9c00000000, 0x41c6b9ea00000000, + 0x952cca7100000000, 0x3bb4730700000000, 0xef5e009c00000000, + 0xd267e5ea00000000, 0x068d967100000000, 0x8e56960700000000, + 0x5abce59c00000000, 0x678500ea00000000, 0xb36f737100000000, + 0x1df7ca0700000000, 0xc91db99c00000000, 0xf4245cea00000000, + 0x20ce2f7100000000, 0xe4935d0600000000, 0x30792e9d00000000, + 0x0d40cbeb00000000, 0xd9aab87000000000, 0x7732010600000000, + 0xa3d8729d00000000, 0x9ee197eb00000000, 0x4a0be47000000000, + 0xc2d0e40600000000, 0x163a979d00000000, 0x2b0372eb00000000, + 0xffe9017000000000, 0x5171b80600000000, 0x859bcb9d00000000, + 0xb8a22eeb00000000, 0x6c485d7000000000, 0x6032940b00000000, + 0xb4d8e79000000000, 0x89e102e600000000, 0x5d0b717d00000000, + 0xf393c80b00000000, 0x2779bb9000000000, 0x1a405ee600000000, + 0xceaa2d7d00000000, 0x46712d0b00000000, 0x929b5e9000000000, + 0xafa2bbe600000000, 0x7b48c87d00000000, 0xd5d0710b00000000, + 0x013a029000000000, 0x3c03e7e600000000, 0xe8e9947d00000000, + 0x2cb4e60a00000000, 0xf85e959100000000, 0xc56770e700000000, + 0x118d037c00000000, 0xbf15ba0a00000000, 0x6bffc99100000000, + 0x56c62ce700000000, 0x822c5f7c00000000, 0x0af75f0a00000000, + 0xde1d2c9100000000, 0xe324c9e700000000, 0x37ceba7c00000000, + 0x9956030a00000000, 0x4dbc709100000000, 0x708595e700000000, + 0xa46fe67c00000000, 0xf83e710900000000, 0x2cd4029200000000, + 0x11ede7e400000000, 0xc507947f00000000, 0x6b9f2d0900000000, + 0xbf755e9200000000, 0x824cbbe400000000, 0x56a6c87f00000000, + 0xde7dc80900000000, 0x0a97bb9200000000, 0x37ae5ee400000000, + 0xe3442d7f00000000, 0x4ddc940900000000, 0x9936e79200000000, + 0xa40f02e400000000, 0x70e5717f00000000, 0xb4b8030800000000, + 0x6052709300000000, 0x5d6b95e500000000, 0x8981e67e00000000, + 0x27195f0800000000, 0xf3f32c9300000000, 0xcecac9e500000000, + 0x1a20ba7e00000000, 0x92fbba0800000000, 0x4611c99300000000, + 0x7b282ce500000000, 0xafc25f7e00000000, 0x015ae60800000000, + 0xd5b0959300000000, 0xe88970e500000000, 0x3c63037e00000000, + 0x502b5e0e00000000, 0x84c12d9500000000, 0xb9f8c8e300000000, + 0x6d12bb7800000000, 0xc38a020e00000000, 0x1760719500000000, + 0x2a5994e300000000, 0xfeb3e77800000000, 0x7668e70e00000000, + 0xa282949500000000, 0x9fbb71e300000000, 0x4b51027800000000, + 0xe5c9bb0e00000000, 0x3123c89500000000, 0x0c1a2de300000000, + 0xd8f05e7800000000, 0x1cad2c0f00000000, 0xc8475f9400000000, + 0xf57ebae200000000, 0x2194c97900000000, 0x8f0c700f00000000, + 0x5be6039400000000, 0x66dfe6e200000000, 0xb235957900000000, + 0x3aee950f00000000, 0xee04e69400000000, 0xd33d03e200000000, + 0x07d7707900000000, 0xa94fc90f00000000, 0x7da5ba9400000000, + 0x409c5fe200000000, 0x94762c7900000000, 0xc827bb0c00000000, + 0x1ccdc89700000000, 0x21f42de100000000, 0xf51e5e7a00000000, + 0x5b86e70c00000000, 0x8f6c949700000000, 0xb25571e100000000, + 0x66bf027a00000000, 0xee64020c00000000, 0x3a8e719700000000, + 0x07b794e100000000, 0xd35de77a00000000, 0x7dc55e0c00000000, + 0xa92f2d9700000000, 0x9416c8e100000000, 0x40fcbb7a00000000, + 0x84a1c90d00000000, 0x504bba9600000000, 0x6d725fe000000000, + 0xb9982c7b00000000, 0x1700950d00000000, 0xc3eae69600000000, + 0xfed303e000000000, 0x2a39707b00000000, 0xa2e2700d00000000, + 0x7608039600000000, 0x4b31e6e000000000, 0x9fdb957b00000000, + 0x31432c0d00000000, 0xe5a95f9600000000, 0xd890bae000000000, + 0x0c7ac97b00000000}, + {0x0000000000000000, 0x2765258100000000, 0x0fcc3bd900000000, + 0x28a91e5800000000, 0x5f9e066900000000, 0x78fb23e800000000, + 0x50523db000000000, 0x7737183100000000, 0xbe3c0dd200000000, + 0x9959285300000000, 0xb1f0360b00000000, 0x9695138a00000000, + 0xe1a20bbb00000000, 0xc6c72e3a00000000, 0xee6e306200000000, + 0xc90b15e300000000, 0x3d7f6b7f00000000, 0x1a1a4efe00000000, + 0x32b350a600000000, 0x15d6752700000000, 0x62e16d1600000000, + 0x4584489700000000, 0x6d2d56cf00000000, 0x4a48734e00000000, + 0x834366ad00000000, 0xa426432c00000000, 0x8c8f5d7400000000, + 0xabea78f500000000, 0xdcdd60c400000000, 0xfbb8454500000000, + 0xd3115b1d00000000, 0xf4747e9c00000000, 0x7afed6fe00000000, + 0x5d9bf37f00000000, 0x7532ed2700000000, 0x5257c8a600000000, + 0x2560d09700000000, 0x0205f51600000000, 0x2aaceb4e00000000, + 0x0dc9cecf00000000, 0xc4c2db2c00000000, 0xe3a7fead00000000, + 0xcb0ee0f500000000, 0xec6bc57400000000, 0x9b5cdd4500000000, + 0xbc39f8c400000000, 0x9490e69c00000000, 0xb3f5c31d00000000, + 0x4781bd8100000000, 0x60e4980000000000, 0x484d865800000000, + 0x6f28a3d900000000, 0x181fbbe800000000, 0x3f7a9e6900000000, + 0x17d3803100000000, 0x30b6a5b000000000, 0xf9bdb05300000000, + 0xded895d200000000, 0xf6718b8a00000000, 0xd114ae0b00000000, + 0xa623b63a00000000, 0x814693bb00000000, 0xa9ef8de300000000, + 0x8e8aa86200000000, 0xb5fadc2600000000, 0x929ff9a700000000, + 0xba36e7ff00000000, 0x9d53c27e00000000, 0xea64da4f00000000, + 0xcd01ffce00000000, 0xe5a8e19600000000, 0xc2cdc41700000000, + 0x0bc6d1f400000000, 0x2ca3f47500000000, 0x040aea2d00000000, + 0x236fcfac00000000, 0x5458d79d00000000, 0x733df21c00000000, + 0x5b94ec4400000000, 0x7cf1c9c500000000, 0x8885b75900000000, + 0xafe092d800000000, 0x87498c8000000000, 0xa02ca90100000000, + 0xd71bb13000000000, 0xf07e94b100000000, 0xd8d78ae900000000, + 0xffb2af6800000000, 0x36b9ba8b00000000, 0x11dc9f0a00000000, + 0x3975815200000000, 0x1e10a4d300000000, 0x6927bce200000000, + 0x4e42996300000000, 0x66eb873b00000000, 0x418ea2ba00000000, + 0xcf040ad800000000, 0xe8612f5900000000, 0xc0c8310100000000, + 0xe7ad148000000000, 0x909a0cb100000000, 0xb7ff293000000000, + 0x9f56376800000000, 0xb83312e900000000, 0x7138070a00000000, + 0x565d228b00000000, 0x7ef43cd300000000, 0x5991195200000000, + 0x2ea6016300000000, 0x09c324e200000000, 0x216a3aba00000000, + 0x060f1f3b00000000, 0xf27b61a700000000, 0xd51e442600000000, + 0xfdb75a7e00000000, 0xdad27fff00000000, 0xade567ce00000000, + 0x8a80424f00000000, 0xa2295c1700000000, 0x854c799600000000, + 0x4c476c7500000000, 0x6b2249f400000000, 0x438b57ac00000000, + 0x64ee722d00000000, 0x13d96a1c00000000, 0x34bc4f9d00000000, + 0x1c1551c500000000, 0x3b70744400000000, 0x6af5b94d00000000, + 0x4d909ccc00000000, 0x6539829400000000, 0x425ca71500000000, + 0x356bbf2400000000, 0x120e9aa500000000, 0x3aa784fd00000000, + 0x1dc2a17c00000000, 0xd4c9b49f00000000, 0xf3ac911e00000000, + 0xdb058f4600000000, 0xfc60aac700000000, 0x8b57b2f600000000, + 0xac32977700000000, 0x849b892f00000000, 0xa3feacae00000000, + 0x578ad23200000000, 0x70eff7b300000000, 0x5846e9eb00000000, + 0x7f23cc6a00000000, 0x0814d45b00000000, 0x2f71f1da00000000, + 0x07d8ef8200000000, 0x20bdca0300000000, 0xe9b6dfe000000000, + 0xced3fa6100000000, 0xe67ae43900000000, 0xc11fc1b800000000, + 0xb628d98900000000, 0x914dfc0800000000, 0xb9e4e25000000000, + 0x9e81c7d100000000, 0x100b6fb300000000, 0x376e4a3200000000, + 0x1fc7546a00000000, 0x38a271eb00000000, 0x4f9569da00000000, + 0x68f04c5b00000000, 0x4059520300000000, 0x673c778200000000, + 0xae37626100000000, 0x895247e000000000, 0xa1fb59b800000000, + 0x869e7c3900000000, 0xf1a9640800000000, 0xd6cc418900000000, + 0xfe655fd100000000, 0xd9007a5000000000, 0x2d7404cc00000000, + 0x0a11214d00000000, 0x22b83f1500000000, 0x05dd1a9400000000, + 0x72ea02a500000000, 0x558f272400000000, 0x7d26397c00000000, + 0x5a431cfd00000000, 0x9348091e00000000, 0xb42d2c9f00000000, + 0x9c8432c700000000, 0xbbe1174600000000, 0xccd60f7700000000, + 0xebb32af600000000, 0xc31a34ae00000000, 0xe47f112f00000000, + 0xdf0f656b00000000, 0xf86a40ea00000000, 0xd0c35eb200000000, + 0xf7a67b3300000000, 0x8091630200000000, 0xa7f4468300000000, + 0x8f5d58db00000000, 0xa8387d5a00000000, 0x613368b900000000, + 0x46564d3800000000, 0x6eff536000000000, 0x499a76e100000000, + 0x3ead6ed000000000, 0x19c84b5100000000, 0x3161550900000000, + 0x1604708800000000, 0xe2700e1400000000, 0xc5152b9500000000, + 0xedbc35cd00000000, 0xcad9104c00000000, 0xbdee087d00000000, + 0x9a8b2dfc00000000, 0xb22233a400000000, 0x9547162500000000, + 0x5c4c03c600000000, 0x7b29264700000000, 0x5380381f00000000, + 0x74e51d9e00000000, 0x03d205af00000000, 0x24b7202e00000000, + 0x0c1e3e7600000000, 0x2b7b1bf700000000, 0xa5f1b39500000000, + 0x8294961400000000, 0xaa3d884c00000000, 0x8d58adcd00000000, + 0xfa6fb5fc00000000, 0xdd0a907d00000000, 0xf5a38e2500000000, + 0xd2c6aba400000000, 0x1bcdbe4700000000, 0x3ca89bc600000000, + 0x1401859e00000000, 0x3364a01f00000000, 0x4453b82e00000000, + 0x63369daf00000000, 0x4b9f83f700000000, 0x6cfaa67600000000, + 0x988ed8ea00000000, 0xbfebfd6b00000000, 0x9742e33300000000, + 0xb027c6b200000000, 0xc710de8300000000, 0xe075fb0200000000, + 0xc8dce55a00000000, 0xefb9c0db00000000, 0x26b2d53800000000, + 0x01d7f0b900000000, 0x297eeee100000000, 0x0e1bcb6000000000, + 0x792cd35100000000, 0x5e49f6d000000000, 0x76e0e88800000000, + 0x5185cd0900000000}}; + +#else /* W == 4 */ + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0x9ba54c6f, 0xec3b9e9f, 0x779ed2f0, 0x03063b7f, + 0x98a37710, 0xef3da5e0, 0x7498e98f, 0x060c76fe, 0x9da93a91, + 0xea37e861, 0x7192a40e, 0x050a4d81, 0x9eaf01ee, 0xe931d31e, + 0x72949f71, 0x0c18edfc, 0x97bda193, 0xe0237363, 0x7b863f0c, + 0x0f1ed683, 0x94bb9aec, 0xe325481c, 0x78800473, 0x0a149b02, + 0x91b1d76d, 0xe62f059d, 0x7d8a49f2, 0x0912a07d, 0x92b7ec12, + 0xe5293ee2, 0x7e8c728d, 0x1831dbf8, 0x83949797, 0xf40a4567, + 0x6faf0908, 0x1b37e087, 0x8092ace8, 0xf70c7e18, 0x6ca93277, + 0x1e3dad06, 0x8598e169, 0xf2063399, 0x69a37ff6, 0x1d3b9679, + 0x869eda16, 0xf10008e6, 0x6aa54489, 0x14293604, 0x8f8c7a6b, + 0xf812a89b, 0x63b7e4f4, 0x172f0d7b, 0x8c8a4114, 0xfb1493e4, + 0x60b1df8b, 0x122540fa, 0x89800c95, 0xfe1ede65, 0x65bb920a, + 0x11237b85, 0x8a8637ea, 0xfd18e51a, 0x66bda975, 0x3063b7f0, + 0xabc6fb9f, 0xdc58296f, 0x47fd6500, 0x33658c8f, 0xa8c0c0e0, + 0xdf5e1210, 0x44fb5e7f, 0x366fc10e, 0xadca8d61, 0xda545f91, + 0x41f113fe, 0x3569fa71, 0xaeccb61e, 0xd95264ee, 0x42f72881, + 0x3c7b5a0c, 0xa7de1663, 0xd040c493, 0x4be588fc, 0x3f7d6173, + 0xa4d82d1c, 0xd346ffec, 0x48e3b383, 0x3a772cf2, 0xa1d2609d, + 0xd64cb26d, 0x4de9fe02, 0x3971178d, 0xa2d45be2, 0xd54a8912, + 0x4eefc57d, 0x28526c08, 0xb3f72067, 0xc469f297, 0x5fccbef8, + 0x2b545777, 0xb0f11b18, 0xc76fc9e8, 0x5cca8587, 0x2e5e1af6, + 0xb5fb5699, 0xc2658469, 0x59c0c806, 0x2d582189, 0xb6fd6de6, + 0xc163bf16, 0x5ac6f379, 0x244a81f4, 0xbfefcd9b, 0xc8711f6b, + 0x53d45304, 0x274cba8b, 0xbce9f6e4, 0xcb772414, 0x50d2687b, + 0x2246f70a, 0xb9e3bb65, 0xce7d6995, 0x55d825fa, 0x2140cc75, + 0xbae5801a, 0xcd7b52ea, 0x56de1e85, 0x60c76fe0, 0xfb62238f, + 0x8cfcf17f, 0x1759bd10, 0x63c1549f, 0xf86418f0, 0x8ffaca00, + 0x145f866f, 0x66cb191e, 0xfd6e5571, 0x8af08781, 0x1155cbee, + 0x65cd2261, 0xfe686e0e, 0x89f6bcfe, 0x1253f091, 0x6cdf821c, + 0xf77ace73, 0x80e41c83, 0x1b4150ec, 0x6fd9b963, 0xf47cf50c, + 0x83e227fc, 0x18476b93, 0x6ad3f4e2, 0xf176b88d, 0x86e86a7d, + 0x1d4d2612, 0x69d5cf9d, 0xf27083f2, 0x85ee5102, 0x1e4b1d6d, + 0x78f6b418, 0xe353f877, 0x94cd2a87, 0x0f6866e8, 0x7bf08f67, + 0xe055c308, 0x97cb11f8, 0x0c6e5d97, 0x7efac2e6, 0xe55f8e89, + 0x92c15c79, 0x09641016, 0x7dfcf999, 0xe659b5f6, 0x91c76706, + 0x0a622b69, 0x74ee59e4, 0xef4b158b, 0x98d5c77b, 0x03708b14, + 0x77e8629b, 0xec4d2ef4, 0x9bd3fc04, 0x0076b06b, 0x72e22f1a, + 0xe9476375, 0x9ed9b185, 0x057cfdea, 0x71e41465, 0xea41580a, + 0x9ddf8afa, 0x067ac695, 0x50a4d810, 0xcb01947f, 0xbc9f468f, + 0x273a0ae0, 0x53a2e36f, 0xc807af00, 0xbf997df0, 0x243c319f, + 0x56a8aeee, 0xcd0de281, 0xba933071, 0x21367c1e, 0x55ae9591, + 0xce0bd9fe, 0xb9950b0e, 0x22304761, 0x5cbc35ec, 0xc7197983, + 0xb087ab73, 0x2b22e71c, 0x5fba0e93, 0xc41f42fc, 0xb381900c, + 0x2824dc63, 0x5ab04312, 0xc1150f7d, 0xb68bdd8d, 0x2d2e91e2, + 0x59b6786d, 0xc2133402, 0xb58de6f2, 0x2e28aa9d, 0x489503e8, + 0xd3304f87, 0xa4ae9d77, 0x3f0bd118, 0x4b933897, 0xd03674f8, + 0xa7a8a608, 0x3c0dea67, 0x4e997516, 0xd53c3979, 0xa2a2eb89, + 0x3907a7e6, 0x4d9f4e69, 0xd63a0206, 0xa1a4d0f6, 0x3a019c99, + 0x448dee14, 0xdf28a27b, 0xa8b6708b, 0x33133ce4, 0x478bd56b, + 0xdc2e9904, 0xabb04bf4, 0x3015079b, 0x428198ea, 0xd924d485, + 0xaeba0675, 0x351f4a1a, 0x4187a395, 0xda22effa, 0xadbc3d0a, + 0x36197165}, + {0x00000000, 0xc18edfc0, 0x586cb9c1, 0x99e26601, 0xb0d97382, + 0x7157ac42, 0xe8b5ca43, 0x293b1583, 0xbac3e145, 0x7b4d3e85, + 0xe2af5884, 0x23218744, 0x0a1a92c7, 0xcb944d07, 0x52762b06, + 0x93f8f4c6, 0xaef6c4cb, 0x6f781b0b, 0xf69a7d0a, 0x3714a2ca, + 0x1e2fb749, 0xdfa16889, 0x46430e88, 0x87cdd148, 0x1435258e, + 0xd5bbfa4e, 0x4c599c4f, 0x8dd7438f, 0xa4ec560c, 0x656289cc, + 0xfc80efcd, 0x3d0e300d, 0x869c8fd7, 0x47125017, 0xdef03616, + 0x1f7ee9d6, 0x3645fc55, 0xf7cb2395, 0x6e294594, 0xafa79a54, + 0x3c5f6e92, 0xfdd1b152, 0x6433d753, 0xa5bd0893, 0x8c861d10, + 0x4d08c2d0, 0xd4eaa4d1, 0x15647b11, 0x286a4b1c, 0xe9e494dc, + 0x7006f2dd, 0xb1882d1d, 0x98b3389e, 0x593de75e, 0xc0df815f, + 0x01515e9f, 0x92a9aa59, 0x53277599, 0xcac51398, 0x0b4bcc58, + 0x2270d9db, 0xe3fe061b, 0x7a1c601a, 0xbb92bfda, 0xd64819ef, + 0x17c6c62f, 0x8e24a02e, 0x4faa7fee, 0x66916a6d, 0xa71fb5ad, + 0x3efdd3ac, 0xff730c6c, 0x6c8bf8aa, 0xad05276a, 0x34e7416b, + 0xf5699eab, 0xdc528b28, 0x1ddc54e8, 0x843e32e9, 0x45b0ed29, + 0x78bedd24, 0xb93002e4, 0x20d264e5, 0xe15cbb25, 0xc867aea6, + 0x09e97166, 0x900b1767, 0x5185c8a7, 0xc27d3c61, 0x03f3e3a1, + 0x9a1185a0, 0x5b9f5a60, 0x72a44fe3, 0xb32a9023, 0x2ac8f622, + 0xeb4629e2, 0x50d49638, 0x915a49f8, 0x08b82ff9, 0xc936f039, + 0xe00de5ba, 0x21833a7a, 0xb8615c7b, 0x79ef83bb, 0xea17777d, + 0x2b99a8bd, 0xb27bcebc, 0x73f5117c, 0x5ace04ff, 0x9b40db3f, + 0x02a2bd3e, 0xc32c62fe, 0xfe2252f3, 0x3fac8d33, 0xa64eeb32, + 0x67c034f2, 0x4efb2171, 0x8f75feb1, 0x169798b0, 0xd7194770, + 0x44e1b3b6, 0x856f6c76, 0x1c8d0a77, 0xdd03d5b7, 0xf438c034, + 0x35b61ff4, 0xac5479f5, 0x6ddaa635, 0x77e1359f, 0xb66fea5f, + 0x2f8d8c5e, 0xee03539e, 0xc738461d, 0x06b699dd, 0x9f54ffdc, + 0x5eda201c, 0xcd22d4da, 0x0cac0b1a, 0x954e6d1b, 0x54c0b2db, + 0x7dfba758, 0xbc757898, 0x25971e99, 0xe419c159, 0xd917f154, + 0x18992e94, 0x817b4895, 0x40f59755, 0x69ce82d6, 0xa8405d16, + 0x31a23b17, 0xf02ce4d7, 0x63d41011, 0xa25acfd1, 0x3bb8a9d0, + 0xfa367610, 0xd30d6393, 0x1283bc53, 0x8b61da52, 0x4aef0592, + 0xf17dba48, 0x30f36588, 0xa9110389, 0x689fdc49, 0x41a4c9ca, + 0x802a160a, 0x19c8700b, 0xd846afcb, 0x4bbe5b0d, 0x8a3084cd, + 0x13d2e2cc, 0xd25c3d0c, 0xfb67288f, 0x3ae9f74f, 0xa30b914e, + 0x62854e8e, 0x5f8b7e83, 0x9e05a143, 0x07e7c742, 0xc6691882, + 0xef520d01, 0x2edcd2c1, 0xb73eb4c0, 0x76b06b00, 0xe5489fc6, + 0x24c64006, 0xbd242607, 0x7caaf9c7, 0x5591ec44, 0x941f3384, + 0x0dfd5585, 0xcc738a45, 0xa1a92c70, 0x6027f3b0, 0xf9c595b1, + 0x384b4a71, 0x11705ff2, 0xd0fe8032, 0x491ce633, 0x889239f3, + 0x1b6acd35, 0xdae412f5, 0x430674f4, 0x8288ab34, 0xabb3beb7, + 0x6a3d6177, 0xf3df0776, 0x3251d8b6, 0x0f5fe8bb, 0xced1377b, + 0x5733517a, 0x96bd8eba, 0xbf869b39, 0x7e0844f9, 0xe7ea22f8, + 0x2664fd38, 0xb59c09fe, 0x7412d63e, 0xedf0b03f, 0x2c7e6fff, + 0x05457a7c, 0xc4cba5bc, 0x5d29c3bd, 0x9ca71c7d, 0x2735a3a7, + 0xe6bb7c67, 0x7f591a66, 0xbed7c5a6, 0x97ecd025, 0x56620fe5, + 0xcf8069e4, 0x0e0eb624, 0x9df642e2, 0x5c789d22, 0xc59afb23, + 0x041424e3, 0x2d2f3160, 0xeca1eea0, 0x754388a1, 0xb4cd5761, + 0x89c3676c, 0x484db8ac, 0xd1afdead, 0x1021016d, 0x391a14ee, + 0xf894cb2e, 0x6176ad2f, 0xa0f872ef, 0x33008629, 0xf28e59e9, + 0x6b6c3fe8, 0xaae2e028, 0x83d9f5ab, 0x42572a6b, 0xdbb54c6a, + 0x1a3b93aa}, + {0x00000000, 0xefc26b3e, 0x04f5d03d, 0xeb37bb03, 0x09eba07a, + 0xe629cb44, 0x0d1e7047, 0xe2dc1b79, 0x13d740f4, 0xfc152bca, + 0x172290c9, 0xf8e0fbf7, 0x1a3ce08e, 0xf5fe8bb0, 0x1ec930b3, + 0xf10b5b8d, 0x27ae81e8, 0xc86cead6, 0x235b51d5, 0xcc993aeb, + 0x2e452192, 0xc1874aac, 0x2ab0f1af, 0xc5729a91, 0x3479c11c, + 0xdbbbaa22, 0x308c1121, 0xdf4e7a1f, 0x3d926166, 0xd2500a58, + 0x3967b15b, 0xd6a5da65, 0x4f5d03d0, 0xa09f68ee, 0x4ba8d3ed, + 0xa46ab8d3, 0x46b6a3aa, 0xa974c894, 0x42437397, 0xad8118a9, + 0x5c8a4324, 0xb348281a, 0x587f9319, 0xb7bdf827, 0x5561e35e, + 0xbaa38860, 0x51943363, 0xbe56585d, 0x68f38238, 0x8731e906, + 0x6c065205, 0x83c4393b, 0x61182242, 0x8eda497c, 0x65edf27f, + 0x8a2f9941, 0x7b24c2cc, 0x94e6a9f2, 0x7fd112f1, 0x901379cf, + 0x72cf62b6, 0x9d0d0988, 0x763ab28b, 0x99f8d9b5, 0x9eba07a0, + 0x71786c9e, 0x9a4fd79d, 0x758dbca3, 0x9751a7da, 0x7893cce4, + 0x93a477e7, 0x7c661cd9, 0x8d6d4754, 0x62af2c6a, 0x89989769, + 0x665afc57, 0x8486e72e, 0x6b448c10, 0x80733713, 0x6fb15c2d, + 0xb9148648, 0x56d6ed76, 0xbde15675, 0x52233d4b, 0xb0ff2632, + 0x5f3d4d0c, 0xb40af60f, 0x5bc89d31, 0xaac3c6bc, 0x4501ad82, + 0xae361681, 0x41f47dbf, 0xa32866c6, 0x4cea0df8, 0xa7ddb6fb, + 0x481fddc5, 0xd1e70470, 0x3e256f4e, 0xd512d44d, 0x3ad0bf73, + 0xd80ca40a, 0x37cecf34, 0xdcf97437, 0x333b1f09, 0xc2304484, + 0x2df22fba, 0xc6c594b9, 0x2907ff87, 0xcbdbe4fe, 0x24198fc0, + 0xcf2e34c3, 0x20ec5ffd, 0xf6498598, 0x198beea6, 0xf2bc55a5, + 0x1d7e3e9b, 0xffa225e2, 0x10604edc, 0xfb57f5df, 0x14959ee1, + 0xe59ec56c, 0x0a5cae52, 0xe16b1551, 0x0ea97e6f, 0xec756516, + 0x03b70e28, 0xe880b52b, 0x0742de15, 0xe6050901, 0x09c7623f, + 0xe2f0d93c, 0x0d32b202, 0xefeea97b, 0x002cc245, 0xeb1b7946, + 0x04d91278, 0xf5d249f5, 0x1a1022cb, 0xf12799c8, 0x1ee5f2f6, + 0xfc39e98f, 0x13fb82b1, 0xf8cc39b2, 0x170e528c, 0xc1ab88e9, + 0x2e69e3d7, 0xc55e58d4, 0x2a9c33ea, 0xc8402893, 0x278243ad, + 0xccb5f8ae, 0x23779390, 0xd27cc81d, 0x3dbea323, 0xd6891820, + 0x394b731e, 0xdb976867, 0x34550359, 0xdf62b85a, 0x30a0d364, + 0xa9580ad1, 0x469a61ef, 0xadaddaec, 0x426fb1d2, 0xa0b3aaab, + 0x4f71c195, 0xa4467a96, 0x4b8411a8, 0xba8f4a25, 0x554d211b, + 0xbe7a9a18, 0x51b8f126, 0xb364ea5f, 0x5ca68161, 0xb7913a62, + 0x5853515c, 0x8ef68b39, 0x6134e007, 0x8a035b04, 0x65c1303a, + 0x871d2b43, 0x68df407d, 0x83e8fb7e, 0x6c2a9040, 0x9d21cbcd, + 0x72e3a0f3, 0x99d41bf0, 0x761670ce, 0x94ca6bb7, 0x7b080089, + 0x903fbb8a, 0x7ffdd0b4, 0x78bf0ea1, 0x977d659f, 0x7c4ade9c, + 0x9388b5a2, 0x7154aedb, 0x9e96c5e5, 0x75a17ee6, 0x9a6315d8, + 0x6b684e55, 0x84aa256b, 0x6f9d9e68, 0x805ff556, 0x6283ee2f, + 0x8d418511, 0x66763e12, 0x89b4552c, 0x5f118f49, 0xb0d3e477, + 0x5be45f74, 0xb426344a, 0x56fa2f33, 0xb938440d, 0x520fff0e, + 0xbdcd9430, 0x4cc6cfbd, 0xa304a483, 0x48331f80, 0xa7f174be, + 0x452d6fc7, 0xaaef04f9, 0x41d8bffa, 0xae1ad4c4, 0x37e20d71, + 0xd820664f, 0x3317dd4c, 0xdcd5b672, 0x3e09ad0b, 0xd1cbc635, + 0x3afc7d36, 0xd53e1608, 0x24354d85, 0xcbf726bb, 0x20c09db8, + 0xcf02f686, 0x2ddeedff, 0xc21c86c1, 0x292b3dc2, 0xc6e956fc, + 0x104c8c99, 0xff8ee7a7, 0x14b95ca4, 0xfb7b379a, 0x19a72ce3, + 0xf66547dd, 0x1d52fcde, 0xf29097e0, 0x039bcc6d, 0xec59a753, + 0x076e1c50, 0xe8ac776e, 0x0a706c17, 0xe5b20729, 0x0e85bc2a, + 0xe147d714}, + {0x00000000, 0x177b1443, 0x2ef62886, 0x398d3cc5, 0x5dec510c, + 0x4a97454f, 0x731a798a, 0x64616dc9, 0xbbd8a218, 0xaca3b65b, + 0x952e8a9e, 0x82559edd, 0xe634f314, 0xf14fe757, 0xc8c2db92, + 0xdfb9cfd1, 0xacc04271, 0xbbbb5632, 0x82366af7, 0x954d7eb4, + 0xf12c137d, 0xe657073e, 0xdfda3bfb, 0xc8a12fb8, 0x1718e069, + 0x0063f42a, 0x39eec8ef, 0x2e95dcac, 0x4af4b165, 0x5d8fa526, + 0x640299e3, 0x73798da0, 0x82f182a3, 0x958a96e0, 0xac07aa25, + 0xbb7cbe66, 0xdf1dd3af, 0xc866c7ec, 0xf1ebfb29, 0xe690ef6a, + 0x392920bb, 0x2e5234f8, 0x17df083d, 0x00a41c7e, 0x64c571b7, + 0x73be65f4, 0x4a335931, 0x5d484d72, 0x2e31c0d2, 0x394ad491, + 0x00c7e854, 0x17bcfc17, 0x73dd91de, 0x64a6859d, 0x5d2bb958, + 0x4a50ad1b, 0x95e962ca, 0x82927689, 0xbb1f4a4c, 0xac645e0f, + 0xc80533c6, 0xdf7e2785, 0xe6f31b40, 0xf1880f03, 0xde920307, + 0xc9e91744, 0xf0642b81, 0xe71f3fc2, 0x837e520b, 0x94054648, + 0xad887a8d, 0xbaf36ece, 0x654aa11f, 0x7231b55c, 0x4bbc8999, + 0x5cc79dda, 0x38a6f013, 0x2fdde450, 0x1650d895, 0x012bccd6, + 0x72524176, 0x65295535, 0x5ca469f0, 0x4bdf7db3, 0x2fbe107a, + 0x38c50439, 0x014838fc, 0x16332cbf, 0xc98ae36e, 0xdef1f72d, + 0xe77ccbe8, 0xf007dfab, 0x9466b262, 0x831da621, 0xba909ae4, + 0xadeb8ea7, 0x5c6381a4, 0x4b1895e7, 0x7295a922, 0x65eebd61, + 0x018fd0a8, 0x16f4c4eb, 0x2f79f82e, 0x3802ec6d, 0xe7bb23bc, + 0xf0c037ff, 0xc94d0b3a, 0xde361f79, 0xba5772b0, 0xad2c66f3, + 0x94a15a36, 0x83da4e75, 0xf0a3c3d5, 0xe7d8d796, 0xde55eb53, + 0xc92eff10, 0xad4f92d9, 0xba34869a, 0x83b9ba5f, 0x94c2ae1c, + 0x4b7b61cd, 0x5c00758e, 0x658d494b, 0x72f65d08, 0x169730c1, + 0x01ec2482, 0x38611847, 0x2f1a0c04, 0x6655004f, 0x712e140c, + 0x48a328c9, 0x5fd83c8a, 0x3bb95143, 0x2cc24500, 0x154f79c5, + 0x02346d86, 0xdd8da257, 0xcaf6b614, 0xf37b8ad1, 0xe4009e92, + 0x8061f35b, 0x971ae718, 0xae97dbdd, 0xb9eccf9e, 0xca95423e, + 0xddee567d, 0xe4636ab8, 0xf3187efb, 0x97791332, 0x80020771, + 0xb98f3bb4, 0xaef42ff7, 0x714de026, 0x6636f465, 0x5fbbc8a0, + 0x48c0dce3, 0x2ca1b12a, 0x3bdaa569, 0x025799ac, 0x152c8def, + 0xe4a482ec, 0xf3df96af, 0xca52aa6a, 0xdd29be29, 0xb948d3e0, + 0xae33c7a3, 0x97befb66, 0x80c5ef25, 0x5f7c20f4, 0x480734b7, + 0x718a0872, 0x66f11c31, 0x029071f8, 0x15eb65bb, 0x2c66597e, + 0x3b1d4d3d, 0x4864c09d, 0x5f1fd4de, 0x6692e81b, 0x71e9fc58, + 0x15889191, 0x02f385d2, 0x3b7eb917, 0x2c05ad54, 0xf3bc6285, + 0xe4c776c6, 0xdd4a4a03, 0xca315e40, 0xae503389, 0xb92b27ca, + 0x80a61b0f, 0x97dd0f4c, 0xb8c70348, 0xafbc170b, 0x96312bce, + 0x814a3f8d, 0xe52b5244, 0xf2504607, 0xcbdd7ac2, 0xdca66e81, + 0x031fa150, 0x1464b513, 0x2de989d6, 0x3a929d95, 0x5ef3f05c, + 0x4988e41f, 0x7005d8da, 0x677ecc99, 0x14074139, 0x037c557a, + 0x3af169bf, 0x2d8a7dfc, 0x49eb1035, 0x5e900476, 0x671d38b3, + 0x70662cf0, 0xafdfe321, 0xb8a4f762, 0x8129cba7, 0x9652dfe4, + 0xf233b22d, 0xe548a66e, 0xdcc59aab, 0xcbbe8ee8, 0x3a3681eb, + 0x2d4d95a8, 0x14c0a96d, 0x03bbbd2e, 0x67dad0e7, 0x70a1c4a4, + 0x492cf861, 0x5e57ec22, 0x81ee23f3, 0x969537b0, 0xaf180b75, + 0xb8631f36, 0xdc0272ff, 0xcb7966bc, 0xf2f45a79, 0xe58f4e3a, + 0x96f6c39a, 0x818dd7d9, 0xb800eb1c, 0xaf7bff5f, 0xcb1a9296, + 0xdc6186d5, 0xe5ecba10, 0xf297ae53, 0x2d2e6182, 0x3a5575c1, + 0x03d84904, 0x14a35d47, 0x70c2308e, 0x67b924cd, 0x5e341808, + 0x494f0c4b}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x00000000, 0x43147b17, 0x8628f62e, 0xc53c8d39, 0x0c51ec5d, + 0x4f45974a, 0x8a791a73, 0xc96d6164, 0x18a2d8bb, 0x5bb6a3ac, + 0x9e8a2e95, 0xdd9e5582, 0x14f334e6, 0x57e74ff1, 0x92dbc2c8, + 0xd1cfb9df, 0x7142c0ac, 0x3256bbbb, 0xf76a3682, 0xb47e4d95, + 0x7d132cf1, 0x3e0757e6, 0xfb3bdadf, 0xb82fa1c8, 0x69e01817, + 0x2af46300, 0xefc8ee39, 0xacdc952e, 0x65b1f44a, 0x26a58f5d, + 0xe3990264, 0xa08d7973, 0xa382f182, 0xe0968a95, 0x25aa07ac, + 0x66be7cbb, 0xafd31ddf, 0xecc766c8, 0x29fbebf1, 0x6aef90e6, + 0xbb202939, 0xf834522e, 0x3d08df17, 0x7e1ca400, 0xb771c564, + 0xf465be73, 0x3159334a, 0x724d485d, 0xd2c0312e, 0x91d44a39, + 0x54e8c700, 0x17fcbc17, 0xde91dd73, 0x9d85a664, 0x58b92b5d, + 0x1bad504a, 0xca62e995, 0x89769282, 0x4c4a1fbb, 0x0f5e64ac, + 0xc63305c8, 0x85277edf, 0x401bf3e6, 0x030f88f1, 0x070392de, + 0x4417e9c9, 0x812b64f0, 0xc23f1fe7, 0x0b527e83, 0x48460594, + 0x8d7a88ad, 0xce6ef3ba, 0x1fa14a65, 0x5cb53172, 0x9989bc4b, + 0xda9dc75c, 0x13f0a638, 0x50e4dd2f, 0x95d85016, 0xd6cc2b01, + 0x76415272, 0x35552965, 0xf069a45c, 0xb37ddf4b, 0x7a10be2f, + 0x3904c538, 0xfc384801, 0xbf2c3316, 0x6ee38ac9, 0x2df7f1de, + 0xe8cb7ce7, 0xabdf07f0, 0x62b26694, 0x21a61d83, 0xe49a90ba, + 0xa78eebad, 0xa481635c, 0xe795184b, 0x22a99572, 0x61bdee65, + 0xa8d08f01, 0xebc4f416, 0x2ef8792f, 0x6dec0238, 0xbc23bbe7, + 0xff37c0f0, 0x3a0b4dc9, 0x791f36de, 0xb07257ba, 0xf3662cad, + 0x365aa194, 0x754eda83, 0xd5c3a3f0, 0x96d7d8e7, 0x53eb55de, + 0x10ff2ec9, 0xd9924fad, 0x9a8634ba, 0x5fbab983, 0x1caec294, + 0xcd617b4b, 0x8e75005c, 0x4b498d65, 0x085df672, 0xc1309716, + 0x8224ec01, 0x47186138, 0x040c1a2f, 0x4f005566, 0x0c142e71, + 0xc928a348, 0x8a3cd85f, 0x4351b93b, 0x0045c22c, 0xc5794f15, + 0x866d3402, 0x57a28ddd, 0x14b6f6ca, 0xd18a7bf3, 0x929e00e4, + 0x5bf36180, 0x18e71a97, 0xdddb97ae, 0x9ecfecb9, 0x3e4295ca, + 0x7d56eedd, 0xb86a63e4, 0xfb7e18f3, 0x32137997, 0x71070280, + 0xb43b8fb9, 0xf72ff4ae, 0x26e04d71, 0x65f43666, 0xa0c8bb5f, + 0xe3dcc048, 0x2ab1a12c, 0x69a5da3b, 0xac995702, 0xef8d2c15, + 0xec82a4e4, 0xaf96dff3, 0x6aaa52ca, 0x29be29dd, 0xe0d348b9, + 0xa3c733ae, 0x66fbbe97, 0x25efc580, 0xf4207c5f, 0xb7340748, + 0x72088a71, 0x311cf166, 0xf8719002, 0xbb65eb15, 0x7e59662c, + 0x3d4d1d3b, 0x9dc06448, 0xded41f5f, 0x1be89266, 0x58fce971, + 0x91918815, 0xd285f302, 0x17b97e3b, 0x54ad052c, 0x8562bcf3, + 0xc676c7e4, 0x034a4add, 0x405e31ca, 0x893350ae, 0xca272bb9, + 0x0f1ba680, 0x4c0fdd97, 0x4803c7b8, 0x0b17bcaf, 0xce2b3196, + 0x8d3f4a81, 0x44522be5, 0x074650f2, 0xc27addcb, 0x816ea6dc, + 0x50a11f03, 0x13b56414, 0xd689e92d, 0x959d923a, 0x5cf0f35e, + 0x1fe48849, 0xdad80570, 0x99cc7e67, 0x39410714, 0x7a557c03, + 0xbf69f13a, 0xfc7d8a2d, 0x3510eb49, 0x7604905e, 0xb3381d67, + 0xf02c6670, 0x21e3dfaf, 0x62f7a4b8, 0xa7cb2981, 0xe4df5296, + 0x2db233f2, 0x6ea648e5, 0xab9ac5dc, 0xe88ebecb, 0xeb81363a, + 0xa8954d2d, 0x6da9c014, 0x2ebdbb03, 0xe7d0da67, 0xa4c4a170, + 0x61f82c49, 0x22ec575e, 0xf323ee81, 0xb0379596, 0x750b18af, + 0x361f63b8, 0xff7202dc, 0xbc6679cb, 0x795af4f2, 0x3a4e8fe5, + 0x9ac3f696, 0xd9d78d81, 0x1ceb00b8, 0x5fff7baf, 0x96921acb, + 0xd58661dc, 0x10baece5, 0x53ae97f2, 0x82612e2d, 0xc175553a, + 0x0449d803, 0x475da314, 0x8e30c270, 0xcd24b967, 0x0818345e, + 0x4b0c4f49}, + {0x00000000, 0x3e6bc2ef, 0x3dd0f504, 0x03bb37eb, 0x7aa0eb09, + 0x44cb29e6, 0x47701e0d, 0x791bdce2, 0xf440d713, 0xca2b15fc, + 0xc9902217, 0xf7fbe0f8, 0x8ee03c1a, 0xb08bfef5, 0xb330c91e, + 0x8d5b0bf1, 0xe881ae27, 0xd6ea6cc8, 0xd5515b23, 0xeb3a99cc, + 0x9221452e, 0xac4a87c1, 0xaff1b02a, 0x919a72c5, 0x1cc17934, + 0x22aabbdb, 0x21118c30, 0x1f7a4edf, 0x6661923d, 0x580a50d2, + 0x5bb16739, 0x65daa5d6, 0xd0035d4f, 0xee689fa0, 0xedd3a84b, + 0xd3b86aa4, 0xaaa3b646, 0x94c874a9, 0x97734342, 0xa91881ad, + 0x24438a5c, 0x1a2848b3, 0x19937f58, 0x27f8bdb7, 0x5ee36155, + 0x6088a3ba, 0x63339451, 0x5d5856be, 0x3882f368, 0x06e93187, + 0x0552066c, 0x3b39c483, 0x42221861, 0x7c49da8e, 0x7ff2ed65, + 0x41992f8a, 0xccc2247b, 0xf2a9e694, 0xf112d17f, 0xcf791390, + 0xb662cf72, 0x88090d9d, 0x8bb23a76, 0xb5d9f899, 0xa007ba9e, + 0x9e6c7871, 0x9dd74f9a, 0xa3bc8d75, 0xdaa75197, 0xe4cc9378, + 0xe777a493, 0xd91c667c, 0x54476d8d, 0x6a2caf62, 0x69979889, + 0x57fc5a66, 0x2ee78684, 0x108c446b, 0x13377380, 0x2d5cb16f, + 0x488614b9, 0x76edd656, 0x7556e1bd, 0x4b3d2352, 0x3226ffb0, + 0x0c4d3d5f, 0x0ff60ab4, 0x319dc85b, 0xbcc6c3aa, 0x82ad0145, + 0x811636ae, 0xbf7df441, 0xc66628a3, 0xf80dea4c, 0xfbb6dda7, + 0xc5dd1f48, 0x7004e7d1, 0x4e6f253e, 0x4dd412d5, 0x73bfd03a, + 0x0aa40cd8, 0x34cfce37, 0x3774f9dc, 0x091f3b33, 0x844430c2, + 0xba2ff22d, 0xb994c5c6, 0x87ff0729, 0xfee4dbcb, 0xc08f1924, + 0xc3342ecf, 0xfd5fec20, 0x988549f6, 0xa6ee8b19, 0xa555bcf2, + 0x9b3e7e1d, 0xe225a2ff, 0xdc4e6010, 0xdff557fb, 0xe19e9514, + 0x6cc59ee5, 0x52ae5c0a, 0x51156be1, 0x6f7ea90e, 0x166575ec, + 0x280eb703, 0x2bb580e8, 0x15de4207, 0x010905e6, 0x3f62c709, + 0x3cd9f0e2, 0x02b2320d, 0x7ba9eeef, 0x45c22c00, 0x46791beb, + 0x7812d904, 0xf549d2f5, 0xcb22101a, 0xc89927f1, 0xf6f2e51e, + 0x8fe939fc, 0xb182fb13, 0xb239ccf8, 0x8c520e17, 0xe988abc1, + 0xd7e3692e, 0xd4585ec5, 0xea339c2a, 0x932840c8, 0xad438227, + 0xaef8b5cc, 0x90937723, 0x1dc87cd2, 0x23a3be3d, 0x201889d6, + 0x1e734b39, 0x676897db, 0x59035534, 0x5ab862df, 0x64d3a030, + 0xd10a58a9, 0xef619a46, 0xecdaadad, 0xd2b16f42, 0xabaab3a0, + 0x95c1714f, 0x967a46a4, 0xa811844b, 0x254a8fba, 0x1b214d55, + 0x189a7abe, 0x26f1b851, 0x5fea64b3, 0x6181a65c, 0x623a91b7, + 0x5c515358, 0x398bf68e, 0x07e03461, 0x045b038a, 0x3a30c165, + 0x432b1d87, 0x7d40df68, 0x7efbe883, 0x40902a6c, 0xcdcb219d, + 0xf3a0e372, 0xf01bd499, 0xce701676, 0xb76bca94, 0x8900087b, + 0x8abb3f90, 0xb4d0fd7f, 0xa10ebf78, 0x9f657d97, 0x9cde4a7c, + 0xa2b58893, 0xdbae5471, 0xe5c5969e, 0xe67ea175, 0xd815639a, + 0x554e686b, 0x6b25aa84, 0x689e9d6f, 0x56f55f80, 0x2fee8362, + 0x1185418d, 0x123e7666, 0x2c55b489, 0x498f115f, 0x77e4d3b0, + 0x745fe45b, 0x4a3426b4, 0x332ffa56, 0x0d4438b9, 0x0eff0f52, + 0x3094cdbd, 0xbdcfc64c, 0x83a404a3, 0x801f3348, 0xbe74f1a7, + 0xc76f2d45, 0xf904efaa, 0xfabfd841, 0xc4d41aae, 0x710de237, + 0x4f6620d8, 0x4cdd1733, 0x72b6d5dc, 0x0bad093e, 0x35c6cbd1, + 0x367dfc3a, 0x08163ed5, 0x854d3524, 0xbb26f7cb, 0xb89dc020, + 0x86f602cf, 0xffedde2d, 0xc1861cc2, 0xc23d2b29, 0xfc56e9c6, + 0x998c4c10, 0xa7e78eff, 0xa45cb914, 0x9a377bfb, 0xe32ca719, + 0xdd4765f6, 0xdefc521d, 0xe09790f2, 0x6dcc9b03, 0x53a759ec, + 0x501c6e07, 0x6e77ace8, 0x176c700a, 0x2907b2e5, 0x2abc850e, + 0x14d747e1}, + {0x00000000, 0xc0df8ec1, 0xc1b96c58, 0x0166e299, 0x8273d9b0, + 0x42ac5771, 0x43cab5e8, 0x83153b29, 0x45e1c3ba, 0x853e4d7b, + 0x8458afe2, 0x44872123, 0xc7921a0a, 0x074d94cb, 0x062b7652, + 0xc6f4f893, 0xcbc4f6ae, 0x0b1b786f, 0x0a7d9af6, 0xcaa21437, + 0x49b72f1e, 0x8968a1df, 0x880e4346, 0x48d1cd87, 0x8e253514, + 0x4efabbd5, 0x4f9c594c, 0x8f43d78d, 0x0c56eca4, 0xcc896265, + 0xcdef80fc, 0x0d300e3d, 0xd78f9c86, 0x17501247, 0x1636f0de, + 0xd6e97e1f, 0x55fc4536, 0x9523cbf7, 0x9445296e, 0x549aa7af, + 0x926e5f3c, 0x52b1d1fd, 0x53d73364, 0x9308bda5, 0x101d868c, + 0xd0c2084d, 0xd1a4ead4, 0x117b6415, 0x1c4b6a28, 0xdc94e4e9, + 0xddf20670, 0x1d2d88b1, 0x9e38b398, 0x5ee73d59, 0x5f81dfc0, + 0x9f5e5101, 0x59aaa992, 0x99752753, 0x9813c5ca, 0x58cc4b0b, + 0xdbd97022, 0x1b06fee3, 0x1a601c7a, 0xdabf92bb, 0xef1948d6, + 0x2fc6c617, 0x2ea0248e, 0xee7faa4f, 0x6d6a9166, 0xadb51fa7, + 0xacd3fd3e, 0x6c0c73ff, 0xaaf88b6c, 0x6a2705ad, 0x6b41e734, + 0xab9e69f5, 0x288b52dc, 0xe854dc1d, 0xe9323e84, 0x29edb045, + 0x24ddbe78, 0xe40230b9, 0xe564d220, 0x25bb5ce1, 0xa6ae67c8, + 0x6671e909, 0x67170b90, 0xa7c88551, 0x613c7dc2, 0xa1e3f303, + 0xa085119a, 0x605a9f5b, 0xe34fa472, 0x23902ab3, 0x22f6c82a, + 0xe22946eb, 0x3896d450, 0xf8495a91, 0xf92fb808, 0x39f036c9, + 0xbae50de0, 0x7a3a8321, 0x7b5c61b8, 0xbb83ef79, 0x7d7717ea, + 0xbda8992b, 0xbcce7bb2, 0x7c11f573, 0xff04ce5a, 0x3fdb409b, + 0x3ebda202, 0xfe622cc3, 0xf35222fe, 0x338dac3f, 0x32eb4ea6, + 0xf234c067, 0x7121fb4e, 0xb1fe758f, 0xb0989716, 0x704719d7, + 0xb6b3e144, 0x766c6f85, 0x770a8d1c, 0xb7d503dd, 0x34c038f4, + 0xf41fb635, 0xf57954ac, 0x35a6da6d, 0x9f35e177, 0x5fea6fb6, + 0x5e8c8d2f, 0x9e5303ee, 0x1d4638c7, 0xdd99b606, 0xdcff549f, + 0x1c20da5e, 0xdad422cd, 0x1a0bac0c, 0x1b6d4e95, 0xdbb2c054, + 0x58a7fb7d, 0x987875bc, 0x991e9725, 0x59c119e4, 0x54f117d9, + 0x942e9918, 0x95487b81, 0x5597f540, 0xd682ce69, 0x165d40a8, + 0x173ba231, 0xd7e42cf0, 0x1110d463, 0xd1cf5aa2, 0xd0a9b83b, + 0x107636fa, 0x93630dd3, 0x53bc8312, 0x52da618b, 0x9205ef4a, + 0x48ba7df1, 0x8865f330, 0x890311a9, 0x49dc9f68, 0xcac9a441, + 0x0a162a80, 0x0b70c819, 0xcbaf46d8, 0x0d5bbe4b, 0xcd84308a, + 0xcce2d213, 0x0c3d5cd2, 0x8f2867fb, 0x4ff7e93a, 0x4e910ba3, + 0x8e4e8562, 0x837e8b5f, 0x43a1059e, 0x42c7e707, 0x821869c6, + 0x010d52ef, 0xc1d2dc2e, 0xc0b43eb7, 0x006bb076, 0xc69f48e5, + 0x0640c624, 0x072624bd, 0xc7f9aa7c, 0x44ec9155, 0x84331f94, + 0x8555fd0d, 0x458a73cc, 0x702ca9a1, 0xb0f32760, 0xb195c5f9, + 0x714a4b38, 0xf25f7011, 0x3280fed0, 0x33e61c49, 0xf3399288, + 0x35cd6a1b, 0xf512e4da, 0xf4740643, 0x34ab8882, 0xb7beb3ab, + 0x77613d6a, 0x7607dff3, 0xb6d85132, 0xbbe85f0f, 0x7b37d1ce, + 0x7a513357, 0xba8ebd96, 0x399b86bf, 0xf944087e, 0xf822eae7, + 0x38fd6426, 0xfe099cb5, 0x3ed61274, 0x3fb0f0ed, 0xff6f7e2c, + 0x7c7a4505, 0xbca5cbc4, 0xbdc3295d, 0x7d1ca79c, 0xa7a33527, + 0x677cbbe6, 0x661a597f, 0xa6c5d7be, 0x25d0ec97, 0xe50f6256, + 0xe46980cf, 0x24b60e0e, 0xe242f69d, 0x229d785c, 0x23fb9ac5, + 0xe3241404, 0x60312f2d, 0xa0eea1ec, 0xa1884375, 0x6157cdb4, + 0x6c67c389, 0xacb84d48, 0xaddeafd1, 0x6d012110, 0xee141a39, + 0x2ecb94f8, 0x2fad7661, 0xef72f8a0, 0x29860033, 0xe9598ef2, + 0xe83f6c6b, 0x28e0e2aa, 0xabf5d983, 0x6b2a5742, 0x6a4cb5db, + 0xaa933b1a}, + {0x00000000, 0x6f4ca59b, 0x9f9e3bec, 0xf0d29e77, 0x7f3b0603, + 0x1077a398, 0xe0a53def, 0x8fe99874, 0xfe760c06, 0x913aa99d, + 0x61e837ea, 0x0ea49271, 0x814d0a05, 0xee01af9e, 0x1ed331e9, + 0x719f9472, 0xfced180c, 0x93a1bd97, 0x637323e0, 0x0c3f867b, + 0x83d61e0f, 0xec9abb94, 0x1c4825e3, 0x73048078, 0x029b140a, + 0x6dd7b191, 0x9d052fe6, 0xf2498a7d, 0x7da01209, 0x12ecb792, + 0xe23e29e5, 0x8d728c7e, 0xf8db3118, 0x97979483, 0x67450af4, + 0x0809af6f, 0x87e0371b, 0xe8ac9280, 0x187e0cf7, 0x7732a96c, + 0x06ad3d1e, 0x69e19885, 0x993306f2, 0xf67fa369, 0x79963b1d, + 0x16da9e86, 0xe60800f1, 0x8944a56a, 0x04362914, 0x6b7a8c8f, + 0x9ba812f8, 0xf4e4b763, 0x7b0d2f17, 0x14418a8c, 0xe49314fb, + 0x8bdfb160, 0xfa402512, 0x950c8089, 0x65de1efe, 0x0a92bb65, + 0x857b2311, 0xea37868a, 0x1ae518fd, 0x75a9bd66, 0xf0b76330, + 0x9ffbc6ab, 0x6f2958dc, 0x0065fd47, 0x8f8c6533, 0xe0c0c0a8, + 0x10125edf, 0x7f5efb44, 0x0ec16f36, 0x618dcaad, 0x915f54da, + 0xfe13f141, 0x71fa6935, 0x1eb6ccae, 0xee6452d9, 0x8128f742, + 0x0c5a7b3c, 0x6316dea7, 0x93c440d0, 0xfc88e54b, 0x73617d3f, + 0x1c2dd8a4, 0xecff46d3, 0x83b3e348, 0xf22c773a, 0x9d60d2a1, + 0x6db24cd6, 0x02fee94d, 0x8d177139, 0xe25bd4a2, 0x12894ad5, + 0x7dc5ef4e, 0x086c5228, 0x6720f7b3, 0x97f269c4, 0xf8becc5f, + 0x7757542b, 0x181bf1b0, 0xe8c96fc7, 0x8785ca5c, 0xf61a5e2e, + 0x9956fbb5, 0x698465c2, 0x06c8c059, 0x8921582d, 0xe66dfdb6, + 0x16bf63c1, 0x79f3c65a, 0xf4814a24, 0x9bcdefbf, 0x6b1f71c8, + 0x0453d453, 0x8bba4c27, 0xe4f6e9bc, 0x142477cb, 0x7b68d250, + 0x0af74622, 0x65bbe3b9, 0x95697dce, 0xfa25d855, 0x75cc4021, + 0x1a80e5ba, 0xea527bcd, 0x851ede56, 0xe06fc760, 0x8f2362fb, + 0x7ff1fc8c, 0x10bd5917, 0x9f54c163, 0xf01864f8, 0x00cafa8f, + 0x6f865f14, 0x1e19cb66, 0x71556efd, 0x8187f08a, 0xeecb5511, + 0x6122cd65, 0x0e6e68fe, 0xfebcf689, 0x91f05312, 0x1c82df6c, + 0x73ce7af7, 0x831ce480, 0xec50411b, 0x63b9d96f, 0x0cf57cf4, + 0xfc27e283, 0x936b4718, 0xe2f4d36a, 0x8db876f1, 0x7d6ae886, + 0x12264d1d, 0x9dcfd569, 0xf28370f2, 0x0251ee85, 0x6d1d4b1e, + 0x18b4f678, 0x77f853e3, 0x872acd94, 0xe866680f, 0x678ff07b, + 0x08c355e0, 0xf811cb97, 0x975d6e0c, 0xe6c2fa7e, 0x898e5fe5, + 0x795cc192, 0x16106409, 0x99f9fc7d, 0xf6b559e6, 0x0667c791, + 0x692b620a, 0xe459ee74, 0x8b154bef, 0x7bc7d598, 0x148b7003, + 0x9b62e877, 0xf42e4dec, 0x04fcd39b, 0x6bb07600, 0x1a2fe272, + 0x756347e9, 0x85b1d99e, 0xeafd7c05, 0x6514e471, 0x0a5841ea, + 0xfa8adf9d, 0x95c67a06, 0x10d8a450, 0x7f9401cb, 0x8f469fbc, + 0xe00a3a27, 0x6fe3a253, 0x00af07c8, 0xf07d99bf, 0x9f313c24, + 0xeeaea856, 0x81e20dcd, 0x713093ba, 0x1e7c3621, 0x9195ae55, + 0xfed90bce, 0x0e0b95b9, 0x61473022, 0xec35bc5c, 0x837919c7, + 0x73ab87b0, 0x1ce7222b, 0x930eba5f, 0xfc421fc4, 0x0c9081b3, + 0x63dc2428, 0x1243b05a, 0x7d0f15c1, 0x8ddd8bb6, 0xe2912e2d, + 0x6d78b659, 0x023413c2, 0xf2e68db5, 0x9daa282e, 0xe8039548, + 0x874f30d3, 0x779daea4, 0x18d10b3f, 0x9738934b, 0xf87436d0, + 0x08a6a8a7, 0x67ea0d3c, 0x1675994e, 0x79393cd5, 0x89eba2a2, + 0xe6a70739, 0x694e9f4d, 0x06023ad6, 0xf6d0a4a1, 0x999c013a, + 0x14ee8d44, 0x7ba228df, 0x8b70b6a8, 0xe43c1333, 0x6bd58b47, + 0x04992edc, 0xf44bb0ab, 0x9b071530, 0xea988142, 0x85d424d9, + 0x7506baae, 0x1a4a1f35, 0x95a38741, 0xfaef22da, 0x0a3dbcad, + 0x65711936}}; + +#endif + +#endif + +#if N == 4 + +#if W == 8 + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xf1da05aa, 0x38c50d15, 0xc91f08bf, 0x718a1a2a, + 0x80501f80, 0x494f173f, 0xb8951295, 0xe3143454, 0x12ce31fe, + 0xdbd13941, 0x2a0b3ceb, 0x929e2e7e, 0x63442bd4, 0xaa5b236b, + 0x5b8126c1, 0x1d596ee9, 0xec836b43, 0x259c63fc, 0xd4466656, + 0x6cd374c3, 0x9d097169, 0x541679d6, 0xa5cc7c7c, 0xfe4d5abd, + 0x0f975f17, 0xc68857a8, 0x37525202, 0x8fc74097, 0x7e1d453d, + 0xb7024d82, 0x46d84828, 0x3ab2ddd2, 0xcb68d878, 0x0277d0c7, + 0xf3add56d, 0x4b38c7f8, 0xbae2c252, 0x73fdcaed, 0x8227cf47, + 0xd9a6e986, 0x287cec2c, 0xe163e493, 0x10b9e139, 0xa82cf3ac, + 0x59f6f606, 0x90e9feb9, 0x6133fb13, 0x27ebb33b, 0xd631b691, + 0x1f2ebe2e, 0xeef4bb84, 0x5661a911, 0xa7bbacbb, 0x6ea4a404, + 0x9f7ea1ae, 0xc4ff876f, 0x352582c5, 0xfc3a8a7a, 0x0de08fd0, + 0xb5759d45, 0x44af98ef, 0x8db09050, 0x7c6a95fa, 0x7565bba4, + 0x84bfbe0e, 0x4da0b6b1, 0xbc7ab31b, 0x04efa18e, 0xf535a424, + 0x3c2aac9b, 0xcdf0a931, 0x96718ff0, 0x67ab8a5a, 0xaeb482e5, + 0x5f6e874f, 0xe7fb95da, 0x16219070, 0xdf3e98cf, 0x2ee49d65, + 0x683cd54d, 0x99e6d0e7, 0x50f9d858, 0xa123ddf2, 0x19b6cf67, + 0xe86ccacd, 0x2173c272, 0xd0a9c7d8, 0x8b28e119, 0x7af2e4b3, + 0xb3edec0c, 0x4237e9a6, 0xfaa2fb33, 0x0b78fe99, 0xc267f626, + 0x33bdf38c, 0x4fd76676, 0xbe0d63dc, 0x77126b63, 0x86c86ec9, + 0x3e5d7c5c, 0xcf8779f6, 0x06987149, 0xf74274e3, 0xacc35222, + 0x5d195788, 0x94065f37, 0x65dc5a9d, 0xdd494808, 0x2c934da2, + 0xe58c451d, 0x145640b7, 0x528e089f, 0xa3540d35, 0x6a4b058a, + 0x9b910020, 0x230412b5, 0xd2de171f, 0x1bc11fa0, 0xea1b1a0a, + 0xb19a3ccb, 0x40403961, 0x895f31de, 0x78853474, 0xc01026e1, + 0x31ca234b, 0xf8d52bf4, 0x090f2e5e, 0xeacb7748, 0x1b1172e2, + 0xd20e7a5d, 0x23d47ff7, 0x9b416d62, 0x6a9b68c8, 0xa3846077, + 0x525e65dd, 0x09df431c, 0xf80546b6, 0x311a4e09, 0xc0c04ba3, + 0x78555936, 0x898f5c9c, 0x40905423, 0xb14a5189, 0xf79219a1, + 0x06481c0b, 0xcf5714b4, 0x3e8d111e, 0x8618038b, 0x77c20621, + 0xbedd0e9e, 0x4f070b34, 0x14862df5, 0xe55c285f, 0x2c4320e0, + 0xdd99254a, 0x650c37df, 0x94d63275, 0x5dc93aca, 0xac133f60, + 0xd079aa9a, 0x21a3af30, 0xe8bca78f, 0x1966a225, 0xa1f3b0b0, + 0x5029b51a, 0x9936bda5, 0x68ecb80f, 0x336d9ece, 0xc2b79b64, + 0x0ba893db, 0xfa729671, 0x42e784e4, 0xb33d814e, 0x7a2289f1, + 0x8bf88c5b, 0xcd20c473, 0x3cfac1d9, 0xf5e5c966, 0x043fcccc, + 0xbcaade59, 0x4d70dbf3, 0x846fd34c, 0x75b5d6e6, 0x2e34f027, + 0xdfeef58d, 0x16f1fd32, 0xe72bf898, 0x5fbeea0d, 0xae64efa7, + 0x677be718, 0x96a1e2b2, 0x9faeccec, 0x6e74c946, 0xa76bc1f9, + 0x56b1c453, 0xee24d6c6, 0x1ffed36c, 0xd6e1dbd3, 0x273bde79, + 0x7cbaf8b8, 0x8d60fd12, 0x447ff5ad, 0xb5a5f007, 0x0d30e292, + 0xfceae738, 0x35f5ef87, 0xc42fea2d, 0x82f7a205, 0x732da7af, + 0xba32af10, 0x4be8aaba, 0xf37db82f, 0x02a7bd85, 0xcbb8b53a, + 0x3a62b090, 0x61e39651, 0x903993fb, 0x59269b44, 0xa8fc9eee, + 0x10698c7b, 0xe1b389d1, 0x28ac816e, 0xd97684c4, 0xa51c113e, + 0x54c61494, 0x9dd91c2b, 0x6c031981, 0xd4960b14, 0x254c0ebe, + 0xec530601, 0x1d8903ab, 0x4608256a, 0xb7d220c0, 0x7ecd287f, + 0x8f172dd5, 0x37823f40, 0xc6583aea, 0x0f473255, 0xfe9d37ff, + 0xb8457fd7, 0x499f7a7d, 0x808072c2, 0x715a7768, 0xc9cf65fd, + 0x38156057, 0xf10a68e8, 0x00d06d42, 0x5b514b83, 0xaa8b4e29, + 0x63944696, 0x924e433c, 0x2adb51a9, 0xdb015403, 0x121e5cbc, + 0xe3c45916}, + {0x00000000, 0x0ee7e8d1, 0x1dcfd1a2, 0x13283973, 0x3b9fa344, + 0x35784b95, 0x265072e6, 0x28b79a37, 0x773f4688, 0x79d8ae59, + 0x6af0972a, 0x64177ffb, 0x4ca0e5cc, 0x42470d1d, 0x516f346e, + 0x5f88dcbf, 0xee7e8d10, 0xe09965c1, 0xf3b15cb2, 0xfd56b463, + 0xd5e12e54, 0xdb06c685, 0xc82efff6, 0xc6c91727, 0x9941cb98, + 0x97a62349, 0x848e1a3a, 0x8a69f2eb, 0xa2de68dc, 0xac39800d, + 0xbf11b97e, 0xb1f651af, 0x078c1c61, 0x096bf4b0, 0x1a43cdc3, + 0x14a42512, 0x3c13bf25, 0x32f457f4, 0x21dc6e87, 0x2f3b8656, + 0x70b35ae9, 0x7e54b238, 0x6d7c8b4b, 0x639b639a, 0x4b2cf9ad, + 0x45cb117c, 0x56e3280f, 0x5804c0de, 0xe9f29171, 0xe71579a0, + 0xf43d40d3, 0xfadaa802, 0xd26d3235, 0xdc8adae4, 0xcfa2e397, + 0xc1450b46, 0x9ecdd7f9, 0x902a3f28, 0x8302065b, 0x8de5ee8a, + 0xa55274bd, 0xabb59c6c, 0xb89da51f, 0xb67a4dce, 0x0f1838c2, + 0x01ffd013, 0x12d7e960, 0x1c3001b1, 0x34879b86, 0x3a607357, + 0x29484a24, 0x27afa2f5, 0x78277e4a, 0x76c0969b, 0x65e8afe8, + 0x6b0f4739, 0x43b8dd0e, 0x4d5f35df, 0x5e770cac, 0x5090e47d, + 0xe166b5d2, 0xef815d03, 0xfca96470, 0xf24e8ca1, 0xdaf91696, + 0xd41efe47, 0xc736c734, 0xc9d12fe5, 0x9659f35a, 0x98be1b8b, + 0x8b9622f8, 0x8571ca29, 0xadc6501e, 0xa321b8cf, 0xb00981bc, + 0xbeee696d, 0x089424a3, 0x0673cc72, 0x155bf501, 0x1bbc1dd0, + 0x330b87e7, 0x3dec6f36, 0x2ec45645, 0x2023be94, 0x7fab622b, + 0x714c8afa, 0x6264b389, 0x6c835b58, 0x4434c16f, 0x4ad329be, + 0x59fb10cd, 0x571cf81c, 0xe6eaa9b3, 0xe80d4162, 0xfb257811, + 0xf5c290c0, 0xdd750af7, 0xd392e226, 0xc0badb55, 0xce5d3384, + 0x91d5ef3b, 0x9f3207ea, 0x8c1a3e99, 0x82fdd648, 0xaa4a4c7f, + 0xa4ada4ae, 0xb7859ddd, 0xb962750c, 0x1e307184, 0x10d79955, + 0x03ffa026, 0x0d1848f7, 0x25afd2c0, 0x2b483a11, 0x38600362, + 0x3687ebb3, 0x690f370c, 0x67e8dfdd, 0x74c0e6ae, 0x7a270e7f, + 0x52909448, 0x5c777c99, 0x4f5f45ea, 0x41b8ad3b, 0xf04efc94, + 0xfea91445, 0xed812d36, 0xe366c5e7, 0xcbd15fd0, 0xc536b701, + 0xd61e8e72, 0xd8f966a3, 0x8771ba1c, 0x899652cd, 0x9abe6bbe, + 0x9459836f, 0xbcee1958, 0xb209f189, 0xa121c8fa, 0xafc6202b, + 0x19bc6de5, 0x175b8534, 0x0473bc47, 0x0a945496, 0x2223cea1, + 0x2cc42670, 0x3fec1f03, 0x310bf7d2, 0x6e832b6d, 0x6064c3bc, + 0x734cfacf, 0x7dab121e, 0x551c8829, 0x5bfb60f8, 0x48d3598b, + 0x4634b15a, 0xf7c2e0f5, 0xf9250824, 0xea0d3157, 0xe4ead986, + 0xcc5d43b1, 0xc2baab60, 0xd1929213, 0xdf757ac2, 0x80fda67d, + 0x8e1a4eac, 0x9d3277df, 0x93d59f0e, 0xbb620539, 0xb585ede8, + 0xa6add49b, 0xa84a3c4a, 0x11284946, 0x1fcfa197, 0x0ce798e4, + 0x02007035, 0x2ab7ea02, 0x245002d3, 0x37783ba0, 0x399fd371, + 0x66170fce, 0x68f0e71f, 0x7bd8de6c, 0x753f36bd, 0x5d88ac8a, + 0x536f445b, 0x40477d28, 0x4ea095f9, 0xff56c456, 0xf1b12c87, + 0xe29915f4, 0xec7efd25, 0xc4c96712, 0xca2e8fc3, 0xd906b6b0, + 0xd7e15e61, 0x886982de, 0x868e6a0f, 0x95a6537c, 0x9b41bbad, + 0xb3f6219a, 0xbd11c94b, 0xae39f038, 0xa0de18e9, 0x16a45527, + 0x1843bdf6, 0x0b6b8485, 0x058c6c54, 0x2d3bf663, 0x23dc1eb2, + 0x30f427c1, 0x3e13cf10, 0x619b13af, 0x6f7cfb7e, 0x7c54c20d, + 0x72b32adc, 0x5a04b0eb, 0x54e3583a, 0x47cb6149, 0x492c8998, + 0xf8dad837, 0xf63d30e6, 0xe5150995, 0xebf2e144, 0xc3457b73, + 0xcda293a2, 0xde8aaad1, 0xd06d4200, 0x8fe59ebf, 0x8102766e, + 0x922a4f1d, 0x9ccda7cc, 0xb47a3dfb, 0xba9dd52a, 0xa9b5ec59, + 0xa7520488}, + {0x00000000, 0x3c60e308, 0x78c1c610, 0x44a12518, 0xf1838c20, + 0xcde36f28, 0x89424a30, 0xb522a938, 0x38761e01, 0x0416fd09, + 0x40b7d811, 0x7cd73b19, 0xc9f59221, 0xf5957129, 0xb1345431, + 0x8d54b739, 0x70ec3c02, 0x4c8cdf0a, 0x082dfa12, 0x344d191a, + 0x816fb022, 0xbd0f532a, 0xf9ae7632, 0xc5ce953a, 0x489a2203, + 0x74fac10b, 0x305be413, 0x0c3b071b, 0xb919ae23, 0x85794d2b, + 0xc1d86833, 0xfdb88b3b, 0xe1d87804, 0xddb89b0c, 0x9919be14, + 0xa5795d1c, 0x105bf424, 0x2c3b172c, 0x689a3234, 0x54fad13c, + 0xd9ae6605, 0xe5ce850d, 0xa16fa015, 0x9d0f431d, 0x282dea25, + 0x144d092d, 0x50ec2c35, 0x6c8ccf3d, 0x91344406, 0xad54a70e, + 0xe9f58216, 0xd595611e, 0x60b7c826, 0x5cd72b2e, 0x18760e36, + 0x2416ed3e, 0xa9425a07, 0x9522b90f, 0xd1839c17, 0xede37f1f, + 0x58c1d627, 0x64a1352f, 0x20001037, 0x1c60f33f, 0x18c1f649, + 0x24a11541, 0x60003059, 0x5c60d351, 0xe9427a69, 0xd5229961, + 0x9183bc79, 0xade35f71, 0x20b7e848, 0x1cd70b40, 0x58762e58, + 0x6416cd50, 0xd1346468, 0xed548760, 0xa9f5a278, 0x95954170, + 0x682dca4b, 0x544d2943, 0x10ec0c5b, 0x2c8cef53, 0x99ae466b, + 0xa5cea563, 0xe16f807b, 0xdd0f6373, 0x505bd44a, 0x6c3b3742, + 0x289a125a, 0x14faf152, 0xa1d8586a, 0x9db8bb62, 0xd9199e7a, + 0xe5797d72, 0xf9198e4d, 0xc5796d45, 0x81d8485d, 0xbdb8ab55, + 0x089a026d, 0x34fae165, 0x705bc47d, 0x4c3b2775, 0xc16f904c, + 0xfd0f7344, 0xb9ae565c, 0x85ceb554, 0x30ec1c6c, 0x0c8cff64, + 0x482dda7c, 0x744d3974, 0x89f5b24f, 0xb5955147, 0xf134745f, + 0xcd549757, 0x78763e6f, 0x4416dd67, 0x00b7f87f, 0x3cd71b77, + 0xb183ac4e, 0x8de34f46, 0xc9426a5e, 0xf5228956, 0x4000206e, + 0x7c60c366, 0x38c1e67e, 0x04a10576, 0x3183ec92, 0x0de30f9a, + 0x49422a82, 0x7522c98a, 0xc00060b2, 0xfc6083ba, 0xb8c1a6a2, + 0x84a145aa, 0x09f5f293, 0x3595119b, 0x71343483, 0x4d54d78b, + 0xf8767eb3, 0xc4169dbb, 0x80b7b8a3, 0xbcd75bab, 0x416fd090, + 0x7d0f3398, 0x39ae1680, 0x05cef588, 0xb0ec5cb0, 0x8c8cbfb8, + 0xc82d9aa0, 0xf44d79a8, 0x7919ce91, 0x45792d99, 0x01d80881, + 0x3db8eb89, 0x889a42b1, 0xb4faa1b9, 0xf05b84a1, 0xcc3b67a9, + 0xd05b9496, 0xec3b779e, 0xa89a5286, 0x94fab18e, 0x21d818b6, + 0x1db8fbbe, 0x5919dea6, 0x65793dae, 0xe82d8a97, 0xd44d699f, + 0x90ec4c87, 0xac8caf8f, 0x19ae06b7, 0x25cee5bf, 0x616fc0a7, + 0x5d0f23af, 0xa0b7a894, 0x9cd74b9c, 0xd8766e84, 0xe4168d8c, + 0x513424b4, 0x6d54c7bc, 0x29f5e2a4, 0x159501ac, 0x98c1b695, + 0xa4a1559d, 0xe0007085, 0xdc60938d, 0x69423ab5, 0x5522d9bd, + 0x1183fca5, 0x2de31fad, 0x29421adb, 0x1522f9d3, 0x5183dccb, + 0x6de33fc3, 0xd8c196fb, 0xe4a175f3, 0xa00050eb, 0x9c60b3e3, + 0x113404da, 0x2d54e7d2, 0x69f5c2ca, 0x559521c2, 0xe0b788fa, + 0xdcd76bf2, 0x98764eea, 0xa416ade2, 0x59ae26d9, 0x65cec5d1, + 0x216fe0c9, 0x1d0f03c1, 0xa82daaf9, 0x944d49f1, 0xd0ec6ce9, + 0xec8c8fe1, 0x61d838d8, 0x5db8dbd0, 0x1919fec8, 0x25791dc0, + 0x905bb4f8, 0xac3b57f0, 0xe89a72e8, 0xd4fa91e0, 0xc89a62df, + 0xf4fa81d7, 0xb05ba4cf, 0x8c3b47c7, 0x3919eeff, 0x05790df7, + 0x41d828ef, 0x7db8cbe7, 0xf0ec7cde, 0xcc8c9fd6, 0x882dbace, + 0xb44d59c6, 0x016ff0fe, 0x3d0f13f6, 0x79ae36ee, 0x45ced5e6, + 0xb8765edd, 0x8416bdd5, 0xc0b798cd, 0xfcd77bc5, 0x49f5d2fd, + 0x759531f5, 0x313414ed, 0x0d54f7e5, 0x800040dc, 0xbc60a3d4, + 0xf8c186cc, 0xc4a165c4, 0x7183ccfc, 0x4de32ff4, 0x09420aec, + 0x3522e9e4}, + {0x00000000, 0x6307d924, 0xc60fb248, 0xa5086b6c, 0x576e62d1, + 0x3469bbf5, 0x9161d099, 0xf26609bd, 0xaedcc5a2, 0xcddb1c86, + 0x68d377ea, 0x0bd4aece, 0xf9b2a773, 0x9ab57e57, 0x3fbd153b, + 0x5cbacc1f, 0x86c88d05, 0xe5cf5421, 0x40c73f4d, 0x23c0e669, + 0xd1a6efd4, 0xb2a136f0, 0x17a95d9c, 0x74ae84b8, 0x281448a7, + 0x4b139183, 0xee1bfaef, 0x8d1c23cb, 0x7f7a2a76, 0x1c7df352, + 0xb975983e, 0xda72411a, 0xd6e01c4b, 0xb5e7c56f, 0x10efae03, + 0x73e87727, 0x818e7e9a, 0xe289a7be, 0x4781ccd2, 0x248615f6, + 0x783cd9e9, 0x1b3b00cd, 0xbe336ba1, 0xdd34b285, 0x2f52bb38, + 0x4c55621c, 0xe95d0970, 0x8a5ad054, 0x5028914e, 0x332f486a, + 0x96272306, 0xf520fa22, 0x0746f39f, 0x64412abb, 0xc14941d7, + 0xa24e98f3, 0xfef454ec, 0x9df38dc8, 0x38fbe6a4, 0x5bfc3f80, + 0xa99a363d, 0xca9def19, 0x6f958475, 0x0c925d51, 0x76b13ed7, + 0x15b6e7f3, 0xb0be8c9f, 0xd3b955bb, 0x21df5c06, 0x42d88522, + 0xe7d0ee4e, 0x84d7376a, 0xd86dfb75, 0xbb6a2251, 0x1e62493d, + 0x7d659019, 0x8f0399a4, 0xec044080, 0x490c2bec, 0x2a0bf2c8, + 0xf079b3d2, 0x937e6af6, 0x3676019a, 0x5571d8be, 0xa717d103, + 0xc4100827, 0x6118634b, 0x021fba6f, 0x5ea57670, 0x3da2af54, + 0x98aac438, 0xfbad1d1c, 0x09cb14a1, 0x6acccd85, 0xcfc4a6e9, + 0xacc37fcd, 0xa051229c, 0xc356fbb8, 0x665e90d4, 0x055949f0, + 0xf73f404d, 0x94389969, 0x3130f205, 0x52372b21, 0x0e8de73e, + 0x6d8a3e1a, 0xc8825576, 0xab858c52, 0x59e385ef, 0x3ae45ccb, + 0x9fec37a7, 0xfcebee83, 0x2699af99, 0x459e76bd, 0xe0961dd1, + 0x8391c4f5, 0x71f7cd48, 0x12f0146c, 0xb7f87f00, 0xd4ffa624, + 0x88456a3b, 0xeb42b31f, 0x4e4ad873, 0x2d4d0157, 0xdf2b08ea, + 0xbc2cd1ce, 0x1924baa2, 0x7a236386, 0xed627dae, 0x8e65a48a, + 0x2b6dcfe6, 0x486a16c2, 0xba0c1f7f, 0xd90bc65b, 0x7c03ad37, + 0x1f047413, 0x43beb80c, 0x20b96128, 0x85b10a44, 0xe6b6d360, + 0x14d0dadd, 0x77d703f9, 0xd2df6895, 0xb1d8b1b1, 0x6baaf0ab, + 0x08ad298f, 0xada542e3, 0xcea29bc7, 0x3cc4927a, 0x5fc34b5e, + 0xfacb2032, 0x99ccf916, 0xc5763509, 0xa671ec2d, 0x03798741, + 0x607e5e65, 0x921857d8, 0xf11f8efc, 0x5417e590, 0x37103cb4, + 0x3b8261e5, 0x5885b8c1, 0xfd8dd3ad, 0x9e8a0a89, 0x6cec0334, + 0x0febda10, 0xaae3b17c, 0xc9e46858, 0x955ea447, 0xf6597d63, + 0x5351160f, 0x3056cf2b, 0xc230c696, 0xa1371fb2, 0x043f74de, + 0x6738adfa, 0xbd4aece0, 0xde4d35c4, 0x7b455ea8, 0x1842878c, + 0xea248e31, 0x89235715, 0x2c2b3c79, 0x4f2ce55d, 0x13962942, + 0x7091f066, 0xd5999b0a, 0xb69e422e, 0x44f84b93, 0x27ff92b7, + 0x82f7f9db, 0xe1f020ff, 0x9bd34379, 0xf8d49a5d, 0x5ddcf131, + 0x3edb2815, 0xccbd21a8, 0xafbaf88c, 0x0ab293e0, 0x69b54ac4, + 0x350f86db, 0x56085fff, 0xf3003493, 0x9007edb7, 0x6261e40a, + 0x01663d2e, 0xa46e5642, 0xc7698f66, 0x1d1bce7c, 0x7e1c1758, + 0xdb147c34, 0xb813a510, 0x4a75acad, 0x29727589, 0x8c7a1ee5, + 0xef7dc7c1, 0xb3c70bde, 0xd0c0d2fa, 0x75c8b996, 0x16cf60b2, + 0xe4a9690f, 0x87aeb02b, 0x22a6db47, 0x41a10263, 0x4d335f32, + 0x2e348616, 0x8b3ced7a, 0xe83b345e, 0x1a5d3de3, 0x795ae4c7, + 0xdc528fab, 0xbf55568f, 0xe3ef9a90, 0x80e843b4, 0x25e028d8, + 0x46e7f1fc, 0xb481f841, 0xd7862165, 0x728e4a09, 0x1189932d, + 0xcbfbd237, 0xa8fc0b13, 0x0df4607f, 0x6ef3b95b, 0x9c95b0e6, + 0xff9269c2, 0x5a9a02ae, 0x399ddb8a, 0x65271795, 0x0620ceb1, + 0xa328a5dd, 0xc02f7cf9, 0x32497544, 0x514eac60, 0xf446c70c, + 0x97411e28}, + {0x00000000, 0x01b5fd1d, 0x036bfa3a, 0x02de0727, 0x06d7f474, + 0x07620969, 0x05bc0e4e, 0x0409f353, 0x0dafe8e8, 0x0c1a15f5, + 0x0ec412d2, 0x0f71efcf, 0x0b781c9c, 0x0acde181, 0x0813e6a6, + 0x09a61bbb, 0x1b5fd1d0, 0x1aea2ccd, 0x18342bea, 0x1981d6f7, + 0x1d8825a4, 0x1c3dd8b9, 0x1ee3df9e, 0x1f562283, 0x16f03938, + 0x1745c425, 0x159bc302, 0x142e3e1f, 0x1027cd4c, 0x11923051, + 0x134c3776, 0x12f9ca6b, 0x36bfa3a0, 0x370a5ebd, 0x35d4599a, + 0x3461a487, 0x306857d4, 0x31ddaac9, 0x3303adee, 0x32b650f3, + 0x3b104b48, 0x3aa5b655, 0x387bb172, 0x39ce4c6f, 0x3dc7bf3c, + 0x3c724221, 0x3eac4506, 0x3f19b81b, 0x2de07270, 0x2c558f6d, + 0x2e8b884a, 0x2f3e7557, 0x2b378604, 0x2a827b19, 0x285c7c3e, + 0x29e98123, 0x204f9a98, 0x21fa6785, 0x232460a2, 0x22919dbf, + 0x26986eec, 0x272d93f1, 0x25f394d6, 0x244669cb, 0x6d7f4740, + 0x6ccaba5d, 0x6e14bd7a, 0x6fa14067, 0x6ba8b334, 0x6a1d4e29, + 0x68c3490e, 0x6976b413, 0x60d0afa8, 0x616552b5, 0x63bb5592, + 0x620ea88f, 0x66075bdc, 0x67b2a6c1, 0x656ca1e6, 0x64d95cfb, + 0x76209690, 0x77956b8d, 0x754b6caa, 0x74fe91b7, 0x70f762e4, + 0x71429ff9, 0x739c98de, 0x722965c3, 0x7b8f7e78, 0x7a3a8365, + 0x78e48442, 0x7951795f, 0x7d588a0c, 0x7ced7711, 0x7e337036, + 0x7f868d2b, 0x5bc0e4e0, 0x5a7519fd, 0x58ab1eda, 0x591ee3c7, + 0x5d171094, 0x5ca2ed89, 0x5e7ceaae, 0x5fc917b3, 0x566f0c08, + 0x57daf115, 0x5504f632, 0x54b10b2f, 0x50b8f87c, 0x510d0561, + 0x53d30246, 0x5266ff5b, 0x409f3530, 0x412ac82d, 0x43f4cf0a, + 0x42413217, 0x4648c144, 0x47fd3c59, 0x45233b7e, 0x4496c663, + 0x4d30ddd8, 0x4c8520c5, 0x4e5b27e2, 0x4feedaff, 0x4be729ac, + 0x4a52d4b1, 0x488cd396, 0x49392e8b, 0xdafe8e80, 0xdb4b739d, + 0xd99574ba, 0xd82089a7, 0xdc297af4, 0xdd9c87e9, 0xdf4280ce, + 0xdef77dd3, 0xd7516668, 0xd6e49b75, 0xd43a9c52, 0xd58f614f, + 0xd186921c, 0xd0336f01, 0xd2ed6826, 0xd358953b, 0xc1a15f50, + 0xc014a24d, 0xc2caa56a, 0xc37f5877, 0xc776ab24, 0xc6c35639, + 0xc41d511e, 0xc5a8ac03, 0xcc0eb7b8, 0xcdbb4aa5, 0xcf654d82, + 0xced0b09f, 0xcad943cc, 0xcb6cbed1, 0xc9b2b9f6, 0xc80744eb, + 0xec412d20, 0xedf4d03d, 0xef2ad71a, 0xee9f2a07, 0xea96d954, + 0xeb232449, 0xe9fd236e, 0xe848de73, 0xe1eec5c8, 0xe05b38d5, + 0xe2853ff2, 0xe330c2ef, 0xe73931bc, 0xe68ccca1, 0xe452cb86, + 0xe5e7369b, 0xf71efcf0, 0xf6ab01ed, 0xf47506ca, 0xf5c0fbd7, + 0xf1c90884, 0xf07cf599, 0xf2a2f2be, 0xf3170fa3, 0xfab11418, + 0xfb04e905, 0xf9daee22, 0xf86f133f, 0xfc66e06c, 0xfdd31d71, + 0xff0d1a56, 0xfeb8e74b, 0xb781c9c0, 0xb63434dd, 0xb4ea33fa, + 0xb55fcee7, 0xb1563db4, 0xb0e3c0a9, 0xb23dc78e, 0xb3883a93, + 0xba2e2128, 0xbb9bdc35, 0xb945db12, 0xb8f0260f, 0xbcf9d55c, + 0xbd4c2841, 0xbf922f66, 0xbe27d27b, 0xacde1810, 0xad6be50d, + 0xafb5e22a, 0xae001f37, 0xaa09ec64, 0xabbc1179, 0xa962165e, + 0xa8d7eb43, 0xa171f0f8, 0xa0c40de5, 0xa21a0ac2, 0xa3aff7df, + 0xa7a6048c, 0xa613f991, 0xa4cdfeb6, 0xa57803ab, 0x813e6a60, + 0x808b977d, 0x8255905a, 0x83e06d47, 0x87e99e14, 0x865c6309, + 0x8482642e, 0x85379933, 0x8c918288, 0x8d247f95, 0x8ffa78b2, + 0x8e4f85af, 0x8a4676fc, 0x8bf38be1, 0x892d8cc6, 0x889871db, + 0x9a61bbb0, 0x9bd446ad, 0x990a418a, 0x98bfbc97, 0x9cb64fc4, + 0x9d03b2d9, 0x9fddb5fe, 0x9e6848e3, 0x97ce5358, 0x967bae45, + 0x94a5a962, 0x9510547f, 0x9119a72c, 0x90ac5a31, 0x92725d16, + 0x93c7a00b}, + {0x00000000, 0x6e8c1b41, 0xdd183682, 0xb3942dc3, 0x61416b45, + 0x0fcd7004, 0xbc595dc7, 0xd2d54686, 0xc282d68a, 0xac0ecdcb, + 0x1f9ae008, 0x7116fb49, 0xa3c3bdcf, 0xcd4fa68e, 0x7edb8b4d, + 0x1057900c, 0x5e74ab55, 0x30f8b014, 0x836c9dd7, 0xede08696, + 0x3f35c010, 0x51b9db51, 0xe22df692, 0x8ca1edd3, 0x9cf67ddf, + 0xf27a669e, 0x41ee4b5d, 0x2f62501c, 0xfdb7169a, 0x933b0ddb, + 0x20af2018, 0x4e233b59, 0xbce956aa, 0xd2654deb, 0x61f16028, + 0x0f7d7b69, 0xdda83def, 0xb32426ae, 0x00b00b6d, 0x6e3c102c, + 0x7e6b8020, 0x10e79b61, 0xa373b6a2, 0xcdffade3, 0x1f2aeb65, + 0x71a6f024, 0xc232dde7, 0xacbec6a6, 0xe29dfdff, 0x8c11e6be, + 0x3f85cb7d, 0x5109d03c, 0x83dc96ba, 0xed508dfb, 0x5ec4a038, + 0x3048bb79, 0x201f2b75, 0x4e933034, 0xfd071df7, 0x938b06b6, + 0x415e4030, 0x2fd25b71, 0x9c4676b2, 0xf2ca6df3, 0xa2a3ab15, + 0xcc2fb054, 0x7fbb9d97, 0x113786d6, 0xc3e2c050, 0xad6edb11, + 0x1efaf6d2, 0x7076ed93, 0x60217d9f, 0x0ead66de, 0xbd394b1d, + 0xd3b5505c, 0x016016da, 0x6fec0d9b, 0xdc782058, 0xb2f43b19, + 0xfcd70040, 0x925b1b01, 0x21cf36c2, 0x4f432d83, 0x9d966b05, + 0xf31a7044, 0x408e5d87, 0x2e0246c6, 0x3e55d6ca, 0x50d9cd8b, + 0xe34de048, 0x8dc1fb09, 0x5f14bd8f, 0x3198a6ce, 0x820c8b0d, + 0xec80904c, 0x1e4afdbf, 0x70c6e6fe, 0xc352cb3d, 0xadded07c, + 0x7f0b96fa, 0x11878dbb, 0xa213a078, 0xcc9fbb39, 0xdcc82b35, + 0xb2443074, 0x01d01db7, 0x6f5c06f6, 0xbd894070, 0xd3055b31, + 0x609176f2, 0x0e1d6db3, 0x403e56ea, 0x2eb24dab, 0x9d266068, + 0xf3aa7b29, 0x217f3daf, 0x4ff326ee, 0xfc670b2d, 0x92eb106c, + 0x82bc8060, 0xec309b21, 0x5fa4b6e2, 0x3128ada3, 0xe3fdeb25, + 0x8d71f064, 0x3ee5dda7, 0x5069c6e6, 0x9e36506b, 0xf0ba4b2a, + 0x432e66e9, 0x2da27da8, 0xff773b2e, 0x91fb206f, 0x226f0dac, + 0x4ce316ed, 0x5cb486e1, 0x32389da0, 0x81acb063, 0xef20ab22, + 0x3df5eda4, 0x5379f6e5, 0xe0eddb26, 0x8e61c067, 0xc042fb3e, + 0xaecee07f, 0x1d5acdbc, 0x73d6d6fd, 0xa103907b, 0xcf8f8b3a, + 0x7c1ba6f9, 0x1297bdb8, 0x02c02db4, 0x6c4c36f5, 0xdfd81b36, + 0xb1540077, 0x638146f1, 0x0d0d5db0, 0xbe997073, 0xd0156b32, + 0x22df06c1, 0x4c531d80, 0xffc73043, 0x914b2b02, 0x439e6d84, + 0x2d1276c5, 0x9e865b06, 0xf00a4047, 0xe05dd04b, 0x8ed1cb0a, + 0x3d45e6c9, 0x53c9fd88, 0x811cbb0e, 0xef90a04f, 0x5c048d8c, + 0x328896cd, 0x7cabad94, 0x1227b6d5, 0xa1b39b16, 0xcf3f8057, + 0x1deac6d1, 0x7366dd90, 0xc0f2f053, 0xae7eeb12, 0xbe297b1e, + 0xd0a5605f, 0x63314d9c, 0x0dbd56dd, 0xdf68105b, 0xb1e40b1a, + 0x027026d9, 0x6cfc3d98, 0x3c95fb7e, 0x5219e03f, 0xe18dcdfc, + 0x8f01d6bd, 0x5dd4903b, 0x33588b7a, 0x80cca6b9, 0xee40bdf8, + 0xfe172df4, 0x909b36b5, 0x230f1b76, 0x4d830037, 0x9f5646b1, + 0xf1da5df0, 0x424e7033, 0x2cc26b72, 0x62e1502b, 0x0c6d4b6a, + 0xbff966a9, 0xd1757de8, 0x03a03b6e, 0x6d2c202f, 0xdeb80dec, + 0xb03416ad, 0xa06386a1, 0xceef9de0, 0x7d7bb023, 0x13f7ab62, + 0xc122ede4, 0xafaef6a5, 0x1c3adb66, 0x72b6c027, 0x807cadd4, + 0xeef0b695, 0x5d649b56, 0x33e88017, 0xe13dc691, 0x8fb1ddd0, + 0x3c25f013, 0x52a9eb52, 0x42fe7b5e, 0x2c72601f, 0x9fe64ddc, + 0xf16a569d, 0x23bf101b, 0x4d330b5a, 0xfea72699, 0x902b3dd8, + 0xde080681, 0xb0841dc0, 0x03103003, 0x6d9c2b42, 0xbf496dc4, + 0xd1c57685, 0x62515b46, 0x0cdd4007, 0x1c8ad00b, 0x7206cb4a, + 0xc192e689, 0xaf1efdc8, 0x7dcbbb4e, 0x1347a00f, 0xa0d38dcc, + 0xce5f968d}, + {0x00000000, 0xe71da697, 0x154a4b6f, 0xf257edf8, 0x2a9496de, + 0xcd893049, 0x3fdeddb1, 0xd8c37b26, 0x55292dbc, 0xb2348b2b, + 0x406366d3, 0xa77ec044, 0x7fbdbb62, 0x98a01df5, 0x6af7f00d, + 0x8dea569a, 0xaa525b78, 0x4d4ffdef, 0xbf181017, 0x5805b680, + 0x80c6cda6, 0x67db6b31, 0x958c86c9, 0x7291205e, 0xff7b76c4, + 0x1866d053, 0xea313dab, 0x0d2c9b3c, 0xd5efe01a, 0x32f2468d, + 0xc0a5ab75, 0x27b80de2, 0x8fd5b0b1, 0x68c81626, 0x9a9ffbde, + 0x7d825d49, 0xa541266f, 0x425c80f8, 0xb00b6d00, 0x5716cb97, + 0xdafc9d0d, 0x3de13b9a, 0xcfb6d662, 0x28ab70f5, 0xf0680bd3, + 0x1775ad44, 0xe52240bc, 0x023fe62b, 0x2587ebc9, 0xc29a4d5e, + 0x30cda0a6, 0xd7d00631, 0x0f137d17, 0xe80edb80, 0x1a593678, + 0xfd4490ef, 0x70aec675, 0x97b360e2, 0x65e48d1a, 0x82f92b8d, + 0x5a3a50ab, 0xbd27f63c, 0x4f701bc4, 0xa86dbd53, 0xc4da6723, + 0x23c7c1b4, 0xd1902c4c, 0x368d8adb, 0xee4ef1fd, 0x0953576a, + 0xfb04ba92, 0x1c191c05, 0x91f34a9f, 0x76eeec08, 0x84b901f0, + 0x63a4a767, 0xbb67dc41, 0x5c7a7ad6, 0xae2d972e, 0x493031b9, + 0x6e883c5b, 0x89959acc, 0x7bc27734, 0x9cdfd1a3, 0x441caa85, + 0xa3010c12, 0x5156e1ea, 0xb64b477d, 0x3ba111e7, 0xdcbcb770, + 0x2eeb5a88, 0xc9f6fc1f, 0x11358739, 0xf62821ae, 0x047fcc56, + 0xe3626ac1, 0x4b0fd792, 0xac127105, 0x5e459cfd, 0xb9583a6a, + 0x619b414c, 0x8686e7db, 0x74d10a23, 0x93ccacb4, 0x1e26fa2e, + 0xf93b5cb9, 0x0b6cb141, 0xec7117d6, 0x34b26cf0, 0xd3afca67, + 0x21f8279f, 0xc6e58108, 0xe15d8cea, 0x06402a7d, 0xf417c785, + 0x130a6112, 0xcbc91a34, 0x2cd4bca3, 0xde83515b, 0x399ef7cc, + 0xb474a156, 0x536907c1, 0xa13eea39, 0x46234cae, 0x9ee03788, + 0x79fd911f, 0x8baa7ce7, 0x6cb7da70, 0x52c5c807, 0xb5d86e90, + 0x478f8368, 0xa09225ff, 0x78515ed9, 0x9f4cf84e, 0x6d1b15b6, + 0x8a06b321, 0x07ece5bb, 0xe0f1432c, 0x12a6aed4, 0xf5bb0843, + 0x2d787365, 0xca65d5f2, 0x3832380a, 0xdf2f9e9d, 0xf897937f, + 0x1f8a35e8, 0xedddd810, 0x0ac07e87, 0xd20305a1, 0x351ea336, + 0xc7494ece, 0x2054e859, 0xadbebec3, 0x4aa31854, 0xb8f4f5ac, + 0x5fe9533b, 0x872a281d, 0x60378e8a, 0x92606372, 0x757dc5e5, + 0xdd1078b6, 0x3a0dde21, 0xc85a33d9, 0x2f47954e, 0xf784ee68, + 0x109948ff, 0xe2cea507, 0x05d30390, 0x8839550a, 0x6f24f39d, + 0x9d731e65, 0x7a6eb8f2, 0xa2adc3d4, 0x45b06543, 0xb7e788bb, + 0x50fa2e2c, 0x774223ce, 0x905f8559, 0x620868a1, 0x8515ce36, + 0x5dd6b510, 0xbacb1387, 0x489cfe7f, 0xaf8158e8, 0x226b0e72, + 0xc576a8e5, 0x3721451d, 0xd03ce38a, 0x08ff98ac, 0xefe23e3b, + 0x1db5d3c3, 0xfaa87554, 0x961faf24, 0x710209b3, 0x8355e44b, + 0x644842dc, 0xbc8b39fa, 0x5b969f6d, 0xa9c17295, 0x4edcd402, + 0xc3368298, 0x242b240f, 0xd67cc9f7, 0x31616f60, 0xe9a21446, + 0x0ebfb2d1, 0xfce85f29, 0x1bf5f9be, 0x3c4df45c, 0xdb5052cb, + 0x2907bf33, 0xce1a19a4, 0x16d96282, 0xf1c4c415, 0x039329ed, + 0xe48e8f7a, 0x6964d9e0, 0x8e797f77, 0x7c2e928f, 0x9b333418, + 0x43f04f3e, 0xa4ede9a9, 0x56ba0451, 0xb1a7a2c6, 0x19ca1f95, + 0xfed7b902, 0x0c8054fa, 0xeb9df26d, 0x335e894b, 0xd4432fdc, + 0x2614c224, 0xc10964b3, 0x4ce33229, 0xabfe94be, 0x59a97946, + 0xbeb4dfd1, 0x6677a4f7, 0x816a0260, 0x733def98, 0x9420490f, + 0xb39844ed, 0x5485e27a, 0xa6d20f82, 0x41cfa915, 0x990cd233, + 0x7e1174a4, 0x8c46995c, 0x6b5b3fcb, 0xe6b16951, 0x01accfc6, + 0xf3fb223e, 0x14e684a9, 0xcc25ff8f, 0x2b385918, 0xd96fb4e0, + 0x3e721277}, + {0x00000000, 0xa58b900e, 0x9066265d, 0x35edb653, 0xfbbd4afb, + 0x5e36daf5, 0x6bdb6ca6, 0xce50fca8, 0x2c0b93b7, 0x898003b9, + 0xbc6db5ea, 0x19e625e4, 0xd7b6d94c, 0x723d4942, 0x47d0ff11, + 0xe25b6f1f, 0x5817276e, 0xfd9cb760, 0xc8710133, 0x6dfa913d, + 0xa3aa6d95, 0x0621fd9b, 0x33cc4bc8, 0x9647dbc6, 0x741cb4d9, + 0xd19724d7, 0xe47a9284, 0x41f1028a, 0x8fa1fe22, 0x2a2a6e2c, + 0x1fc7d87f, 0xba4c4871, 0xb02e4edc, 0x15a5ded2, 0x20486881, + 0x85c3f88f, 0x4b930427, 0xee189429, 0xdbf5227a, 0x7e7eb274, + 0x9c25dd6b, 0x39ae4d65, 0x0c43fb36, 0xa9c86b38, 0x67989790, + 0xc213079e, 0xf7feb1cd, 0x527521c3, 0xe83969b2, 0x4db2f9bc, + 0x785f4fef, 0xddd4dfe1, 0x13842349, 0xb60fb347, 0x83e20514, + 0x2669951a, 0xc432fa05, 0x61b96a0b, 0x5454dc58, 0xf1df4c56, + 0x3f8fb0fe, 0x9a0420f0, 0xafe996a3, 0x0a6206ad, 0xbb2d9bf9, + 0x1ea60bf7, 0x2b4bbda4, 0x8ec02daa, 0x4090d102, 0xe51b410c, + 0xd0f6f75f, 0x757d6751, 0x9726084e, 0x32ad9840, 0x07402e13, + 0xa2cbbe1d, 0x6c9b42b5, 0xc910d2bb, 0xfcfd64e8, 0x5976f4e6, + 0xe33abc97, 0x46b12c99, 0x735c9aca, 0xd6d70ac4, 0x1887f66c, + 0xbd0c6662, 0x88e1d031, 0x2d6a403f, 0xcf312f20, 0x6ababf2e, + 0x5f57097d, 0xfadc9973, 0x348c65db, 0x9107f5d5, 0xa4ea4386, + 0x0161d388, 0x0b03d525, 0xae88452b, 0x9b65f378, 0x3eee6376, + 0xf0be9fde, 0x55350fd0, 0x60d8b983, 0xc553298d, 0x27084692, + 0x8283d69c, 0xb76e60cf, 0x12e5f0c1, 0xdcb50c69, 0x793e9c67, + 0x4cd32a34, 0xe958ba3a, 0x5314f24b, 0xf69f6245, 0xc372d416, + 0x66f94418, 0xa8a9b8b0, 0x0d2228be, 0x38cf9eed, 0x9d440ee3, + 0x7f1f61fc, 0xda94f1f2, 0xef7947a1, 0x4af2d7af, 0x84a22b07, + 0x2129bb09, 0x14c40d5a, 0xb14f9d54, 0xad2a31b3, 0x08a1a1bd, + 0x3d4c17ee, 0x98c787e0, 0x56977b48, 0xf31ceb46, 0xc6f15d15, + 0x637acd1b, 0x8121a204, 0x24aa320a, 0x11478459, 0xb4cc1457, + 0x7a9ce8ff, 0xdf1778f1, 0xeafacea2, 0x4f715eac, 0xf53d16dd, + 0x50b686d3, 0x655b3080, 0xc0d0a08e, 0x0e805c26, 0xab0bcc28, + 0x9ee67a7b, 0x3b6dea75, 0xd936856a, 0x7cbd1564, 0x4950a337, + 0xecdb3339, 0x228bcf91, 0x87005f9f, 0xb2ede9cc, 0x176679c2, + 0x1d047f6f, 0xb88fef61, 0x8d625932, 0x28e9c93c, 0xe6b93594, + 0x4332a59a, 0x76df13c9, 0xd35483c7, 0x310fecd8, 0x94847cd6, + 0xa169ca85, 0x04e25a8b, 0xcab2a623, 0x6f39362d, 0x5ad4807e, + 0xff5f1070, 0x45135801, 0xe098c80f, 0xd5757e5c, 0x70feee52, + 0xbeae12fa, 0x1b2582f4, 0x2ec834a7, 0x8b43a4a9, 0x6918cbb6, + 0xcc935bb8, 0xf97eedeb, 0x5cf57de5, 0x92a5814d, 0x372e1143, + 0x02c3a710, 0xa748371e, 0x1607aa4a, 0xb38c3a44, 0x86618c17, + 0x23ea1c19, 0xedbae0b1, 0x483170bf, 0x7ddcc6ec, 0xd85756e2, + 0x3a0c39fd, 0x9f87a9f3, 0xaa6a1fa0, 0x0fe18fae, 0xc1b17306, + 0x643ae308, 0x51d7555b, 0xf45cc555, 0x4e108d24, 0xeb9b1d2a, + 0xde76ab79, 0x7bfd3b77, 0xb5adc7df, 0x102657d1, 0x25cbe182, + 0x8040718c, 0x621b1e93, 0xc7908e9d, 0xf27d38ce, 0x57f6a8c0, + 0x99a65468, 0x3c2dc466, 0x09c07235, 0xac4be23b, 0xa629e496, + 0x03a27498, 0x364fc2cb, 0x93c452c5, 0x5d94ae6d, 0xf81f3e63, + 0xcdf28830, 0x6879183e, 0x8a227721, 0x2fa9e72f, 0x1a44517c, + 0xbfcfc172, 0x719f3dda, 0xd414add4, 0xe1f91b87, 0x44728b89, + 0xfe3ec3f8, 0x5bb553f6, 0x6e58e5a5, 0xcbd375ab, 0x05838903, + 0xa008190d, 0x95e5af5e, 0x306e3f50, 0xd235504f, 0x77bec041, + 0x42537612, 0xe7d8e61c, 0x29881ab4, 0x8c038aba, 0xb9ee3ce9, + 0x1c65ace7}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x0000000000000000, 0x0e908ba500000000, 0x5d26669000000000, + 0x53b6ed3500000000, 0xfb4abdfb00000000, 0xf5da365e00000000, + 0xa66cdb6b00000000, 0xa8fc50ce00000000, 0xb7930b2c00000000, + 0xb903808900000000, 0xeab56dbc00000000, 0xe425e61900000000, + 0x4cd9b6d700000000, 0x42493d7200000000, 0x11ffd04700000000, + 0x1f6f5be200000000, 0x6e27175800000000, 0x60b79cfd00000000, + 0x330171c800000000, 0x3d91fa6d00000000, 0x956daaa300000000, + 0x9bfd210600000000, 0xc84bcc3300000000, 0xc6db479600000000, + 0xd9b41c7400000000, 0xd72497d100000000, 0x84927ae400000000, + 0x8a02f14100000000, 0x22fea18f00000000, 0x2c6e2a2a00000000, + 0x7fd8c71f00000000, 0x71484cba00000000, 0xdc4e2eb000000000, + 0xd2dea51500000000, 0x8168482000000000, 0x8ff8c38500000000, + 0x2704934b00000000, 0x299418ee00000000, 0x7a22f5db00000000, + 0x74b27e7e00000000, 0x6bdd259c00000000, 0x654dae3900000000, + 0x36fb430c00000000, 0x386bc8a900000000, 0x9097986700000000, + 0x9e0713c200000000, 0xcdb1fef700000000, 0xc321755200000000, + 0xb26939e800000000, 0xbcf9b24d00000000, 0xef4f5f7800000000, + 0xe1dfd4dd00000000, 0x4923841300000000, 0x47b30fb600000000, + 0x1405e28300000000, 0x1a95692600000000, 0x05fa32c400000000, + 0x0b6ab96100000000, 0x58dc545400000000, 0x564cdff100000000, + 0xfeb08f3f00000000, 0xf020049a00000000, 0xa396e9af00000000, + 0xad06620a00000000, 0xf99b2dbb00000000, 0xf70ba61e00000000, + 0xa4bd4b2b00000000, 0xaa2dc08e00000000, 0x02d1904000000000, + 0x0c411be500000000, 0x5ff7f6d000000000, 0x51677d7500000000, + 0x4e08269700000000, 0x4098ad3200000000, 0x132e400700000000, + 0x1dbecba200000000, 0xb5429b6c00000000, 0xbbd210c900000000, + 0xe864fdfc00000000, 0xe6f4765900000000, 0x97bc3ae300000000, + 0x992cb14600000000, 0xca9a5c7300000000, 0xc40ad7d600000000, + 0x6cf6871800000000, 0x62660cbd00000000, 0x31d0e18800000000, + 0x3f406a2d00000000, 0x202f31cf00000000, 0x2ebfba6a00000000, + 0x7d09575f00000000, 0x7399dcfa00000000, 0xdb658c3400000000, + 0xd5f5079100000000, 0x8643eaa400000000, 0x88d3610100000000, + 0x25d5030b00000000, 0x2b4588ae00000000, 0x78f3659b00000000, + 0x7663ee3e00000000, 0xde9fbef000000000, 0xd00f355500000000, + 0x83b9d86000000000, 0x8d2953c500000000, 0x9246082700000000, + 0x9cd6838200000000, 0xcf606eb700000000, 0xc1f0e51200000000, + 0x690cb5dc00000000, 0x679c3e7900000000, 0x342ad34c00000000, + 0x3aba58e900000000, 0x4bf2145300000000, 0x45629ff600000000, + 0x16d472c300000000, 0x1844f96600000000, 0xb0b8a9a800000000, + 0xbe28220d00000000, 0xed9ecf3800000000, 0xe30e449d00000000, + 0xfc611f7f00000000, 0xf2f194da00000000, 0xa14779ef00000000, + 0xafd7f24a00000000, 0x072ba28400000000, 0x09bb292100000000, + 0x5a0dc41400000000, 0x549d4fb100000000, 0xb3312aad00000000, + 0xbda1a10800000000, 0xee174c3d00000000, 0xe087c79800000000, + 0x487b975600000000, 0x46eb1cf300000000, 0x155df1c600000000, + 0x1bcd7a6300000000, 0x04a2218100000000, 0x0a32aa2400000000, + 0x5984471100000000, 0x5714ccb400000000, 0xffe89c7a00000000, + 0xf17817df00000000, 0xa2cefaea00000000, 0xac5e714f00000000, + 0xdd163df500000000, 0xd386b65000000000, 0x80305b6500000000, + 0x8ea0d0c000000000, 0x265c800e00000000, 0x28cc0bab00000000, + 0x7b7ae69e00000000, 0x75ea6d3b00000000, 0x6a8536d900000000, + 0x6415bd7c00000000, 0x37a3504900000000, 0x3933dbec00000000, + 0x91cf8b2200000000, 0x9f5f008700000000, 0xcce9edb200000000, + 0xc279661700000000, 0x6f7f041d00000000, 0x61ef8fb800000000, + 0x3259628d00000000, 0x3cc9e92800000000, 0x9435b9e600000000, + 0x9aa5324300000000, 0xc913df7600000000, 0xc78354d300000000, + 0xd8ec0f3100000000, 0xd67c849400000000, 0x85ca69a100000000, + 0x8b5ae20400000000, 0x23a6b2ca00000000, 0x2d36396f00000000, + 0x7e80d45a00000000, 0x70105fff00000000, 0x0158134500000000, + 0x0fc898e000000000, 0x5c7e75d500000000, 0x52eefe7000000000, + 0xfa12aebe00000000, 0xf482251b00000000, 0xa734c82e00000000, + 0xa9a4438b00000000, 0xb6cb186900000000, 0xb85b93cc00000000, + 0xebed7ef900000000, 0xe57df55c00000000, 0x4d81a59200000000, + 0x43112e3700000000, 0x10a7c30200000000, 0x1e3748a700000000, + 0x4aaa071600000000, 0x443a8cb300000000, 0x178c618600000000, + 0x191cea2300000000, 0xb1e0baed00000000, 0xbf70314800000000, + 0xecc6dc7d00000000, 0xe25657d800000000, 0xfd390c3a00000000, + 0xf3a9879f00000000, 0xa01f6aaa00000000, 0xae8fe10f00000000, + 0x0673b1c100000000, 0x08e33a6400000000, 0x5b55d75100000000, + 0x55c55cf400000000, 0x248d104e00000000, 0x2a1d9beb00000000, + 0x79ab76de00000000, 0x773bfd7b00000000, 0xdfc7adb500000000, + 0xd157261000000000, 0x82e1cb2500000000, 0x8c71408000000000, + 0x931e1b6200000000, 0x9d8e90c700000000, 0xce387df200000000, + 0xc0a8f65700000000, 0x6854a69900000000, 0x66c42d3c00000000, + 0x3572c00900000000, 0x3be24bac00000000, 0x96e429a600000000, + 0x9874a20300000000, 0xcbc24f3600000000, 0xc552c49300000000, + 0x6dae945d00000000, 0x633e1ff800000000, 0x3088f2cd00000000, + 0x3e18796800000000, 0x2177228a00000000, 0x2fe7a92f00000000, + 0x7c51441a00000000, 0x72c1cfbf00000000, 0xda3d9f7100000000, + 0xd4ad14d400000000, 0x871bf9e100000000, 0x898b724400000000, + 0xf8c33efe00000000, 0xf653b55b00000000, 0xa5e5586e00000000, + 0xab75d3cb00000000, 0x0389830500000000, 0x0d1908a000000000, + 0x5eafe59500000000, 0x503f6e3000000000, 0x4f5035d200000000, + 0x41c0be7700000000, 0x1276534200000000, 0x1ce6d8e700000000, + 0xb41a882900000000, 0xba8a038c00000000, 0xe93ceeb900000000, + 0xe7ac651c00000000}, + {0x0000000000000000, 0x97a61de700000000, 0x6f4b4a1500000000, + 0xf8ed57f200000000, 0xde96942a00000000, 0x493089cd00000000, + 0xb1ddde3f00000000, 0x267bc3d800000000, 0xbc2d295500000000, + 0x2b8b34b200000000, 0xd366634000000000, 0x44c07ea700000000, + 0x62bbbd7f00000000, 0xf51da09800000000, 0x0df0f76a00000000, + 0x9a56ea8d00000000, 0x785b52aa00000000, 0xeffd4f4d00000000, + 0x171018bf00000000, 0x80b6055800000000, 0xa6cdc68000000000, + 0x316bdb6700000000, 0xc9868c9500000000, 0x5e20917200000000, + 0xc4767bff00000000, 0x53d0661800000000, 0xab3d31ea00000000, + 0x3c9b2c0d00000000, 0x1ae0efd500000000, 0x8d46f23200000000, + 0x75aba5c000000000, 0xe20db82700000000, 0xb1b0d58f00000000, + 0x2616c86800000000, 0xdefb9f9a00000000, 0x495d827d00000000, + 0x6f2641a500000000, 0xf8805c4200000000, 0x006d0bb000000000, + 0x97cb165700000000, 0x0d9dfcda00000000, 0x9a3be13d00000000, + 0x62d6b6cf00000000, 0xf570ab2800000000, 0xd30b68f000000000, + 0x44ad751700000000, 0xbc4022e500000000, 0x2be63f0200000000, + 0xc9eb872500000000, 0x5e4d9ac200000000, 0xa6a0cd3000000000, + 0x3106d0d700000000, 0x177d130f00000000, 0x80db0ee800000000, + 0x7836591a00000000, 0xef9044fd00000000, 0x75c6ae7000000000, + 0xe260b39700000000, 0x1a8de46500000000, 0x8d2bf98200000000, + 0xab503a5a00000000, 0x3cf627bd00000000, 0xc41b704f00000000, + 0x53bd6da800000000, 0x2367dac400000000, 0xb4c1c72300000000, + 0x4c2c90d100000000, 0xdb8a8d3600000000, 0xfdf14eee00000000, + 0x6a57530900000000, 0x92ba04fb00000000, 0x051c191c00000000, + 0x9f4af39100000000, 0x08ecee7600000000, 0xf001b98400000000, + 0x67a7a46300000000, 0x41dc67bb00000000, 0xd67a7a5c00000000, + 0x2e972dae00000000, 0xb931304900000000, 0x5b3c886e00000000, + 0xcc9a958900000000, 0x3477c27b00000000, 0xa3d1df9c00000000, + 0x85aa1c4400000000, 0x120c01a300000000, 0xeae1565100000000, + 0x7d474bb600000000, 0xe711a13b00000000, 0x70b7bcdc00000000, + 0x885aeb2e00000000, 0x1ffcf6c900000000, 0x3987351100000000, + 0xae2128f600000000, 0x56cc7f0400000000, 0xc16a62e300000000, + 0x92d70f4b00000000, 0x057112ac00000000, 0xfd9c455e00000000, + 0x6a3a58b900000000, 0x4c419b6100000000, 0xdbe7868600000000, + 0x230ad17400000000, 0xb4accc9300000000, 0x2efa261e00000000, + 0xb95c3bf900000000, 0x41b16c0b00000000, 0xd61771ec00000000, + 0xf06cb23400000000, 0x67caafd300000000, 0x9f27f82100000000, + 0x0881e5c600000000, 0xea8c5de100000000, 0x7d2a400600000000, + 0x85c717f400000000, 0x12610a1300000000, 0x341ac9cb00000000, + 0xa3bcd42c00000000, 0x5b5183de00000000, 0xccf79e3900000000, + 0x56a174b400000000, 0xc107695300000000, 0x39ea3ea100000000, + 0xae4c234600000000, 0x8837e09e00000000, 0x1f91fd7900000000, + 0xe77caa8b00000000, 0x70dab76c00000000, 0x07c8c55200000000, + 0x906ed8b500000000, 0x68838f4700000000, 0xff2592a000000000, + 0xd95e517800000000, 0x4ef84c9f00000000, 0xb6151b6d00000000, + 0x21b3068a00000000, 0xbbe5ec0700000000, 0x2c43f1e000000000, + 0xd4aea61200000000, 0x4308bbf500000000, 0x6573782d00000000, + 0xf2d565ca00000000, 0x0a38323800000000, 0x9d9e2fdf00000000, + 0x7f9397f800000000, 0xe8358a1f00000000, 0x10d8dded00000000, + 0x877ec00a00000000, 0xa10503d200000000, 0x36a31e3500000000, + 0xce4e49c700000000, 0x59e8542000000000, 0xc3bebead00000000, + 0x5418a34a00000000, 0xacf5f4b800000000, 0x3b53e95f00000000, + 0x1d282a8700000000, 0x8a8e376000000000, 0x7263609200000000, + 0xe5c57d7500000000, 0xb67810dd00000000, 0x21de0d3a00000000, + 0xd9335ac800000000, 0x4e95472f00000000, 0x68ee84f700000000, + 0xff48991000000000, 0x07a5cee200000000, 0x9003d30500000000, + 0x0a55398800000000, 0x9df3246f00000000, 0x651e739d00000000, + 0xf2b86e7a00000000, 0xd4c3ada200000000, 0x4365b04500000000, + 0xbb88e7b700000000, 0x2c2efa5000000000, 0xce23427700000000, + 0x59855f9000000000, 0xa168086200000000, 0x36ce158500000000, + 0x10b5d65d00000000, 0x8713cbba00000000, 0x7ffe9c4800000000, + 0xe85881af00000000, 0x720e6b2200000000, 0xe5a876c500000000, + 0x1d45213700000000, 0x8ae33cd000000000, 0xac98ff0800000000, + 0x3b3ee2ef00000000, 0xc3d3b51d00000000, 0x5475a8fa00000000, + 0x24af1f9600000000, 0xb309027100000000, 0x4be4558300000000, + 0xdc42486400000000, 0xfa398bbc00000000, 0x6d9f965b00000000, + 0x9572c1a900000000, 0x02d4dc4e00000000, 0x988236c300000000, + 0x0f242b2400000000, 0xf7c97cd600000000, 0x606f613100000000, + 0x4614a2e900000000, 0xd1b2bf0e00000000, 0x295fe8fc00000000, + 0xbef9f51b00000000, 0x5cf44d3c00000000, 0xcb5250db00000000, + 0x33bf072900000000, 0xa4191ace00000000, 0x8262d91600000000, + 0x15c4c4f100000000, 0xed29930300000000, 0x7a8f8ee400000000, + 0xe0d9646900000000, 0x777f798e00000000, 0x8f922e7c00000000, + 0x1834339b00000000, 0x3e4ff04300000000, 0xa9e9eda400000000, + 0x5104ba5600000000, 0xc6a2a7b100000000, 0x951fca1900000000, + 0x02b9d7fe00000000, 0xfa54800c00000000, 0x6df29deb00000000, + 0x4b895e3300000000, 0xdc2f43d400000000, 0x24c2142600000000, + 0xb36409c100000000, 0x2932e34c00000000, 0xbe94feab00000000, + 0x4679a95900000000, 0xd1dfb4be00000000, 0xf7a4776600000000, + 0x60026a8100000000, 0x98ef3d7300000000, 0x0f49209400000000, + 0xed4498b300000000, 0x7ae2855400000000, 0x820fd2a600000000, + 0x15a9cf4100000000, 0x33d20c9900000000, 0xa474117e00000000, + 0x5c99468c00000000, 0xcb3f5b6b00000000, 0x5169b1e600000000, + 0xc6cfac0100000000, 0x3e22fbf300000000, 0xa984e61400000000, + 0x8fff25cc00000000, 0x1859382b00000000, 0xe0b46fd900000000, + 0x7712723e00000000}, + {0x0000000000000000, 0x411b8c6e00000000, 0x823618dd00000000, + 0xc32d94b300000000, 0x456b416100000000, 0x0470cd0f00000000, + 0xc75d59bc00000000, 0x8646d5d200000000, 0x8ad682c200000000, + 0xcbcd0eac00000000, 0x08e09a1f00000000, 0x49fb167100000000, + 0xcfbdc3a300000000, 0x8ea64fcd00000000, 0x4d8bdb7e00000000, + 0x0c90571000000000, 0x55ab745e00000000, 0x14b0f83000000000, + 0xd79d6c8300000000, 0x9686e0ed00000000, 0x10c0353f00000000, + 0x51dbb95100000000, 0x92f62de200000000, 0xd3eda18c00000000, + 0xdf7df69c00000000, 0x9e667af200000000, 0x5d4bee4100000000, + 0x1c50622f00000000, 0x9a16b7fd00000000, 0xdb0d3b9300000000, + 0x1820af2000000000, 0x593b234e00000000, 0xaa56e9bc00000000, + 0xeb4d65d200000000, 0x2860f16100000000, 0x697b7d0f00000000, + 0xef3da8dd00000000, 0xae2624b300000000, 0x6d0bb00000000000, + 0x2c103c6e00000000, 0x20806b7e00000000, 0x619be71000000000, + 0xa2b673a300000000, 0xe3adffcd00000000, 0x65eb2a1f00000000, + 0x24f0a67100000000, 0xe7dd32c200000000, 0xa6c6beac00000000, + 0xfffd9de200000000, 0xbee6118c00000000, 0x7dcb853f00000000, + 0x3cd0095100000000, 0xba96dc8300000000, 0xfb8d50ed00000000, + 0x38a0c45e00000000, 0x79bb483000000000, 0x752b1f2000000000, + 0x3430934e00000000, 0xf71d07fd00000000, 0xb6068b9300000000, + 0x30405e4100000000, 0x715bd22f00000000, 0xb276469c00000000, + 0xf36dcaf200000000, 0x15aba3a200000000, 0x54b02fcc00000000, + 0x979dbb7f00000000, 0xd686371100000000, 0x50c0e2c300000000, + 0x11db6ead00000000, 0xd2f6fa1e00000000, 0x93ed767000000000, + 0x9f7d216000000000, 0xde66ad0e00000000, 0x1d4b39bd00000000, + 0x5c50b5d300000000, 0xda16600100000000, 0x9b0dec6f00000000, + 0x582078dc00000000, 0x193bf4b200000000, 0x4000d7fc00000000, + 0x011b5b9200000000, 0xc236cf2100000000, 0x832d434f00000000, + 0x056b969d00000000, 0x44701af300000000, 0x875d8e4000000000, + 0xc646022e00000000, 0xcad6553e00000000, 0x8bcdd95000000000, + 0x48e04de300000000, 0x09fbc18d00000000, 0x8fbd145f00000000, + 0xcea6983100000000, 0x0d8b0c8200000000, 0x4c9080ec00000000, + 0xbffd4a1e00000000, 0xfee6c67000000000, 0x3dcb52c300000000, + 0x7cd0dead00000000, 0xfa960b7f00000000, 0xbb8d871100000000, + 0x78a013a200000000, 0x39bb9fcc00000000, 0x352bc8dc00000000, + 0x743044b200000000, 0xb71dd00100000000, 0xf6065c6f00000000, + 0x704089bd00000000, 0x315b05d300000000, 0xf276916000000000, + 0xb36d1d0e00000000, 0xea563e4000000000, 0xab4db22e00000000, + 0x6860269d00000000, 0x297baaf300000000, 0xaf3d7f2100000000, + 0xee26f34f00000000, 0x2d0b67fc00000000, 0x6c10eb9200000000, + 0x6080bc8200000000, 0x219b30ec00000000, 0xe2b6a45f00000000, + 0xa3ad283100000000, 0x25ebfde300000000, 0x64f0718d00000000, + 0xa7dde53e00000000, 0xe6c6695000000000, 0x6b50369e00000000, + 0x2a4bbaf000000000, 0xe9662e4300000000, 0xa87da22d00000000, + 0x2e3b77ff00000000, 0x6f20fb9100000000, 0xac0d6f2200000000, + 0xed16e34c00000000, 0xe186b45c00000000, 0xa09d383200000000, + 0x63b0ac8100000000, 0x22ab20ef00000000, 0xa4edf53d00000000, + 0xe5f6795300000000, 0x26dbede000000000, 0x67c0618e00000000, + 0x3efb42c000000000, 0x7fe0ceae00000000, 0xbccd5a1d00000000, + 0xfdd6d67300000000, 0x7b9003a100000000, 0x3a8b8fcf00000000, + 0xf9a61b7c00000000, 0xb8bd971200000000, 0xb42dc00200000000, + 0xf5364c6c00000000, 0x361bd8df00000000, 0x770054b100000000, + 0xf146816300000000, 0xb05d0d0d00000000, 0x737099be00000000, + 0x326b15d000000000, 0xc106df2200000000, 0x801d534c00000000, + 0x4330c7ff00000000, 0x022b4b9100000000, 0x846d9e4300000000, + 0xc576122d00000000, 0x065b869e00000000, 0x47400af000000000, + 0x4bd05de000000000, 0x0acbd18e00000000, 0xc9e6453d00000000, + 0x88fdc95300000000, 0x0ebb1c8100000000, 0x4fa090ef00000000, + 0x8c8d045c00000000, 0xcd96883200000000, 0x94adab7c00000000, + 0xd5b6271200000000, 0x169bb3a100000000, 0x57803fcf00000000, + 0xd1c6ea1d00000000, 0x90dd667300000000, 0x53f0f2c000000000, + 0x12eb7eae00000000, 0x1e7b29be00000000, 0x5f60a5d000000000, + 0x9c4d316300000000, 0xdd56bd0d00000000, 0x5b1068df00000000, + 0x1a0be4b100000000, 0xd926700200000000, 0x983dfc6c00000000, + 0x7efb953c00000000, 0x3fe0195200000000, 0xfccd8de100000000, + 0xbdd6018f00000000, 0x3b90d45d00000000, 0x7a8b583300000000, + 0xb9a6cc8000000000, 0xf8bd40ee00000000, 0xf42d17fe00000000, + 0xb5369b9000000000, 0x761b0f2300000000, 0x3700834d00000000, + 0xb146569f00000000, 0xf05ddaf100000000, 0x33704e4200000000, + 0x726bc22c00000000, 0x2b50e16200000000, 0x6a4b6d0c00000000, + 0xa966f9bf00000000, 0xe87d75d100000000, 0x6e3ba00300000000, + 0x2f202c6d00000000, 0xec0db8de00000000, 0xad1634b000000000, + 0xa18663a000000000, 0xe09defce00000000, 0x23b07b7d00000000, + 0x62abf71300000000, 0xe4ed22c100000000, 0xa5f6aeaf00000000, + 0x66db3a1c00000000, 0x27c0b67200000000, 0xd4ad7c8000000000, + 0x95b6f0ee00000000, 0x569b645d00000000, 0x1780e83300000000, + 0x91c63de100000000, 0xd0ddb18f00000000, 0x13f0253c00000000, + 0x52eba95200000000, 0x5e7bfe4200000000, 0x1f60722c00000000, + 0xdc4de69f00000000, 0x9d566af100000000, 0x1b10bf2300000000, + 0x5a0b334d00000000, 0x9926a7fe00000000, 0xd83d2b9000000000, + 0x810608de00000000, 0xc01d84b000000000, 0x0330100300000000, + 0x422b9c6d00000000, 0xc46d49bf00000000, 0x8576c5d100000000, + 0x465b516200000000, 0x0740dd0c00000000, 0x0bd08a1c00000000, + 0x4acb067200000000, 0x89e692c100000000, 0xc8fd1eaf00000000, + 0x4ebbcb7d00000000, 0x0fa0471300000000, 0xcc8dd3a000000000, + 0x8d965fce00000000}, + {0x0000000000000000, 0x1dfdb50100000000, 0x3afa6b0300000000, + 0x2707de0200000000, 0x74f4d70600000000, 0x6909620700000000, + 0x4e0ebc0500000000, 0x53f3090400000000, 0xe8e8af0d00000000, + 0xf5151a0c00000000, 0xd212c40e00000000, 0xcfef710f00000000, + 0x9c1c780b00000000, 0x81e1cd0a00000000, 0xa6e6130800000000, + 0xbb1ba60900000000, 0xd0d15f1b00000000, 0xcd2cea1a00000000, + 0xea2b341800000000, 0xf7d6811900000000, 0xa425881d00000000, + 0xb9d83d1c00000000, 0x9edfe31e00000000, 0x8322561f00000000, + 0x3839f01600000000, 0x25c4451700000000, 0x02c39b1500000000, + 0x1f3e2e1400000000, 0x4ccd271000000000, 0x5130921100000000, + 0x76374c1300000000, 0x6bcaf91200000000, 0xa0a3bf3600000000, + 0xbd5e0a3700000000, 0x9a59d43500000000, 0x87a4613400000000, + 0xd457683000000000, 0xc9aadd3100000000, 0xeead033300000000, + 0xf350b63200000000, 0x484b103b00000000, 0x55b6a53a00000000, + 0x72b17b3800000000, 0x6f4cce3900000000, 0x3cbfc73d00000000, + 0x2142723c00000000, 0x0645ac3e00000000, 0x1bb8193f00000000, + 0x7072e02d00000000, 0x6d8f552c00000000, 0x4a888b2e00000000, + 0x57753e2f00000000, 0x0486372b00000000, 0x197b822a00000000, + 0x3e7c5c2800000000, 0x2381e92900000000, 0x989a4f2000000000, + 0x8567fa2100000000, 0xa260242300000000, 0xbf9d912200000000, + 0xec6e982600000000, 0xf1932d2700000000, 0xd694f32500000000, + 0xcb69462400000000, 0x40477f6d00000000, 0x5dbaca6c00000000, + 0x7abd146e00000000, 0x6740a16f00000000, 0x34b3a86b00000000, + 0x294e1d6a00000000, 0x0e49c36800000000, 0x13b4766900000000, + 0xa8afd06000000000, 0xb552656100000000, 0x9255bb6300000000, + 0x8fa80e6200000000, 0xdc5b076600000000, 0xc1a6b26700000000, + 0xe6a16c6500000000, 0xfb5cd96400000000, 0x9096207600000000, + 0x8d6b957700000000, 0xaa6c4b7500000000, 0xb791fe7400000000, + 0xe462f77000000000, 0xf99f427100000000, 0xde989c7300000000, + 0xc365297200000000, 0x787e8f7b00000000, 0x65833a7a00000000, + 0x4284e47800000000, 0x5f79517900000000, 0x0c8a587d00000000, + 0x1177ed7c00000000, 0x3670337e00000000, 0x2b8d867f00000000, + 0xe0e4c05b00000000, 0xfd19755a00000000, 0xda1eab5800000000, + 0xc7e31e5900000000, 0x9410175d00000000, 0x89eda25c00000000, + 0xaeea7c5e00000000, 0xb317c95f00000000, 0x080c6f5600000000, + 0x15f1da5700000000, 0x32f6045500000000, 0x2f0bb15400000000, + 0x7cf8b85000000000, 0x61050d5100000000, 0x4602d35300000000, + 0x5bff665200000000, 0x30359f4000000000, 0x2dc82a4100000000, + 0x0acff44300000000, 0x1732414200000000, 0x44c1484600000000, + 0x593cfd4700000000, 0x7e3b234500000000, 0x63c6964400000000, + 0xd8dd304d00000000, 0xc520854c00000000, 0xe2275b4e00000000, + 0xffdaee4f00000000, 0xac29e74b00000000, 0xb1d4524a00000000, + 0x96d38c4800000000, 0x8b2e394900000000, 0x808efeda00000000, + 0x9d734bdb00000000, 0xba7495d900000000, 0xa78920d800000000, + 0xf47a29dc00000000, 0xe9879cdd00000000, 0xce8042df00000000, + 0xd37df7de00000000, 0x686651d700000000, 0x759be4d600000000, + 0x529c3ad400000000, 0x4f618fd500000000, 0x1c9286d100000000, + 0x016f33d000000000, 0x2668edd200000000, 0x3b9558d300000000, + 0x505fa1c100000000, 0x4da214c000000000, 0x6aa5cac200000000, + 0x77587fc300000000, 0x24ab76c700000000, 0x3956c3c600000000, + 0x1e511dc400000000, 0x03aca8c500000000, 0xb8b70ecc00000000, + 0xa54abbcd00000000, 0x824d65cf00000000, 0x9fb0d0ce00000000, + 0xcc43d9ca00000000, 0xd1be6ccb00000000, 0xf6b9b2c900000000, + 0xeb4407c800000000, 0x202d41ec00000000, 0x3dd0f4ed00000000, + 0x1ad72aef00000000, 0x072a9fee00000000, 0x54d996ea00000000, + 0x492423eb00000000, 0x6e23fde900000000, 0x73de48e800000000, + 0xc8c5eee100000000, 0xd5385be000000000, 0xf23f85e200000000, + 0xefc230e300000000, 0xbc3139e700000000, 0xa1cc8ce600000000, + 0x86cb52e400000000, 0x9b36e7e500000000, 0xf0fc1ef700000000, + 0xed01abf600000000, 0xca0675f400000000, 0xd7fbc0f500000000, + 0x8408c9f100000000, 0x99f57cf000000000, 0xbef2a2f200000000, + 0xa30f17f300000000, 0x1814b1fa00000000, 0x05e904fb00000000, + 0x22eedaf900000000, 0x3f136ff800000000, 0x6ce066fc00000000, + 0x711dd3fd00000000, 0x561a0dff00000000, 0x4be7b8fe00000000, + 0xc0c981b700000000, 0xdd3434b600000000, 0xfa33eab400000000, + 0xe7ce5fb500000000, 0xb43d56b100000000, 0xa9c0e3b000000000, + 0x8ec73db200000000, 0x933a88b300000000, 0x28212eba00000000, + 0x35dc9bbb00000000, 0x12db45b900000000, 0x0f26f0b800000000, + 0x5cd5f9bc00000000, 0x41284cbd00000000, 0x662f92bf00000000, + 0x7bd227be00000000, 0x1018deac00000000, 0x0de56bad00000000, + 0x2ae2b5af00000000, 0x371f00ae00000000, 0x64ec09aa00000000, + 0x7911bcab00000000, 0x5e1662a900000000, 0x43ebd7a800000000, + 0xf8f071a100000000, 0xe50dc4a000000000, 0xc20a1aa200000000, + 0xdff7afa300000000, 0x8c04a6a700000000, 0x91f913a600000000, + 0xb6fecda400000000, 0xab0378a500000000, 0x606a3e8100000000, + 0x7d978b8000000000, 0x5a90558200000000, 0x476de08300000000, + 0x149ee98700000000, 0x09635c8600000000, 0x2e64828400000000, + 0x3399378500000000, 0x8882918c00000000, 0x957f248d00000000, + 0xb278fa8f00000000, 0xaf854f8e00000000, 0xfc76468a00000000, + 0xe18bf38b00000000, 0xc68c2d8900000000, 0xdb71988800000000, + 0xb0bb619a00000000, 0xad46d49b00000000, 0x8a410a9900000000, + 0x97bcbf9800000000, 0xc44fb69c00000000, 0xd9b2039d00000000, + 0xfeb5dd9f00000000, 0xe348689e00000000, 0x5853ce9700000000, + 0x45ae7b9600000000, 0x62a9a59400000000, 0x7f54109500000000, + 0x2ca7199100000000, 0x315aac9000000000, 0x165d729200000000, + 0x0ba0c79300000000}, + {0x0000000000000000, 0x24d9076300000000, 0x48b20fc600000000, + 0x6c6b08a500000000, 0xd1626e5700000000, 0xf5bb693400000000, + 0x99d0619100000000, 0xbd0966f200000000, 0xa2c5dcae00000000, + 0x861cdbcd00000000, 0xea77d36800000000, 0xceaed40b00000000, + 0x73a7b2f900000000, 0x577eb59a00000000, 0x3b15bd3f00000000, + 0x1fccba5c00000000, 0x058dc88600000000, 0x2154cfe500000000, + 0x4d3fc74000000000, 0x69e6c02300000000, 0xd4efa6d100000000, + 0xf036a1b200000000, 0x9c5da91700000000, 0xb884ae7400000000, + 0xa748142800000000, 0x8391134b00000000, 0xeffa1bee00000000, + 0xcb231c8d00000000, 0x762a7a7f00000000, 0x52f37d1c00000000, + 0x3e9875b900000000, 0x1a4172da00000000, 0x4b1ce0d600000000, + 0x6fc5e7b500000000, 0x03aeef1000000000, 0x2777e87300000000, + 0x9a7e8e8100000000, 0xbea789e200000000, 0xd2cc814700000000, + 0xf615862400000000, 0xe9d93c7800000000, 0xcd003b1b00000000, + 0xa16b33be00000000, 0x85b234dd00000000, 0x38bb522f00000000, + 0x1c62554c00000000, 0x70095de900000000, 0x54d05a8a00000000, + 0x4e91285000000000, 0x6a482f3300000000, 0x0623279600000000, + 0x22fa20f500000000, 0x9ff3460700000000, 0xbb2a416400000000, + 0xd74149c100000000, 0xf3984ea200000000, 0xec54f4fe00000000, + 0xc88df39d00000000, 0xa4e6fb3800000000, 0x803ffc5b00000000, + 0x3d369aa900000000, 0x19ef9dca00000000, 0x7584956f00000000, + 0x515d920c00000000, 0xd73eb17600000000, 0xf3e7b61500000000, + 0x9f8cbeb000000000, 0xbb55b9d300000000, 0x065cdf2100000000, + 0x2285d84200000000, 0x4eeed0e700000000, 0x6a37d78400000000, + 0x75fb6dd800000000, 0x51226abb00000000, 0x3d49621e00000000, + 0x1990657d00000000, 0xa499038f00000000, 0x804004ec00000000, + 0xec2b0c4900000000, 0xc8f20b2a00000000, 0xd2b379f000000000, + 0xf66a7e9300000000, 0x9a01763600000000, 0xbed8715500000000, + 0x03d117a700000000, 0x270810c400000000, 0x4b63186100000000, + 0x6fba1f0200000000, 0x7076a55e00000000, 0x54afa23d00000000, + 0x38c4aa9800000000, 0x1c1dadfb00000000, 0xa114cb0900000000, + 0x85cdcc6a00000000, 0xe9a6c4cf00000000, 0xcd7fc3ac00000000, + 0x9c2251a000000000, 0xb8fb56c300000000, 0xd4905e6600000000, + 0xf049590500000000, 0x4d403ff700000000, 0x6999389400000000, + 0x05f2303100000000, 0x212b375200000000, 0x3ee78d0e00000000, + 0x1a3e8a6d00000000, 0x765582c800000000, 0x528c85ab00000000, + 0xef85e35900000000, 0xcb5ce43a00000000, 0xa737ec9f00000000, + 0x83eeebfc00000000, 0x99af992600000000, 0xbd769e4500000000, + 0xd11d96e000000000, 0xf5c4918300000000, 0x48cdf77100000000, + 0x6c14f01200000000, 0x007ff8b700000000, 0x24a6ffd400000000, + 0x3b6a458800000000, 0x1fb342eb00000000, 0x73d84a4e00000000, + 0x57014d2d00000000, 0xea082bdf00000000, 0xced12cbc00000000, + 0xa2ba241900000000, 0x8663237a00000000, 0xae7d62ed00000000, + 0x8aa4658e00000000, 0xe6cf6d2b00000000, 0xc2166a4800000000, + 0x7f1f0cba00000000, 0x5bc60bd900000000, 0x37ad037c00000000, + 0x1374041f00000000, 0x0cb8be4300000000, 0x2861b92000000000, + 0x440ab18500000000, 0x60d3b6e600000000, 0xdddad01400000000, + 0xf903d77700000000, 0x9568dfd200000000, 0xb1b1d8b100000000, + 0xabf0aa6b00000000, 0x8f29ad0800000000, 0xe342a5ad00000000, + 0xc79ba2ce00000000, 0x7a92c43c00000000, 0x5e4bc35f00000000, + 0x3220cbfa00000000, 0x16f9cc9900000000, 0x093576c500000000, + 0x2dec71a600000000, 0x4187790300000000, 0x655e7e6000000000, + 0xd857189200000000, 0xfc8e1ff100000000, 0x90e5175400000000, + 0xb43c103700000000, 0xe561823b00000000, 0xc1b8855800000000, + 0xadd38dfd00000000, 0x890a8a9e00000000, 0x3403ec6c00000000, + 0x10daeb0f00000000, 0x7cb1e3aa00000000, 0x5868e4c900000000, + 0x47a45e9500000000, 0x637d59f600000000, 0x0f16515300000000, + 0x2bcf563000000000, 0x96c630c200000000, 0xb21f37a100000000, + 0xde743f0400000000, 0xfaad386700000000, 0xe0ec4abd00000000, + 0xc4354dde00000000, 0xa85e457b00000000, 0x8c87421800000000, + 0x318e24ea00000000, 0x1557238900000000, 0x793c2b2c00000000, + 0x5de52c4f00000000, 0x4229961300000000, 0x66f0917000000000, + 0x0a9b99d500000000, 0x2e429eb600000000, 0x934bf84400000000, + 0xb792ff2700000000, 0xdbf9f78200000000, 0xff20f0e100000000, + 0x7943d39b00000000, 0x5d9ad4f800000000, 0x31f1dc5d00000000, + 0x1528db3e00000000, 0xa821bdcc00000000, 0x8cf8baaf00000000, + 0xe093b20a00000000, 0xc44ab56900000000, 0xdb860f3500000000, + 0xff5f085600000000, 0x933400f300000000, 0xb7ed079000000000, + 0x0ae4616200000000, 0x2e3d660100000000, 0x42566ea400000000, + 0x668f69c700000000, 0x7cce1b1d00000000, 0x58171c7e00000000, + 0x347c14db00000000, 0x10a513b800000000, 0xadac754a00000000, + 0x8975722900000000, 0xe51e7a8c00000000, 0xc1c77def00000000, + 0xde0bc7b300000000, 0xfad2c0d000000000, 0x96b9c87500000000, + 0xb260cf1600000000, 0x0f69a9e400000000, 0x2bb0ae8700000000, + 0x47dba62200000000, 0x6302a14100000000, 0x325f334d00000000, + 0x1686342e00000000, 0x7aed3c8b00000000, 0x5e343be800000000, + 0xe33d5d1a00000000, 0xc7e45a7900000000, 0xab8f52dc00000000, + 0x8f5655bf00000000, 0x909aefe300000000, 0xb443e88000000000, + 0xd828e02500000000, 0xfcf1e74600000000, 0x41f881b400000000, + 0x652186d700000000, 0x094a8e7200000000, 0x2d93891100000000, + 0x37d2fbcb00000000, 0x130bfca800000000, 0x7f60f40d00000000, + 0x5bb9f36e00000000, 0xe6b0959c00000000, 0xc26992ff00000000, + 0xae029a5a00000000, 0x8adb9d3900000000, 0x9517276500000000, + 0xb1ce200600000000, 0xdda528a300000000, 0xf97c2fc000000000, + 0x4475493200000000, 0x60ac4e5100000000, 0x0cc746f400000000, + 0x281e419700000000}, + {0x0000000000000000, 0x08e3603c00000000, 0x10c6c17800000000, + 0x1825a14400000000, 0x208c83f100000000, 0x286fe3cd00000000, + 0x304a428900000000, 0x38a922b500000000, 0x011e763800000000, + 0x09fd160400000000, 0x11d8b74000000000, 0x193bd77c00000000, + 0x2192f5c900000000, 0x297195f500000000, 0x315434b100000000, + 0x39b7548d00000000, 0x023cec7000000000, 0x0adf8c4c00000000, + 0x12fa2d0800000000, 0x1a194d3400000000, 0x22b06f8100000000, + 0x2a530fbd00000000, 0x3276aef900000000, 0x3a95cec500000000, + 0x03229a4800000000, 0x0bc1fa7400000000, 0x13e45b3000000000, + 0x1b073b0c00000000, 0x23ae19b900000000, 0x2b4d798500000000, + 0x3368d8c100000000, 0x3b8bb8fd00000000, 0x0478d8e100000000, + 0x0c9bb8dd00000000, 0x14be199900000000, 0x1c5d79a500000000, + 0x24f45b1000000000, 0x2c173b2c00000000, 0x34329a6800000000, + 0x3cd1fa5400000000, 0x0566aed900000000, 0x0d85cee500000000, + 0x15a06fa100000000, 0x1d430f9d00000000, 0x25ea2d2800000000, + 0x2d094d1400000000, 0x352cec5000000000, 0x3dcf8c6c00000000, + 0x0644349100000000, 0x0ea754ad00000000, 0x1682f5e900000000, + 0x1e6195d500000000, 0x26c8b76000000000, 0x2e2bd75c00000000, + 0x360e761800000000, 0x3eed162400000000, 0x075a42a900000000, + 0x0fb9229500000000, 0x179c83d100000000, 0x1f7fe3ed00000000, + 0x27d6c15800000000, 0x2f35a16400000000, 0x3710002000000000, + 0x3ff3601c00000000, 0x49f6c11800000000, 0x4115a12400000000, + 0x5930006000000000, 0x51d3605c00000000, 0x697a42e900000000, + 0x619922d500000000, 0x79bc839100000000, 0x715fe3ad00000000, + 0x48e8b72000000000, 0x400bd71c00000000, 0x582e765800000000, + 0x50cd166400000000, 0x686434d100000000, 0x608754ed00000000, + 0x78a2f5a900000000, 0x7041959500000000, 0x4bca2d6800000000, + 0x43294d5400000000, 0x5b0cec1000000000, 0x53ef8c2c00000000, + 0x6b46ae9900000000, 0x63a5cea500000000, 0x7b806fe100000000, + 0x73630fdd00000000, 0x4ad45b5000000000, 0x42373b6c00000000, + 0x5a129a2800000000, 0x52f1fa1400000000, 0x6a58d8a100000000, + 0x62bbb89d00000000, 0x7a9e19d900000000, 0x727d79e500000000, + 0x4d8e19f900000000, 0x456d79c500000000, 0x5d48d88100000000, + 0x55abb8bd00000000, 0x6d029a0800000000, 0x65e1fa3400000000, + 0x7dc45b7000000000, 0x75273b4c00000000, 0x4c906fc100000000, + 0x44730ffd00000000, 0x5c56aeb900000000, 0x54b5ce8500000000, + 0x6c1cec3000000000, 0x64ff8c0c00000000, 0x7cda2d4800000000, + 0x74394d7400000000, 0x4fb2f58900000000, 0x475195b500000000, + 0x5f7434f100000000, 0x579754cd00000000, 0x6f3e767800000000, + 0x67dd164400000000, 0x7ff8b70000000000, 0x771bd73c00000000, + 0x4eac83b100000000, 0x464fe38d00000000, 0x5e6a42c900000000, + 0x568922f500000000, 0x6e20004000000000, 0x66c3607c00000000, + 0x7ee6c13800000000, 0x7605a10400000000, 0x92ec833100000000, + 0x9a0fe30d00000000, 0x822a424900000000, 0x8ac9227500000000, + 0xb26000c000000000, 0xba8360fc00000000, 0xa2a6c1b800000000, + 0xaa45a18400000000, 0x93f2f50900000000, 0x9b11953500000000, + 0x8334347100000000, 0x8bd7544d00000000, 0xb37e76f800000000, + 0xbb9d16c400000000, 0xa3b8b78000000000, 0xab5bd7bc00000000, + 0x90d06f4100000000, 0x98330f7d00000000, 0x8016ae3900000000, + 0x88f5ce0500000000, 0xb05cecb000000000, 0xb8bf8c8c00000000, + 0xa09a2dc800000000, 0xa8794df400000000, 0x91ce197900000000, + 0x992d794500000000, 0x8108d80100000000, 0x89ebb83d00000000, + 0xb1429a8800000000, 0xb9a1fab400000000, 0xa1845bf000000000, + 0xa9673bcc00000000, 0x96945bd000000000, 0x9e773bec00000000, + 0x86529aa800000000, 0x8eb1fa9400000000, 0xb618d82100000000, + 0xbefbb81d00000000, 0xa6de195900000000, 0xae3d796500000000, + 0x978a2de800000000, 0x9f694dd400000000, 0x874cec9000000000, + 0x8faf8cac00000000, 0xb706ae1900000000, 0xbfe5ce2500000000, + 0xa7c06f6100000000, 0xaf230f5d00000000, 0x94a8b7a000000000, + 0x9c4bd79c00000000, 0x846e76d800000000, 0x8c8d16e400000000, + 0xb424345100000000, 0xbcc7546d00000000, 0xa4e2f52900000000, + 0xac01951500000000, 0x95b6c19800000000, 0x9d55a1a400000000, + 0x857000e000000000, 0x8d9360dc00000000, 0xb53a426900000000, + 0xbdd9225500000000, 0xa5fc831100000000, 0xad1fe32d00000000, + 0xdb1a422900000000, 0xd3f9221500000000, 0xcbdc835100000000, + 0xc33fe36d00000000, 0xfb96c1d800000000, 0xf375a1e400000000, + 0xeb5000a000000000, 0xe3b3609c00000000, 0xda04341100000000, + 0xd2e7542d00000000, 0xcac2f56900000000, 0xc221955500000000, + 0xfa88b7e000000000, 0xf26bd7dc00000000, 0xea4e769800000000, + 0xe2ad16a400000000, 0xd926ae5900000000, 0xd1c5ce6500000000, + 0xc9e06f2100000000, 0xc1030f1d00000000, 0xf9aa2da800000000, + 0xf1494d9400000000, 0xe96cecd000000000, 0xe18f8cec00000000, + 0xd838d86100000000, 0xd0dbb85d00000000, 0xc8fe191900000000, + 0xc01d792500000000, 0xf8b45b9000000000, 0xf0573bac00000000, + 0xe8729ae800000000, 0xe091fad400000000, 0xdf629ac800000000, + 0xd781faf400000000, 0xcfa45bb000000000, 0xc7473b8c00000000, + 0xffee193900000000, 0xf70d790500000000, 0xef28d84100000000, + 0xe7cbb87d00000000, 0xde7cecf000000000, 0xd69f8ccc00000000, + 0xceba2d8800000000, 0xc6594db400000000, 0xfef06f0100000000, + 0xf6130f3d00000000, 0xee36ae7900000000, 0xe6d5ce4500000000, + 0xdd5e76b800000000, 0xd5bd168400000000, 0xcd98b7c000000000, + 0xc57bd7fc00000000, 0xfdd2f54900000000, 0xf531957500000000, + 0xed14343100000000, 0xe5f7540d00000000, 0xdc40008000000000, + 0xd4a360bc00000000, 0xcc86c1f800000000, 0xc465a1c400000000, + 0xfccc837100000000, 0xf42fe34d00000000, 0xec0a420900000000, + 0xe4e9223500000000}, + {0x0000000000000000, 0xd1e8e70e00000000, 0xa2d1cf1d00000000, + 0x7339281300000000, 0x44a39f3b00000000, 0x954b783500000000, + 0xe672502600000000, 0x379ab72800000000, 0x88463f7700000000, + 0x59aed87900000000, 0x2a97f06a00000000, 0xfb7f176400000000, + 0xcce5a04c00000000, 0x1d0d474200000000, 0x6e346f5100000000, + 0xbfdc885f00000000, 0x108d7eee00000000, 0xc16599e000000000, + 0xb25cb1f300000000, 0x63b456fd00000000, 0x542ee1d500000000, + 0x85c606db00000000, 0xf6ff2ec800000000, 0x2717c9c600000000, + 0x98cb419900000000, 0x4923a69700000000, 0x3a1a8e8400000000, + 0xebf2698a00000000, 0xdc68dea200000000, 0x0d8039ac00000000, + 0x7eb911bf00000000, 0xaf51f6b100000000, 0x611c8c0700000000, + 0xb0f46b0900000000, 0xc3cd431a00000000, 0x1225a41400000000, + 0x25bf133c00000000, 0xf457f43200000000, 0x876edc2100000000, + 0x56863b2f00000000, 0xe95ab37000000000, 0x38b2547e00000000, + 0x4b8b7c6d00000000, 0x9a639b6300000000, 0xadf92c4b00000000, + 0x7c11cb4500000000, 0x0f28e35600000000, 0xdec0045800000000, + 0x7191f2e900000000, 0xa07915e700000000, 0xd3403df400000000, + 0x02a8dafa00000000, 0x35326dd200000000, 0xe4da8adc00000000, + 0x97e3a2cf00000000, 0x460b45c100000000, 0xf9d7cd9e00000000, + 0x283f2a9000000000, 0x5b06028300000000, 0x8aeee58d00000000, + 0xbd7452a500000000, 0x6c9cb5ab00000000, 0x1fa59db800000000, + 0xce4d7ab600000000, 0xc238180f00000000, 0x13d0ff0100000000, + 0x60e9d71200000000, 0xb101301c00000000, 0x869b873400000000, + 0x5773603a00000000, 0x244a482900000000, 0xf5a2af2700000000, + 0x4a7e277800000000, 0x9b96c07600000000, 0xe8afe86500000000, + 0x39470f6b00000000, 0x0eddb84300000000, 0xdf355f4d00000000, + 0xac0c775e00000000, 0x7de4905000000000, 0xd2b566e100000000, + 0x035d81ef00000000, 0x7064a9fc00000000, 0xa18c4ef200000000, + 0x9616f9da00000000, 0x47fe1ed400000000, 0x34c736c700000000, + 0xe52fd1c900000000, 0x5af3599600000000, 0x8b1bbe9800000000, + 0xf822968b00000000, 0x29ca718500000000, 0x1e50c6ad00000000, + 0xcfb821a300000000, 0xbc8109b000000000, 0x6d69eebe00000000, + 0xa324940800000000, 0x72cc730600000000, 0x01f55b1500000000, + 0xd01dbc1b00000000, 0xe7870b3300000000, 0x366fec3d00000000, + 0x4556c42e00000000, 0x94be232000000000, 0x2b62ab7f00000000, + 0xfa8a4c7100000000, 0x89b3646200000000, 0x585b836c00000000, + 0x6fc1344400000000, 0xbe29d34a00000000, 0xcd10fb5900000000, + 0x1cf81c5700000000, 0xb3a9eae600000000, 0x62410de800000000, + 0x117825fb00000000, 0xc090c2f500000000, 0xf70a75dd00000000, + 0x26e292d300000000, 0x55dbbac000000000, 0x84335dce00000000, + 0x3befd59100000000, 0xea07329f00000000, 0x993e1a8c00000000, + 0x48d6fd8200000000, 0x7f4c4aaa00000000, 0xaea4ada400000000, + 0xdd9d85b700000000, 0x0c7562b900000000, 0x8471301e00000000, + 0x5599d71000000000, 0x26a0ff0300000000, 0xf748180d00000000, + 0xc0d2af2500000000, 0x113a482b00000000, 0x6203603800000000, + 0xb3eb873600000000, 0x0c370f6900000000, 0xdddfe86700000000, + 0xaee6c07400000000, 0x7f0e277a00000000, 0x4894905200000000, + 0x997c775c00000000, 0xea455f4f00000000, 0x3badb84100000000, + 0x94fc4ef000000000, 0x4514a9fe00000000, 0x362d81ed00000000, + 0xe7c566e300000000, 0xd05fd1cb00000000, 0x01b736c500000000, + 0x728e1ed600000000, 0xa366f9d800000000, 0x1cba718700000000, + 0xcd52968900000000, 0xbe6bbe9a00000000, 0x6f83599400000000, + 0x5819eebc00000000, 0x89f109b200000000, 0xfac821a100000000, + 0x2b20c6af00000000, 0xe56dbc1900000000, 0x34855b1700000000, + 0x47bc730400000000, 0x9654940a00000000, 0xa1ce232200000000, + 0x7026c42c00000000, 0x031fec3f00000000, 0xd2f70b3100000000, + 0x6d2b836e00000000, 0xbcc3646000000000, 0xcffa4c7300000000, + 0x1e12ab7d00000000, 0x29881c5500000000, 0xf860fb5b00000000, + 0x8b59d34800000000, 0x5ab1344600000000, 0xf5e0c2f700000000, + 0x240825f900000000, 0x57310dea00000000, 0x86d9eae400000000, + 0xb1435dcc00000000, 0x60abbac200000000, 0x139292d100000000, + 0xc27a75df00000000, 0x7da6fd8000000000, 0xac4e1a8e00000000, + 0xdf77329d00000000, 0x0e9fd59300000000, 0x390562bb00000000, + 0xe8ed85b500000000, 0x9bd4ada600000000, 0x4a3c4aa800000000, + 0x4649281100000000, 0x97a1cf1f00000000, 0xe498e70c00000000, + 0x3570000200000000, 0x02eab72a00000000, 0xd302502400000000, + 0xa03b783700000000, 0x71d39f3900000000, 0xce0f176600000000, + 0x1fe7f06800000000, 0x6cded87b00000000, 0xbd363f7500000000, + 0x8aac885d00000000, 0x5b446f5300000000, 0x287d474000000000, + 0xf995a04e00000000, 0x56c456ff00000000, 0x872cb1f100000000, + 0xf41599e200000000, 0x25fd7eec00000000, 0x1267c9c400000000, + 0xc38f2eca00000000, 0xb0b606d900000000, 0x615ee1d700000000, + 0xde82698800000000, 0x0f6a8e8600000000, 0x7c53a69500000000, + 0xadbb419b00000000, 0x9a21f6b300000000, 0x4bc911bd00000000, + 0x38f039ae00000000, 0xe918dea000000000, 0x2755a41600000000, + 0xf6bd431800000000, 0x85846b0b00000000, 0x546c8c0500000000, + 0x63f63b2d00000000, 0xb21edc2300000000, 0xc127f43000000000, + 0x10cf133e00000000, 0xaf139b6100000000, 0x7efb7c6f00000000, + 0x0dc2547c00000000, 0xdc2ab37200000000, 0xebb0045a00000000, + 0x3a58e35400000000, 0x4961cb4700000000, 0x98892c4900000000, + 0x37d8daf800000000, 0xe6303df600000000, 0x950915e500000000, + 0x44e1f2eb00000000, 0x737b45c300000000, 0xa293a2cd00000000, + 0xd1aa8ade00000000, 0x00426dd000000000, 0xbf9ee58f00000000, + 0x6e76028100000000, 0x1d4f2a9200000000, 0xcca7cd9c00000000, + 0xfb3d7ab400000000, 0x2ad59dba00000000, 0x59ecb5a900000000, + 0x880452a700000000}, + {0x0000000000000000, 0xaa05daf100000000, 0x150dc53800000000, + 0xbf081fc900000000, 0x2a1a8a7100000000, 0x801f508000000000, + 0x3f174f4900000000, 0x951295b800000000, 0x543414e300000000, + 0xfe31ce1200000000, 0x4139d1db00000000, 0xeb3c0b2a00000000, + 0x7e2e9e9200000000, 0xd42b446300000000, 0x6b235baa00000000, + 0xc126815b00000000, 0xe96e591d00000000, 0x436b83ec00000000, + 0xfc639c2500000000, 0x566646d400000000, 0xc374d36c00000000, + 0x6971099d00000000, 0xd679165400000000, 0x7c7ccca500000000, + 0xbd5a4dfe00000000, 0x175f970f00000000, 0xa85788c600000000, + 0x0252523700000000, 0x9740c78f00000000, 0x3d451d7e00000000, + 0x824d02b700000000, 0x2848d84600000000, 0xd2ddb23a00000000, + 0x78d868cb00000000, 0xc7d0770200000000, 0x6dd5adf300000000, + 0xf8c7384b00000000, 0x52c2e2ba00000000, 0xedcafd7300000000, + 0x47cf278200000000, 0x86e9a6d900000000, 0x2cec7c2800000000, + 0x93e463e100000000, 0x39e1b91000000000, 0xacf32ca800000000, + 0x06f6f65900000000, 0xb9fee99000000000, 0x13fb336100000000, + 0x3bb3eb2700000000, 0x91b631d600000000, 0x2ebe2e1f00000000, + 0x84bbf4ee00000000, 0x11a9615600000000, 0xbbacbba700000000, + 0x04a4a46e00000000, 0xaea17e9f00000000, 0x6f87ffc400000000, + 0xc582253500000000, 0x7a8a3afc00000000, 0xd08fe00d00000000, + 0x459d75b500000000, 0xef98af4400000000, 0x5090b08d00000000, + 0xfa956a7c00000000, 0xa4bb657500000000, 0x0ebebf8400000000, + 0xb1b6a04d00000000, 0x1bb37abc00000000, 0x8ea1ef0400000000, + 0x24a435f500000000, 0x9bac2a3c00000000, 0x31a9f0cd00000000, + 0xf08f719600000000, 0x5a8aab6700000000, 0xe582b4ae00000000, + 0x4f876e5f00000000, 0xda95fbe700000000, 0x7090211600000000, + 0xcf983edf00000000, 0x659de42e00000000, 0x4dd53c6800000000, + 0xe7d0e69900000000, 0x58d8f95000000000, 0xf2dd23a100000000, + 0x67cfb61900000000, 0xcdca6ce800000000, 0x72c2732100000000, + 0xd8c7a9d000000000, 0x19e1288b00000000, 0xb3e4f27a00000000, + 0x0cecedb300000000, 0xa6e9374200000000, 0x33fba2fa00000000, + 0x99fe780b00000000, 0x26f667c200000000, 0x8cf3bd3300000000, + 0x7666d74f00000000, 0xdc630dbe00000000, 0x636b127700000000, + 0xc96ec88600000000, 0x5c7c5d3e00000000, 0xf67987cf00000000, + 0x4971980600000000, 0xe37442f700000000, 0x2252c3ac00000000, + 0x8857195d00000000, 0x375f069400000000, 0x9d5adc6500000000, + 0x084849dd00000000, 0xa24d932c00000000, 0x1d458ce500000000, + 0xb740561400000000, 0x9f088e5200000000, 0x350d54a300000000, + 0x8a054b6a00000000, 0x2000919b00000000, 0xb512042300000000, + 0x1f17ded200000000, 0xa01fc11b00000000, 0x0a1a1bea00000000, + 0xcb3c9ab100000000, 0x6139404000000000, 0xde315f8900000000, + 0x7434857800000000, 0xe12610c000000000, 0x4b23ca3100000000, + 0xf42bd5f800000000, 0x5e2e0f0900000000, 0x4877cbea00000000, + 0xe272111b00000000, 0x5d7a0ed200000000, 0xf77fd42300000000, + 0x626d419b00000000, 0xc8689b6a00000000, 0x776084a300000000, + 0xdd655e5200000000, 0x1c43df0900000000, 0xb64605f800000000, + 0x094e1a3100000000, 0xa34bc0c000000000, 0x3659557800000000, + 0x9c5c8f8900000000, 0x2354904000000000, 0x89514ab100000000, + 0xa11992f700000000, 0x0b1c480600000000, 0xb41457cf00000000, + 0x1e118d3e00000000, 0x8b03188600000000, 0x2106c27700000000, + 0x9e0eddbe00000000, 0x340b074f00000000, 0xf52d861400000000, + 0x5f285ce500000000, 0xe020432c00000000, 0x4a2599dd00000000, + 0xdf370c6500000000, 0x7532d69400000000, 0xca3ac95d00000000, + 0x603f13ac00000000, 0x9aaa79d000000000, 0x30afa32100000000, + 0x8fa7bce800000000, 0x25a2661900000000, 0xb0b0f3a100000000, + 0x1ab5295000000000, 0xa5bd369900000000, 0x0fb8ec6800000000, + 0xce9e6d3300000000, 0x649bb7c200000000, 0xdb93a80b00000000, + 0x719672fa00000000, 0xe484e74200000000, 0x4e813db300000000, + 0xf189227a00000000, 0x5b8cf88b00000000, 0x73c420cd00000000, + 0xd9c1fa3c00000000, 0x66c9e5f500000000, 0xcccc3f0400000000, + 0x59deaabc00000000, 0xf3db704d00000000, 0x4cd36f8400000000, + 0xe6d6b57500000000, 0x27f0342e00000000, 0x8df5eedf00000000, + 0x32fdf11600000000, 0x98f82be700000000, 0x0deabe5f00000000, + 0xa7ef64ae00000000, 0x18e77b6700000000, 0xb2e2a19600000000, + 0xecccae9f00000000, 0x46c9746e00000000, 0xf9c16ba700000000, + 0x53c4b15600000000, 0xc6d624ee00000000, 0x6cd3fe1f00000000, + 0xd3dbe1d600000000, 0x79de3b2700000000, 0xb8f8ba7c00000000, + 0x12fd608d00000000, 0xadf57f4400000000, 0x07f0a5b500000000, + 0x92e2300d00000000, 0x38e7eafc00000000, 0x87eff53500000000, + 0x2dea2fc400000000, 0x05a2f78200000000, 0xafa72d7300000000, + 0x10af32ba00000000, 0xbaaae84b00000000, 0x2fb87df300000000, + 0x85bda70200000000, 0x3ab5b8cb00000000, 0x90b0623a00000000, + 0x5196e36100000000, 0xfb93399000000000, 0x449b265900000000, + 0xee9efca800000000, 0x7b8c691000000000, 0xd189b3e100000000, + 0x6e81ac2800000000, 0xc48476d900000000, 0x3e111ca500000000, + 0x9414c65400000000, 0x2b1cd99d00000000, 0x8119036c00000000, + 0x140b96d400000000, 0xbe0e4c2500000000, 0x010653ec00000000, + 0xab03891d00000000, 0x6a25084600000000, 0xc020d2b700000000, + 0x7f28cd7e00000000, 0xd52d178f00000000, 0x403f823700000000, + 0xea3a58c600000000, 0x5532470f00000000, 0xff379dfe00000000, + 0xd77f45b800000000, 0x7d7a9f4900000000, 0xc272808000000000, + 0x68775a7100000000, 0xfd65cfc900000000, 0x5760153800000000, + 0xe8680af100000000, 0x426dd00000000000, 0x834b515b00000000, + 0x294e8baa00000000, 0x9646946300000000, 0x3c434e9200000000, + 0xa951db2a00000000, 0x035401db00000000, 0xbc5c1e1200000000, + 0x1659c4e300000000}}; + +#else /* W == 4 */ + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xae689191, 0x87a02563, 0x29c8b4f2, 0xd4314c87, + 0x7a59dd16, 0x539169e4, 0xfdf9f875, 0x73139f4f, 0xdd7b0ede, + 0xf4b3ba2c, 0x5adb2bbd, 0xa722d3c8, 0x094a4259, 0x2082f6ab, + 0x8eea673a, 0xe6273e9e, 0x484faf0f, 0x61871bfd, 0xcfef8a6c, + 0x32167219, 0x9c7ee388, 0xb5b6577a, 0x1bdec6eb, 0x9534a1d1, + 0x3b5c3040, 0x129484b2, 0xbcfc1523, 0x4105ed56, 0xef6d7cc7, + 0xc6a5c835, 0x68cd59a4, 0x173f7b7d, 0xb957eaec, 0x909f5e1e, + 0x3ef7cf8f, 0xc30e37fa, 0x6d66a66b, 0x44ae1299, 0xeac68308, + 0x642ce432, 0xca4475a3, 0xe38cc151, 0x4de450c0, 0xb01da8b5, + 0x1e753924, 0x37bd8dd6, 0x99d51c47, 0xf11845e3, 0x5f70d472, + 0x76b86080, 0xd8d0f111, 0x25290964, 0x8b4198f5, 0xa2892c07, + 0x0ce1bd96, 0x820bdaac, 0x2c634b3d, 0x05abffcf, 0xabc36e5e, + 0x563a962b, 0xf85207ba, 0xd19ab348, 0x7ff222d9, 0x2e7ef6fa, + 0x8016676b, 0xa9ded399, 0x07b64208, 0xfa4fba7d, 0x54272bec, + 0x7def9f1e, 0xd3870e8f, 0x5d6d69b5, 0xf305f824, 0xdacd4cd6, + 0x74a5dd47, 0x895c2532, 0x2734b4a3, 0x0efc0051, 0xa09491c0, + 0xc859c864, 0x663159f5, 0x4ff9ed07, 0xe1917c96, 0x1c6884e3, + 0xb2001572, 0x9bc8a180, 0x35a03011, 0xbb4a572b, 0x1522c6ba, + 0x3cea7248, 0x9282e3d9, 0x6f7b1bac, 0xc1138a3d, 0xe8db3ecf, + 0x46b3af5e, 0x39418d87, 0x97291c16, 0xbee1a8e4, 0x10893975, + 0xed70c100, 0x43185091, 0x6ad0e463, 0xc4b875f2, 0x4a5212c8, + 0xe43a8359, 0xcdf237ab, 0x639aa63a, 0x9e635e4f, 0x300bcfde, + 0x19c37b2c, 0xb7abeabd, 0xdf66b319, 0x710e2288, 0x58c6967a, + 0xf6ae07eb, 0x0b57ff9e, 0xa53f6e0f, 0x8cf7dafd, 0x229f4b6c, + 0xac752c56, 0x021dbdc7, 0x2bd50935, 0x85bd98a4, 0x784460d1, + 0xd62cf140, 0xffe445b2, 0x518cd423, 0x5cfdedf4, 0xf2957c65, + 0xdb5dc897, 0x75355906, 0x88cca173, 0x26a430e2, 0x0f6c8410, + 0xa1041581, 0x2fee72bb, 0x8186e32a, 0xa84e57d8, 0x0626c649, + 0xfbdf3e3c, 0x55b7afad, 0x7c7f1b5f, 0xd2178ace, 0xbadad36a, + 0x14b242fb, 0x3d7af609, 0x93126798, 0x6eeb9fed, 0xc0830e7c, + 0xe94bba8e, 0x47232b1f, 0xc9c94c25, 0x67a1ddb4, 0x4e696946, + 0xe001f8d7, 0x1df800a2, 0xb3909133, 0x9a5825c1, 0x3430b450, + 0x4bc29689, 0xe5aa0718, 0xcc62b3ea, 0x620a227b, 0x9ff3da0e, + 0x319b4b9f, 0x1853ff6d, 0xb63b6efc, 0x38d109c6, 0x96b99857, + 0xbf712ca5, 0x1119bd34, 0xece04541, 0x4288d4d0, 0x6b406022, + 0xc528f1b3, 0xade5a817, 0x038d3986, 0x2a458d74, 0x842d1ce5, + 0x79d4e490, 0xd7bc7501, 0xfe74c1f3, 0x501c5062, 0xdef63758, + 0x709ea6c9, 0x5956123b, 0xf73e83aa, 0x0ac77bdf, 0xa4afea4e, + 0x8d675ebc, 0x230fcf2d, 0x72831b0e, 0xdceb8a9f, 0xf5233e6d, + 0x5b4baffc, 0xa6b25789, 0x08dac618, 0x211272ea, 0x8f7ae37b, + 0x01908441, 0xaff815d0, 0x8630a122, 0x285830b3, 0xd5a1c8c6, + 0x7bc95957, 0x5201eda5, 0xfc697c34, 0x94a42590, 0x3accb401, + 0x130400f3, 0xbd6c9162, 0x40956917, 0xeefdf886, 0xc7354c74, + 0x695ddde5, 0xe7b7badf, 0x49df2b4e, 0x60179fbc, 0xce7f0e2d, + 0x3386f658, 0x9dee67c9, 0xb426d33b, 0x1a4e42aa, 0x65bc6073, + 0xcbd4f1e2, 0xe21c4510, 0x4c74d481, 0xb18d2cf4, 0x1fe5bd65, + 0x362d0997, 0x98459806, 0x16afff3c, 0xb8c76ead, 0x910fda5f, + 0x3f674bce, 0xc29eb3bb, 0x6cf6222a, 0x453e96d8, 0xeb560749, + 0x839b5eed, 0x2df3cf7c, 0x043b7b8e, 0xaa53ea1f, 0x57aa126a, + 0xf9c283fb, 0xd00a3709, 0x7e62a698, 0xf088c1a2, 0x5ee05033, + 0x7728e4c1, 0xd9407550, 0x24b98d25, 0x8ad11cb4, 0xa319a846, + 0x0d7139d7}, + {0x00000000, 0xb9fbdbe8, 0xa886b191, 0x117d6a79, 0x8a7c6563, + 0x3387be8b, 0x22fad4f2, 0x9b010f1a, 0xcf89cc87, 0x7672176f, + 0x670f7d16, 0xdef4a6fe, 0x45f5a9e4, 0xfc0e720c, 0xed731875, + 0x5488c39d, 0x44629f4f, 0xfd9944a7, 0xece42ede, 0x551ff536, + 0xce1efa2c, 0x77e521c4, 0x66984bbd, 0xdf639055, 0x8beb53c8, + 0x32108820, 0x236de259, 0x9a9639b1, 0x019736ab, 0xb86ced43, + 0xa911873a, 0x10ea5cd2, 0x88c53e9e, 0x313ee576, 0x20438f0f, + 0x99b854e7, 0x02b95bfd, 0xbb428015, 0xaa3fea6c, 0x13c43184, + 0x474cf219, 0xfeb729f1, 0xefca4388, 0x56319860, 0xcd30977a, + 0x74cb4c92, 0x65b626eb, 0xdc4dfd03, 0xcca7a1d1, 0x755c7a39, + 0x64211040, 0xdddacba8, 0x46dbc4b2, 0xff201f5a, 0xee5d7523, + 0x57a6aecb, 0x032e6d56, 0xbad5b6be, 0xaba8dcc7, 0x1253072f, + 0x89520835, 0x30a9d3dd, 0x21d4b9a4, 0x982f624c, 0xcafb7b7d, + 0x7300a095, 0x627dcaec, 0xdb861104, 0x40871e1e, 0xf97cc5f6, + 0xe801af8f, 0x51fa7467, 0x0572b7fa, 0xbc896c12, 0xadf4066b, + 0x140fdd83, 0x8f0ed299, 0x36f50971, 0x27886308, 0x9e73b8e0, + 0x8e99e432, 0x37623fda, 0x261f55a3, 0x9fe48e4b, 0x04e58151, + 0xbd1e5ab9, 0xac6330c0, 0x1598eb28, 0x411028b5, 0xf8ebf35d, + 0xe9969924, 0x506d42cc, 0xcb6c4dd6, 0x7297963e, 0x63eafc47, + 0xda1127af, 0x423e45e3, 0xfbc59e0b, 0xeab8f472, 0x53432f9a, + 0xc8422080, 0x71b9fb68, 0x60c49111, 0xd93f4af9, 0x8db78964, + 0x344c528c, 0x253138f5, 0x9ccae31d, 0x07cbec07, 0xbe3037ef, + 0xaf4d5d96, 0x16b6867e, 0x065cdaac, 0xbfa70144, 0xaeda6b3d, + 0x1721b0d5, 0x8c20bfcf, 0x35db6427, 0x24a60e5e, 0x9d5dd5b6, + 0xc9d5162b, 0x702ecdc3, 0x6153a7ba, 0xd8a87c52, 0x43a97348, + 0xfa52a8a0, 0xeb2fc2d9, 0x52d41931, 0x4e87f0bb, 0xf77c2b53, + 0xe601412a, 0x5ffa9ac2, 0xc4fb95d8, 0x7d004e30, 0x6c7d2449, + 0xd586ffa1, 0x810e3c3c, 0x38f5e7d4, 0x29888dad, 0x90735645, + 0x0b72595f, 0xb28982b7, 0xa3f4e8ce, 0x1a0f3326, 0x0ae56ff4, + 0xb31eb41c, 0xa263de65, 0x1b98058d, 0x80990a97, 0x3962d17f, + 0x281fbb06, 0x91e460ee, 0xc56ca373, 0x7c97789b, 0x6dea12e2, + 0xd411c90a, 0x4f10c610, 0xf6eb1df8, 0xe7967781, 0x5e6dac69, + 0xc642ce25, 0x7fb915cd, 0x6ec47fb4, 0xd73fa45c, 0x4c3eab46, + 0xf5c570ae, 0xe4b81ad7, 0x5d43c13f, 0x09cb02a2, 0xb030d94a, + 0xa14db333, 0x18b668db, 0x83b767c1, 0x3a4cbc29, 0x2b31d650, + 0x92ca0db8, 0x8220516a, 0x3bdb8a82, 0x2aa6e0fb, 0x935d3b13, + 0x085c3409, 0xb1a7efe1, 0xa0da8598, 0x19215e70, 0x4da99ded, + 0xf4524605, 0xe52f2c7c, 0x5cd4f794, 0xc7d5f88e, 0x7e2e2366, + 0x6f53491f, 0xd6a892f7, 0x847c8bc6, 0x3d87502e, 0x2cfa3a57, + 0x9501e1bf, 0x0e00eea5, 0xb7fb354d, 0xa6865f34, 0x1f7d84dc, + 0x4bf54741, 0xf20e9ca9, 0xe373f6d0, 0x5a882d38, 0xc1892222, + 0x7872f9ca, 0x690f93b3, 0xd0f4485b, 0xc01e1489, 0x79e5cf61, + 0x6898a518, 0xd1637ef0, 0x4a6271ea, 0xf399aa02, 0xe2e4c07b, + 0x5b1f1b93, 0x0f97d80e, 0xb66c03e6, 0xa711699f, 0x1eeab277, + 0x85ebbd6d, 0x3c106685, 0x2d6d0cfc, 0x9496d714, 0x0cb9b558, + 0xb5426eb0, 0xa43f04c9, 0x1dc4df21, 0x86c5d03b, 0x3f3e0bd3, + 0x2e4361aa, 0x97b8ba42, 0xc33079df, 0x7acba237, 0x6bb6c84e, + 0xd24d13a6, 0x494c1cbc, 0xf0b7c754, 0xe1caad2d, 0x583176c5, + 0x48db2a17, 0xf120f1ff, 0xe05d9b86, 0x59a6406e, 0xc2a74f74, + 0x7b5c949c, 0x6a21fee5, 0xd3da250d, 0x8752e690, 0x3ea93d78, + 0x2fd45701, 0x962f8ce9, 0x0d2e83f3, 0xb4d5581b, 0xa5a83262, + 0x1c53e98a}, + {0x00000000, 0x9d0fe176, 0xe16ec4ad, 0x7c6125db, 0x19ac8f1b, + 0x84a36e6d, 0xf8c24bb6, 0x65cdaac0, 0x33591e36, 0xae56ff40, + 0xd237da9b, 0x4f383bed, 0x2af5912d, 0xb7fa705b, 0xcb9b5580, + 0x5694b4f6, 0x66b23c6c, 0xfbbddd1a, 0x87dcf8c1, 0x1ad319b7, + 0x7f1eb377, 0xe2115201, 0x9e7077da, 0x037f96ac, 0x55eb225a, + 0xc8e4c32c, 0xb485e6f7, 0x298a0781, 0x4c47ad41, 0xd1484c37, + 0xad2969ec, 0x3026889a, 0xcd6478d8, 0x506b99ae, 0x2c0abc75, + 0xb1055d03, 0xd4c8f7c3, 0x49c716b5, 0x35a6336e, 0xa8a9d218, + 0xfe3d66ee, 0x63328798, 0x1f53a243, 0x825c4335, 0xe791e9f5, + 0x7a9e0883, 0x06ff2d58, 0x9bf0cc2e, 0xabd644b4, 0x36d9a5c2, + 0x4ab88019, 0xd7b7616f, 0xb27acbaf, 0x2f752ad9, 0x53140f02, + 0xce1bee74, 0x988f5a82, 0x0580bbf4, 0x79e19e2f, 0xe4ee7f59, + 0x8123d599, 0x1c2c34ef, 0x604d1134, 0xfd42f042, 0x41b9f7f1, + 0xdcb61687, 0xa0d7335c, 0x3dd8d22a, 0x581578ea, 0xc51a999c, + 0xb97bbc47, 0x24745d31, 0x72e0e9c7, 0xefef08b1, 0x938e2d6a, + 0x0e81cc1c, 0x6b4c66dc, 0xf64387aa, 0x8a22a271, 0x172d4307, + 0x270bcb9d, 0xba042aeb, 0xc6650f30, 0x5b6aee46, 0x3ea74486, + 0xa3a8a5f0, 0xdfc9802b, 0x42c6615d, 0x1452d5ab, 0x895d34dd, + 0xf53c1106, 0x6833f070, 0x0dfe5ab0, 0x90f1bbc6, 0xec909e1d, + 0x719f7f6b, 0x8cdd8f29, 0x11d26e5f, 0x6db34b84, 0xf0bcaaf2, + 0x95710032, 0x087ee144, 0x741fc49f, 0xe91025e9, 0xbf84911f, + 0x228b7069, 0x5eea55b2, 0xc3e5b4c4, 0xa6281e04, 0x3b27ff72, + 0x4746daa9, 0xda493bdf, 0xea6fb345, 0x77605233, 0x0b0177e8, + 0x960e969e, 0xf3c33c5e, 0x6eccdd28, 0x12adf8f3, 0x8fa21985, + 0xd936ad73, 0x44394c05, 0x385869de, 0xa55788a8, 0xc09a2268, + 0x5d95c31e, 0x21f4e6c5, 0xbcfb07b3, 0x8373efe2, 0x1e7c0e94, + 0x621d2b4f, 0xff12ca39, 0x9adf60f9, 0x07d0818f, 0x7bb1a454, + 0xe6be4522, 0xb02af1d4, 0x2d2510a2, 0x51443579, 0xcc4bd40f, + 0xa9867ecf, 0x34899fb9, 0x48e8ba62, 0xd5e75b14, 0xe5c1d38e, + 0x78ce32f8, 0x04af1723, 0x99a0f655, 0xfc6d5c95, 0x6162bde3, + 0x1d039838, 0x800c794e, 0xd698cdb8, 0x4b972cce, 0x37f60915, + 0xaaf9e863, 0xcf3442a3, 0x523ba3d5, 0x2e5a860e, 0xb3556778, + 0x4e17973a, 0xd318764c, 0xaf795397, 0x3276b2e1, 0x57bb1821, + 0xcab4f957, 0xb6d5dc8c, 0x2bda3dfa, 0x7d4e890c, 0xe041687a, + 0x9c204da1, 0x012facd7, 0x64e20617, 0xf9ede761, 0x858cc2ba, + 0x188323cc, 0x28a5ab56, 0xb5aa4a20, 0xc9cb6ffb, 0x54c48e8d, + 0x3109244d, 0xac06c53b, 0xd067e0e0, 0x4d680196, 0x1bfcb560, + 0x86f35416, 0xfa9271cd, 0x679d90bb, 0x02503a7b, 0x9f5fdb0d, + 0xe33efed6, 0x7e311fa0, 0xc2ca1813, 0x5fc5f965, 0x23a4dcbe, + 0xbeab3dc8, 0xdb669708, 0x4669767e, 0x3a0853a5, 0xa707b2d3, + 0xf1930625, 0x6c9ce753, 0x10fdc288, 0x8df223fe, 0xe83f893e, + 0x75306848, 0x09514d93, 0x945eace5, 0xa478247f, 0x3977c509, + 0x4516e0d2, 0xd81901a4, 0xbdd4ab64, 0x20db4a12, 0x5cba6fc9, + 0xc1b58ebf, 0x97213a49, 0x0a2edb3f, 0x764ffee4, 0xeb401f92, + 0x8e8db552, 0x13825424, 0x6fe371ff, 0xf2ec9089, 0x0fae60cb, + 0x92a181bd, 0xeec0a466, 0x73cf4510, 0x1602efd0, 0x8b0d0ea6, + 0xf76c2b7d, 0x6a63ca0b, 0x3cf77efd, 0xa1f89f8b, 0xdd99ba50, + 0x40965b26, 0x255bf1e6, 0xb8541090, 0xc435354b, 0x593ad43d, + 0x691c5ca7, 0xf413bdd1, 0x8872980a, 0x157d797c, 0x70b0d3bc, + 0xedbf32ca, 0x91de1711, 0x0cd1f667, 0x5a454291, 0xc74aa3e7, + 0xbb2b863c, 0x2624674a, 0x43e9cd8a, 0xdee62cfc, 0xa2870927, + 0x3f88e851}, + {0x00000000, 0xdd96d985, 0x605cb54b, 0xbdca6cce, 0xc0b96a96, + 0x1d2fb313, 0xa0e5dfdd, 0x7d730658, 0x5a03d36d, 0x87950ae8, + 0x3a5f6626, 0xe7c9bfa3, 0x9abab9fb, 0x472c607e, 0xfae60cb0, + 0x2770d535, 0xb407a6da, 0x69917f5f, 0xd45b1391, 0x09cdca14, + 0x74becc4c, 0xa92815c9, 0x14e27907, 0xc974a082, 0xee0475b7, + 0x3392ac32, 0x8e58c0fc, 0x53ce1979, 0x2ebd1f21, 0xf32bc6a4, + 0x4ee1aa6a, 0x937773ef, 0xb37e4bf5, 0x6ee89270, 0xd322febe, + 0x0eb4273b, 0x73c72163, 0xae51f8e6, 0x139b9428, 0xce0d4dad, + 0xe97d9898, 0x34eb411d, 0x89212dd3, 0x54b7f456, 0x29c4f20e, + 0xf4522b8b, 0x49984745, 0x940e9ec0, 0x0779ed2f, 0xdaef34aa, + 0x67255864, 0xbab381e1, 0xc7c087b9, 0x1a565e3c, 0xa79c32f2, + 0x7a0aeb77, 0x5d7a3e42, 0x80ece7c7, 0x3d268b09, 0xe0b0528c, + 0x9dc354d4, 0x40558d51, 0xfd9fe19f, 0x2009381a, 0xbd8d91ab, + 0x601b482e, 0xddd124e0, 0x0047fd65, 0x7d34fb3d, 0xa0a222b8, + 0x1d684e76, 0xc0fe97f3, 0xe78e42c6, 0x3a189b43, 0x87d2f78d, + 0x5a442e08, 0x27372850, 0xfaa1f1d5, 0x476b9d1b, 0x9afd449e, + 0x098a3771, 0xd41ceef4, 0x69d6823a, 0xb4405bbf, 0xc9335de7, + 0x14a58462, 0xa96fe8ac, 0x74f93129, 0x5389e41c, 0x8e1f3d99, + 0x33d55157, 0xee4388d2, 0x93308e8a, 0x4ea6570f, 0xf36c3bc1, + 0x2efae244, 0x0ef3da5e, 0xd36503db, 0x6eaf6f15, 0xb339b690, + 0xce4ab0c8, 0x13dc694d, 0xae160583, 0x7380dc06, 0x54f00933, + 0x8966d0b6, 0x34acbc78, 0xe93a65fd, 0x944963a5, 0x49dfba20, + 0xf415d6ee, 0x29830f6b, 0xbaf47c84, 0x6762a501, 0xdaa8c9cf, + 0x073e104a, 0x7a4d1612, 0xa7dbcf97, 0x1a11a359, 0xc7877adc, + 0xe0f7afe9, 0x3d61766c, 0x80ab1aa2, 0x5d3dc327, 0x204ec57f, + 0xfdd81cfa, 0x40127034, 0x9d84a9b1, 0xa06a2517, 0x7dfcfc92, + 0xc036905c, 0x1da049d9, 0x60d34f81, 0xbd459604, 0x008ffaca, + 0xdd19234f, 0xfa69f67a, 0x27ff2fff, 0x9a354331, 0x47a39ab4, + 0x3ad09cec, 0xe7464569, 0x5a8c29a7, 0x871af022, 0x146d83cd, + 0xc9fb5a48, 0x74313686, 0xa9a7ef03, 0xd4d4e95b, 0x094230de, + 0xb4885c10, 0x691e8595, 0x4e6e50a0, 0x93f88925, 0x2e32e5eb, + 0xf3a43c6e, 0x8ed73a36, 0x5341e3b3, 0xee8b8f7d, 0x331d56f8, + 0x13146ee2, 0xce82b767, 0x7348dba9, 0xaede022c, 0xd3ad0474, + 0x0e3bddf1, 0xb3f1b13f, 0x6e6768ba, 0x4917bd8f, 0x9481640a, + 0x294b08c4, 0xf4ddd141, 0x89aed719, 0x54380e9c, 0xe9f26252, + 0x3464bbd7, 0xa713c838, 0x7a8511bd, 0xc74f7d73, 0x1ad9a4f6, + 0x67aaa2ae, 0xba3c7b2b, 0x07f617e5, 0xda60ce60, 0xfd101b55, + 0x2086c2d0, 0x9d4cae1e, 0x40da779b, 0x3da971c3, 0xe03fa846, + 0x5df5c488, 0x80631d0d, 0x1de7b4bc, 0xc0716d39, 0x7dbb01f7, + 0xa02dd872, 0xdd5ede2a, 0x00c807af, 0xbd026b61, 0x6094b2e4, + 0x47e467d1, 0x9a72be54, 0x27b8d29a, 0xfa2e0b1f, 0x875d0d47, + 0x5acbd4c2, 0xe701b80c, 0x3a976189, 0xa9e01266, 0x7476cbe3, + 0xc9bca72d, 0x142a7ea8, 0x695978f0, 0xb4cfa175, 0x0905cdbb, + 0xd493143e, 0xf3e3c10b, 0x2e75188e, 0x93bf7440, 0x4e29adc5, + 0x335aab9d, 0xeecc7218, 0x53061ed6, 0x8e90c753, 0xae99ff49, + 0x730f26cc, 0xcec54a02, 0x13539387, 0x6e2095df, 0xb3b64c5a, + 0x0e7c2094, 0xd3eaf911, 0xf49a2c24, 0x290cf5a1, 0x94c6996f, + 0x495040ea, 0x342346b2, 0xe9b59f37, 0x547ff3f9, 0x89e92a7c, + 0x1a9e5993, 0xc7088016, 0x7ac2ecd8, 0xa754355d, 0xda273305, + 0x07b1ea80, 0xba7b864e, 0x67ed5fcb, 0x409d8afe, 0x9d0b537b, + 0x20c13fb5, 0xfd57e630, 0x8024e068, 0x5db239ed, 0xe0785523, + 0x3dee8ca6}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x00000000, 0x85d996dd, 0x4bb55c60, 0xce6ccabd, 0x966ab9c0, + 0x13b32f1d, 0xdddfe5a0, 0x5806737d, 0x6dd3035a, 0xe80a9587, + 0x26665f3a, 0xa3bfc9e7, 0xfbb9ba9a, 0x7e602c47, 0xb00ce6fa, + 0x35d57027, 0xdaa607b4, 0x5f7f9169, 0x91135bd4, 0x14cacd09, + 0x4cccbe74, 0xc91528a9, 0x0779e214, 0x82a074c9, 0xb77504ee, + 0x32ac9233, 0xfcc0588e, 0x7919ce53, 0x211fbd2e, 0xa4c62bf3, + 0x6aaae14e, 0xef737793, 0xf54b7eb3, 0x7092e86e, 0xbefe22d3, + 0x3b27b40e, 0x6321c773, 0xe6f851ae, 0x28949b13, 0xad4d0dce, + 0x98987de9, 0x1d41eb34, 0xd32d2189, 0x56f4b754, 0x0ef2c429, + 0x8b2b52f4, 0x45479849, 0xc09e0e94, 0x2fed7907, 0xaa34efda, + 0x64582567, 0xe181b3ba, 0xb987c0c7, 0x3c5e561a, 0xf2329ca7, + 0x77eb0a7a, 0x423e7a5d, 0xc7e7ec80, 0x098b263d, 0x8c52b0e0, + 0xd454c39d, 0x518d5540, 0x9fe19ffd, 0x1a380920, 0xab918dbd, + 0x2e481b60, 0xe024d1dd, 0x65fd4700, 0x3dfb347d, 0xb822a2a0, + 0x764e681d, 0xf397fec0, 0xc6428ee7, 0x439b183a, 0x8df7d287, + 0x082e445a, 0x50283727, 0xd5f1a1fa, 0x1b9d6b47, 0x9e44fd9a, + 0x71378a09, 0xf4ee1cd4, 0x3a82d669, 0xbf5b40b4, 0xe75d33c9, + 0x6284a514, 0xace86fa9, 0x2931f974, 0x1ce48953, 0x993d1f8e, + 0x5751d533, 0xd28843ee, 0x8a8e3093, 0x0f57a64e, 0xc13b6cf3, + 0x44e2fa2e, 0x5edaf30e, 0xdb0365d3, 0x156faf6e, 0x90b639b3, + 0xc8b04ace, 0x4d69dc13, 0x830516ae, 0x06dc8073, 0x3309f054, + 0xb6d06689, 0x78bcac34, 0xfd653ae9, 0xa5634994, 0x20badf49, + 0xeed615f4, 0x6b0f8329, 0x847cf4ba, 0x01a56267, 0xcfc9a8da, + 0x4a103e07, 0x12164d7a, 0x97cfdba7, 0x59a3111a, 0xdc7a87c7, + 0xe9aff7e0, 0x6c76613d, 0xa21aab80, 0x27c33d5d, 0x7fc54e20, + 0xfa1cd8fd, 0x34701240, 0xb1a9849d, 0x17256aa0, 0x92fcfc7d, + 0x5c9036c0, 0xd949a01d, 0x814fd360, 0x049645bd, 0xcafa8f00, + 0x4f2319dd, 0x7af669fa, 0xff2fff27, 0x3143359a, 0xb49aa347, + 0xec9cd03a, 0x694546e7, 0xa7298c5a, 0x22f01a87, 0xcd836d14, + 0x485afbc9, 0x86363174, 0x03efa7a9, 0x5be9d4d4, 0xde304209, + 0x105c88b4, 0x95851e69, 0xa0506e4e, 0x2589f893, 0xebe5322e, + 0x6e3ca4f3, 0x363ad78e, 0xb3e34153, 0x7d8f8bee, 0xf8561d33, + 0xe26e1413, 0x67b782ce, 0xa9db4873, 0x2c02deae, 0x7404add3, + 0xf1dd3b0e, 0x3fb1f1b3, 0xba68676e, 0x8fbd1749, 0x0a648194, + 0xc4084b29, 0x41d1ddf4, 0x19d7ae89, 0x9c0e3854, 0x5262f2e9, + 0xd7bb6434, 0x38c813a7, 0xbd11857a, 0x737d4fc7, 0xf6a4d91a, + 0xaea2aa67, 0x2b7b3cba, 0xe517f607, 0x60ce60da, 0x551b10fd, + 0xd0c28620, 0x1eae4c9d, 0x9b77da40, 0xc371a93d, 0x46a83fe0, + 0x88c4f55d, 0x0d1d6380, 0xbcb4e71d, 0x396d71c0, 0xf701bb7d, + 0x72d82da0, 0x2ade5edd, 0xaf07c800, 0x616b02bd, 0xe4b29460, + 0xd167e447, 0x54be729a, 0x9ad2b827, 0x1f0b2efa, 0x470d5d87, + 0xc2d4cb5a, 0x0cb801e7, 0x8961973a, 0x6612e0a9, 0xe3cb7674, + 0x2da7bcc9, 0xa87e2a14, 0xf0785969, 0x75a1cfb4, 0xbbcd0509, + 0x3e1493d4, 0x0bc1e3f3, 0x8e18752e, 0x4074bf93, 0xc5ad294e, + 0x9dab5a33, 0x1872ccee, 0xd61e0653, 0x53c7908e, 0x49ff99ae, + 0xcc260f73, 0x024ac5ce, 0x87935313, 0xdf95206e, 0x5a4cb6b3, + 0x94207c0e, 0x11f9ead3, 0x242c9af4, 0xa1f50c29, 0x6f99c694, + 0xea405049, 0xb2462334, 0x379fb5e9, 0xf9f37f54, 0x7c2ae989, + 0x93599e1a, 0x168008c7, 0xd8ecc27a, 0x5d3554a7, 0x053327da, + 0x80eab107, 0x4e867bba, 0xcb5fed67, 0xfe8a9d40, 0x7b530b9d, + 0xb53fc120, 0x30e657fd, 0x68e02480, 0xed39b25d, 0x235578e0, + 0xa68cee3d}, + {0x00000000, 0x76e10f9d, 0xadc46ee1, 0xdb25617c, 0x1b8fac19, + 0x6d6ea384, 0xb64bc2f8, 0xc0aacd65, 0x361e5933, 0x40ff56ae, + 0x9bda37d2, 0xed3b384f, 0x2d91f52a, 0x5b70fab7, 0x80559bcb, + 0xf6b49456, 0x6c3cb266, 0x1addbdfb, 0xc1f8dc87, 0xb719d31a, + 0x77b31e7f, 0x015211e2, 0xda77709e, 0xac967f03, 0x5a22eb55, + 0x2cc3e4c8, 0xf7e685b4, 0x81078a29, 0x41ad474c, 0x374c48d1, + 0xec6929ad, 0x9a882630, 0xd87864cd, 0xae996b50, 0x75bc0a2c, + 0x035d05b1, 0xc3f7c8d4, 0xb516c749, 0x6e33a635, 0x18d2a9a8, + 0xee663dfe, 0x98873263, 0x43a2531f, 0x35435c82, 0xf5e991e7, + 0x83089e7a, 0x582dff06, 0x2eccf09b, 0xb444d6ab, 0xc2a5d936, + 0x1980b84a, 0x6f61b7d7, 0xafcb7ab2, 0xd92a752f, 0x020f1453, + 0x74ee1bce, 0x825a8f98, 0xf4bb8005, 0x2f9ee179, 0x597feee4, + 0x99d52381, 0xef342c1c, 0x34114d60, 0x42f042fd, 0xf1f7b941, + 0x8716b6dc, 0x5c33d7a0, 0x2ad2d83d, 0xea781558, 0x9c991ac5, + 0x47bc7bb9, 0x315d7424, 0xc7e9e072, 0xb108efef, 0x6a2d8e93, + 0x1ccc810e, 0xdc664c6b, 0xaa8743f6, 0x71a2228a, 0x07432d17, + 0x9dcb0b27, 0xeb2a04ba, 0x300f65c6, 0x46ee6a5b, 0x8644a73e, + 0xf0a5a8a3, 0x2b80c9df, 0x5d61c642, 0xabd55214, 0xdd345d89, + 0x06113cf5, 0x70f03368, 0xb05afe0d, 0xc6bbf190, 0x1d9e90ec, + 0x6b7f9f71, 0x298fdd8c, 0x5f6ed211, 0x844bb36d, 0xf2aabcf0, + 0x32007195, 0x44e17e08, 0x9fc41f74, 0xe92510e9, 0x1f9184bf, + 0x69708b22, 0xb255ea5e, 0xc4b4e5c3, 0x041e28a6, 0x72ff273b, + 0xa9da4647, 0xdf3b49da, 0x45b36fea, 0x33526077, 0xe877010b, + 0x9e960e96, 0x5e3cc3f3, 0x28ddcc6e, 0xf3f8ad12, 0x8519a28f, + 0x73ad36d9, 0x054c3944, 0xde695838, 0xa88857a5, 0x68229ac0, + 0x1ec3955d, 0xc5e6f421, 0xb307fbbc, 0xe2ef7383, 0x940e7c1e, + 0x4f2b1d62, 0x39ca12ff, 0xf960df9a, 0x8f81d007, 0x54a4b17b, + 0x2245bee6, 0xd4f12ab0, 0xa210252d, 0x79354451, 0x0fd44bcc, + 0xcf7e86a9, 0xb99f8934, 0x62bae848, 0x145be7d5, 0x8ed3c1e5, + 0xf832ce78, 0x2317af04, 0x55f6a099, 0x955c6dfc, 0xe3bd6261, + 0x3898031d, 0x4e790c80, 0xb8cd98d6, 0xce2c974b, 0x1509f637, + 0x63e8f9aa, 0xa34234cf, 0xd5a33b52, 0x0e865a2e, 0x786755b3, + 0x3a97174e, 0x4c7618d3, 0x975379af, 0xe1b27632, 0x2118bb57, + 0x57f9b4ca, 0x8cdcd5b6, 0xfa3dda2b, 0x0c894e7d, 0x7a6841e0, + 0xa14d209c, 0xd7ac2f01, 0x1706e264, 0x61e7edf9, 0xbac28c85, + 0xcc238318, 0x56aba528, 0x204aaab5, 0xfb6fcbc9, 0x8d8ec454, + 0x4d240931, 0x3bc506ac, 0xe0e067d0, 0x9601684d, 0x60b5fc1b, + 0x1654f386, 0xcd7192fa, 0xbb909d67, 0x7b3a5002, 0x0ddb5f9f, + 0xd6fe3ee3, 0xa01f317e, 0x1318cac2, 0x65f9c55f, 0xbedca423, + 0xc83dabbe, 0x089766db, 0x7e766946, 0xa553083a, 0xd3b207a7, + 0x250693f1, 0x53e79c6c, 0x88c2fd10, 0xfe23f28d, 0x3e893fe8, + 0x48683075, 0x934d5109, 0xe5ac5e94, 0x7f2478a4, 0x09c57739, + 0xd2e01645, 0xa40119d8, 0x64abd4bd, 0x124adb20, 0xc96fba5c, + 0xbf8eb5c1, 0x493a2197, 0x3fdb2e0a, 0xe4fe4f76, 0x921f40eb, + 0x52b58d8e, 0x24548213, 0xff71e36f, 0x8990ecf2, 0xcb60ae0f, + 0xbd81a192, 0x66a4c0ee, 0x1045cf73, 0xd0ef0216, 0xa60e0d8b, + 0x7d2b6cf7, 0x0bca636a, 0xfd7ef73c, 0x8b9ff8a1, 0x50ba99dd, + 0x265b9640, 0xe6f15b25, 0x901054b8, 0x4b3535c4, 0x3dd43a59, + 0xa75c1c69, 0xd1bd13f4, 0x0a987288, 0x7c797d15, 0xbcd3b070, + 0xca32bfed, 0x1117de91, 0x67f6d10c, 0x9142455a, 0xe7a34ac7, + 0x3c862bbb, 0x4a672426, 0x8acde943, 0xfc2ce6de, 0x270987a2, + 0x51e8883f}, + {0x00000000, 0xe8dbfbb9, 0x91b186a8, 0x796a7d11, 0x63657c8a, + 0x8bbe8733, 0xf2d4fa22, 0x1a0f019b, 0x87cc89cf, 0x6f177276, + 0x167d0f67, 0xfea6f4de, 0xe4a9f545, 0x0c720efc, 0x751873ed, + 0x9dc38854, 0x4f9f6244, 0xa74499fd, 0xde2ee4ec, 0x36f51f55, + 0x2cfa1ece, 0xc421e577, 0xbd4b9866, 0x559063df, 0xc853eb8b, + 0x20881032, 0x59e26d23, 0xb139969a, 0xab369701, 0x43ed6cb8, + 0x3a8711a9, 0xd25cea10, 0x9e3ec588, 0x76e53e31, 0x0f8f4320, + 0xe754b899, 0xfd5bb902, 0x158042bb, 0x6cea3faa, 0x8431c413, + 0x19f24c47, 0xf129b7fe, 0x8843caef, 0x60983156, 0x7a9730cd, + 0x924ccb74, 0xeb26b665, 0x03fd4ddc, 0xd1a1a7cc, 0x397a5c75, + 0x40102164, 0xa8cbdadd, 0xb2c4db46, 0x5a1f20ff, 0x23755dee, + 0xcbaea657, 0x566d2e03, 0xbeb6d5ba, 0xc7dca8ab, 0x2f075312, + 0x35085289, 0xddd3a930, 0xa4b9d421, 0x4c622f98, 0x7d7bfbca, + 0x95a00073, 0xecca7d62, 0x041186db, 0x1e1e8740, 0xf6c57cf9, + 0x8faf01e8, 0x6774fa51, 0xfab77205, 0x126c89bc, 0x6b06f4ad, + 0x83dd0f14, 0x99d20e8f, 0x7109f536, 0x08638827, 0xe0b8739e, + 0x32e4998e, 0xda3f6237, 0xa3551f26, 0x4b8ee49f, 0x5181e504, + 0xb95a1ebd, 0xc03063ac, 0x28eb9815, 0xb5281041, 0x5df3ebf8, + 0x249996e9, 0xcc426d50, 0xd64d6ccb, 0x3e969772, 0x47fcea63, + 0xaf2711da, 0xe3453e42, 0x0b9ec5fb, 0x72f4b8ea, 0x9a2f4353, + 0x802042c8, 0x68fbb971, 0x1191c460, 0xf94a3fd9, 0x6489b78d, + 0x8c524c34, 0xf5383125, 0x1de3ca9c, 0x07eccb07, 0xef3730be, + 0x965d4daf, 0x7e86b616, 0xacda5c06, 0x4401a7bf, 0x3d6bdaae, + 0xd5b02117, 0xcfbf208c, 0x2764db35, 0x5e0ea624, 0xb6d55d9d, + 0x2b16d5c9, 0xc3cd2e70, 0xbaa75361, 0x527ca8d8, 0x4873a943, + 0xa0a852fa, 0xd9c22feb, 0x3119d452, 0xbbf0874e, 0x532b7cf7, + 0x2a4101e6, 0xc29afa5f, 0xd895fbc4, 0x304e007d, 0x49247d6c, + 0xa1ff86d5, 0x3c3c0e81, 0xd4e7f538, 0xad8d8829, 0x45567390, + 0x5f59720b, 0xb78289b2, 0xcee8f4a3, 0x26330f1a, 0xf46fe50a, + 0x1cb41eb3, 0x65de63a2, 0x8d05981b, 0x970a9980, 0x7fd16239, + 0x06bb1f28, 0xee60e491, 0x73a36cc5, 0x9b78977c, 0xe212ea6d, + 0x0ac911d4, 0x10c6104f, 0xf81debf6, 0x817796e7, 0x69ac6d5e, + 0x25ce42c6, 0xcd15b97f, 0xb47fc46e, 0x5ca43fd7, 0x46ab3e4c, + 0xae70c5f5, 0xd71ab8e4, 0x3fc1435d, 0xa202cb09, 0x4ad930b0, + 0x33b34da1, 0xdb68b618, 0xc167b783, 0x29bc4c3a, 0x50d6312b, + 0xb80dca92, 0x6a512082, 0x828adb3b, 0xfbe0a62a, 0x133b5d93, + 0x09345c08, 0xe1efa7b1, 0x9885daa0, 0x705e2119, 0xed9da94d, + 0x054652f4, 0x7c2c2fe5, 0x94f7d45c, 0x8ef8d5c7, 0x66232e7e, + 0x1f49536f, 0xf792a8d6, 0xc68b7c84, 0x2e50873d, 0x573afa2c, + 0xbfe10195, 0xa5ee000e, 0x4d35fbb7, 0x345f86a6, 0xdc847d1f, + 0x4147f54b, 0xa99c0ef2, 0xd0f673e3, 0x382d885a, 0x222289c1, + 0xcaf97278, 0xb3930f69, 0x5b48f4d0, 0x89141ec0, 0x61cfe579, + 0x18a59868, 0xf07e63d1, 0xea71624a, 0x02aa99f3, 0x7bc0e4e2, + 0x931b1f5b, 0x0ed8970f, 0xe6036cb6, 0x9f6911a7, 0x77b2ea1e, + 0x6dbdeb85, 0x8566103c, 0xfc0c6d2d, 0x14d79694, 0x58b5b90c, + 0xb06e42b5, 0xc9043fa4, 0x21dfc41d, 0x3bd0c586, 0xd30b3e3f, + 0xaa61432e, 0x42bab897, 0xdf7930c3, 0x37a2cb7a, 0x4ec8b66b, + 0xa6134dd2, 0xbc1c4c49, 0x54c7b7f0, 0x2dadcae1, 0xc5763158, + 0x172adb48, 0xfff120f1, 0x869b5de0, 0x6e40a659, 0x744fa7c2, + 0x9c945c7b, 0xe5fe216a, 0x0d25dad3, 0x90e65287, 0x783da93e, + 0x0157d42f, 0xe98c2f96, 0xf3832e0d, 0x1b58d5b4, 0x6232a8a5, + 0x8ae9531c}, + {0x00000000, 0x919168ae, 0x6325a087, 0xf2b4c829, 0x874c31d4, + 0x16dd597a, 0xe4699153, 0x75f8f9fd, 0x4f9f1373, 0xde0e7bdd, + 0x2cbab3f4, 0xbd2bdb5a, 0xc8d322a7, 0x59424a09, 0xabf68220, + 0x3a67ea8e, 0x9e3e27e6, 0x0faf4f48, 0xfd1b8761, 0x6c8aefcf, + 0x19721632, 0x88e37e9c, 0x7a57b6b5, 0xebc6de1b, 0xd1a13495, + 0x40305c3b, 0xb2849412, 0x2315fcbc, 0x56ed0541, 0xc77c6def, + 0x35c8a5c6, 0xa459cd68, 0x7d7b3f17, 0xecea57b9, 0x1e5e9f90, + 0x8fcff73e, 0xfa370ec3, 0x6ba6666d, 0x9912ae44, 0x0883c6ea, + 0x32e42c64, 0xa37544ca, 0x51c18ce3, 0xc050e44d, 0xb5a81db0, + 0x2439751e, 0xd68dbd37, 0x471cd599, 0xe34518f1, 0x72d4705f, + 0x8060b876, 0x11f1d0d8, 0x64092925, 0xf598418b, 0x072c89a2, + 0x96bde10c, 0xacda0b82, 0x3d4b632c, 0xcfffab05, 0x5e6ec3ab, + 0x2b963a56, 0xba0752f8, 0x48b39ad1, 0xd922f27f, 0xfaf67e2e, + 0x6b671680, 0x99d3dea9, 0x0842b607, 0x7dba4ffa, 0xec2b2754, + 0x1e9fef7d, 0x8f0e87d3, 0xb5696d5d, 0x24f805f3, 0xd64ccdda, + 0x47dda574, 0x32255c89, 0xa3b43427, 0x5100fc0e, 0xc09194a0, + 0x64c859c8, 0xf5593166, 0x07edf94f, 0x967c91e1, 0xe384681c, + 0x721500b2, 0x80a1c89b, 0x1130a035, 0x2b574abb, 0xbac62215, + 0x4872ea3c, 0xd9e38292, 0xac1b7b6f, 0x3d8a13c1, 0xcf3edbe8, + 0x5eafb346, 0x878d4139, 0x161c2997, 0xe4a8e1be, 0x75398910, + 0x00c170ed, 0x91501843, 0x63e4d06a, 0xf275b8c4, 0xc812524a, + 0x59833ae4, 0xab37f2cd, 0x3aa69a63, 0x4f5e639e, 0xdecf0b30, + 0x2c7bc319, 0xbdeaabb7, 0x19b366df, 0x88220e71, 0x7a96c658, + 0xeb07aef6, 0x9eff570b, 0x0f6e3fa5, 0xfddaf78c, 0x6c4b9f22, + 0x562c75ac, 0xc7bd1d02, 0x3509d52b, 0xa498bd85, 0xd1604478, + 0x40f12cd6, 0xb245e4ff, 0x23d48c51, 0xf4edfd5c, 0x657c95f2, + 0x97c85ddb, 0x06593575, 0x73a1cc88, 0xe230a426, 0x10846c0f, + 0x811504a1, 0xbb72ee2f, 0x2ae38681, 0xd8574ea8, 0x49c62606, + 0x3c3edffb, 0xadafb755, 0x5f1b7f7c, 0xce8a17d2, 0x6ad3daba, + 0xfb42b214, 0x09f67a3d, 0x98671293, 0xed9feb6e, 0x7c0e83c0, + 0x8eba4be9, 0x1f2b2347, 0x254cc9c9, 0xb4dda167, 0x4669694e, + 0xd7f801e0, 0xa200f81d, 0x339190b3, 0xc125589a, 0x50b43034, + 0x8996c24b, 0x1807aae5, 0xeab362cc, 0x7b220a62, 0x0edaf39f, + 0x9f4b9b31, 0x6dff5318, 0xfc6e3bb6, 0xc609d138, 0x5798b996, + 0xa52c71bf, 0x34bd1911, 0x4145e0ec, 0xd0d48842, 0x2260406b, + 0xb3f128c5, 0x17a8e5ad, 0x86398d03, 0x748d452a, 0xe51c2d84, + 0x90e4d479, 0x0175bcd7, 0xf3c174fe, 0x62501c50, 0x5837f6de, + 0xc9a69e70, 0x3b125659, 0xaa833ef7, 0xdf7bc70a, 0x4eeaafa4, + 0xbc5e678d, 0x2dcf0f23, 0x0e1b8372, 0x9f8aebdc, 0x6d3e23f5, + 0xfcaf4b5b, 0x8957b2a6, 0x18c6da08, 0xea721221, 0x7be37a8f, + 0x41849001, 0xd015f8af, 0x22a13086, 0xb3305828, 0xc6c8a1d5, + 0x5759c97b, 0xa5ed0152, 0x347c69fc, 0x9025a494, 0x01b4cc3a, + 0xf3000413, 0x62916cbd, 0x17699540, 0x86f8fdee, 0x744c35c7, + 0xe5dd5d69, 0xdfbab7e7, 0x4e2bdf49, 0xbc9f1760, 0x2d0e7fce, + 0x58f68633, 0xc967ee9d, 0x3bd326b4, 0xaa424e1a, 0x7360bc65, + 0xe2f1d4cb, 0x10451ce2, 0x81d4744c, 0xf42c8db1, 0x65bde51f, + 0x97092d36, 0x06984598, 0x3cffaf16, 0xad6ec7b8, 0x5fda0f91, + 0xce4b673f, 0xbbb39ec2, 0x2a22f66c, 0xd8963e45, 0x490756eb, + 0xed5e9b83, 0x7ccff32d, 0x8e7b3b04, 0x1fea53aa, 0x6a12aa57, + 0xfb83c2f9, 0x09370ad0, 0x98a6627e, 0xa2c188f0, 0x3350e05e, + 0xc1e42877, 0x507540d9, 0x258db924, 0xb41cd18a, 0x46a819a3, + 0xd739710d}}; + +#endif + +#endif + +#if N == 5 + +#if W == 8 + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xaf449247, 0x85f822cf, 0x2abcb088, 0xd08143df, + 0x7fc5d198, 0x55796110, 0xfa3df357, 0x7a7381ff, 0xd53713b8, + 0xff8ba330, 0x50cf3177, 0xaaf2c220, 0x05b65067, 0x2f0ae0ef, + 0x804e72a8, 0xf4e703fe, 0x5ba391b9, 0x711f2131, 0xde5bb376, + 0x24664021, 0x8b22d266, 0xa19e62ee, 0x0edaf0a9, 0x8e948201, + 0x21d01046, 0x0b6ca0ce, 0xa4283289, 0x5e15c1de, 0xf1515399, + 0xdbede311, 0x74a97156, 0x32bf01bd, 0x9dfb93fa, 0xb7472372, + 0x1803b135, 0xe23e4262, 0x4d7ad025, 0x67c660ad, 0xc882f2ea, + 0x48cc8042, 0xe7881205, 0xcd34a28d, 0x627030ca, 0x984dc39d, + 0x370951da, 0x1db5e152, 0xb2f17315, 0xc6580243, 0x691c9004, + 0x43a0208c, 0xece4b2cb, 0x16d9419c, 0xb99dd3db, 0x93216353, + 0x3c65f114, 0xbc2b83bc, 0x136f11fb, 0x39d3a173, 0x96973334, + 0x6caac063, 0xc3ee5224, 0xe952e2ac, 0x461670eb, 0x657e037a, + 0xca3a913d, 0xe08621b5, 0x4fc2b3f2, 0xb5ff40a5, 0x1abbd2e2, + 0x3007626a, 0x9f43f02d, 0x1f0d8285, 0xb04910c2, 0x9af5a04a, + 0x35b1320d, 0xcf8cc15a, 0x60c8531d, 0x4a74e395, 0xe53071d2, + 0x91990084, 0x3edd92c3, 0x1461224b, 0xbb25b00c, 0x4118435b, + 0xee5cd11c, 0xc4e06194, 0x6ba4f3d3, 0xebea817b, 0x44ae133c, + 0x6e12a3b4, 0xc15631f3, 0x3b6bc2a4, 0x942f50e3, 0xbe93e06b, + 0x11d7722c, 0x57c102c7, 0xf8859080, 0xd2392008, 0x7d7db24f, + 0x87404118, 0x2804d35f, 0x02b863d7, 0xadfcf190, 0x2db28338, + 0x82f6117f, 0xa84aa1f7, 0x070e33b0, 0xfd33c0e7, 0x527752a0, + 0x78cbe228, 0xd78f706f, 0xa3260139, 0x0c62937e, 0x26de23f6, + 0x899ab1b1, 0x73a742e6, 0xdce3d0a1, 0xf65f6029, 0x591bf26e, + 0xd95580c6, 0x76111281, 0x5cada209, 0xf3e9304e, 0x09d4c319, + 0xa690515e, 0x8c2ce1d6, 0x23687391, 0xcafc06f4, 0x65b894b3, + 0x4f04243b, 0xe040b67c, 0x1a7d452b, 0xb539d76c, 0x9f8567e4, + 0x30c1f5a3, 0xb08f870b, 0x1fcb154c, 0x3577a5c4, 0x9a333783, + 0x600ec4d4, 0xcf4a5693, 0xe5f6e61b, 0x4ab2745c, 0x3e1b050a, + 0x915f974d, 0xbbe327c5, 0x14a7b582, 0xee9a46d5, 0x41ded492, + 0x6b62641a, 0xc426f65d, 0x446884f5, 0xeb2c16b2, 0xc190a63a, + 0x6ed4347d, 0x94e9c72a, 0x3bad556d, 0x1111e5e5, 0xbe5577a2, + 0xf8430749, 0x5707950e, 0x7dbb2586, 0xd2ffb7c1, 0x28c24496, + 0x8786d6d1, 0xad3a6659, 0x027ef41e, 0x823086b6, 0x2d7414f1, + 0x07c8a479, 0xa88c363e, 0x52b1c569, 0xfdf5572e, 0xd749e7a6, + 0x780d75e1, 0x0ca404b7, 0xa3e096f0, 0x895c2678, 0x2618b43f, + 0xdc254768, 0x7361d52f, 0x59dd65a7, 0xf699f7e0, 0x76d78548, + 0xd993170f, 0xf32fa787, 0x5c6b35c0, 0xa656c697, 0x091254d0, + 0x23aee458, 0x8cea761f, 0xaf82058e, 0x00c697c9, 0x2a7a2741, + 0x853eb506, 0x7f034651, 0xd047d416, 0xfafb649e, 0x55bff6d9, + 0xd5f18471, 0x7ab51636, 0x5009a6be, 0xff4d34f9, 0x0570c7ae, + 0xaa3455e9, 0x8088e561, 0x2fcc7726, 0x5b650670, 0xf4219437, + 0xde9d24bf, 0x71d9b6f8, 0x8be445af, 0x24a0d7e8, 0x0e1c6760, + 0xa158f527, 0x2116878f, 0x8e5215c8, 0xa4eea540, 0x0baa3707, + 0xf197c450, 0x5ed35617, 0x746fe69f, 0xdb2b74d8, 0x9d3d0433, + 0x32799674, 0x18c526fc, 0xb781b4bb, 0x4dbc47ec, 0xe2f8d5ab, + 0xc8446523, 0x6700f764, 0xe74e85cc, 0x480a178b, 0x62b6a703, + 0xcdf23544, 0x37cfc613, 0x988b5454, 0xb237e4dc, 0x1d73769b, + 0x69da07cd, 0xc69e958a, 0xec222502, 0x4366b745, 0xb95b4412, + 0x161fd655, 0x3ca366dd, 0x93e7f49a, 0x13a98632, 0xbced1475, + 0x9651a4fd, 0x391536ba, 0xc328c5ed, 0x6c6c57aa, 0x46d0e722, + 0xe9947565}, + {0x00000000, 0x4e890ba9, 0x9d121752, 0xd39b1cfb, 0xe15528e5, + 0xafdc234c, 0x7c473fb7, 0x32ce341e, 0x19db578b, 0x57525c22, + 0x84c940d9, 0xca404b70, 0xf88e7f6e, 0xb60774c7, 0x659c683c, + 0x2b156395, 0x33b6af16, 0x7d3fa4bf, 0xaea4b844, 0xe02db3ed, + 0xd2e387f3, 0x9c6a8c5a, 0x4ff190a1, 0x01789b08, 0x2a6df89d, + 0x64e4f334, 0xb77fefcf, 0xf9f6e466, 0xcb38d078, 0x85b1dbd1, + 0x562ac72a, 0x18a3cc83, 0x676d5e2c, 0x29e45585, 0xfa7f497e, + 0xb4f642d7, 0x863876c9, 0xc8b17d60, 0x1b2a619b, 0x55a36a32, + 0x7eb609a7, 0x303f020e, 0xe3a41ef5, 0xad2d155c, 0x9fe32142, + 0xd16a2aeb, 0x02f13610, 0x4c783db9, 0x54dbf13a, 0x1a52fa93, + 0xc9c9e668, 0x8740edc1, 0xb58ed9df, 0xfb07d276, 0x289cce8d, + 0x6615c524, 0x4d00a6b1, 0x0389ad18, 0xd012b1e3, 0x9e9bba4a, + 0xac558e54, 0xe2dc85fd, 0x31479906, 0x7fce92af, 0xcedabc58, + 0x8053b7f1, 0x53c8ab0a, 0x1d41a0a3, 0x2f8f94bd, 0x61069f14, + 0xb29d83ef, 0xfc148846, 0xd701ebd3, 0x9988e07a, 0x4a13fc81, + 0x049af728, 0x3654c336, 0x78ddc89f, 0xab46d464, 0xe5cfdfcd, + 0xfd6c134e, 0xb3e518e7, 0x607e041c, 0x2ef70fb5, 0x1c393bab, + 0x52b03002, 0x812b2cf9, 0xcfa22750, 0xe4b744c5, 0xaa3e4f6c, + 0x79a55397, 0x372c583e, 0x05e26c20, 0x4b6b6789, 0x98f07b72, + 0xd67970db, 0xa9b7e274, 0xe73ee9dd, 0x34a5f526, 0x7a2cfe8f, + 0x48e2ca91, 0x066bc138, 0xd5f0ddc3, 0x9b79d66a, 0xb06cb5ff, + 0xfee5be56, 0x2d7ea2ad, 0x63f7a904, 0x51399d1a, 0x1fb096b3, + 0xcc2b8a48, 0x82a281e1, 0x9a014d62, 0xd48846cb, 0x07135a30, + 0x499a5199, 0x7b546587, 0x35dd6e2e, 0xe64672d5, 0xa8cf797c, + 0x83da1ae9, 0xcd531140, 0x1ec80dbb, 0x50410612, 0x628f320c, + 0x2c0639a5, 0xff9d255e, 0xb1142ef7, 0x46c47ef1, 0x084d7558, + 0xdbd669a3, 0x955f620a, 0xa7915614, 0xe9185dbd, 0x3a834146, + 0x740a4aef, 0x5f1f297a, 0x119622d3, 0xc20d3e28, 0x8c843581, + 0xbe4a019f, 0xf0c30a36, 0x235816cd, 0x6dd11d64, 0x7572d1e7, + 0x3bfbda4e, 0xe860c6b5, 0xa6e9cd1c, 0x9427f902, 0xdaaef2ab, + 0x0935ee50, 0x47bce5f9, 0x6ca9866c, 0x22208dc5, 0xf1bb913e, + 0xbf329a97, 0x8dfcae89, 0xc375a520, 0x10eeb9db, 0x5e67b272, + 0x21a920dd, 0x6f202b74, 0xbcbb378f, 0xf2323c26, 0xc0fc0838, + 0x8e750391, 0x5dee1f6a, 0x136714c3, 0x38727756, 0x76fb7cff, + 0xa5606004, 0xebe96bad, 0xd9275fb3, 0x97ae541a, 0x443548e1, + 0x0abc4348, 0x121f8fcb, 0x5c968462, 0x8f0d9899, 0xc1849330, + 0xf34aa72e, 0xbdc3ac87, 0x6e58b07c, 0x20d1bbd5, 0x0bc4d840, + 0x454dd3e9, 0x96d6cf12, 0xd85fc4bb, 0xea91f0a5, 0xa418fb0c, + 0x7783e7f7, 0x390aec5e, 0x881ec2a9, 0xc697c900, 0x150cd5fb, + 0x5b85de52, 0x694bea4c, 0x27c2e1e5, 0xf459fd1e, 0xbad0f6b7, + 0x91c59522, 0xdf4c9e8b, 0x0cd78270, 0x425e89d9, 0x7090bdc7, + 0x3e19b66e, 0xed82aa95, 0xa30ba13c, 0xbba86dbf, 0xf5216616, + 0x26ba7aed, 0x68337144, 0x5afd455a, 0x14744ef3, 0xc7ef5208, + 0x896659a1, 0xa2733a34, 0xecfa319d, 0x3f612d66, 0x71e826cf, + 0x432612d1, 0x0daf1978, 0xde340583, 0x90bd0e2a, 0xef739c85, + 0xa1fa972c, 0x72618bd7, 0x3ce8807e, 0x0e26b460, 0x40afbfc9, + 0x9334a332, 0xddbda89b, 0xf6a8cb0e, 0xb821c0a7, 0x6bbadc5c, + 0x2533d7f5, 0x17fde3eb, 0x5974e842, 0x8aeff4b9, 0xc466ff10, + 0xdcc53393, 0x924c383a, 0x41d724c1, 0x0f5e2f68, 0x3d901b76, + 0x731910df, 0xa0820c24, 0xee0b078d, 0xc51e6418, 0x8b976fb1, + 0x580c734a, 0x168578e3, 0x244b4cfd, 0x6ac24754, 0xb9595baf, + 0xf7d05006}, + {0x00000000, 0x8d88fde2, 0xc060fd85, 0x4de80067, 0x5bb0fd4b, + 0xd63800a9, 0x9bd000ce, 0x1658fd2c, 0xb761fa96, 0x3ae90774, + 0x77010713, 0xfa89faf1, 0xecd107dd, 0x6159fa3f, 0x2cb1fa58, + 0xa13907ba, 0xb5b2f36d, 0x383a0e8f, 0x75d20ee8, 0xf85af30a, + 0xee020e26, 0x638af3c4, 0x2e62f3a3, 0xa3ea0e41, 0x02d309fb, + 0x8f5bf419, 0xc2b3f47e, 0x4f3b099c, 0x5963f4b0, 0xd4eb0952, + 0x99030935, 0x148bf4d7, 0xb014e09b, 0x3d9c1d79, 0x70741d1e, + 0xfdfce0fc, 0xeba41dd0, 0x662ce032, 0x2bc4e055, 0xa64c1db7, + 0x07751a0d, 0x8afde7ef, 0xc715e788, 0x4a9d1a6a, 0x5cc5e746, + 0xd14d1aa4, 0x9ca51ac3, 0x112de721, 0x05a613f6, 0x882eee14, + 0xc5c6ee73, 0x484e1391, 0x5e16eebd, 0xd39e135f, 0x9e761338, + 0x13feeeda, 0xb2c7e960, 0x3f4f1482, 0x72a714e5, 0xff2fe907, + 0xe977142b, 0x64ffe9c9, 0x2917e9ae, 0xa49f144c, 0xbb58c777, + 0x36d03a95, 0x7b383af2, 0xf6b0c710, 0xe0e83a3c, 0x6d60c7de, + 0x2088c7b9, 0xad003a5b, 0x0c393de1, 0x81b1c003, 0xcc59c064, + 0x41d13d86, 0x5789c0aa, 0xda013d48, 0x97e93d2f, 0x1a61c0cd, + 0x0eea341a, 0x8362c9f8, 0xce8ac99f, 0x4302347d, 0x555ac951, + 0xd8d234b3, 0x953a34d4, 0x18b2c936, 0xb98bce8c, 0x3403336e, + 0x79eb3309, 0xf463ceeb, 0xe23b33c7, 0x6fb3ce25, 0x225bce42, + 0xafd333a0, 0x0b4c27ec, 0x86c4da0e, 0xcb2cda69, 0x46a4278b, + 0x50fcdaa7, 0xdd742745, 0x909c2722, 0x1d14dac0, 0xbc2ddd7a, + 0x31a52098, 0x7c4d20ff, 0xf1c5dd1d, 0xe79d2031, 0x6a15ddd3, + 0x27fdddb4, 0xaa752056, 0xbefed481, 0x33762963, 0x7e9e2904, + 0xf316d4e6, 0xe54e29ca, 0x68c6d428, 0x252ed44f, 0xa8a629ad, + 0x099f2e17, 0x8417d3f5, 0xc9ffd392, 0x44772e70, 0x522fd35c, + 0xdfa72ebe, 0x924f2ed9, 0x1fc7d33b, 0xadc088af, 0x2048754d, + 0x6da0752a, 0xe02888c8, 0xf67075e4, 0x7bf88806, 0x36108861, + 0xbb987583, 0x1aa17239, 0x97298fdb, 0xdac18fbc, 0x5749725e, + 0x41118f72, 0xcc997290, 0x817172f7, 0x0cf98f15, 0x18727bc2, + 0x95fa8620, 0xd8128647, 0x559a7ba5, 0x43c28689, 0xce4a7b6b, + 0x83a27b0c, 0x0e2a86ee, 0xaf138154, 0x229b7cb6, 0x6f737cd1, + 0xe2fb8133, 0xf4a37c1f, 0x792b81fd, 0x34c3819a, 0xb94b7c78, + 0x1dd46834, 0x905c95d6, 0xddb495b1, 0x503c6853, 0x4664957f, + 0xcbec689d, 0x860468fa, 0x0b8c9518, 0xaab592a2, 0x273d6f40, + 0x6ad56f27, 0xe75d92c5, 0xf1056fe9, 0x7c8d920b, 0x3165926c, + 0xbced6f8e, 0xa8669b59, 0x25ee66bb, 0x680666dc, 0xe58e9b3e, + 0xf3d66612, 0x7e5e9bf0, 0x33b69b97, 0xbe3e6675, 0x1f0761cf, + 0x928f9c2d, 0xdf679c4a, 0x52ef61a8, 0x44b79c84, 0xc93f6166, + 0x84d76101, 0x095f9ce3, 0x16984fd8, 0x9b10b23a, 0xd6f8b25d, + 0x5b704fbf, 0x4d28b293, 0xc0a04f71, 0x8d484f16, 0x00c0b2f4, + 0xa1f9b54e, 0x2c7148ac, 0x619948cb, 0xec11b529, 0xfa494805, + 0x77c1b5e7, 0x3a29b580, 0xb7a14862, 0xa32abcb5, 0x2ea24157, + 0x634a4130, 0xeec2bcd2, 0xf89a41fe, 0x7512bc1c, 0x38fabc7b, + 0xb5724199, 0x144b4623, 0x99c3bbc1, 0xd42bbba6, 0x59a34644, + 0x4ffbbb68, 0xc273468a, 0x8f9b46ed, 0x0213bb0f, 0xa68caf43, + 0x2b0452a1, 0x66ec52c6, 0xeb64af24, 0xfd3c5208, 0x70b4afea, + 0x3d5caf8d, 0xb0d4526f, 0x11ed55d5, 0x9c65a837, 0xd18da850, + 0x5c0555b2, 0x4a5da89e, 0xc7d5557c, 0x8a3d551b, 0x07b5a8f9, + 0x133e5c2e, 0x9eb6a1cc, 0xd35ea1ab, 0x5ed65c49, 0x488ea165, + 0xc5065c87, 0x88ee5ce0, 0x0566a102, 0xa45fa6b8, 0x29d75b5a, + 0x643f5b3d, 0xe9b7a6df, 0xffef5bf3, 0x7267a611, 0x3f8fa676, + 0xb2075b94}, + {0x00000000, 0x80f0171f, 0xda91287f, 0x5a613f60, 0x6e5356bf, + 0xeea341a0, 0xb4c27ec0, 0x343269df, 0xdca6ad7e, 0x5c56ba61, + 0x06378501, 0x86c7921e, 0xb2f5fbc1, 0x3205ecde, 0x6864d3be, + 0xe894c4a1, 0x623c5cbd, 0xe2cc4ba2, 0xb8ad74c2, 0x385d63dd, + 0x0c6f0a02, 0x8c9f1d1d, 0xd6fe227d, 0x560e3562, 0xbe9af1c3, + 0x3e6ae6dc, 0x640bd9bc, 0xe4fbcea3, 0xd0c9a77c, 0x5039b063, + 0x0a588f03, 0x8aa8981c, 0xc478b97a, 0x4488ae65, 0x1ee99105, + 0x9e19861a, 0xaa2befc5, 0x2adbf8da, 0x70bac7ba, 0xf04ad0a5, + 0x18de1404, 0x982e031b, 0xc24f3c7b, 0x42bf2b64, 0x768d42bb, + 0xf67d55a4, 0xac1c6ac4, 0x2cec7ddb, 0xa644e5c7, 0x26b4f2d8, + 0x7cd5cdb8, 0xfc25daa7, 0xc817b378, 0x48e7a467, 0x12869b07, + 0x92768c18, 0x7ae248b9, 0xfa125fa6, 0xa07360c6, 0x208377d9, + 0x14b11e06, 0x94410919, 0xce203679, 0x4ed02166, 0x538074b5, + 0xd37063aa, 0x89115cca, 0x09e14bd5, 0x3dd3220a, 0xbd233515, + 0xe7420a75, 0x67b21d6a, 0x8f26d9cb, 0x0fd6ced4, 0x55b7f1b4, + 0xd547e6ab, 0xe1758f74, 0x6185986b, 0x3be4a70b, 0xbb14b014, + 0x31bc2808, 0xb14c3f17, 0xeb2d0077, 0x6bdd1768, 0x5fef7eb7, + 0xdf1f69a8, 0x857e56c8, 0x058e41d7, 0xed1a8576, 0x6dea9269, + 0x378bad09, 0xb77bba16, 0x8349d3c9, 0x03b9c4d6, 0x59d8fbb6, + 0xd928eca9, 0x97f8cdcf, 0x1708dad0, 0x4d69e5b0, 0xcd99f2af, + 0xf9ab9b70, 0x795b8c6f, 0x233ab30f, 0xa3caa410, 0x4b5e60b1, + 0xcbae77ae, 0x91cf48ce, 0x113f5fd1, 0x250d360e, 0xa5fd2111, + 0xff9c1e71, 0x7f6c096e, 0xf5c49172, 0x7534866d, 0x2f55b90d, + 0xafa5ae12, 0x9b97c7cd, 0x1b67d0d2, 0x4106efb2, 0xc1f6f8ad, + 0x29623c0c, 0xa9922b13, 0xf3f31473, 0x7303036c, 0x47316ab3, + 0xc7c17dac, 0x9da042cc, 0x1d5055d3, 0xa700e96a, 0x27f0fe75, + 0x7d91c115, 0xfd61d60a, 0xc953bfd5, 0x49a3a8ca, 0x13c297aa, + 0x933280b5, 0x7ba64414, 0xfb56530b, 0xa1376c6b, 0x21c77b74, + 0x15f512ab, 0x950505b4, 0xcf643ad4, 0x4f942dcb, 0xc53cb5d7, + 0x45cca2c8, 0x1fad9da8, 0x9f5d8ab7, 0xab6fe368, 0x2b9ff477, + 0x71fecb17, 0xf10edc08, 0x199a18a9, 0x996a0fb6, 0xc30b30d6, + 0x43fb27c9, 0x77c94e16, 0xf7395909, 0xad586669, 0x2da87176, + 0x63785010, 0xe388470f, 0xb9e9786f, 0x39196f70, 0x0d2b06af, + 0x8ddb11b0, 0xd7ba2ed0, 0x574a39cf, 0xbfdefd6e, 0x3f2eea71, + 0x654fd511, 0xe5bfc20e, 0xd18dabd1, 0x517dbcce, 0x0b1c83ae, + 0x8bec94b1, 0x01440cad, 0x81b41bb2, 0xdbd524d2, 0x5b2533cd, + 0x6f175a12, 0xefe74d0d, 0xb586726d, 0x35766572, 0xdde2a1d3, + 0x5d12b6cc, 0x077389ac, 0x87839eb3, 0xb3b1f76c, 0x3341e073, + 0x6920df13, 0xe9d0c80c, 0xf4809ddf, 0x74708ac0, 0x2e11b5a0, + 0xaee1a2bf, 0x9ad3cb60, 0x1a23dc7f, 0x4042e31f, 0xc0b2f400, + 0x282630a1, 0xa8d627be, 0xf2b718de, 0x72470fc1, 0x4675661e, + 0xc6857101, 0x9ce44e61, 0x1c14597e, 0x96bcc162, 0x164cd67d, + 0x4c2de91d, 0xccddfe02, 0xf8ef97dd, 0x781f80c2, 0x227ebfa2, + 0xa28ea8bd, 0x4a1a6c1c, 0xcaea7b03, 0x908b4463, 0x107b537c, + 0x24493aa3, 0xa4b92dbc, 0xfed812dc, 0x7e2805c3, 0x30f824a5, + 0xb00833ba, 0xea690cda, 0x6a991bc5, 0x5eab721a, 0xde5b6505, + 0x843a5a65, 0x04ca4d7a, 0xec5e89db, 0x6cae9ec4, 0x36cfa1a4, + 0xb63fb6bb, 0x820ddf64, 0x02fdc87b, 0x589cf71b, 0xd86ce004, + 0x52c47818, 0xd2346f07, 0x88555067, 0x08a54778, 0x3c972ea7, + 0xbc6739b8, 0xe60606d8, 0x66f611c7, 0x8e62d566, 0x0e92c279, + 0x54f3fd19, 0xd403ea06, 0xe03183d9, 0x60c194c6, 0x3aa0aba6, + 0xba50bcb9}, + {0x00000000, 0x9570d495, 0xf190af6b, 0x64e07bfe, 0x38505897, + 0xad208c02, 0xc9c0f7fc, 0x5cb02369, 0x70a0b12e, 0xe5d065bb, + 0x81301e45, 0x1440cad0, 0x48f0e9b9, 0xdd803d2c, 0xb96046d2, + 0x2c109247, 0xe141625c, 0x7431b6c9, 0x10d1cd37, 0x85a119a2, + 0xd9113acb, 0x4c61ee5e, 0x288195a0, 0xbdf14135, 0x91e1d372, + 0x049107e7, 0x60717c19, 0xf501a88c, 0xa9b18be5, 0x3cc15f70, + 0x5821248e, 0xcd51f01b, 0x19f3c2f9, 0x8c83166c, 0xe8636d92, + 0x7d13b907, 0x21a39a6e, 0xb4d34efb, 0xd0333505, 0x4543e190, + 0x695373d7, 0xfc23a742, 0x98c3dcbc, 0x0db30829, 0x51032b40, + 0xc473ffd5, 0xa093842b, 0x35e350be, 0xf8b2a0a5, 0x6dc27430, + 0x09220fce, 0x9c52db5b, 0xc0e2f832, 0x55922ca7, 0x31725759, + 0xa40283cc, 0x8812118b, 0x1d62c51e, 0x7982bee0, 0xecf26a75, + 0xb042491c, 0x25329d89, 0x41d2e677, 0xd4a232e2, 0x33e785f2, + 0xa6975167, 0xc2772a99, 0x5707fe0c, 0x0bb7dd65, 0x9ec709f0, + 0xfa27720e, 0x6f57a69b, 0x434734dc, 0xd637e049, 0xb2d79bb7, + 0x27a74f22, 0x7b176c4b, 0xee67b8de, 0x8a87c320, 0x1ff717b5, + 0xd2a6e7ae, 0x47d6333b, 0x233648c5, 0xb6469c50, 0xeaf6bf39, + 0x7f866bac, 0x1b661052, 0x8e16c4c7, 0xa2065680, 0x37768215, + 0x5396f9eb, 0xc6e62d7e, 0x9a560e17, 0x0f26da82, 0x6bc6a17c, + 0xfeb675e9, 0x2a14470b, 0xbf64939e, 0xdb84e860, 0x4ef43cf5, + 0x12441f9c, 0x8734cb09, 0xe3d4b0f7, 0x76a46462, 0x5ab4f625, + 0xcfc422b0, 0xab24594e, 0x3e548ddb, 0x62e4aeb2, 0xf7947a27, + 0x937401d9, 0x0604d54c, 0xcb552557, 0x5e25f1c2, 0x3ac58a3c, + 0xafb55ea9, 0xf3057dc0, 0x6675a955, 0x0295d2ab, 0x97e5063e, + 0xbbf59479, 0x2e8540ec, 0x4a653b12, 0xdf15ef87, 0x83a5ccee, + 0x16d5187b, 0x72356385, 0xe745b710, 0x67cf0be4, 0xf2bfdf71, + 0x965fa48f, 0x032f701a, 0x5f9f5373, 0xcaef87e6, 0xae0ffc18, + 0x3b7f288d, 0x176fbaca, 0x821f6e5f, 0xe6ff15a1, 0x738fc134, + 0x2f3fe25d, 0xba4f36c8, 0xdeaf4d36, 0x4bdf99a3, 0x868e69b8, + 0x13febd2d, 0x771ec6d3, 0xe26e1246, 0xbede312f, 0x2baee5ba, + 0x4f4e9e44, 0xda3e4ad1, 0xf62ed896, 0x635e0c03, 0x07be77fd, + 0x92cea368, 0xce7e8001, 0x5b0e5494, 0x3fee2f6a, 0xaa9efbff, + 0x7e3cc91d, 0xeb4c1d88, 0x8fac6676, 0x1adcb2e3, 0x466c918a, + 0xd31c451f, 0xb7fc3ee1, 0x228cea74, 0x0e9c7833, 0x9becaca6, + 0xff0cd758, 0x6a7c03cd, 0x36cc20a4, 0xa3bcf431, 0xc75c8fcf, + 0x522c5b5a, 0x9f7dab41, 0x0a0d7fd4, 0x6eed042a, 0xfb9dd0bf, + 0xa72df3d6, 0x325d2743, 0x56bd5cbd, 0xc3cd8828, 0xefdd1a6f, + 0x7aadcefa, 0x1e4db504, 0x8b3d6191, 0xd78d42f8, 0x42fd966d, + 0x261ded93, 0xb36d3906, 0x54288e16, 0xc1585a83, 0xa5b8217d, + 0x30c8f5e8, 0x6c78d681, 0xf9080214, 0x9de879ea, 0x0898ad7f, + 0x24883f38, 0xb1f8ebad, 0xd5189053, 0x406844c6, 0x1cd867af, + 0x89a8b33a, 0xed48c8c4, 0x78381c51, 0xb569ec4a, 0x201938df, + 0x44f94321, 0xd18997b4, 0x8d39b4dd, 0x18496048, 0x7ca91bb6, + 0xe9d9cf23, 0xc5c95d64, 0x50b989f1, 0x3459f20f, 0xa129269a, + 0xfd9905f3, 0x68e9d166, 0x0c09aa98, 0x99797e0d, 0x4ddb4cef, + 0xd8ab987a, 0xbc4be384, 0x293b3711, 0x758b1478, 0xe0fbc0ed, + 0x841bbb13, 0x116b6f86, 0x3d7bfdc1, 0xa80b2954, 0xcceb52aa, + 0x599b863f, 0x052ba556, 0x905b71c3, 0xf4bb0a3d, 0x61cbdea8, + 0xac9a2eb3, 0x39eafa26, 0x5d0a81d8, 0xc87a554d, 0x94ca7624, + 0x01baa2b1, 0x655ad94f, 0xf02a0dda, 0xdc3a9f9d, 0x494a4b08, + 0x2daa30f6, 0xb8dae463, 0xe46ac70a, 0x711a139f, 0x15fa6861, + 0x808abcf4}, + {0x00000000, 0xcf9e17c8, 0x444d29d1, 0x8bd33e19, 0x889a53a2, + 0x4704446a, 0xccd77a73, 0x03496dbb, 0xca45a105, 0x05dbb6cd, + 0x8e0888d4, 0x41969f1c, 0x42dff2a7, 0x8d41e56f, 0x0692db76, + 0xc90cccbe, 0x4ffa444b, 0x80645383, 0x0bb76d9a, 0xc4297a52, + 0xc76017e9, 0x08fe0021, 0x832d3e38, 0x4cb329f0, 0x85bfe54e, + 0x4a21f286, 0xc1f2cc9f, 0x0e6cdb57, 0x0d25b6ec, 0xc2bba124, + 0x49689f3d, 0x86f688f5, 0x9ff48896, 0x506a9f5e, 0xdbb9a147, + 0x1427b68f, 0x176edb34, 0xd8f0ccfc, 0x5323f2e5, 0x9cbde52d, + 0x55b12993, 0x9a2f3e5b, 0x11fc0042, 0xde62178a, 0xdd2b7a31, + 0x12b56df9, 0x996653e0, 0x56f84428, 0xd00eccdd, 0x1f90db15, + 0x9443e50c, 0x5bddf2c4, 0x58949f7f, 0x970a88b7, 0x1cd9b6ae, + 0xd347a166, 0x1a4b6dd8, 0xd5d57a10, 0x5e064409, 0x919853c1, + 0x92d13e7a, 0x5d4f29b2, 0xd69c17ab, 0x19020063, 0xe498176d, + 0x2b0600a5, 0xa0d53ebc, 0x6f4b2974, 0x6c0244cf, 0xa39c5307, + 0x284f6d1e, 0xe7d17ad6, 0x2eddb668, 0xe143a1a0, 0x6a909fb9, + 0xa50e8871, 0xa647e5ca, 0x69d9f202, 0xe20acc1b, 0x2d94dbd3, + 0xab625326, 0x64fc44ee, 0xef2f7af7, 0x20b16d3f, 0x23f80084, + 0xec66174c, 0x67b52955, 0xa82b3e9d, 0x6127f223, 0xaeb9e5eb, + 0x256adbf2, 0xeaf4cc3a, 0xe9bda181, 0x2623b649, 0xadf08850, + 0x626e9f98, 0x7b6c9ffb, 0xb4f28833, 0x3f21b62a, 0xf0bfa1e2, + 0xf3f6cc59, 0x3c68db91, 0xb7bbe588, 0x7825f240, 0xb1293efe, + 0x7eb72936, 0xf564172f, 0x3afa00e7, 0x39b36d5c, 0xf62d7a94, + 0x7dfe448d, 0xb2605345, 0x3496dbb0, 0xfb08cc78, 0x70dbf261, + 0xbf45e5a9, 0xbc0c8812, 0x73929fda, 0xf841a1c3, 0x37dfb60b, + 0xfed37ab5, 0x314d6d7d, 0xba9e5364, 0x750044ac, 0x76492917, + 0xb9d73edf, 0x320400c6, 0xfd9a170e, 0x1241289b, 0xdddf3f53, + 0x560c014a, 0x99921682, 0x9adb7b39, 0x55456cf1, 0xde9652e8, + 0x11084520, 0xd804899e, 0x179a9e56, 0x9c49a04f, 0x53d7b787, + 0x509eda3c, 0x9f00cdf4, 0x14d3f3ed, 0xdb4de425, 0x5dbb6cd0, + 0x92257b18, 0x19f64501, 0xd66852c9, 0xd5213f72, 0x1abf28ba, + 0x916c16a3, 0x5ef2016b, 0x97fecdd5, 0x5860da1d, 0xd3b3e404, + 0x1c2df3cc, 0x1f649e77, 0xd0fa89bf, 0x5b29b7a6, 0x94b7a06e, + 0x8db5a00d, 0x422bb7c5, 0xc9f889dc, 0x06669e14, 0x052ff3af, + 0xcab1e467, 0x4162da7e, 0x8efccdb6, 0x47f00108, 0x886e16c0, + 0x03bd28d9, 0xcc233f11, 0xcf6a52aa, 0x00f44562, 0x8b277b7b, + 0x44b96cb3, 0xc24fe446, 0x0dd1f38e, 0x8602cd97, 0x499cda5f, + 0x4ad5b7e4, 0x854ba02c, 0x0e989e35, 0xc10689fd, 0x080a4543, + 0xc794528b, 0x4c476c92, 0x83d97b5a, 0x809016e1, 0x4f0e0129, + 0xc4dd3f30, 0x0b4328f8, 0xf6d93ff6, 0x3947283e, 0xb2941627, + 0x7d0a01ef, 0x7e436c54, 0xb1dd7b9c, 0x3a0e4585, 0xf590524d, + 0x3c9c9ef3, 0xf302893b, 0x78d1b722, 0xb74fa0ea, 0xb406cd51, + 0x7b98da99, 0xf04be480, 0x3fd5f348, 0xb9237bbd, 0x76bd6c75, + 0xfd6e526c, 0x32f045a4, 0x31b9281f, 0xfe273fd7, 0x75f401ce, + 0xba6a1606, 0x7366dab8, 0xbcf8cd70, 0x372bf369, 0xf8b5e4a1, + 0xfbfc891a, 0x34629ed2, 0xbfb1a0cb, 0x702fb703, 0x692db760, + 0xa6b3a0a8, 0x2d609eb1, 0xe2fe8979, 0xe1b7e4c2, 0x2e29f30a, + 0xa5facd13, 0x6a64dadb, 0xa3681665, 0x6cf601ad, 0xe7253fb4, + 0x28bb287c, 0x2bf245c7, 0xe46c520f, 0x6fbf6c16, 0xa0217bde, + 0x26d7f32b, 0xe949e4e3, 0x629adafa, 0xad04cd32, 0xae4da089, + 0x61d3b741, 0xea008958, 0x259e9e90, 0xec92522e, 0x230c45e6, + 0xa8df7bff, 0x67416c37, 0x6408018c, 0xab961644, 0x2045285d, + 0xefdb3f95}, + {0x00000000, 0x24825136, 0x4904a26c, 0x6d86f35a, 0x920944d8, + 0xb68b15ee, 0xdb0de6b4, 0xff8fb782, 0xff638ff1, 0xdbe1dec7, + 0xb6672d9d, 0x92e57cab, 0x6d6acb29, 0x49e89a1f, 0x246e6945, + 0x00ec3873, 0x25b619a3, 0x01344895, 0x6cb2bbcf, 0x4830eaf9, + 0xb7bf5d7b, 0x933d0c4d, 0xfebbff17, 0xda39ae21, 0xdad59652, + 0xfe57c764, 0x93d1343e, 0xb7536508, 0x48dcd28a, 0x6c5e83bc, + 0x01d870e6, 0x255a21d0, 0x4b6c3346, 0x6fee6270, 0x0268912a, + 0x26eac01c, 0xd965779e, 0xfde726a8, 0x9061d5f2, 0xb4e384c4, + 0xb40fbcb7, 0x908ded81, 0xfd0b1edb, 0xd9894fed, 0x2606f86f, + 0x0284a959, 0x6f025a03, 0x4b800b35, 0x6eda2ae5, 0x4a587bd3, + 0x27de8889, 0x035cd9bf, 0xfcd36e3d, 0xd8513f0b, 0xb5d7cc51, + 0x91559d67, 0x91b9a514, 0xb53bf422, 0xd8bd0778, 0xfc3f564e, + 0x03b0e1cc, 0x2732b0fa, 0x4ab443a0, 0x6e361296, 0x96d8668c, + 0xb25a37ba, 0xdfdcc4e0, 0xfb5e95d6, 0x04d12254, 0x20537362, + 0x4dd58038, 0x6957d10e, 0x69bbe97d, 0x4d39b84b, 0x20bf4b11, + 0x043d1a27, 0xfbb2ada5, 0xdf30fc93, 0xb2b60fc9, 0x96345eff, + 0xb36e7f2f, 0x97ec2e19, 0xfa6add43, 0xdee88c75, 0x21673bf7, + 0x05e56ac1, 0x6863999b, 0x4ce1c8ad, 0x4c0df0de, 0x688fa1e8, + 0x050952b2, 0x218b0384, 0xde04b406, 0xfa86e530, 0x9700166a, + 0xb382475c, 0xddb455ca, 0xf93604fc, 0x94b0f7a6, 0xb032a690, + 0x4fbd1112, 0x6b3f4024, 0x06b9b37e, 0x223be248, 0x22d7da3b, + 0x06558b0d, 0x6bd37857, 0x4f512961, 0xb0de9ee3, 0x945ccfd5, + 0xf9da3c8f, 0xdd586db9, 0xf8024c69, 0xdc801d5f, 0xb106ee05, + 0x9584bf33, 0x6a0b08b1, 0x4e895987, 0x230faadd, 0x078dfbeb, + 0x0761c398, 0x23e392ae, 0x4e6561f4, 0x6ae730c2, 0x95688740, + 0xb1ead676, 0xdc6c252c, 0xf8ee741a, 0xf6c1cb59, 0xd2439a6f, + 0xbfc56935, 0x9b473803, 0x64c88f81, 0x404adeb7, 0x2dcc2ded, + 0x094e7cdb, 0x09a244a8, 0x2d20159e, 0x40a6e6c4, 0x6424b7f2, + 0x9bab0070, 0xbf295146, 0xd2afa21c, 0xf62df32a, 0xd377d2fa, + 0xf7f583cc, 0x9a737096, 0xbef121a0, 0x417e9622, 0x65fcc714, + 0x087a344e, 0x2cf86578, 0x2c145d0b, 0x08960c3d, 0x6510ff67, + 0x4192ae51, 0xbe1d19d3, 0x9a9f48e5, 0xf719bbbf, 0xd39bea89, + 0xbdadf81f, 0x992fa929, 0xf4a95a73, 0xd02b0b45, 0x2fa4bcc7, + 0x0b26edf1, 0x66a01eab, 0x42224f9d, 0x42ce77ee, 0x664c26d8, + 0x0bcad582, 0x2f4884b4, 0xd0c73336, 0xf4456200, 0x99c3915a, + 0xbd41c06c, 0x981be1bc, 0xbc99b08a, 0xd11f43d0, 0xf59d12e6, + 0x0a12a564, 0x2e90f452, 0x43160708, 0x6794563e, 0x67786e4d, + 0x43fa3f7b, 0x2e7ccc21, 0x0afe9d17, 0xf5712a95, 0xd1f37ba3, + 0xbc7588f9, 0x98f7d9cf, 0x6019add5, 0x449bfce3, 0x291d0fb9, + 0x0d9f5e8f, 0xf210e90d, 0xd692b83b, 0xbb144b61, 0x9f961a57, + 0x9f7a2224, 0xbbf87312, 0xd67e8048, 0xf2fcd17e, 0x0d7366fc, + 0x29f137ca, 0x4477c490, 0x60f595a6, 0x45afb476, 0x612de540, + 0x0cab161a, 0x2829472c, 0xd7a6f0ae, 0xf324a198, 0x9ea252c2, + 0xba2003f4, 0xbacc3b87, 0x9e4e6ab1, 0xf3c899eb, 0xd74ac8dd, + 0x28c57f5f, 0x0c472e69, 0x61c1dd33, 0x45438c05, 0x2b759e93, + 0x0ff7cfa5, 0x62713cff, 0x46f36dc9, 0xb97cda4b, 0x9dfe8b7d, + 0xf0787827, 0xd4fa2911, 0xd4161162, 0xf0944054, 0x9d12b30e, + 0xb990e238, 0x461f55ba, 0x629d048c, 0x0f1bf7d6, 0x2b99a6e0, + 0x0ec38730, 0x2a41d606, 0x47c7255c, 0x6345746a, 0x9ccac3e8, + 0xb84892de, 0xd5ce6184, 0xf14c30b2, 0xf1a008c1, 0xd52259f7, + 0xb8a4aaad, 0x9c26fb9b, 0x63a94c19, 0x472b1d2f, 0x2aadee75, + 0x0e2fbf43}, + {0x00000000, 0x36f290f3, 0x6de521e6, 0x5b17b115, 0xdbca43cc, + 0xed38d33f, 0xb62f622a, 0x80ddf2d9, 0x6ce581d9, 0x5a17112a, + 0x0100a03f, 0x37f230cc, 0xb72fc215, 0x81dd52e6, 0xdacae3f3, + 0xec387300, 0xd9cb03b2, 0xef399341, 0xb42e2254, 0x82dcb2a7, + 0x0201407e, 0x34f3d08d, 0x6fe46198, 0x5916f16b, 0xb52e826b, + 0x83dc1298, 0xd8cba38d, 0xee39337e, 0x6ee4c1a7, 0x58165154, + 0x0301e041, 0x35f370b2, 0x68e70125, 0x5e1591d6, 0x050220c3, + 0x33f0b030, 0xb32d42e9, 0x85dfd21a, 0xdec8630f, 0xe83af3fc, + 0x040280fc, 0x32f0100f, 0x69e7a11a, 0x5f1531e9, 0xdfc8c330, + 0xe93a53c3, 0xb22de2d6, 0x84df7225, 0xb12c0297, 0x87de9264, + 0xdcc92371, 0xea3bb382, 0x6ae6415b, 0x5c14d1a8, 0x070360bd, + 0x31f1f04e, 0xddc9834e, 0xeb3b13bd, 0xb02ca2a8, 0x86de325b, + 0x0603c082, 0x30f15071, 0x6be6e164, 0x5d147197, 0xd1ce024a, + 0xe73c92b9, 0xbc2b23ac, 0x8ad9b35f, 0x0a044186, 0x3cf6d175, + 0x67e16060, 0x5113f093, 0xbd2b8393, 0x8bd91360, 0xd0cea275, + 0xe63c3286, 0x66e1c05f, 0x501350ac, 0x0b04e1b9, 0x3df6714a, + 0x080501f8, 0x3ef7910b, 0x65e0201e, 0x5312b0ed, 0xd3cf4234, + 0xe53dd2c7, 0xbe2a63d2, 0x88d8f321, 0x64e08021, 0x521210d2, + 0x0905a1c7, 0x3ff73134, 0xbf2ac3ed, 0x89d8531e, 0xd2cfe20b, + 0xe43d72f8, 0xb929036f, 0x8fdb939c, 0xd4cc2289, 0xe23eb27a, + 0x62e340a3, 0x5411d050, 0x0f066145, 0x39f4f1b6, 0xd5cc82b6, + 0xe33e1245, 0xb829a350, 0x8edb33a3, 0x0e06c17a, 0x38f45189, + 0x63e3e09c, 0x5511706f, 0x60e200dd, 0x5610902e, 0x0d07213b, + 0x3bf5b1c8, 0xbb284311, 0x8ddad3e2, 0xd6cd62f7, 0xe03ff204, + 0x0c078104, 0x3af511f7, 0x61e2a0e2, 0x57103011, 0xd7cdc2c8, + 0xe13f523b, 0xba28e32e, 0x8cda73dd, 0x78ed02d5, 0x4e1f9226, + 0x15082333, 0x23fab3c0, 0xa3274119, 0x95d5d1ea, 0xcec260ff, + 0xf830f00c, 0x1408830c, 0x22fa13ff, 0x79eda2ea, 0x4f1f3219, + 0xcfc2c0c0, 0xf9305033, 0xa227e126, 0x94d571d5, 0xa1260167, + 0x97d49194, 0xccc32081, 0xfa31b072, 0x7aec42ab, 0x4c1ed258, + 0x1709634d, 0x21fbf3be, 0xcdc380be, 0xfb31104d, 0xa026a158, + 0x96d431ab, 0x1609c372, 0x20fb5381, 0x7bece294, 0x4d1e7267, + 0x100a03f0, 0x26f89303, 0x7def2216, 0x4b1db2e5, 0xcbc0403c, + 0xfd32d0cf, 0xa62561da, 0x90d7f129, 0x7cef8229, 0x4a1d12da, + 0x110aa3cf, 0x27f8333c, 0xa725c1e5, 0x91d75116, 0xcac0e003, + 0xfc3270f0, 0xc9c10042, 0xff3390b1, 0xa42421a4, 0x92d6b157, + 0x120b438e, 0x24f9d37d, 0x7fee6268, 0x491cf29b, 0xa524819b, + 0x93d61168, 0xc8c1a07d, 0xfe33308e, 0x7eeec257, 0x481c52a4, + 0x130be3b1, 0x25f97342, 0xa923009f, 0x9fd1906c, 0xc4c62179, + 0xf234b18a, 0x72e94353, 0x441bd3a0, 0x1f0c62b5, 0x29fef246, + 0xc5c68146, 0xf33411b5, 0xa823a0a0, 0x9ed13053, 0x1e0cc28a, + 0x28fe5279, 0x73e9e36c, 0x451b739f, 0x70e8032d, 0x461a93de, + 0x1d0d22cb, 0x2bffb238, 0xab2240e1, 0x9dd0d012, 0xc6c76107, + 0xf035f1f4, 0x1c0d82f4, 0x2aff1207, 0x71e8a312, 0x471a33e1, + 0xc7c7c138, 0xf13551cb, 0xaa22e0de, 0x9cd0702d, 0xc1c401ba, + 0xf7369149, 0xac21205c, 0x9ad3b0af, 0x1a0e4276, 0x2cfcd285, + 0x77eb6390, 0x4119f363, 0xad218063, 0x9bd31090, 0xc0c4a185, + 0xf6363176, 0x76ebc3af, 0x4019535c, 0x1b0ee249, 0x2dfc72ba, + 0x180f0208, 0x2efd92fb, 0x75ea23ee, 0x4318b31d, 0xc3c541c4, + 0xf537d137, 0xae206022, 0x98d2f0d1, 0x74ea83d1, 0x42181322, + 0x190fa237, 0x2ffd32c4, 0xaf20c01d, 0x99d250ee, 0xc2c5e1fb, + 0xf4377108}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x0000000000000000, 0xf390f23600000000, 0xe621e56d00000000, + 0x15b1175b00000000, 0xcc43cadb00000000, 0x3fd338ed00000000, + 0x2a622fb600000000, 0xd9f2dd8000000000, 0xd981e56c00000000, + 0x2a11175a00000000, 0x3fa0000100000000, 0xcc30f23700000000, + 0x15c22fb700000000, 0xe652dd8100000000, 0xf3e3cada00000000, + 0x007338ec00000000, 0xb203cbd900000000, 0x419339ef00000000, + 0x54222eb400000000, 0xa7b2dc8200000000, 0x7e40010200000000, + 0x8dd0f33400000000, 0x9861e46f00000000, 0x6bf1165900000000, + 0x6b822eb500000000, 0x9812dc8300000000, 0x8da3cbd800000000, + 0x7e3339ee00000000, 0xa7c1e46e00000000, 0x5451165800000000, + 0x41e0010300000000, 0xb270f33500000000, 0x2501e76800000000, + 0xd691155e00000000, 0xc320020500000000, 0x30b0f03300000000, + 0xe9422db300000000, 0x1ad2df8500000000, 0x0f63c8de00000000, + 0xfcf33ae800000000, 0xfc80020400000000, 0x0f10f03200000000, + 0x1aa1e76900000000, 0xe931155f00000000, 0x30c3c8df00000000, + 0xc3533ae900000000, 0xd6e22db200000000, 0x2572df8400000000, + 0x97022cb100000000, 0x6492de8700000000, 0x7123c9dc00000000, + 0x82b33bea00000000, 0x5b41e66a00000000, 0xa8d1145c00000000, + 0xbd60030700000000, 0x4ef0f13100000000, 0x4e83c9dd00000000, + 0xbd133beb00000000, 0xa8a22cb000000000, 0x5b32de8600000000, + 0x82c0030600000000, 0x7150f13000000000, 0x64e1e66b00000000, + 0x9771145d00000000, 0x4a02ced100000000, 0xb9923ce700000000, + 0xac232bbc00000000, 0x5fb3d98a00000000, 0x8641040a00000000, + 0x75d1f63c00000000, 0x6060e16700000000, 0x93f0135100000000, + 0x93832bbd00000000, 0x6013d98b00000000, 0x75a2ced000000000, + 0x86323ce600000000, 0x5fc0e16600000000, 0xac50135000000000, + 0xb9e1040b00000000, 0x4a71f63d00000000, 0xf801050800000000, + 0x0b91f73e00000000, 0x1e20e06500000000, 0xedb0125300000000, + 0x3442cfd300000000, 0xc7d23de500000000, 0xd2632abe00000000, + 0x21f3d88800000000, 0x2180e06400000000, 0xd210125200000000, + 0xc7a1050900000000, 0x3431f73f00000000, 0xedc32abf00000000, + 0x1e53d88900000000, 0x0be2cfd200000000, 0xf8723de400000000, + 0x6f0329b900000000, 0x9c93db8f00000000, 0x8922ccd400000000, + 0x7ab23ee200000000, 0xa340e36200000000, 0x50d0115400000000, + 0x4561060f00000000, 0xb6f1f43900000000, 0xb682ccd500000000, + 0x45123ee300000000, 0x50a329b800000000, 0xa333db8e00000000, + 0x7ac1060e00000000, 0x8951f43800000000, 0x9ce0e36300000000, + 0x6f70115500000000, 0xdd00e26000000000, 0x2e90105600000000, + 0x3b21070d00000000, 0xc8b1f53b00000000, 0x114328bb00000000, + 0xe2d3da8d00000000, 0xf762cdd600000000, 0x04f23fe000000000, + 0x0481070c00000000, 0xf711f53a00000000, 0xe2a0e26100000000, + 0x1130105700000000, 0xc8c2cdd700000000, 0x3b523fe100000000, + 0x2ee328ba00000000, 0xdd73da8c00000000, 0xd502ed7800000000, + 0x26921f4e00000000, 0x3323081500000000, 0xc0b3fa2300000000, + 0x194127a300000000, 0xead1d59500000000, 0xff60c2ce00000000, + 0x0cf030f800000000, 0x0c83081400000000, 0xff13fa2200000000, + 0xeaa2ed7900000000, 0x19321f4f00000000, 0xc0c0c2cf00000000, + 0x335030f900000000, 0x26e127a200000000, 0xd571d59400000000, + 0x670126a100000000, 0x9491d49700000000, 0x8120c3cc00000000, + 0x72b031fa00000000, 0xab42ec7a00000000, 0x58d21e4c00000000, + 0x4d63091700000000, 0xbef3fb2100000000, 0xbe80c3cd00000000, + 0x4d1031fb00000000, 0x58a126a000000000, 0xab31d49600000000, + 0x72c3091600000000, 0x8153fb2000000000, 0x94e2ec7b00000000, + 0x67721e4d00000000, 0xf0030a1000000000, 0x0393f82600000000, + 0x1622ef7d00000000, 0xe5b21d4b00000000, 0x3c40c0cb00000000, + 0xcfd032fd00000000, 0xda6125a600000000, 0x29f1d79000000000, + 0x2982ef7c00000000, 0xda121d4a00000000, 0xcfa30a1100000000, + 0x3c33f82700000000, 0xe5c125a700000000, 0x1651d79100000000, + 0x03e0c0ca00000000, 0xf07032fc00000000, 0x4200c1c900000000, + 0xb19033ff00000000, 0xa42124a400000000, 0x57b1d69200000000, + 0x8e430b1200000000, 0x7dd3f92400000000, 0x6862ee7f00000000, + 0x9bf21c4900000000, 0x9b8124a500000000, 0x6811d69300000000, + 0x7da0c1c800000000, 0x8e3033fe00000000, 0x57c2ee7e00000000, + 0xa4521c4800000000, 0xb1e30b1300000000, 0x4273f92500000000, + 0x9f0023a900000000, 0x6c90d19f00000000, 0x7921c6c400000000, + 0x8ab134f200000000, 0x5343e97200000000, 0xa0d31b4400000000, + 0xb5620c1f00000000, 0x46f2fe2900000000, 0x4681c6c500000000, + 0xb51134f300000000, 0xa0a023a800000000, 0x5330d19e00000000, + 0x8ac20c1e00000000, 0x7952fe2800000000, 0x6ce3e97300000000, + 0x9f731b4500000000, 0x2d03e87000000000, 0xde931a4600000000, + 0xcb220d1d00000000, 0x38b2ff2b00000000, 0xe14022ab00000000, + 0x12d0d09d00000000, 0x0761c7c600000000, 0xf4f135f000000000, + 0xf4820d1c00000000, 0x0712ff2a00000000, 0x12a3e87100000000, + 0xe1331a4700000000, 0x38c1c7c700000000, 0xcb5135f100000000, + 0xdee022aa00000000, 0x2d70d09c00000000, 0xba01c4c100000000, + 0x499136f700000000, 0x5c2021ac00000000, 0xafb0d39a00000000, + 0x76420e1a00000000, 0x85d2fc2c00000000, 0x9063eb7700000000, + 0x63f3194100000000, 0x638021ad00000000, 0x9010d39b00000000, + 0x85a1c4c000000000, 0x763136f600000000, 0xafc3eb7600000000, + 0x5c53194000000000, 0x49e20e1b00000000, 0xba72fc2d00000000, + 0x08020f1800000000, 0xfb92fd2e00000000, 0xee23ea7500000000, + 0x1db3184300000000, 0xc441c5c300000000, 0x37d137f500000000, + 0x226020ae00000000, 0xd1f0d29800000000, 0xd183ea7400000000, + 0x2213184200000000, 0x37a20f1900000000, 0xc432fd2f00000000, + 0x1dc020af00000000, 0xee50d29900000000, 0xfbe1c5c200000000, + 0x087137f400000000}, + {0x0000000000000000, 0x3651822400000000, 0x6ca2044900000000, + 0x5af3866d00000000, 0xd844099200000000, 0xee158bb600000000, + 0xb4e60ddb00000000, 0x82b78fff00000000, 0xf18f63ff00000000, + 0xc7dee1db00000000, 0x9d2d67b600000000, 0xab7ce59200000000, + 0x29cb6a6d00000000, 0x1f9ae84900000000, 0x45696e2400000000, + 0x7338ec0000000000, 0xa319b62500000000, 0x9548340100000000, + 0xcfbbb26c00000000, 0xf9ea304800000000, 0x7b5dbfb700000000, + 0x4d0c3d9300000000, 0x17ffbbfe00000000, 0x21ae39da00000000, + 0x5296d5da00000000, 0x64c757fe00000000, 0x3e34d19300000000, + 0x086553b700000000, 0x8ad2dc4800000000, 0xbc835e6c00000000, + 0xe670d80100000000, 0xd0215a2500000000, 0x46336c4b00000000, + 0x7062ee6f00000000, 0x2a91680200000000, 0x1cc0ea2600000000, + 0x9e7765d900000000, 0xa826e7fd00000000, 0xf2d5619000000000, + 0xc484e3b400000000, 0xb7bc0fb400000000, 0x81ed8d9000000000, + 0xdb1e0bfd00000000, 0xed4f89d900000000, 0x6ff8062600000000, + 0x59a9840200000000, 0x035a026f00000000, 0x350b804b00000000, + 0xe52ada6e00000000, 0xd37b584a00000000, 0x8988de2700000000, + 0xbfd95c0300000000, 0x3d6ed3fc00000000, 0x0b3f51d800000000, + 0x51ccd7b500000000, 0x679d559100000000, 0x14a5b99100000000, + 0x22f43bb500000000, 0x7807bdd800000000, 0x4e563ffc00000000, + 0xcce1b00300000000, 0xfab0322700000000, 0xa043b44a00000000, + 0x9612366e00000000, 0x8c66d89600000000, 0xba375ab200000000, + 0xe0c4dcdf00000000, 0xd6955efb00000000, 0x5422d10400000000, + 0x6273532000000000, 0x3880d54d00000000, 0x0ed1576900000000, + 0x7de9bb6900000000, 0x4bb8394d00000000, 0x114bbf2000000000, + 0x271a3d0400000000, 0xa5adb2fb00000000, 0x93fc30df00000000, + 0xc90fb6b200000000, 0xff5e349600000000, 0x2f7f6eb300000000, + 0x192eec9700000000, 0x43dd6afa00000000, 0x758ce8de00000000, + 0xf73b672100000000, 0xc16ae50500000000, 0x9b99636800000000, + 0xadc8e14c00000000, 0xdef00d4c00000000, 0xe8a18f6800000000, + 0xb252090500000000, 0x84038b2100000000, 0x06b404de00000000, + 0x30e586fa00000000, 0x6a16009700000000, 0x5c4782b300000000, + 0xca55b4dd00000000, 0xfc0436f900000000, 0xa6f7b09400000000, + 0x90a632b000000000, 0x1211bd4f00000000, 0x24403f6b00000000, + 0x7eb3b90600000000, 0x48e23b2200000000, 0x3bdad72200000000, + 0x0d8b550600000000, 0x5778d36b00000000, 0x6129514f00000000, + 0xe39edeb000000000, 0xd5cf5c9400000000, 0x8f3cdaf900000000, + 0xb96d58dd00000000, 0x694c02f800000000, 0x5f1d80dc00000000, + 0x05ee06b100000000, 0x33bf849500000000, 0xb1080b6a00000000, + 0x8759894e00000000, 0xddaa0f2300000000, 0xebfb8d0700000000, + 0x98c3610700000000, 0xae92e32300000000, 0xf461654e00000000, + 0xc230e76a00000000, 0x4087689500000000, 0x76d6eab100000000, + 0x2c256cdc00000000, 0x1a74eef800000000, 0x59cbc1f600000000, + 0x6f9a43d200000000, 0x3569c5bf00000000, 0x0338479b00000000, + 0x818fc86400000000, 0xb7de4a4000000000, 0xed2dcc2d00000000, + 0xdb7c4e0900000000, 0xa844a20900000000, 0x9e15202d00000000, + 0xc4e6a64000000000, 0xf2b7246400000000, 0x7000ab9b00000000, + 0x465129bf00000000, 0x1ca2afd200000000, 0x2af32df600000000, + 0xfad277d300000000, 0xcc83f5f700000000, 0x9670739a00000000, + 0xa021f1be00000000, 0x22967e4100000000, 0x14c7fc6500000000, + 0x4e347a0800000000, 0x7865f82c00000000, 0x0b5d142c00000000, + 0x3d0c960800000000, 0x67ff106500000000, 0x51ae924100000000, + 0xd3191dbe00000000, 0xe5489f9a00000000, 0xbfbb19f700000000, + 0x89ea9bd300000000, 0x1ff8adbd00000000, 0x29a92f9900000000, + 0x735aa9f400000000, 0x450b2bd000000000, 0xc7bca42f00000000, + 0xf1ed260b00000000, 0xab1ea06600000000, 0x9d4f224200000000, + 0xee77ce4200000000, 0xd8264c6600000000, 0x82d5ca0b00000000, + 0xb484482f00000000, 0x3633c7d000000000, 0x006245f400000000, + 0x5a91c39900000000, 0x6cc041bd00000000, 0xbce11b9800000000, + 0x8ab099bc00000000, 0xd0431fd100000000, 0xe6129df500000000, + 0x64a5120a00000000, 0x52f4902e00000000, 0x0807164300000000, + 0x3e56946700000000, 0x4d6e786700000000, 0x7b3ffa4300000000, + 0x21cc7c2e00000000, 0x179dfe0a00000000, 0x952a71f500000000, + 0xa37bf3d100000000, 0xf98875bc00000000, 0xcfd9f79800000000, + 0xd5ad196000000000, 0xe3fc9b4400000000, 0xb90f1d2900000000, + 0x8f5e9f0d00000000, 0x0de910f200000000, 0x3bb892d600000000, + 0x614b14bb00000000, 0x571a969f00000000, 0x24227a9f00000000, + 0x1273f8bb00000000, 0x48807ed600000000, 0x7ed1fcf200000000, + 0xfc66730d00000000, 0xca37f12900000000, 0x90c4774400000000, + 0xa695f56000000000, 0x76b4af4500000000, 0x40e52d6100000000, + 0x1a16ab0c00000000, 0x2c47292800000000, 0xaef0a6d700000000, + 0x98a124f300000000, 0xc252a29e00000000, 0xf40320ba00000000, + 0x873bccba00000000, 0xb16a4e9e00000000, 0xeb99c8f300000000, + 0xddc84ad700000000, 0x5f7fc52800000000, 0x692e470c00000000, + 0x33ddc16100000000, 0x058c434500000000, 0x939e752b00000000, + 0xa5cff70f00000000, 0xff3c716200000000, 0xc96df34600000000, + 0x4bda7cb900000000, 0x7d8bfe9d00000000, 0x277878f000000000, + 0x1129fad400000000, 0x621116d400000000, 0x544094f000000000, + 0x0eb3129d00000000, 0x38e290b900000000, 0xba551f4600000000, + 0x8c049d6200000000, 0xd6f71b0f00000000, 0xe0a6992b00000000, + 0x3087c30e00000000, 0x06d6412a00000000, 0x5c25c74700000000, + 0x6a74456300000000, 0xe8c3ca9c00000000, 0xde9248b800000000, + 0x8461ced500000000, 0xb2304cf100000000, 0xc108a0f100000000, + 0xf75922d500000000, 0xadaaa4b800000000, 0x9bfb269c00000000, + 0x194ca96300000000, 0x2f1d2b4700000000, 0x75eead2a00000000, + 0x43bf2f0e00000000}, + {0x0000000000000000, 0xc8179ecf00000000, 0xd1294d4400000000, + 0x193ed38b00000000, 0xa2539a8800000000, 0x6a44044700000000, + 0x737ad7cc00000000, 0xbb6d490300000000, 0x05a145ca00000000, + 0xcdb6db0500000000, 0xd488088e00000000, 0x1c9f964100000000, + 0xa7f2df4200000000, 0x6fe5418d00000000, 0x76db920600000000, + 0xbecc0cc900000000, 0x4b44fa4f00000000, 0x8353648000000000, + 0x9a6db70b00000000, 0x527a29c400000000, 0xe91760c700000000, + 0x2100fe0800000000, 0x383e2d8300000000, 0xf029b34c00000000, + 0x4ee5bf8500000000, 0x86f2214a00000000, 0x9fccf2c100000000, + 0x57db6c0e00000000, 0xecb6250d00000000, 0x24a1bbc200000000, + 0x3d9f684900000000, 0xf588f68600000000, 0x9688f49f00000000, + 0x5e9f6a5000000000, 0x47a1b9db00000000, 0x8fb6271400000000, + 0x34db6e1700000000, 0xfcccf0d800000000, 0xe5f2235300000000, + 0x2de5bd9c00000000, 0x9329b15500000000, 0x5b3e2f9a00000000, + 0x4200fc1100000000, 0x8a1762de00000000, 0x317a2bdd00000000, + 0xf96db51200000000, 0xe053669900000000, 0x2844f85600000000, + 0xddcc0ed000000000, 0x15db901f00000000, 0x0ce5439400000000, + 0xc4f2dd5b00000000, 0x7f9f945800000000, 0xb7880a9700000000, + 0xaeb6d91c00000000, 0x66a147d300000000, 0xd86d4b1a00000000, + 0x107ad5d500000000, 0x0944065e00000000, 0xc153989100000000, + 0x7a3ed19200000000, 0xb2294f5d00000000, 0xab179cd600000000, + 0x6300021900000000, 0x6d1798e400000000, 0xa500062b00000000, + 0xbc3ed5a000000000, 0x74294b6f00000000, 0xcf44026c00000000, + 0x07539ca300000000, 0x1e6d4f2800000000, 0xd67ad1e700000000, + 0x68b6dd2e00000000, 0xa0a143e100000000, 0xb99f906a00000000, + 0x71880ea500000000, 0xcae547a600000000, 0x02f2d96900000000, + 0x1bcc0ae200000000, 0xd3db942d00000000, 0x265362ab00000000, + 0xee44fc6400000000, 0xf77a2fef00000000, 0x3f6db12000000000, + 0x8400f82300000000, 0x4c1766ec00000000, 0x5529b56700000000, + 0x9d3e2ba800000000, 0x23f2276100000000, 0xebe5b9ae00000000, + 0xf2db6a2500000000, 0x3accf4ea00000000, 0x81a1bde900000000, + 0x49b6232600000000, 0x5088f0ad00000000, 0x989f6e6200000000, + 0xfb9f6c7b00000000, 0x3388f2b400000000, 0x2ab6213f00000000, + 0xe2a1bff000000000, 0x59ccf6f300000000, 0x91db683c00000000, + 0x88e5bbb700000000, 0x40f2257800000000, 0xfe3e29b100000000, + 0x3629b77e00000000, 0x2f1764f500000000, 0xe700fa3a00000000, + 0x5c6db33900000000, 0x947a2df600000000, 0x8d44fe7d00000000, + 0x455360b200000000, 0xb0db963400000000, 0x78cc08fb00000000, + 0x61f2db7000000000, 0xa9e545bf00000000, 0x12880cbc00000000, + 0xda9f927300000000, 0xc3a141f800000000, 0x0bb6df3700000000, + 0xb57ad3fe00000000, 0x7d6d4d3100000000, 0x64539eba00000000, + 0xac44007500000000, 0x1729497600000000, 0xdf3ed7b900000000, + 0xc600043200000000, 0x0e179afd00000000, 0x9b28411200000000, + 0x533fdfdd00000000, 0x4a010c5600000000, 0x8216929900000000, + 0x397bdb9a00000000, 0xf16c455500000000, 0xe85296de00000000, + 0x2045081100000000, 0x9e8904d800000000, 0x569e9a1700000000, + 0x4fa0499c00000000, 0x87b7d75300000000, 0x3cda9e5000000000, + 0xf4cd009f00000000, 0xedf3d31400000000, 0x25e44ddb00000000, + 0xd06cbb5d00000000, 0x187b259200000000, 0x0145f61900000000, + 0xc95268d600000000, 0x723f21d500000000, 0xba28bf1a00000000, + 0xa3166c9100000000, 0x6b01f25e00000000, 0xd5cdfe9700000000, + 0x1dda605800000000, 0x04e4b3d300000000, 0xccf32d1c00000000, + 0x779e641f00000000, 0xbf89fad000000000, 0xa6b7295b00000000, + 0x6ea0b79400000000, 0x0da0b58d00000000, 0xc5b72b4200000000, + 0xdc89f8c900000000, 0x149e660600000000, 0xaff32f0500000000, + 0x67e4b1ca00000000, 0x7eda624100000000, 0xb6cdfc8e00000000, + 0x0801f04700000000, 0xc0166e8800000000, 0xd928bd0300000000, + 0x113f23cc00000000, 0xaa526acf00000000, 0x6245f40000000000, + 0x7b7b278b00000000, 0xb36cb94400000000, 0x46e44fc200000000, + 0x8ef3d10d00000000, 0x97cd028600000000, 0x5fda9c4900000000, + 0xe4b7d54a00000000, 0x2ca04b8500000000, 0x359e980e00000000, + 0xfd8906c100000000, 0x43450a0800000000, 0x8b5294c700000000, + 0x926c474c00000000, 0x5a7bd98300000000, 0xe116908000000000, + 0x29010e4f00000000, 0x303fddc400000000, 0xf828430b00000000, + 0xf63fd9f600000000, 0x3e28473900000000, 0x271694b200000000, + 0xef010a7d00000000, 0x546c437e00000000, 0x9c7bddb100000000, + 0x85450e3a00000000, 0x4d5290f500000000, 0xf39e9c3c00000000, + 0x3b8902f300000000, 0x22b7d17800000000, 0xeaa04fb700000000, + 0x51cd06b400000000, 0x99da987b00000000, 0x80e44bf000000000, + 0x48f3d53f00000000, 0xbd7b23b900000000, 0x756cbd7600000000, + 0x6c526efd00000000, 0xa445f03200000000, 0x1f28b93100000000, + 0xd73f27fe00000000, 0xce01f47500000000, 0x06166aba00000000, + 0xb8da667300000000, 0x70cdf8bc00000000, 0x69f32b3700000000, + 0xa1e4b5f800000000, 0x1a89fcfb00000000, 0xd29e623400000000, + 0xcba0b1bf00000000, 0x03b72f7000000000, 0x60b72d6900000000, + 0xa8a0b3a600000000, 0xb19e602d00000000, 0x7989fee200000000, + 0xc2e4b7e100000000, 0x0af3292e00000000, 0x13cdfaa500000000, + 0xdbda646a00000000, 0x651668a300000000, 0xad01f66c00000000, + 0xb43f25e700000000, 0x7c28bb2800000000, 0xc745f22b00000000, + 0x0f526ce400000000, 0x166cbf6f00000000, 0xde7b21a000000000, + 0x2bf3d72600000000, 0xe3e449e900000000, 0xfada9a6200000000, + 0x32cd04ad00000000, 0x89a04dae00000000, 0x41b7d36100000000, + 0x588900ea00000000, 0x909e9e2500000000, 0x2e5292ec00000000, + 0xe6450c2300000000, 0xff7bdfa800000000, 0x376c416700000000, + 0x8c01086400000000, 0x441696ab00000000, 0x5d28452000000000, + 0x953fdbef00000000}, + {0x0000000000000000, 0x95d4709500000000, 0x6baf90f100000000, + 0xfe7be06400000000, 0x9758503800000000, 0x028c20ad00000000, + 0xfcf7c0c900000000, 0x6923b05c00000000, 0x2eb1a07000000000, + 0xbb65d0e500000000, 0x451e308100000000, 0xd0ca401400000000, + 0xb9e9f04800000000, 0x2c3d80dd00000000, 0xd24660b900000000, + 0x4792102c00000000, 0x5c6241e100000000, 0xc9b6317400000000, + 0x37cdd11000000000, 0xa219a18500000000, 0xcb3a11d900000000, + 0x5eee614c00000000, 0xa095812800000000, 0x3541f1bd00000000, + 0x72d3e19100000000, 0xe707910400000000, 0x197c716000000000, + 0x8ca801f500000000, 0xe58bb1a900000000, 0x705fc13c00000000, + 0x8e24215800000000, 0x1bf051cd00000000, 0xf9c2f31900000000, + 0x6c16838c00000000, 0x926d63e800000000, 0x07b9137d00000000, + 0x6e9aa32100000000, 0xfb4ed3b400000000, 0x053533d000000000, + 0x90e1434500000000, 0xd773536900000000, 0x42a723fc00000000, + 0xbcdcc39800000000, 0x2908b30d00000000, 0x402b035100000000, + 0xd5ff73c400000000, 0x2b8493a000000000, 0xbe50e33500000000, + 0xa5a0b2f800000000, 0x3074c26d00000000, 0xce0f220900000000, + 0x5bdb529c00000000, 0x32f8e2c000000000, 0xa72c925500000000, + 0x5957723100000000, 0xcc8302a400000000, 0x8b11128800000000, + 0x1ec5621d00000000, 0xe0be827900000000, 0x756af2ec00000000, + 0x1c4942b000000000, 0x899d322500000000, 0x77e6d24100000000, + 0xe232a2d400000000, 0xf285e73300000000, 0x675197a600000000, + 0x992a77c200000000, 0x0cfe075700000000, 0x65ddb70b00000000, + 0xf009c79e00000000, 0x0e7227fa00000000, 0x9ba6576f00000000, + 0xdc34474300000000, 0x49e037d600000000, 0xb79bd7b200000000, + 0x224fa72700000000, 0x4b6c177b00000000, 0xdeb867ee00000000, + 0x20c3878a00000000, 0xb517f71f00000000, 0xaee7a6d200000000, + 0x3b33d64700000000, 0xc548362300000000, 0x509c46b600000000, + 0x39bff6ea00000000, 0xac6b867f00000000, 0x5210661b00000000, + 0xc7c4168e00000000, 0x805606a200000000, 0x1582763700000000, + 0xebf9965300000000, 0x7e2de6c600000000, 0x170e569a00000000, + 0x82da260f00000000, 0x7ca1c66b00000000, 0xe975b6fe00000000, + 0x0b47142a00000000, 0x9e9364bf00000000, 0x60e884db00000000, + 0xf53cf44e00000000, 0x9c1f441200000000, 0x09cb348700000000, + 0xf7b0d4e300000000, 0x6264a47600000000, 0x25f6b45a00000000, + 0xb022c4cf00000000, 0x4e5924ab00000000, 0xdb8d543e00000000, + 0xb2aee46200000000, 0x277a94f700000000, 0xd901749300000000, + 0x4cd5040600000000, 0x572555cb00000000, 0xc2f1255e00000000, + 0x3c8ac53a00000000, 0xa95eb5af00000000, 0xc07d05f300000000, + 0x55a9756600000000, 0xabd2950200000000, 0x3e06e59700000000, + 0x7994f5bb00000000, 0xec40852e00000000, 0x123b654a00000000, + 0x87ef15df00000000, 0xeecca58300000000, 0x7b18d51600000000, + 0x8563357200000000, 0x10b745e700000000, 0xe40bcf6700000000, + 0x71dfbff200000000, 0x8fa45f9600000000, 0x1a702f0300000000, + 0x73539f5f00000000, 0xe687efca00000000, 0x18fc0fae00000000, + 0x8d287f3b00000000, 0xcaba6f1700000000, 0x5f6e1f8200000000, + 0xa115ffe600000000, 0x34c18f7300000000, 0x5de23f2f00000000, + 0xc8364fba00000000, 0x364dafde00000000, 0xa399df4b00000000, + 0xb8698e8600000000, 0x2dbdfe1300000000, 0xd3c61e7700000000, + 0x46126ee200000000, 0x2f31debe00000000, 0xbae5ae2b00000000, + 0x449e4e4f00000000, 0xd14a3eda00000000, 0x96d82ef600000000, + 0x030c5e6300000000, 0xfd77be0700000000, 0x68a3ce9200000000, + 0x01807ece00000000, 0x94540e5b00000000, 0x6a2fee3f00000000, + 0xfffb9eaa00000000, 0x1dc93c7e00000000, 0x881d4ceb00000000, + 0x7666ac8f00000000, 0xe3b2dc1a00000000, 0x8a916c4600000000, + 0x1f451cd300000000, 0xe13efcb700000000, 0x74ea8c2200000000, + 0x33789c0e00000000, 0xa6acec9b00000000, 0x58d70cff00000000, + 0xcd037c6a00000000, 0xa420cc3600000000, 0x31f4bca300000000, + 0xcf8f5cc700000000, 0x5a5b2c5200000000, 0x41ab7d9f00000000, + 0xd47f0d0a00000000, 0x2a04ed6e00000000, 0xbfd09dfb00000000, + 0xd6f32da700000000, 0x43275d3200000000, 0xbd5cbd5600000000, + 0x2888cdc300000000, 0x6f1addef00000000, 0xfacead7a00000000, + 0x04b54d1e00000000, 0x91613d8b00000000, 0xf8428dd700000000, + 0x6d96fd4200000000, 0x93ed1d2600000000, 0x06396db300000000, + 0x168e285400000000, 0x835a58c100000000, 0x7d21b8a500000000, + 0xe8f5c83000000000, 0x81d6786c00000000, 0x140208f900000000, + 0xea79e89d00000000, 0x7fad980800000000, 0x383f882400000000, + 0xadebf8b100000000, 0x539018d500000000, 0xc644684000000000, + 0xaf67d81c00000000, 0x3ab3a88900000000, 0xc4c848ed00000000, + 0x511c387800000000, 0x4aec69b500000000, 0xdf38192000000000, + 0x2143f94400000000, 0xb49789d100000000, 0xddb4398d00000000, + 0x4860491800000000, 0xb61ba97c00000000, 0x23cfd9e900000000, + 0x645dc9c500000000, 0xf189b95000000000, 0x0ff2593400000000, + 0x9a2629a100000000, 0xf30599fd00000000, 0x66d1e96800000000, + 0x98aa090c00000000, 0x0d7e799900000000, 0xef4cdb4d00000000, + 0x7a98abd800000000, 0x84e34bbc00000000, 0x11373b2900000000, + 0x78148b7500000000, 0xedc0fbe000000000, 0x13bb1b8400000000, + 0x866f6b1100000000, 0xc1fd7b3d00000000, 0x54290ba800000000, + 0xaa52ebcc00000000, 0x3f869b5900000000, 0x56a52b0500000000, + 0xc3715b9000000000, 0x3d0abbf400000000, 0xa8decb6100000000, + 0xb32e9aac00000000, 0x26faea3900000000, 0xd8810a5d00000000, + 0x4d557ac800000000, 0x2476ca9400000000, 0xb1a2ba0100000000, + 0x4fd95a6500000000, 0xda0d2af000000000, 0x9d9f3adc00000000, + 0x084b4a4900000000, 0xf630aa2d00000000, 0x63e4dab800000000, + 0x0ac76ae400000000, 0x9f131a7100000000, 0x6168fa1500000000, + 0xf4bc8a8000000000}, + {0x0000000000000000, 0x1f17f08000000000, 0x7f2891da00000000, + 0x603f615a00000000, 0xbf56536e00000000, 0xa041a3ee00000000, + 0xc07ec2b400000000, 0xdf69323400000000, 0x7eada6dc00000000, + 0x61ba565c00000000, 0x0185370600000000, 0x1e92c78600000000, + 0xc1fbf5b200000000, 0xdeec053200000000, 0xbed3646800000000, + 0xa1c494e800000000, 0xbd5c3c6200000000, 0xa24bcce200000000, + 0xc274adb800000000, 0xdd635d3800000000, 0x020a6f0c00000000, + 0x1d1d9f8c00000000, 0x7d22fed600000000, 0x62350e5600000000, + 0xc3f19abe00000000, 0xdce66a3e00000000, 0xbcd90b6400000000, + 0xa3cefbe400000000, 0x7ca7c9d000000000, 0x63b0395000000000, + 0x038f580a00000000, 0x1c98a88a00000000, 0x7ab978c400000000, + 0x65ae884400000000, 0x0591e91e00000000, 0x1a86199e00000000, + 0xc5ef2baa00000000, 0xdaf8db2a00000000, 0xbac7ba7000000000, + 0xa5d04af000000000, 0x0414de1800000000, 0x1b032e9800000000, + 0x7b3c4fc200000000, 0x642bbf4200000000, 0xbb428d7600000000, + 0xa4557df600000000, 0xc46a1cac00000000, 0xdb7dec2c00000000, + 0xc7e544a600000000, 0xd8f2b42600000000, 0xb8cdd57c00000000, + 0xa7da25fc00000000, 0x78b317c800000000, 0x67a4e74800000000, + 0x079b861200000000, 0x188c769200000000, 0xb948e27a00000000, + 0xa65f12fa00000000, 0xc66073a000000000, 0xd977832000000000, + 0x061eb11400000000, 0x1909419400000000, 0x793620ce00000000, + 0x6621d04e00000000, 0xb574805300000000, 0xaa6370d300000000, + 0xca5c118900000000, 0xd54be10900000000, 0x0a22d33d00000000, + 0x153523bd00000000, 0x750a42e700000000, 0x6a1db26700000000, + 0xcbd9268f00000000, 0xd4ced60f00000000, 0xb4f1b75500000000, + 0xabe647d500000000, 0x748f75e100000000, 0x6b98856100000000, + 0x0ba7e43b00000000, 0x14b014bb00000000, 0x0828bc3100000000, + 0x173f4cb100000000, 0x77002deb00000000, 0x6817dd6b00000000, + 0xb77eef5f00000000, 0xa8691fdf00000000, 0xc8567e8500000000, + 0xd7418e0500000000, 0x76851aed00000000, 0x6992ea6d00000000, + 0x09ad8b3700000000, 0x16ba7bb700000000, 0xc9d3498300000000, + 0xd6c4b90300000000, 0xb6fbd85900000000, 0xa9ec28d900000000, + 0xcfcdf89700000000, 0xd0da081700000000, 0xb0e5694d00000000, + 0xaff299cd00000000, 0x709babf900000000, 0x6f8c5b7900000000, + 0x0fb33a2300000000, 0x10a4caa300000000, 0xb1605e4b00000000, + 0xae77aecb00000000, 0xce48cf9100000000, 0xd15f3f1100000000, + 0x0e360d2500000000, 0x1121fda500000000, 0x711e9cff00000000, + 0x6e096c7f00000000, 0x7291c4f500000000, 0x6d86347500000000, + 0x0db9552f00000000, 0x12aea5af00000000, 0xcdc7979b00000000, + 0xd2d0671b00000000, 0xb2ef064100000000, 0xadf8f6c100000000, + 0x0c3c622900000000, 0x132b92a900000000, 0x7314f3f300000000, + 0x6c03037300000000, 0xb36a314700000000, 0xac7dc1c700000000, + 0xcc42a09d00000000, 0xd355501d00000000, 0x6ae900a700000000, + 0x75fef02700000000, 0x15c1917d00000000, 0x0ad661fd00000000, + 0xd5bf53c900000000, 0xcaa8a34900000000, 0xaa97c21300000000, + 0xb580329300000000, 0x1444a67b00000000, 0x0b5356fb00000000, + 0x6b6c37a100000000, 0x747bc72100000000, 0xab12f51500000000, + 0xb405059500000000, 0xd43a64cf00000000, 0xcb2d944f00000000, + 0xd7b53cc500000000, 0xc8a2cc4500000000, 0xa89dad1f00000000, + 0xb78a5d9f00000000, 0x68e36fab00000000, 0x77f49f2b00000000, + 0x17cbfe7100000000, 0x08dc0ef100000000, 0xa9189a1900000000, + 0xb60f6a9900000000, 0xd6300bc300000000, 0xc927fb4300000000, + 0x164ec97700000000, 0x095939f700000000, 0x696658ad00000000, + 0x7671a82d00000000, 0x1050786300000000, 0x0f4788e300000000, + 0x6f78e9b900000000, 0x706f193900000000, 0xaf062b0d00000000, + 0xb011db8d00000000, 0xd02ebad700000000, 0xcf394a5700000000, + 0x6efddebf00000000, 0x71ea2e3f00000000, 0x11d54f6500000000, + 0x0ec2bfe500000000, 0xd1ab8dd100000000, 0xcebc7d5100000000, + 0xae831c0b00000000, 0xb194ec8b00000000, 0xad0c440100000000, + 0xb21bb48100000000, 0xd224d5db00000000, 0xcd33255b00000000, + 0x125a176f00000000, 0x0d4de7ef00000000, 0x6d7286b500000000, + 0x7265763500000000, 0xd3a1e2dd00000000, 0xccb6125d00000000, + 0xac89730700000000, 0xb39e838700000000, 0x6cf7b1b300000000, + 0x73e0413300000000, 0x13df206900000000, 0x0cc8d0e900000000, + 0xdf9d80f400000000, 0xc08a707400000000, 0xa0b5112e00000000, + 0xbfa2e1ae00000000, 0x60cbd39a00000000, 0x7fdc231a00000000, + 0x1fe3424000000000, 0x00f4b2c000000000, 0xa130262800000000, + 0xbe27d6a800000000, 0xde18b7f200000000, 0xc10f477200000000, + 0x1e66754600000000, 0x017185c600000000, 0x614ee49c00000000, + 0x7e59141c00000000, 0x62c1bc9600000000, 0x7dd64c1600000000, + 0x1de92d4c00000000, 0x02feddcc00000000, 0xdd97eff800000000, + 0xc2801f7800000000, 0xa2bf7e2200000000, 0xbda88ea200000000, + 0x1c6c1a4a00000000, 0x037beaca00000000, 0x63448b9000000000, + 0x7c537b1000000000, 0xa33a492400000000, 0xbc2db9a400000000, + 0xdc12d8fe00000000, 0xc305287e00000000, 0xa524f83000000000, + 0xba3308b000000000, 0xda0c69ea00000000, 0xc51b996a00000000, + 0x1a72ab5e00000000, 0x05655bde00000000, 0x655a3a8400000000, + 0x7a4dca0400000000, 0xdb895eec00000000, 0xc49eae6c00000000, + 0xa4a1cf3600000000, 0xbbb63fb600000000, 0x64df0d8200000000, + 0x7bc8fd0200000000, 0x1bf79c5800000000, 0x04e06cd800000000, + 0x1878c45200000000, 0x076f34d200000000, 0x6750558800000000, + 0x7847a50800000000, 0xa72e973c00000000, 0xb83967bc00000000, + 0xd80606e600000000, 0xc711f66600000000, 0x66d5628e00000000, + 0x79c2920e00000000, 0x19fdf35400000000, 0x06ea03d400000000, + 0xd98331e000000000, 0xc694c16000000000, 0xa6aba03a00000000, + 0xb9bc50ba00000000}, + {0x0000000000000000, 0xe2fd888d00000000, 0x85fd60c000000000, + 0x6700e84d00000000, 0x4bfdb05b00000000, 0xa90038d600000000, + 0xce00d09b00000000, 0x2cfd581600000000, 0x96fa61b700000000, + 0x7407e93a00000000, 0x1307017700000000, 0xf1fa89fa00000000, + 0xdd07d1ec00000000, 0x3ffa596100000000, 0x58fab12c00000000, + 0xba0739a100000000, 0x6df3b2b500000000, 0x8f0e3a3800000000, + 0xe80ed27500000000, 0x0af35af800000000, 0x260e02ee00000000, + 0xc4f38a6300000000, 0xa3f3622e00000000, 0x410eeaa300000000, + 0xfb09d30200000000, 0x19f45b8f00000000, 0x7ef4b3c200000000, + 0x9c093b4f00000000, 0xb0f4635900000000, 0x5209ebd400000000, + 0x3509039900000000, 0xd7f48b1400000000, 0x9be014b000000000, + 0x791d9c3d00000000, 0x1e1d747000000000, 0xfce0fcfd00000000, + 0xd01da4eb00000000, 0x32e02c6600000000, 0x55e0c42b00000000, + 0xb71d4ca600000000, 0x0d1a750700000000, 0xefe7fd8a00000000, + 0x88e715c700000000, 0x6a1a9d4a00000000, 0x46e7c55c00000000, + 0xa41a4dd100000000, 0xc31aa59c00000000, 0x21e72d1100000000, + 0xf613a60500000000, 0x14ee2e8800000000, 0x73eec6c500000000, + 0x91134e4800000000, 0xbdee165e00000000, 0x5f139ed300000000, + 0x3813769e00000000, 0xdaeefe1300000000, 0x60e9c7b200000000, + 0x82144f3f00000000, 0xe514a77200000000, 0x07e92fff00000000, + 0x2b1477e900000000, 0xc9e9ff6400000000, 0xaee9172900000000, + 0x4c149fa400000000, 0x77c758bb00000000, 0x953ad03600000000, + 0xf23a387b00000000, 0x10c7b0f600000000, 0x3c3ae8e000000000, + 0xdec7606d00000000, 0xb9c7882000000000, 0x5b3a00ad00000000, + 0xe13d390c00000000, 0x03c0b18100000000, 0x64c059cc00000000, + 0x863dd14100000000, 0xaac0895700000000, 0x483d01da00000000, + 0x2f3de99700000000, 0xcdc0611a00000000, 0x1a34ea0e00000000, + 0xf8c9628300000000, 0x9fc98ace00000000, 0x7d34024300000000, + 0x51c95a5500000000, 0xb334d2d800000000, 0xd4343a9500000000, + 0x36c9b21800000000, 0x8cce8bb900000000, 0x6e33033400000000, + 0x0933eb7900000000, 0xebce63f400000000, 0xc7333be200000000, + 0x25ceb36f00000000, 0x42ce5b2200000000, 0xa033d3af00000000, + 0xec274c0b00000000, 0x0edac48600000000, 0x69da2ccb00000000, + 0x8b27a44600000000, 0xa7dafc5000000000, 0x452774dd00000000, + 0x22279c9000000000, 0xc0da141d00000000, 0x7add2dbc00000000, + 0x9820a53100000000, 0xff204d7c00000000, 0x1dddc5f100000000, + 0x31209de700000000, 0xd3dd156a00000000, 0xb4ddfd2700000000, + 0x562075aa00000000, 0x81d4febe00000000, 0x6329763300000000, + 0x04299e7e00000000, 0xe6d416f300000000, 0xca294ee500000000, + 0x28d4c66800000000, 0x4fd42e2500000000, 0xad29a6a800000000, + 0x172e9f0900000000, 0xf5d3178400000000, 0x92d3ffc900000000, + 0x702e774400000000, 0x5cd32f5200000000, 0xbe2ea7df00000000, + 0xd92e4f9200000000, 0x3bd3c71f00000000, 0xaf88c0ad00000000, + 0x4d75482000000000, 0x2a75a06d00000000, 0xc88828e000000000, + 0xe47570f600000000, 0x0688f87b00000000, 0x6188103600000000, + 0x837598bb00000000, 0x3972a11a00000000, 0xdb8f299700000000, + 0xbc8fc1da00000000, 0x5e72495700000000, 0x728f114100000000, + 0x907299cc00000000, 0xf772718100000000, 0x158ff90c00000000, + 0xc27b721800000000, 0x2086fa9500000000, 0x478612d800000000, + 0xa57b9a5500000000, 0x8986c24300000000, 0x6b7b4ace00000000, + 0x0c7ba28300000000, 0xee862a0e00000000, 0x548113af00000000, + 0xb67c9b2200000000, 0xd17c736f00000000, 0x3381fbe200000000, + 0x1f7ca3f400000000, 0xfd812b7900000000, 0x9a81c33400000000, + 0x787c4bb900000000, 0x3468d41d00000000, 0xd6955c9000000000, + 0xb195b4dd00000000, 0x53683c5000000000, 0x7f95644600000000, + 0x9d68eccb00000000, 0xfa68048600000000, 0x18958c0b00000000, + 0xa292b5aa00000000, 0x406f3d2700000000, 0x276fd56a00000000, + 0xc5925de700000000, 0xe96f05f100000000, 0x0b928d7c00000000, + 0x6c92653100000000, 0x8e6fedbc00000000, 0x599b66a800000000, + 0xbb66ee2500000000, 0xdc66066800000000, 0x3e9b8ee500000000, + 0x1266d6f300000000, 0xf09b5e7e00000000, 0x979bb63300000000, + 0x75663ebe00000000, 0xcf61071f00000000, 0x2d9c8f9200000000, + 0x4a9c67df00000000, 0xa861ef5200000000, 0x849cb74400000000, + 0x66613fc900000000, 0x0161d78400000000, 0xe39c5f0900000000, + 0xd84f981600000000, 0x3ab2109b00000000, 0x5db2f8d600000000, + 0xbf4f705b00000000, 0x93b2284d00000000, 0x714fa0c000000000, + 0x164f488d00000000, 0xf4b2c00000000000, 0x4eb5f9a100000000, + 0xac48712c00000000, 0xcb48996100000000, 0x29b511ec00000000, + 0x054849fa00000000, 0xe7b5c17700000000, 0x80b5293a00000000, + 0x6248a1b700000000, 0xb5bc2aa300000000, 0x5741a22e00000000, + 0x30414a6300000000, 0xd2bcc2ee00000000, 0xfe419af800000000, + 0x1cbc127500000000, 0x7bbcfa3800000000, 0x994172b500000000, + 0x23464b1400000000, 0xc1bbc39900000000, 0xa6bb2bd400000000, + 0x4446a35900000000, 0x68bbfb4f00000000, 0x8a4673c200000000, + 0xed469b8f00000000, 0x0fbb130200000000, 0x43af8ca600000000, + 0xa152042b00000000, 0xc652ec6600000000, 0x24af64eb00000000, + 0x08523cfd00000000, 0xeaafb47000000000, 0x8daf5c3d00000000, + 0x6f52d4b000000000, 0xd555ed1100000000, 0x37a8659c00000000, + 0x50a88dd100000000, 0xb255055c00000000, 0x9ea85d4a00000000, + 0x7c55d5c700000000, 0x1b553d8a00000000, 0xf9a8b50700000000, + 0x2e5c3e1300000000, 0xcca1b69e00000000, 0xaba15ed300000000, + 0x495cd65e00000000, 0x65a18e4800000000, 0x875c06c500000000, + 0xe05cee8800000000, 0x02a1660500000000, 0xb8a65fa400000000, + 0x5a5bd72900000000, 0x3d5b3f6400000000, 0xdfa6b7e900000000, + 0xf35befff00000000, 0x11a6677200000000, 0x76a68f3f00000000, + 0x945b07b200000000}, + {0x0000000000000000, 0xa90b894e00000000, 0x5217129d00000000, + 0xfb1c9bd300000000, 0xe52855e100000000, 0x4c23dcaf00000000, + 0xb73f477c00000000, 0x1e34ce3200000000, 0x8b57db1900000000, + 0x225c525700000000, 0xd940c98400000000, 0x704b40ca00000000, + 0x6e7f8ef800000000, 0xc77407b600000000, 0x3c689c6500000000, + 0x9563152b00000000, 0x16afb63300000000, 0xbfa43f7d00000000, + 0x44b8a4ae00000000, 0xedb32de000000000, 0xf387e3d200000000, + 0x5a8c6a9c00000000, 0xa190f14f00000000, 0x089b780100000000, + 0x9df86d2a00000000, 0x34f3e46400000000, 0xcfef7fb700000000, + 0x66e4f6f900000000, 0x78d038cb00000000, 0xd1dbb18500000000, + 0x2ac72a5600000000, 0x83cca31800000000, 0x2c5e6d6700000000, + 0x8555e42900000000, 0x7e497ffa00000000, 0xd742f6b400000000, + 0xc976388600000000, 0x607db1c800000000, 0x9b612a1b00000000, + 0x326aa35500000000, 0xa709b67e00000000, 0x0e023f3000000000, + 0xf51ea4e300000000, 0x5c152dad00000000, 0x4221e39f00000000, + 0xeb2a6ad100000000, 0x1036f10200000000, 0xb93d784c00000000, + 0x3af1db5400000000, 0x93fa521a00000000, 0x68e6c9c900000000, + 0xc1ed408700000000, 0xdfd98eb500000000, 0x76d207fb00000000, + 0x8dce9c2800000000, 0x24c5156600000000, 0xb1a6004d00000000, + 0x18ad890300000000, 0xe3b112d000000000, 0x4aba9b9e00000000, + 0x548e55ac00000000, 0xfd85dce200000000, 0x0699473100000000, + 0xaf92ce7f00000000, 0x58bcdace00000000, 0xf1b7538000000000, + 0x0aabc85300000000, 0xa3a0411d00000000, 0xbd948f2f00000000, + 0x149f066100000000, 0xef839db200000000, 0x468814fc00000000, + 0xd3eb01d700000000, 0x7ae0889900000000, 0x81fc134a00000000, + 0x28f79a0400000000, 0x36c3543600000000, 0x9fc8dd7800000000, + 0x64d446ab00000000, 0xcddfcfe500000000, 0x4e136cfd00000000, + 0xe718e5b300000000, 0x1c047e6000000000, 0xb50ff72e00000000, + 0xab3b391c00000000, 0x0230b05200000000, 0xf92c2b8100000000, + 0x5027a2cf00000000, 0xc544b7e400000000, 0x6c4f3eaa00000000, + 0x9753a57900000000, 0x3e582c3700000000, 0x206ce20500000000, + 0x89676b4b00000000, 0x727bf09800000000, 0xdb7079d600000000, + 0x74e2b7a900000000, 0xdde93ee700000000, 0x26f5a53400000000, + 0x8ffe2c7a00000000, 0x91cae24800000000, 0x38c16b0600000000, + 0xc3ddf0d500000000, 0x6ad6799b00000000, 0xffb56cb000000000, + 0x56bee5fe00000000, 0xada27e2d00000000, 0x04a9f76300000000, + 0x1a9d395100000000, 0xb396b01f00000000, 0x488a2bcc00000000, + 0xe181a28200000000, 0x624d019a00000000, 0xcb4688d400000000, + 0x305a130700000000, 0x99519a4900000000, 0x8765547b00000000, + 0x2e6edd3500000000, 0xd57246e600000000, 0x7c79cfa800000000, + 0xe91ada8300000000, 0x401153cd00000000, 0xbb0dc81e00000000, + 0x1206415000000000, 0x0c328f6200000000, 0xa539062c00000000, + 0x5e259dff00000000, 0xf72e14b100000000, 0xf17ec44600000000, + 0x58754d0800000000, 0xa369d6db00000000, 0x0a625f9500000000, + 0x145691a700000000, 0xbd5d18e900000000, 0x4641833a00000000, + 0xef4a0a7400000000, 0x7a291f5f00000000, 0xd322961100000000, + 0x283e0dc200000000, 0x8135848c00000000, 0x9f014abe00000000, + 0x360ac3f000000000, 0xcd16582300000000, 0x641dd16d00000000, + 0xe7d1727500000000, 0x4edafb3b00000000, 0xb5c660e800000000, + 0x1ccde9a600000000, 0x02f9279400000000, 0xabf2aeda00000000, + 0x50ee350900000000, 0xf9e5bc4700000000, 0x6c86a96c00000000, + 0xc58d202200000000, 0x3e91bbf100000000, 0x979a32bf00000000, + 0x89aefc8d00000000, 0x20a575c300000000, 0xdbb9ee1000000000, + 0x72b2675e00000000, 0xdd20a92100000000, 0x742b206f00000000, + 0x8f37bbbc00000000, 0x263c32f200000000, 0x3808fcc000000000, + 0x9103758e00000000, 0x6a1fee5d00000000, 0xc314671300000000, + 0x5677723800000000, 0xff7cfb7600000000, 0x046060a500000000, + 0xad6be9eb00000000, 0xb35f27d900000000, 0x1a54ae9700000000, + 0xe148354400000000, 0x4843bc0a00000000, 0xcb8f1f1200000000, + 0x6284965c00000000, 0x99980d8f00000000, 0x309384c100000000, + 0x2ea74af300000000, 0x87acc3bd00000000, 0x7cb0586e00000000, + 0xd5bbd12000000000, 0x40d8c40b00000000, 0xe9d34d4500000000, + 0x12cfd69600000000, 0xbbc45fd800000000, 0xa5f091ea00000000, + 0x0cfb18a400000000, 0xf7e7837700000000, 0x5eec0a3900000000, + 0xa9c21e8800000000, 0x00c997c600000000, 0xfbd50c1500000000, + 0x52de855b00000000, 0x4cea4b6900000000, 0xe5e1c22700000000, + 0x1efd59f400000000, 0xb7f6d0ba00000000, 0x2295c59100000000, + 0x8b9e4cdf00000000, 0x7082d70c00000000, 0xd9895e4200000000, + 0xc7bd907000000000, 0x6eb6193e00000000, 0x95aa82ed00000000, + 0x3ca10ba300000000, 0xbf6da8bb00000000, 0x166621f500000000, + 0xed7aba2600000000, 0x4471336800000000, 0x5a45fd5a00000000, + 0xf34e741400000000, 0x0852efc700000000, 0xa159668900000000, + 0x343a73a200000000, 0x9d31faec00000000, 0x662d613f00000000, + 0xcf26e87100000000, 0xd112264300000000, 0x7819af0d00000000, + 0x830534de00000000, 0x2a0ebd9000000000, 0x859c73ef00000000, + 0x2c97faa100000000, 0xd78b617200000000, 0x7e80e83c00000000, + 0x60b4260e00000000, 0xc9bfaf4000000000, 0x32a3349300000000, + 0x9ba8bddd00000000, 0x0ecba8f600000000, 0xa7c021b800000000, + 0x5cdcba6b00000000, 0xf5d7332500000000, 0xebe3fd1700000000, + 0x42e8745900000000, 0xb9f4ef8a00000000, 0x10ff66c400000000, + 0x9333c5dc00000000, 0x3a384c9200000000, 0xc124d74100000000, + 0x682f5e0f00000000, 0x761b903d00000000, 0xdf10197300000000, + 0x240c82a000000000, 0x8d070bee00000000, 0x18641ec500000000, + 0xb16f978b00000000, 0x4a730c5800000000, 0xe378851600000000, + 0xfd4c4b2400000000, 0x5447c26a00000000, 0xaf5b59b900000000, + 0x0650d0f700000000}, + {0x0000000000000000, 0x479244af00000000, 0xcf22f88500000000, + 0x88b0bc2a00000000, 0xdf4381d000000000, 0x98d1c57f00000000, + 0x1061795500000000, 0x57f33dfa00000000, 0xff81737a00000000, + 0xb81337d500000000, 0x30a38bff00000000, 0x7731cf5000000000, + 0x20c2f2aa00000000, 0x6750b60500000000, 0xefe00a2f00000000, + 0xa8724e8000000000, 0xfe03e7f400000000, 0xb991a35b00000000, + 0x31211f7100000000, 0x76b35bde00000000, 0x2140662400000000, + 0x66d2228b00000000, 0xee629ea100000000, 0xa9f0da0e00000000, + 0x0182948e00000000, 0x4610d02100000000, 0xcea06c0b00000000, + 0x893228a400000000, 0xdec1155e00000000, 0x995351f100000000, + 0x11e3eddb00000000, 0x5671a97400000000, 0xbd01bf3200000000, + 0xfa93fb9d00000000, 0x722347b700000000, 0x35b1031800000000, + 0x62423ee200000000, 0x25d07a4d00000000, 0xad60c66700000000, + 0xeaf282c800000000, 0x4280cc4800000000, 0x051288e700000000, + 0x8da234cd00000000, 0xca30706200000000, 0x9dc34d9800000000, + 0xda51093700000000, 0x52e1b51d00000000, 0x1573f1b200000000, + 0x430258c600000000, 0x04901c6900000000, 0x8c20a04300000000, + 0xcbb2e4ec00000000, 0x9c41d91600000000, 0xdbd39db900000000, + 0x5363219300000000, 0x14f1653c00000000, 0xbc832bbc00000000, + 0xfb116f1300000000, 0x73a1d33900000000, 0x3433979600000000, + 0x63c0aa6c00000000, 0x2452eec300000000, 0xace252e900000000, + 0xeb70164600000000, 0x7a037e6500000000, 0x3d913aca00000000, + 0xb52186e000000000, 0xf2b3c24f00000000, 0xa540ffb500000000, + 0xe2d2bb1a00000000, 0x6a62073000000000, 0x2df0439f00000000, + 0x85820d1f00000000, 0xc21049b000000000, 0x4aa0f59a00000000, + 0x0d32b13500000000, 0x5ac18ccf00000000, 0x1d53c86000000000, + 0x95e3744a00000000, 0xd27130e500000000, 0x8400999100000000, + 0xc392dd3e00000000, 0x4b22611400000000, 0x0cb025bb00000000, + 0x5b43184100000000, 0x1cd15cee00000000, 0x9461e0c400000000, + 0xd3f3a46b00000000, 0x7b81eaeb00000000, 0x3c13ae4400000000, + 0xb4a3126e00000000, 0xf33156c100000000, 0xa4c26b3b00000000, + 0xe3502f9400000000, 0x6be093be00000000, 0x2c72d71100000000, + 0xc702c15700000000, 0x809085f800000000, 0x082039d200000000, + 0x4fb27d7d00000000, 0x1841408700000000, 0x5fd3042800000000, + 0xd763b80200000000, 0x90f1fcad00000000, 0x3883b22d00000000, + 0x7f11f68200000000, 0xf7a14aa800000000, 0xb0330e0700000000, + 0xe7c033fd00000000, 0xa052775200000000, 0x28e2cb7800000000, + 0x6f708fd700000000, 0x390126a300000000, 0x7e93620c00000000, + 0xf623de2600000000, 0xb1b19a8900000000, 0xe642a77300000000, + 0xa1d0e3dc00000000, 0x29605ff600000000, 0x6ef21b5900000000, + 0xc68055d900000000, 0x8112117600000000, 0x09a2ad5c00000000, + 0x4e30e9f300000000, 0x19c3d40900000000, 0x5e5190a600000000, + 0xd6e12c8c00000000, 0x9173682300000000, 0xf406fcca00000000, + 0xb394b86500000000, 0x3b24044f00000000, 0x7cb640e000000000, + 0x2b457d1a00000000, 0x6cd739b500000000, 0xe467859f00000000, + 0xa3f5c13000000000, 0x0b878fb000000000, 0x4c15cb1f00000000, + 0xc4a5773500000000, 0x8337339a00000000, 0xd4c40e6000000000, + 0x93564acf00000000, 0x1be6f6e500000000, 0x5c74b24a00000000, + 0x0a051b3e00000000, 0x4d975f9100000000, 0xc527e3bb00000000, + 0x82b5a71400000000, 0xd5469aee00000000, 0x92d4de4100000000, + 0x1a64626b00000000, 0x5df626c400000000, 0xf584684400000000, + 0xb2162ceb00000000, 0x3aa690c100000000, 0x7d34d46e00000000, + 0x2ac7e99400000000, 0x6d55ad3b00000000, 0xe5e5111100000000, + 0xa27755be00000000, 0x490743f800000000, 0x0e95075700000000, + 0x8625bb7d00000000, 0xc1b7ffd200000000, 0x9644c22800000000, + 0xd1d6868700000000, 0x59663aad00000000, 0x1ef47e0200000000, + 0xb686308200000000, 0xf114742d00000000, 0x79a4c80700000000, + 0x3e368ca800000000, 0x69c5b15200000000, 0x2e57f5fd00000000, + 0xa6e749d700000000, 0xe1750d7800000000, 0xb704a40c00000000, + 0xf096e0a300000000, 0x78265c8900000000, 0x3fb4182600000000, + 0x684725dc00000000, 0x2fd5617300000000, 0xa765dd5900000000, + 0xe0f799f600000000, 0x4885d77600000000, 0x0f1793d900000000, + 0x87a72ff300000000, 0xc0356b5c00000000, 0x97c656a600000000, + 0xd054120900000000, 0x58e4ae2300000000, 0x1f76ea8c00000000, + 0x8e0582af00000000, 0xc997c60000000000, 0x41277a2a00000000, + 0x06b53e8500000000, 0x5146037f00000000, 0x16d447d000000000, + 0x9e64fbfa00000000, 0xd9f6bf5500000000, 0x7184f1d500000000, + 0x3616b57a00000000, 0xbea6095000000000, 0xf9344dff00000000, + 0xaec7700500000000, 0xe95534aa00000000, 0x61e5888000000000, + 0x2677cc2f00000000, 0x7006655b00000000, 0x379421f400000000, + 0xbf249dde00000000, 0xf8b6d97100000000, 0xaf45e48b00000000, + 0xe8d7a02400000000, 0x60671c0e00000000, 0x27f558a100000000, + 0x8f87162100000000, 0xc815528e00000000, 0x40a5eea400000000, + 0x0737aa0b00000000, 0x50c497f100000000, 0x1756d35e00000000, + 0x9fe66f7400000000, 0xd8742bdb00000000, 0x33043d9d00000000, + 0x7496793200000000, 0xfc26c51800000000, 0xbbb481b700000000, + 0xec47bc4d00000000, 0xabd5f8e200000000, 0x236544c800000000, + 0x64f7006700000000, 0xcc854ee700000000, 0x8b170a4800000000, + 0x03a7b66200000000, 0x4435f2cd00000000, 0x13c6cf3700000000, + 0x54548b9800000000, 0xdce437b200000000, 0x9b76731d00000000, + 0xcd07da6900000000, 0x8a959ec600000000, 0x022522ec00000000, + 0x45b7664300000000, 0x12445bb900000000, 0x55d61f1600000000, + 0xdd66a33c00000000, 0x9af4e79300000000, 0x3286a91300000000, + 0x7514edbc00000000, 0xfda4519600000000, 0xba36153900000000, + 0xedc528c300000000, 0xaa576c6c00000000, 0x22e7d04600000000, + 0x657594e900000000}}; + +#else /* W == 4 */ + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0x65673b46, 0xcace768c, 0xafa94dca, 0x4eedeb59, + 0x2b8ad01f, 0x84239dd5, 0xe144a693, 0x9ddbd6b2, 0xf8bcedf4, + 0x5715a03e, 0x32729b78, 0xd3363deb, 0xb65106ad, 0x19f84b67, + 0x7c9f7021, 0xe0c6ab25, 0x85a19063, 0x2a08dda9, 0x4f6fe6ef, + 0xae2b407c, 0xcb4c7b3a, 0x64e536f0, 0x01820db6, 0x7d1d7d97, + 0x187a46d1, 0xb7d30b1b, 0xd2b4305d, 0x33f096ce, 0x5697ad88, + 0xf93ee042, 0x9c59db04, 0x1afc500b, 0x7f9b6b4d, 0xd0322687, + 0xb5551dc1, 0x5411bb52, 0x31768014, 0x9edfcdde, 0xfbb8f698, + 0x872786b9, 0xe240bdff, 0x4de9f035, 0x288ecb73, 0xc9ca6de0, + 0xacad56a6, 0x03041b6c, 0x6663202a, 0xfa3afb2e, 0x9f5dc068, + 0x30f48da2, 0x5593b6e4, 0xb4d71077, 0xd1b02b31, 0x7e1966fb, + 0x1b7e5dbd, 0x67e12d9c, 0x028616da, 0xad2f5b10, 0xc8486056, + 0x290cc6c5, 0x4c6bfd83, 0xe3c2b049, 0x86a58b0f, 0x35f8a016, + 0x509f9b50, 0xff36d69a, 0x9a51eddc, 0x7b154b4f, 0x1e727009, + 0xb1db3dc3, 0xd4bc0685, 0xa82376a4, 0xcd444de2, 0x62ed0028, + 0x078a3b6e, 0xe6ce9dfd, 0x83a9a6bb, 0x2c00eb71, 0x4967d037, + 0xd53e0b33, 0xb0593075, 0x1ff07dbf, 0x7a9746f9, 0x9bd3e06a, + 0xfeb4db2c, 0x511d96e6, 0x347aada0, 0x48e5dd81, 0x2d82e6c7, + 0x822bab0d, 0xe74c904b, 0x060836d8, 0x636f0d9e, 0xccc64054, + 0xa9a17b12, 0x2f04f01d, 0x4a63cb5b, 0xe5ca8691, 0x80adbdd7, + 0x61e91b44, 0x048e2002, 0xab276dc8, 0xce40568e, 0xb2df26af, + 0xd7b81de9, 0x78115023, 0x1d766b65, 0xfc32cdf6, 0x9955f6b0, + 0x36fcbb7a, 0x539b803c, 0xcfc25b38, 0xaaa5607e, 0x050c2db4, + 0x606b16f2, 0x812fb061, 0xe4488b27, 0x4be1c6ed, 0x2e86fdab, + 0x52198d8a, 0x377eb6cc, 0x98d7fb06, 0xfdb0c040, 0x1cf466d3, + 0x79935d95, 0xd63a105f, 0xb35d2b19, 0x6bf1402c, 0x0e967b6a, + 0xa13f36a0, 0xc4580de6, 0x251cab75, 0x407b9033, 0xefd2ddf9, + 0x8ab5e6bf, 0xf62a969e, 0x934dadd8, 0x3ce4e012, 0x5983db54, + 0xb8c77dc7, 0xdda04681, 0x72090b4b, 0x176e300d, 0x8b37eb09, + 0xee50d04f, 0x41f99d85, 0x249ea6c3, 0xc5da0050, 0xa0bd3b16, + 0x0f1476dc, 0x6a734d9a, 0x16ec3dbb, 0x738b06fd, 0xdc224b37, + 0xb9457071, 0x5801d6e2, 0x3d66eda4, 0x92cfa06e, 0xf7a89b28, + 0x710d1027, 0x146a2b61, 0xbbc366ab, 0xdea45ded, 0x3fe0fb7e, + 0x5a87c038, 0xf52e8df2, 0x9049b6b4, 0xecd6c695, 0x89b1fdd3, + 0x2618b019, 0x437f8b5f, 0xa23b2dcc, 0xc75c168a, 0x68f55b40, + 0x0d926006, 0x91cbbb02, 0xf4ac8044, 0x5b05cd8e, 0x3e62f6c8, + 0xdf26505b, 0xba416b1d, 0x15e826d7, 0x708f1d91, 0x0c106db0, + 0x697756f6, 0xc6de1b3c, 0xa3b9207a, 0x42fd86e9, 0x279abdaf, + 0x8833f065, 0xed54cb23, 0x5e09e03a, 0x3b6edb7c, 0x94c796b6, + 0xf1a0adf0, 0x10e40b63, 0x75833025, 0xda2a7def, 0xbf4d46a9, + 0xc3d23688, 0xa6b50dce, 0x091c4004, 0x6c7b7b42, 0x8d3fddd1, + 0xe858e697, 0x47f1ab5d, 0x2296901b, 0xbecf4b1f, 0xdba87059, + 0x74013d93, 0x116606d5, 0xf022a046, 0x95459b00, 0x3aecd6ca, + 0x5f8bed8c, 0x23149dad, 0x4673a6eb, 0xe9daeb21, 0x8cbdd067, + 0x6df976f4, 0x089e4db2, 0xa7370078, 0xc2503b3e, 0x44f5b031, + 0x21928b77, 0x8e3bc6bd, 0xeb5cfdfb, 0x0a185b68, 0x6f7f602e, + 0xc0d62de4, 0xa5b116a2, 0xd92e6683, 0xbc495dc5, 0x13e0100f, + 0x76872b49, 0x97c38dda, 0xf2a4b69c, 0x5d0dfb56, 0x386ac010, + 0xa4331b14, 0xc1542052, 0x6efd6d98, 0x0b9a56de, 0xeadef04d, + 0x8fb9cb0b, 0x201086c1, 0x4577bd87, 0x39e8cda6, 0x5c8ff6e0, + 0xf326bb2a, 0x9641806c, 0x770526ff, 0x12621db9, 0xbdcb5073, + 0xd8ac6b35}, + {0x00000000, 0xd7e28058, 0x74b406f1, 0xa35686a9, 0xe9680de2, + 0x3e8a8dba, 0x9ddc0b13, 0x4a3e8b4b, 0x09a11d85, 0xde439ddd, + 0x7d151b74, 0xaaf79b2c, 0xe0c91067, 0x372b903f, 0x947d1696, + 0x439f96ce, 0x13423b0a, 0xc4a0bb52, 0x67f63dfb, 0xb014bda3, + 0xfa2a36e8, 0x2dc8b6b0, 0x8e9e3019, 0x597cb041, 0x1ae3268f, + 0xcd01a6d7, 0x6e57207e, 0xb9b5a026, 0xf38b2b6d, 0x2469ab35, + 0x873f2d9c, 0x50ddadc4, 0x26847614, 0xf166f64c, 0x523070e5, + 0x85d2f0bd, 0xcfec7bf6, 0x180efbae, 0xbb587d07, 0x6cbafd5f, + 0x2f256b91, 0xf8c7ebc9, 0x5b916d60, 0x8c73ed38, 0xc64d6673, + 0x11afe62b, 0xb2f96082, 0x651be0da, 0x35c64d1e, 0xe224cd46, + 0x41724bef, 0x9690cbb7, 0xdcae40fc, 0x0b4cc0a4, 0xa81a460d, + 0x7ff8c655, 0x3c67509b, 0xeb85d0c3, 0x48d3566a, 0x9f31d632, + 0xd50f5d79, 0x02eddd21, 0xa1bb5b88, 0x7659dbd0, 0x4d08ec28, + 0x9aea6c70, 0x39bcead9, 0xee5e6a81, 0xa460e1ca, 0x73826192, + 0xd0d4e73b, 0x07366763, 0x44a9f1ad, 0x934b71f5, 0x301df75c, + 0xe7ff7704, 0xadc1fc4f, 0x7a237c17, 0xd975fabe, 0x0e977ae6, + 0x5e4ad722, 0x89a8577a, 0x2afed1d3, 0xfd1c518b, 0xb722dac0, + 0x60c05a98, 0xc396dc31, 0x14745c69, 0x57ebcaa7, 0x80094aff, + 0x235fcc56, 0xf4bd4c0e, 0xbe83c745, 0x6961471d, 0xca37c1b4, + 0x1dd541ec, 0x6b8c9a3c, 0xbc6e1a64, 0x1f389ccd, 0xc8da1c95, + 0x82e497de, 0x55061786, 0xf650912f, 0x21b21177, 0x622d87b9, + 0xb5cf07e1, 0x16998148, 0xc17b0110, 0x8b458a5b, 0x5ca70a03, + 0xfff18caa, 0x28130cf2, 0x78cea136, 0xaf2c216e, 0x0c7aa7c7, + 0xdb98279f, 0x91a6acd4, 0x46442c8c, 0xe512aa25, 0x32f02a7d, + 0x716fbcb3, 0xa68d3ceb, 0x05dbba42, 0xd2393a1a, 0x9807b151, + 0x4fe53109, 0xecb3b7a0, 0x3b5137f8, 0x9a11d850, 0x4df35808, + 0xeea5dea1, 0x39475ef9, 0x7379d5b2, 0xa49b55ea, 0x07cdd343, + 0xd02f531b, 0x93b0c5d5, 0x4452458d, 0xe704c324, 0x30e6437c, + 0x7ad8c837, 0xad3a486f, 0x0e6ccec6, 0xd98e4e9e, 0x8953e35a, + 0x5eb16302, 0xfde7e5ab, 0x2a0565f3, 0x603beeb8, 0xb7d96ee0, + 0x148fe849, 0xc36d6811, 0x80f2fedf, 0x57107e87, 0xf446f82e, + 0x23a47876, 0x699af33d, 0xbe787365, 0x1d2ef5cc, 0xcacc7594, + 0xbc95ae44, 0x6b772e1c, 0xc821a8b5, 0x1fc328ed, 0x55fda3a6, + 0x821f23fe, 0x2149a557, 0xf6ab250f, 0xb534b3c1, 0x62d63399, + 0xc180b530, 0x16623568, 0x5c5cbe23, 0x8bbe3e7b, 0x28e8b8d2, + 0xff0a388a, 0xafd7954e, 0x78351516, 0xdb6393bf, 0x0c8113e7, + 0x46bf98ac, 0x915d18f4, 0x320b9e5d, 0xe5e91e05, 0xa67688cb, + 0x71940893, 0xd2c28e3a, 0x05200e62, 0x4f1e8529, 0x98fc0571, + 0x3baa83d8, 0xec480380, 0xd7193478, 0x00fbb420, 0xa3ad3289, + 0x744fb2d1, 0x3e71399a, 0xe993b9c2, 0x4ac53f6b, 0x9d27bf33, + 0xdeb829fd, 0x095aa9a5, 0xaa0c2f0c, 0x7deeaf54, 0x37d0241f, + 0xe032a447, 0x436422ee, 0x9486a2b6, 0xc45b0f72, 0x13b98f2a, + 0xb0ef0983, 0x670d89db, 0x2d330290, 0xfad182c8, 0x59870461, + 0x8e658439, 0xcdfa12f7, 0x1a1892af, 0xb94e1406, 0x6eac945e, + 0x24921f15, 0xf3709f4d, 0x502619e4, 0x87c499bc, 0xf19d426c, + 0x267fc234, 0x8529449d, 0x52cbc4c5, 0x18f54f8e, 0xcf17cfd6, + 0x6c41497f, 0xbba3c927, 0xf83c5fe9, 0x2fdedfb1, 0x8c885918, + 0x5b6ad940, 0x1154520b, 0xc6b6d253, 0x65e054fa, 0xb202d4a2, + 0xe2df7966, 0x353df93e, 0x966b7f97, 0x4189ffcf, 0x0bb77484, + 0xdc55f4dc, 0x7f037275, 0xa8e1f22d, 0xeb7e64e3, 0x3c9ce4bb, + 0x9fca6212, 0x4828e24a, 0x02166901, 0xd5f4e959, 0x76a26ff0, + 0xa140efa8}, + {0x00000000, 0xef52b6e1, 0x05d46b83, 0xea86dd62, 0x0ba8d706, + 0xe4fa61e7, 0x0e7cbc85, 0xe12e0a64, 0x1751ae0c, 0xf80318ed, + 0x1285c58f, 0xfdd7736e, 0x1cf9790a, 0xf3abcfeb, 0x192d1289, + 0xf67fa468, 0x2ea35c18, 0xc1f1eaf9, 0x2b77379b, 0xc425817a, + 0x250b8b1e, 0xca593dff, 0x20dfe09d, 0xcf8d567c, 0x39f2f214, + 0xd6a044f5, 0x3c269997, 0xd3742f76, 0x325a2512, 0xdd0893f3, + 0x378e4e91, 0xd8dcf870, 0x5d46b830, 0xb2140ed1, 0x5892d3b3, + 0xb7c06552, 0x56ee6f36, 0xb9bcd9d7, 0x533a04b5, 0xbc68b254, + 0x4a17163c, 0xa545a0dd, 0x4fc37dbf, 0xa091cb5e, 0x41bfc13a, + 0xaeed77db, 0x446baab9, 0xab391c58, 0x73e5e428, 0x9cb752c9, + 0x76318fab, 0x9963394a, 0x784d332e, 0x971f85cf, 0x7d9958ad, + 0x92cbee4c, 0x64b44a24, 0x8be6fcc5, 0x616021a7, 0x8e329746, + 0x6f1c9d22, 0x804e2bc3, 0x6ac8f6a1, 0x859a4040, 0xba8d7060, + 0x55dfc681, 0xbf591be3, 0x500bad02, 0xb125a766, 0x5e771187, + 0xb4f1cce5, 0x5ba37a04, 0xaddcde6c, 0x428e688d, 0xa808b5ef, + 0x475a030e, 0xa674096a, 0x4926bf8b, 0xa3a062e9, 0x4cf2d408, + 0x942e2c78, 0x7b7c9a99, 0x91fa47fb, 0x7ea8f11a, 0x9f86fb7e, + 0x70d44d9f, 0x9a5290fd, 0x7500261c, 0x837f8274, 0x6c2d3495, + 0x86abe9f7, 0x69f95f16, 0x88d75572, 0x6785e393, 0x8d033ef1, + 0x62518810, 0xe7cbc850, 0x08997eb1, 0xe21fa3d3, 0x0d4d1532, + 0xec631f56, 0x0331a9b7, 0xe9b774d5, 0x06e5c234, 0xf09a665c, + 0x1fc8d0bd, 0xf54e0ddf, 0x1a1cbb3e, 0xfb32b15a, 0x146007bb, + 0xfee6dad9, 0x11b46c38, 0xc9689448, 0x263a22a9, 0xccbcffcb, + 0x23ee492a, 0xc2c0434e, 0x2d92f5af, 0xc71428cd, 0x28469e2c, + 0xde393a44, 0x316b8ca5, 0xdbed51c7, 0x34bfe726, 0xd591ed42, + 0x3ac35ba3, 0xd04586c1, 0x3f173020, 0xae6be681, 0x41395060, + 0xabbf8d02, 0x44ed3be3, 0xa5c33187, 0x4a918766, 0xa0175a04, + 0x4f45ece5, 0xb93a488d, 0x5668fe6c, 0xbcee230e, 0x53bc95ef, + 0xb2929f8b, 0x5dc0296a, 0xb746f408, 0x581442e9, 0x80c8ba99, + 0x6f9a0c78, 0x851cd11a, 0x6a4e67fb, 0x8b606d9f, 0x6432db7e, + 0x8eb4061c, 0x61e6b0fd, 0x97991495, 0x78cba274, 0x924d7f16, + 0x7d1fc9f7, 0x9c31c393, 0x73637572, 0x99e5a810, 0x76b71ef1, + 0xf32d5eb1, 0x1c7fe850, 0xf6f93532, 0x19ab83d3, 0xf88589b7, + 0x17d73f56, 0xfd51e234, 0x120354d5, 0xe47cf0bd, 0x0b2e465c, + 0xe1a89b3e, 0x0efa2ddf, 0xefd427bb, 0x0086915a, 0xea004c38, + 0x0552fad9, 0xdd8e02a9, 0x32dcb448, 0xd85a692a, 0x3708dfcb, + 0xd626d5af, 0x3974634e, 0xd3f2be2c, 0x3ca008cd, 0xcadfaca5, + 0x258d1a44, 0xcf0bc726, 0x205971c7, 0xc1777ba3, 0x2e25cd42, + 0xc4a31020, 0x2bf1a6c1, 0x14e696e1, 0xfbb42000, 0x1132fd62, + 0xfe604b83, 0x1f4e41e7, 0xf01cf706, 0x1a9a2a64, 0xf5c89c85, + 0x03b738ed, 0xece58e0c, 0x0663536e, 0xe931e58f, 0x081fefeb, + 0xe74d590a, 0x0dcb8468, 0xe2993289, 0x3a45caf9, 0xd5177c18, + 0x3f91a17a, 0xd0c3179b, 0x31ed1dff, 0xdebfab1e, 0x3439767c, + 0xdb6bc09d, 0x2d1464f5, 0xc246d214, 0x28c00f76, 0xc792b997, + 0x26bcb3f3, 0xc9ee0512, 0x2368d870, 0xcc3a6e91, 0x49a02ed1, + 0xa6f29830, 0x4c744552, 0xa326f3b3, 0x4208f9d7, 0xad5a4f36, + 0x47dc9254, 0xa88e24b5, 0x5ef180dd, 0xb1a3363c, 0x5b25eb5e, + 0xb4775dbf, 0x555957db, 0xba0be13a, 0x508d3c58, 0xbfdf8ab9, + 0x670372c9, 0x8851c428, 0x62d7194a, 0x8d85afab, 0x6caba5cf, + 0x83f9132e, 0x697fce4c, 0x862d78ad, 0x7052dcc5, 0x9f006a24, + 0x7586b746, 0x9ad401a7, 0x7bfa0bc3, 0x94a8bd22, 0x7e2e6040, + 0x917cd6a1}, + {0x00000000, 0x87a6cb43, 0xd43c90c7, 0x539a5b84, 0x730827cf, + 0xf4aeec8c, 0xa734b708, 0x20927c4b, 0xe6104f9e, 0x61b684dd, + 0x322cdf59, 0xb58a141a, 0x95186851, 0x12bea312, 0x4124f896, + 0xc68233d5, 0x1751997d, 0x90f7523e, 0xc36d09ba, 0x44cbc2f9, + 0x6459beb2, 0xe3ff75f1, 0xb0652e75, 0x37c3e536, 0xf141d6e3, + 0x76e71da0, 0x257d4624, 0xa2db8d67, 0x8249f12c, 0x05ef3a6f, + 0x567561eb, 0xd1d3aaa8, 0x2ea332fa, 0xa905f9b9, 0xfa9fa23d, + 0x7d39697e, 0x5dab1535, 0xda0dde76, 0x899785f2, 0x0e314eb1, + 0xc8b37d64, 0x4f15b627, 0x1c8feda3, 0x9b2926e0, 0xbbbb5aab, + 0x3c1d91e8, 0x6f87ca6c, 0xe821012f, 0x39f2ab87, 0xbe5460c4, + 0xedce3b40, 0x6a68f003, 0x4afa8c48, 0xcd5c470b, 0x9ec61c8f, + 0x1960d7cc, 0xdfe2e419, 0x58442f5a, 0x0bde74de, 0x8c78bf9d, + 0xaceac3d6, 0x2b4c0895, 0x78d65311, 0xff709852, 0x5d4665f4, + 0xdae0aeb7, 0x897af533, 0x0edc3e70, 0x2e4e423b, 0xa9e88978, + 0xfa72d2fc, 0x7dd419bf, 0xbb562a6a, 0x3cf0e129, 0x6f6abaad, + 0xe8cc71ee, 0xc85e0da5, 0x4ff8c6e6, 0x1c629d62, 0x9bc45621, + 0x4a17fc89, 0xcdb137ca, 0x9e2b6c4e, 0x198da70d, 0x391fdb46, + 0xbeb91005, 0xed234b81, 0x6a8580c2, 0xac07b317, 0x2ba17854, + 0x783b23d0, 0xff9de893, 0xdf0f94d8, 0x58a95f9b, 0x0b33041f, + 0x8c95cf5c, 0x73e5570e, 0xf4439c4d, 0xa7d9c7c9, 0x207f0c8a, + 0x00ed70c1, 0x874bbb82, 0xd4d1e006, 0x53772b45, 0x95f51890, + 0x1253d3d3, 0x41c98857, 0xc66f4314, 0xe6fd3f5f, 0x615bf41c, + 0x32c1af98, 0xb56764db, 0x64b4ce73, 0xe3120530, 0xb0885eb4, + 0x372e95f7, 0x17bce9bc, 0x901a22ff, 0xc380797b, 0x4426b238, + 0x82a481ed, 0x05024aae, 0x5698112a, 0xd13eda69, 0xf1aca622, + 0x760a6d61, 0x259036e5, 0xa236fda6, 0xba8ccbe8, 0x3d2a00ab, + 0x6eb05b2f, 0xe916906c, 0xc984ec27, 0x4e222764, 0x1db87ce0, + 0x9a1eb7a3, 0x5c9c8476, 0xdb3a4f35, 0x88a014b1, 0x0f06dff2, + 0x2f94a3b9, 0xa83268fa, 0xfba8337e, 0x7c0ef83d, 0xaddd5295, + 0x2a7b99d6, 0x79e1c252, 0xfe470911, 0xded5755a, 0x5973be19, + 0x0ae9e59d, 0x8d4f2ede, 0x4bcd1d0b, 0xcc6bd648, 0x9ff18dcc, + 0x1857468f, 0x38c53ac4, 0xbf63f187, 0xecf9aa03, 0x6b5f6140, + 0x942ff912, 0x13893251, 0x401369d5, 0xc7b5a296, 0xe727dedd, + 0x6081159e, 0x331b4e1a, 0xb4bd8559, 0x723fb68c, 0xf5997dcf, + 0xa603264b, 0x21a5ed08, 0x01379143, 0x86915a00, 0xd50b0184, + 0x52adcac7, 0x837e606f, 0x04d8ab2c, 0x5742f0a8, 0xd0e43beb, + 0xf07647a0, 0x77d08ce3, 0x244ad767, 0xa3ec1c24, 0x656e2ff1, + 0xe2c8e4b2, 0xb152bf36, 0x36f47475, 0x1666083e, 0x91c0c37d, + 0xc25a98f9, 0x45fc53ba, 0xe7caae1c, 0x606c655f, 0x33f63edb, + 0xb450f598, 0x94c289d3, 0x13644290, 0x40fe1914, 0xc758d257, + 0x01dae182, 0x867c2ac1, 0xd5e67145, 0x5240ba06, 0x72d2c64d, + 0xf5740d0e, 0xa6ee568a, 0x21489dc9, 0xf09b3761, 0x773dfc22, + 0x24a7a7a6, 0xa3016ce5, 0x839310ae, 0x0435dbed, 0x57af8069, + 0xd0094b2a, 0x168b78ff, 0x912db3bc, 0xc2b7e838, 0x4511237b, + 0x65835f30, 0xe2259473, 0xb1bfcff7, 0x361904b4, 0xc9699ce6, + 0x4ecf57a5, 0x1d550c21, 0x9af3c762, 0xba61bb29, 0x3dc7706a, + 0x6e5d2bee, 0xe9fbe0ad, 0x2f79d378, 0xa8df183b, 0xfb4543bf, + 0x7ce388fc, 0x5c71f4b7, 0xdbd73ff4, 0x884d6470, 0x0febaf33, + 0xde38059b, 0x599eced8, 0x0a04955c, 0x8da25e1f, 0xad302254, + 0x2a96e917, 0x790cb293, 0xfeaa79d0, 0x38284a05, 0xbf8e8146, + 0xec14dac2, 0x6bb21181, 0x4b206dca, 0xcc86a689, 0x9f1cfd0d, + 0x18ba364e}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x00000000, 0x43cba687, 0xc7903cd4, 0x845b9a53, 0xcf270873, + 0x8cecaef4, 0x08b734a7, 0x4b7c9220, 0x9e4f10e6, 0xdd84b661, + 0x59df2c32, 0x1a148ab5, 0x51681895, 0x12a3be12, 0x96f82441, + 0xd53382c6, 0x7d995117, 0x3e52f790, 0xba096dc3, 0xf9c2cb44, + 0xb2be5964, 0xf175ffe3, 0x752e65b0, 0x36e5c337, 0xe3d641f1, + 0xa01de776, 0x24467d25, 0x678ddba2, 0x2cf14982, 0x6f3aef05, + 0xeb617556, 0xa8aad3d1, 0xfa32a32e, 0xb9f905a9, 0x3da29ffa, + 0x7e69397d, 0x3515ab5d, 0x76de0dda, 0xf2859789, 0xb14e310e, + 0x647db3c8, 0x27b6154f, 0xa3ed8f1c, 0xe026299b, 0xab5abbbb, + 0xe8911d3c, 0x6cca876f, 0x2f0121e8, 0x87abf239, 0xc46054be, + 0x403bceed, 0x03f0686a, 0x488cfa4a, 0x0b475ccd, 0x8f1cc69e, + 0xccd76019, 0x19e4e2df, 0x5a2f4458, 0xde74de0b, 0x9dbf788c, + 0xd6c3eaac, 0x95084c2b, 0x1153d678, 0x529870ff, 0xf465465d, + 0xb7aee0da, 0x33f57a89, 0x703edc0e, 0x3b424e2e, 0x7889e8a9, + 0xfcd272fa, 0xbf19d47d, 0x6a2a56bb, 0x29e1f03c, 0xadba6a6f, + 0xee71cce8, 0xa50d5ec8, 0xe6c6f84f, 0x629d621c, 0x2156c49b, + 0x89fc174a, 0xca37b1cd, 0x4e6c2b9e, 0x0da78d19, 0x46db1f39, + 0x0510b9be, 0x814b23ed, 0xc280856a, 0x17b307ac, 0x5478a12b, + 0xd0233b78, 0x93e89dff, 0xd8940fdf, 0x9b5fa958, 0x1f04330b, + 0x5ccf958c, 0x0e57e573, 0x4d9c43f4, 0xc9c7d9a7, 0x8a0c7f20, + 0xc170ed00, 0x82bb4b87, 0x06e0d1d4, 0x452b7753, 0x9018f595, + 0xd3d35312, 0x5788c941, 0x14436fc6, 0x5f3ffde6, 0x1cf45b61, + 0x98afc132, 0xdb6467b5, 0x73ceb464, 0x300512e3, 0xb45e88b0, + 0xf7952e37, 0xbce9bc17, 0xff221a90, 0x7b7980c3, 0x38b22644, + 0xed81a482, 0xae4a0205, 0x2a119856, 0x69da3ed1, 0x22a6acf1, + 0x616d0a76, 0xe5369025, 0xa6fd36a2, 0xe8cb8cba, 0xab002a3d, + 0x2f5bb06e, 0x6c9016e9, 0x27ec84c9, 0x6427224e, 0xe07cb81d, + 0xa3b71e9a, 0x76849c5c, 0x354f3adb, 0xb114a088, 0xf2df060f, + 0xb9a3942f, 0xfa6832a8, 0x7e33a8fb, 0x3df80e7c, 0x9552ddad, + 0xd6997b2a, 0x52c2e179, 0x110947fe, 0x5a75d5de, 0x19be7359, + 0x9de5e90a, 0xde2e4f8d, 0x0b1dcd4b, 0x48d66bcc, 0xcc8df19f, + 0x8f465718, 0xc43ac538, 0x87f163bf, 0x03aaf9ec, 0x40615f6b, + 0x12f92f94, 0x51328913, 0xd5691340, 0x96a2b5c7, 0xddde27e7, + 0x9e158160, 0x1a4e1b33, 0x5985bdb4, 0x8cb63f72, 0xcf7d99f5, + 0x4b2603a6, 0x08eda521, 0x43913701, 0x005a9186, 0x84010bd5, + 0xc7caad52, 0x6f607e83, 0x2cabd804, 0xa8f04257, 0xeb3be4d0, + 0xa04776f0, 0xe38cd077, 0x67d74a24, 0x241ceca3, 0xf12f6e65, + 0xb2e4c8e2, 0x36bf52b1, 0x7574f436, 0x3e086616, 0x7dc3c091, + 0xf9985ac2, 0xba53fc45, 0x1caecae7, 0x5f656c60, 0xdb3ef633, + 0x98f550b4, 0xd389c294, 0x90426413, 0x1419fe40, 0x57d258c7, + 0x82e1da01, 0xc12a7c86, 0x4571e6d5, 0x06ba4052, 0x4dc6d272, + 0x0e0d74f5, 0x8a56eea6, 0xc99d4821, 0x61379bf0, 0x22fc3d77, + 0xa6a7a724, 0xe56c01a3, 0xae109383, 0xeddb3504, 0x6980af57, + 0x2a4b09d0, 0xff788b16, 0xbcb32d91, 0x38e8b7c2, 0x7b231145, + 0x305f8365, 0x739425e2, 0xf7cfbfb1, 0xb4041936, 0xe69c69c9, + 0xa557cf4e, 0x210c551d, 0x62c7f39a, 0x29bb61ba, 0x6a70c73d, + 0xee2b5d6e, 0xade0fbe9, 0x78d3792f, 0x3b18dfa8, 0xbf4345fb, + 0xfc88e37c, 0xb7f4715c, 0xf43fd7db, 0x70644d88, 0x33afeb0f, + 0x9b0538de, 0xd8ce9e59, 0x5c95040a, 0x1f5ea28d, 0x542230ad, + 0x17e9962a, 0x93b20c79, 0xd079aafe, 0x054a2838, 0x46818ebf, + 0xc2da14ec, 0x8111b26b, 0xca6d204b, 0x89a686cc, 0x0dfd1c9f, + 0x4e36ba18}, + {0x00000000, 0xe1b652ef, 0x836bd405, 0x62dd86ea, 0x06d7a80b, + 0xe761fae4, 0x85bc7c0e, 0x640a2ee1, 0x0cae5117, 0xed1803f8, + 0x8fc58512, 0x6e73d7fd, 0x0a79f91c, 0xebcfabf3, 0x89122d19, + 0x68a47ff6, 0x185ca32e, 0xf9eaf1c1, 0x9b37772b, 0x7a8125c4, + 0x1e8b0b25, 0xff3d59ca, 0x9de0df20, 0x7c568dcf, 0x14f2f239, + 0xf544a0d6, 0x9799263c, 0x762f74d3, 0x12255a32, 0xf39308dd, + 0x914e8e37, 0x70f8dcd8, 0x30b8465d, 0xd10e14b2, 0xb3d39258, + 0x5265c0b7, 0x366fee56, 0xd7d9bcb9, 0xb5043a53, 0x54b268bc, + 0x3c16174a, 0xdda045a5, 0xbf7dc34f, 0x5ecb91a0, 0x3ac1bf41, + 0xdb77edae, 0xb9aa6b44, 0x581c39ab, 0x28e4e573, 0xc952b79c, + 0xab8f3176, 0x4a396399, 0x2e334d78, 0xcf851f97, 0xad58997d, + 0x4ceecb92, 0x244ab464, 0xc5fce68b, 0xa7216061, 0x4697328e, + 0x229d1c6f, 0xc32b4e80, 0xa1f6c86a, 0x40409a85, 0x60708dba, + 0x81c6df55, 0xe31b59bf, 0x02ad0b50, 0x66a725b1, 0x8711775e, + 0xe5ccf1b4, 0x047aa35b, 0x6cdedcad, 0x8d688e42, 0xefb508a8, + 0x0e035a47, 0x6a0974a6, 0x8bbf2649, 0xe962a0a3, 0x08d4f24c, + 0x782c2e94, 0x999a7c7b, 0xfb47fa91, 0x1af1a87e, 0x7efb869f, + 0x9f4dd470, 0xfd90529a, 0x1c260075, 0x74827f83, 0x95342d6c, + 0xf7e9ab86, 0x165ff969, 0x7255d788, 0x93e38567, 0xf13e038d, + 0x10885162, 0x50c8cbe7, 0xb17e9908, 0xd3a31fe2, 0x32154d0d, + 0x561f63ec, 0xb7a93103, 0xd574b7e9, 0x34c2e506, 0x5c669af0, + 0xbdd0c81f, 0xdf0d4ef5, 0x3ebb1c1a, 0x5ab132fb, 0xbb076014, + 0xd9dae6fe, 0x386cb411, 0x489468c9, 0xa9223a26, 0xcbffbccc, + 0x2a49ee23, 0x4e43c0c2, 0xaff5922d, 0xcd2814c7, 0x2c9e4628, + 0x443a39de, 0xa58c6b31, 0xc751eddb, 0x26e7bf34, 0x42ed91d5, + 0xa35bc33a, 0xc18645d0, 0x2030173f, 0x81e66bae, 0x60503941, + 0x028dbfab, 0xe33bed44, 0x8731c3a5, 0x6687914a, 0x045a17a0, + 0xe5ec454f, 0x8d483ab9, 0x6cfe6856, 0x0e23eebc, 0xef95bc53, + 0x8b9f92b2, 0x6a29c05d, 0x08f446b7, 0xe9421458, 0x99bac880, + 0x780c9a6f, 0x1ad11c85, 0xfb674e6a, 0x9f6d608b, 0x7edb3264, + 0x1c06b48e, 0xfdb0e661, 0x95149997, 0x74a2cb78, 0x167f4d92, + 0xf7c91f7d, 0x93c3319c, 0x72756373, 0x10a8e599, 0xf11eb776, + 0xb15e2df3, 0x50e87f1c, 0x3235f9f6, 0xd383ab19, 0xb78985f8, + 0x563fd717, 0x34e251fd, 0xd5540312, 0xbdf07ce4, 0x5c462e0b, + 0x3e9ba8e1, 0xdf2dfa0e, 0xbb27d4ef, 0x5a918600, 0x384c00ea, + 0xd9fa5205, 0xa9028edd, 0x48b4dc32, 0x2a695ad8, 0xcbdf0837, + 0xafd526d6, 0x4e637439, 0x2cbef2d3, 0xcd08a03c, 0xa5acdfca, + 0x441a8d25, 0x26c70bcf, 0xc7715920, 0xa37b77c1, 0x42cd252e, + 0x2010a3c4, 0xc1a6f12b, 0xe196e614, 0x0020b4fb, 0x62fd3211, + 0x834b60fe, 0xe7414e1f, 0x06f71cf0, 0x642a9a1a, 0x859cc8f5, + 0xed38b703, 0x0c8ee5ec, 0x6e536306, 0x8fe531e9, 0xebef1f08, + 0x0a594de7, 0x6884cb0d, 0x893299e2, 0xf9ca453a, 0x187c17d5, + 0x7aa1913f, 0x9b17c3d0, 0xff1ded31, 0x1eabbfde, 0x7c763934, + 0x9dc06bdb, 0xf564142d, 0x14d246c2, 0x760fc028, 0x97b992c7, + 0xf3b3bc26, 0x1205eec9, 0x70d86823, 0x916e3acc, 0xd12ea049, + 0x3098f2a6, 0x5245744c, 0xb3f326a3, 0xd7f90842, 0x364f5aad, + 0x5492dc47, 0xb5248ea8, 0xdd80f15e, 0x3c36a3b1, 0x5eeb255b, + 0xbf5d77b4, 0xdb575955, 0x3ae10bba, 0x583c8d50, 0xb98adfbf, + 0xc9720367, 0x28c45188, 0x4a19d762, 0xabaf858d, 0xcfa5ab6c, + 0x2e13f983, 0x4cce7f69, 0xad782d86, 0xc5dc5270, 0x246a009f, + 0x46b78675, 0xa701d49a, 0xc30bfa7b, 0x22bda894, 0x40602e7e, + 0xa1d67c91}, + {0x00000000, 0x5880e2d7, 0xf106b474, 0xa98656a3, 0xe20d68e9, + 0xba8d8a3e, 0x130bdc9d, 0x4b8b3e4a, 0x851da109, 0xdd9d43de, + 0x741b157d, 0x2c9bf7aa, 0x6710c9e0, 0x3f902b37, 0x96167d94, + 0xce969f43, 0x0a3b4213, 0x52bba0c4, 0xfb3df667, 0xa3bd14b0, + 0xe8362afa, 0xb0b6c82d, 0x19309e8e, 0x41b07c59, 0x8f26e31a, + 0xd7a601cd, 0x7e20576e, 0x26a0b5b9, 0x6d2b8bf3, 0x35ab6924, + 0x9c2d3f87, 0xc4addd50, 0x14768426, 0x4cf666f1, 0xe5703052, + 0xbdf0d285, 0xf67beccf, 0xaefb0e18, 0x077d58bb, 0x5ffdba6c, + 0x916b252f, 0xc9ebc7f8, 0x606d915b, 0x38ed738c, 0x73664dc6, + 0x2be6af11, 0x8260f9b2, 0xdae01b65, 0x1e4dc635, 0x46cd24e2, + 0xef4b7241, 0xb7cb9096, 0xfc40aedc, 0xa4c04c0b, 0x0d461aa8, + 0x55c6f87f, 0x9b50673c, 0xc3d085eb, 0x6a56d348, 0x32d6319f, + 0x795d0fd5, 0x21dded02, 0x885bbba1, 0xd0db5976, 0x28ec084d, + 0x706cea9a, 0xd9eabc39, 0x816a5eee, 0xcae160a4, 0x92618273, + 0x3be7d4d0, 0x63673607, 0xadf1a944, 0xf5714b93, 0x5cf71d30, + 0x0477ffe7, 0x4ffcc1ad, 0x177c237a, 0xbefa75d9, 0xe67a970e, + 0x22d74a5e, 0x7a57a889, 0xd3d1fe2a, 0x8b511cfd, 0xc0da22b7, + 0x985ac060, 0x31dc96c3, 0x695c7414, 0xa7caeb57, 0xff4a0980, + 0x56cc5f23, 0x0e4cbdf4, 0x45c783be, 0x1d476169, 0xb4c137ca, + 0xec41d51d, 0x3c9a8c6b, 0x641a6ebc, 0xcd9c381f, 0x951cdac8, + 0xde97e482, 0x86170655, 0x2f9150f6, 0x7711b221, 0xb9872d62, + 0xe107cfb5, 0x48819916, 0x10017bc1, 0x5b8a458b, 0x030aa75c, + 0xaa8cf1ff, 0xf20c1328, 0x36a1ce78, 0x6e212caf, 0xc7a77a0c, + 0x9f2798db, 0xd4aca691, 0x8c2c4446, 0x25aa12e5, 0x7d2af032, + 0xb3bc6f71, 0xeb3c8da6, 0x42badb05, 0x1a3a39d2, 0x51b10798, + 0x0931e54f, 0xa0b7b3ec, 0xf837513b, 0x50d8119a, 0x0858f34d, + 0xa1dea5ee, 0xf95e4739, 0xb2d57973, 0xea559ba4, 0x43d3cd07, + 0x1b532fd0, 0xd5c5b093, 0x8d455244, 0x24c304e7, 0x7c43e630, + 0x37c8d87a, 0x6f483aad, 0xc6ce6c0e, 0x9e4e8ed9, 0x5ae35389, + 0x0263b15e, 0xabe5e7fd, 0xf365052a, 0xb8ee3b60, 0xe06ed9b7, + 0x49e88f14, 0x11686dc3, 0xdffef280, 0x877e1057, 0x2ef846f4, + 0x7678a423, 0x3df39a69, 0x657378be, 0xccf52e1d, 0x9475ccca, + 0x44ae95bc, 0x1c2e776b, 0xb5a821c8, 0xed28c31f, 0xa6a3fd55, + 0xfe231f82, 0x57a54921, 0x0f25abf6, 0xc1b334b5, 0x9933d662, + 0x30b580c1, 0x68356216, 0x23be5c5c, 0x7b3ebe8b, 0xd2b8e828, + 0x8a380aff, 0x4e95d7af, 0x16153578, 0xbf9363db, 0xe713810c, + 0xac98bf46, 0xf4185d91, 0x5d9e0b32, 0x051ee9e5, 0xcb8876a6, + 0x93089471, 0x3a8ec2d2, 0x620e2005, 0x29851e4f, 0x7105fc98, + 0xd883aa3b, 0x800348ec, 0x783419d7, 0x20b4fb00, 0x8932ada3, + 0xd1b24f74, 0x9a39713e, 0xc2b993e9, 0x6b3fc54a, 0x33bf279d, + 0xfd29b8de, 0xa5a95a09, 0x0c2f0caa, 0x54afee7d, 0x1f24d037, + 0x47a432e0, 0xee226443, 0xb6a28694, 0x720f5bc4, 0x2a8fb913, + 0x8309efb0, 0xdb890d67, 0x9002332d, 0xc882d1fa, 0x61048759, + 0x3984658e, 0xf712facd, 0xaf92181a, 0x06144eb9, 0x5e94ac6e, + 0x151f9224, 0x4d9f70f3, 0xe4192650, 0xbc99c487, 0x6c429df1, + 0x34c27f26, 0x9d442985, 0xc5c4cb52, 0x8e4ff518, 0xd6cf17cf, + 0x7f49416c, 0x27c9a3bb, 0xe95f3cf8, 0xb1dfde2f, 0x1859888c, + 0x40d96a5b, 0x0b525411, 0x53d2b6c6, 0xfa54e065, 0xa2d402b2, + 0x6679dfe2, 0x3ef93d35, 0x977f6b96, 0xcfff8941, 0x8474b70b, + 0xdcf455dc, 0x7572037f, 0x2df2e1a8, 0xe3647eeb, 0xbbe49c3c, + 0x1262ca9f, 0x4ae22848, 0x01691602, 0x59e9f4d5, 0xf06fa276, + 0xa8ef40a1}, + {0x00000000, 0x463b6765, 0x8c76ceca, 0xca4da9af, 0x59ebed4e, + 0x1fd08a2b, 0xd59d2384, 0x93a644e1, 0xb2d6db9d, 0xf4edbcf8, + 0x3ea01557, 0x789b7232, 0xeb3d36d3, 0xad0651b6, 0x674bf819, + 0x21709f7c, 0x25abc6e0, 0x6390a185, 0xa9dd082a, 0xefe66f4f, + 0x7c402bae, 0x3a7b4ccb, 0xf036e564, 0xb60d8201, 0x977d1d7d, + 0xd1467a18, 0x1b0bd3b7, 0x5d30b4d2, 0xce96f033, 0x88ad9756, + 0x42e03ef9, 0x04db599c, 0x0b50fc1a, 0x4d6b9b7f, 0x872632d0, + 0xc11d55b5, 0x52bb1154, 0x14807631, 0xdecddf9e, 0x98f6b8fb, + 0xb9862787, 0xffbd40e2, 0x35f0e94d, 0x73cb8e28, 0xe06dcac9, + 0xa656adac, 0x6c1b0403, 0x2a206366, 0x2efb3afa, 0x68c05d9f, + 0xa28df430, 0xe4b69355, 0x7710d7b4, 0x312bb0d1, 0xfb66197e, + 0xbd5d7e1b, 0x9c2de167, 0xda168602, 0x105b2fad, 0x566048c8, + 0xc5c60c29, 0x83fd6b4c, 0x49b0c2e3, 0x0f8ba586, 0x16a0f835, + 0x509b9f50, 0x9ad636ff, 0xdced519a, 0x4f4b157b, 0x0970721e, + 0xc33ddbb1, 0x8506bcd4, 0xa47623a8, 0xe24d44cd, 0x2800ed62, + 0x6e3b8a07, 0xfd9dcee6, 0xbba6a983, 0x71eb002c, 0x37d06749, + 0x330b3ed5, 0x753059b0, 0xbf7df01f, 0xf946977a, 0x6ae0d39b, + 0x2cdbb4fe, 0xe6961d51, 0xa0ad7a34, 0x81dde548, 0xc7e6822d, + 0x0dab2b82, 0x4b904ce7, 0xd8360806, 0x9e0d6f63, 0x5440c6cc, + 0x127ba1a9, 0x1df0042f, 0x5bcb634a, 0x9186cae5, 0xd7bdad80, + 0x441be961, 0x02208e04, 0xc86d27ab, 0x8e5640ce, 0xaf26dfb2, + 0xe91db8d7, 0x23501178, 0x656b761d, 0xf6cd32fc, 0xb0f65599, + 0x7abbfc36, 0x3c809b53, 0x385bc2cf, 0x7e60a5aa, 0xb42d0c05, + 0xf2166b60, 0x61b02f81, 0x278b48e4, 0xedc6e14b, 0xabfd862e, + 0x8a8d1952, 0xccb67e37, 0x06fbd798, 0x40c0b0fd, 0xd366f41c, + 0x955d9379, 0x5f103ad6, 0x192b5db3, 0x2c40f16b, 0x6a7b960e, + 0xa0363fa1, 0xe60d58c4, 0x75ab1c25, 0x33907b40, 0xf9ddd2ef, + 0xbfe6b58a, 0x9e962af6, 0xd8ad4d93, 0x12e0e43c, 0x54db8359, + 0xc77dc7b8, 0x8146a0dd, 0x4b0b0972, 0x0d306e17, 0x09eb378b, + 0x4fd050ee, 0x859df941, 0xc3a69e24, 0x5000dac5, 0x163bbda0, + 0xdc76140f, 0x9a4d736a, 0xbb3dec16, 0xfd068b73, 0x374b22dc, + 0x717045b9, 0xe2d60158, 0xa4ed663d, 0x6ea0cf92, 0x289ba8f7, + 0x27100d71, 0x612b6a14, 0xab66c3bb, 0xed5da4de, 0x7efbe03f, + 0x38c0875a, 0xf28d2ef5, 0xb4b64990, 0x95c6d6ec, 0xd3fdb189, + 0x19b01826, 0x5f8b7f43, 0xcc2d3ba2, 0x8a165cc7, 0x405bf568, + 0x0660920d, 0x02bbcb91, 0x4480acf4, 0x8ecd055b, 0xc8f6623e, + 0x5b5026df, 0x1d6b41ba, 0xd726e815, 0x911d8f70, 0xb06d100c, + 0xf6567769, 0x3c1bdec6, 0x7a20b9a3, 0xe986fd42, 0xafbd9a27, + 0x65f03388, 0x23cb54ed, 0x3ae0095e, 0x7cdb6e3b, 0xb696c794, + 0xf0ada0f1, 0x630be410, 0x25308375, 0xef7d2ada, 0xa9464dbf, + 0x8836d2c3, 0xce0db5a6, 0x04401c09, 0x427b7b6c, 0xd1dd3f8d, + 0x97e658e8, 0x5dabf147, 0x1b909622, 0x1f4bcfbe, 0x5970a8db, + 0x933d0174, 0xd5066611, 0x46a022f0, 0x009b4595, 0xcad6ec3a, + 0x8ced8b5f, 0xad9d1423, 0xeba67346, 0x21ebdae9, 0x67d0bd8c, + 0xf476f96d, 0xb24d9e08, 0x780037a7, 0x3e3b50c2, 0x31b0f544, + 0x778b9221, 0xbdc63b8e, 0xfbfd5ceb, 0x685b180a, 0x2e607f6f, + 0xe42dd6c0, 0xa216b1a5, 0x83662ed9, 0xc55d49bc, 0x0f10e013, + 0x492b8776, 0xda8dc397, 0x9cb6a4f2, 0x56fb0d5d, 0x10c06a38, + 0x141b33a4, 0x522054c1, 0x986dfd6e, 0xde569a0b, 0x4df0deea, + 0x0bcbb98f, 0xc1861020, 0x87bd7745, 0xa6cde839, 0xe0f68f5c, + 0x2abb26f3, 0x6c804196, 0xff260577, 0xb91d6212, 0x7350cbbd, + 0x356bacd8}}; + +#endif + +#endif + +#if N == 6 + +#if W == 8 + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0x3db1ecdc, 0x7b63d9b8, 0x46d23564, 0xf6c7b370, + 0xcb765fac, 0x8da46ac8, 0xb0158614, 0x36fe60a1, 0x0b4f8c7d, + 0x4d9db919, 0x702c55c5, 0xc039d3d1, 0xfd883f0d, 0xbb5a0a69, + 0x86ebe6b5, 0x6dfcc142, 0x504d2d9e, 0x169f18fa, 0x2b2ef426, + 0x9b3b7232, 0xa68a9eee, 0xe058ab8a, 0xdde94756, 0x5b02a1e3, + 0x66b34d3f, 0x2061785b, 0x1dd09487, 0xadc51293, 0x9074fe4f, + 0xd6a6cb2b, 0xeb1727f7, 0xdbf98284, 0xe6486e58, 0xa09a5b3c, + 0x9d2bb7e0, 0x2d3e31f4, 0x108fdd28, 0x565de84c, 0x6bec0490, + 0xed07e225, 0xd0b60ef9, 0x96643b9d, 0xabd5d741, 0x1bc05155, + 0x2671bd89, 0x60a388ed, 0x5d126431, 0xb60543c6, 0x8bb4af1a, + 0xcd669a7e, 0xf0d776a2, 0x40c2f0b6, 0x7d731c6a, 0x3ba1290e, + 0x0610c5d2, 0x80fb2367, 0xbd4acfbb, 0xfb98fadf, 0xc6291603, + 0x763c9017, 0x4b8d7ccb, 0x0d5f49af, 0x30eea573, 0x6c820349, + 0x5133ef95, 0x17e1daf1, 0x2a50362d, 0x9a45b039, 0xa7f45ce5, + 0xe1266981, 0xdc97855d, 0x5a7c63e8, 0x67cd8f34, 0x211fba50, + 0x1cae568c, 0xacbbd098, 0x910a3c44, 0xd7d80920, 0xea69e5fc, + 0x017ec20b, 0x3ccf2ed7, 0x7a1d1bb3, 0x47acf76f, 0xf7b9717b, + 0xca089da7, 0x8cdaa8c3, 0xb16b441f, 0x3780a2aa, 0x0a314e76, + 0x4ce37b12, 0x715297ce, 0xc14711da, 0xfcf6fd06, 0xba24c862, + 0x879524be, 0xb77b81cd, 0x8aca6d11, 0xcc185875, 0xf1a9b4a9, + 0x41bc32bd, 0x7c0dde61, 0x3adfeb05, 0x076e07d9, 0x8185e16c, + 0xbc340db0, 0xfae638d4, 0xc757d408, 0x7742521c, 0x4af3bec0, + 0x0c218ba4, 0x31906778, 0xda87408f, 0xe736ac53, 0xa1e49937, + 0x9c5575eb, 0x2c40f3ff, 0x11f11f23, 0x57232a47, 0x6a92c69b, + 0xec79202e, 0xd1c8ccf2, 0x971af996, 0xaaab154a, 0x1abe935e, + 0x270f7f82, 0x61dd4ae6, 0x5c6ca63a, 0xd9040692, 0xe4b5ea4e, + 0xa267df2a, 0x9fd633f6, 0x2fc3b5e2, 0x1272593e, 0x54a06c5a, + 0x69118086, 0xeffa6633, 0xd24b8aef, 0x9499bf8b, 0xa9285357, + 0x193dd543, 0x248c399f, 0x625e0cfb, 0x5fefe027, 0xb4f8c7d0, + 0x89492b0c, 0xcf9b1e68, 0xf22af2b4, 0x423f74a0, 0x7f8e987c, + 0x395cad18, 0x04ed41c4, 0x8206a771, 0xbfb74bad, 0xf9657ec9, + 0xc4d49215, 0x74c11401, 0x4970f8dd, 0x0fa2cdb9, 0x32132165, + 0x02fd8416, 0x3f4c68ca, 0x799e5dae, 0x442fb172, 0xf43a3766, + 0xc98bdbba, 0x8f59eede, 0xb2e80202, 0x3403e4b7, 0x09b2086b, + 0x4f603d0f, 0x72d1d1d3, 0xc2c457c7, 0xff75bb1b, 0xb9a78e7f, + 0x841662a3, 0x6f014554, 0x52b0a988, 0x14629cec, 0x29d37030, + 0x99c6f624, 0xa4771af8, 0xe2a52f9c, 0xdf14c340, 0x59ff25f5, + 0x644ec929, 0x229cfc4d, 0x1f2d1091, 0xaf389685, 0x92897a59, + 0xd45b4f3d, 0xe9eaa3e1, 0xb58605db, 0x8837e907, 0xcee5dc63, + 0xf35430bf, 0x4341b6ab, 0x7ef05a77, 0x38226f13, 0x059383cf, + 0x8378657a, 0xbec989a6, 0xf81bbcc2, 0xc5aa501e, 0x75bfd60a, + 0x480e3ad6, 0x0edc0fb2, 0x336de36e, 0xd87ac499, 0xe5cb2845, + 0xa3191d21, 0x9ea8f1fd, 0x2ebd77e9, 0x130c9b35, 0x55deae51, + 0x686f428d, 0xee84a438, 0xd33548e4, 0x95e77d80, 0xa856915c, + 0x18431748, 0x25f2fb94, 0x6320cef0, 0x5e91222c, 0x6e7f875f, + 0x53ce6b83, 0x151c5ee7, 0x28adb23b, 0x98b8342f, 0xa509d8f3, + 0xe3dbed97, 0xde6a014b, 0x5881e7fe, 0x65300b22, 0x23e23e46, + 0x1e53d29a, 0xae46548e, 0x93f7b852, 0xd5258d36, 0xe89461ea, + 0x0383461d, 0x3e32aac1, 0x78e09fa5, 0x45517379, 0xf544f56d, + 0xc8f519b1, 0x8e272cd5, 0xb396c009, 0x357d26bc, 0x08ccca60, + 0x4e1eff04, 0x73af13d8, 0xc3ba95cc, 0xfe0b7910, 0xb8d94c74, + 0x8568a0a8}, + {0x00000000, 0x69790b65, 0xd2f216ca, 0xbb8b1daf, 0x7e952bd5, + 0x17ec20b0, 0xac673d1f, 0xc51e367a, 0xfd2a57aa, 0x94535ccf, + 0x2fd84160, 0x46a14a05, 0x83bf7c7f, 0xeac6771a, 0x514d6ab5, + 0x383461d0, 0x2125a915, 0x485ca270, 0xf3d7bfdf, 0x9aaeb4ba, + 0x5fb082c0, 0x36c989a5, 0x8d42940a, 0xe43b9f6f, 0xdc0ffebf, + 0xb576f5da, 0x0efde875, 0x6784e310, 0xa29ad56a, 0xcbe3de0f, + 0x7068c3a0, 0x1911c8c5, 0x424b522a, 0x2b32594f, 0x90b944e0, + 0xf9c04f85, 0x3cde79ff, 0x55a7729a, 0xee2c6f35, 0x87556450, + 0xbf610580, 0xd6180ee5, 0x6d93134a, 0x04ea182f, 0xc1f42e55, + 0xa88d2530, 0x1306389f, 0x7a7f33fa, 0x636efb3f, 0x0a17f05a, + 0xb19cedf5, 0xd8e5e690, 0x1dfbd0ea, 0x7482db8f, 0xcf09c620, + 0xa670cd45, 0x9e44ac95, 0xf73da7f0, 0x4cb6ba5f, 0x25cfb13a, + 0xe0d18740, 0x89a88c25, 0x3223918a, 0x5b5a9aef, 0x8496a454, + 0xedefaf31, 0x5664b29e, 0x3f1db9fb, 0xfa038f81, 0x937a84e4, + 0x28f1994b, 0x4188922e, 0x79bcf3fe, 0x10c5f89b, 0xab4ee534, + 0xc237ee51, 0x0729d82b, 0x6e50d34e, 0xd5dbcee1, 0xbca2c584, + 0xa5b30d41, 0xccca0624, 0x77411b8b, 0x1e3810ee, 0xdb262694, + 0xb25f2df1, 0x09d4305e, 0x60ad3b3b, 0x58995aeb, 0x31e0518e, + 0x8a6b4c21, 0xe3124744, 0x260c713e, 0x4f757a5b, 0xf4fe67f4, + 0x9d876c91, 0xc6ddf67e, 0xafa4fd1b, 0x142fe0b4, 0x7d56ebd1, + 0xb848ddab, 0xd131d6ce, 0x6abacb61, 0x03c3c004, 0x3bf7a1d4, + 0x528eaab1, 0xe905b71e, 0x807cbc7b, 0x45628a01, 0x2c1b8164, + 0x97909ccb, 0xfee997ae, 0xe7f85f6b, 0x8e81540e, 0x350a49a1, + 0x5c7342c4, 0x996d74be, 0xf0147fdb, 0x4b9f6274, 0x22e66911, + 0x1ad208c1, 0x73ab03a4, 0xc8201e0b, 0xa159156e, 0x64472314, + 0x0d3e2871, 0xb6b535de, 0xdfcc3ebb, 0xd25c4ee9, 0xbb25458c, + 0x00ae5823, 0x69d75346, 0xacc9653c, 0xc5b06e59, 0x7e3b73f6, + 0x17427893, 0x2f761943, 0x460f1226, 0xfd840f89, 0x94fd04ec, + 0x51e33296, 0x389a39f3, 0x8311245c, 0xea682f39, 0xf379e7fc, + 0x9a00ec99, 0x218bf136, 0x48f2fa53, 0x8deccc29, 0xe495c74c, + 0x5f1edae3, 0x3667d186, 0x0e53b056, 0x672abb33, 0xdca1a69c, + 0xb5d8adf9, 0x70c69b83, 0x19bf90e6, 0xa2348d49, 0xcb4d862c, + 0x90171cc3, 0xf96e17a6, 0x42e50a09, 0x2b9c016c, 0xee823716, + 0x87fb3c73, 0x3c7021dc, 0x55092ab9, 0x6d3d4b69, 0x0444400c, + 0xbfcf5da3, 0xd6b656c6, 0x13a860bc, 0x7ad16bd9, 0xc15a7676, + 0xa8237d13, 0xb132b5d6, 0xd84bbeb3, 0x63c0a31c, 0x0ab9a879, + 0xcfa79e03, 0xa6de9566, 0x1d5588c9, 0x742c83ac, 0x4c18e27c, + 0x2561e919, 0x9eeaf4b6, 0xf793ffd3, 0x328dc9a9, 0x5bf4c2cc, + 0xe07fdf63, 0x8906d406, 0x56caeabd, 0x3fb3e1d8, 0x8438fc77, + 0xed41f712, 0x285fc168, 0x4126ca0d, 0xfaadd7a2, 0x93d4dcc7, + 0xabe0bd17, 0xc299b672, 0x7912abdd, 0x106ba0b8, 0xd57596c2, + 0xbc0c9da7, 0x07878008, 0x6efe8b6d, 0x77ef43a8, 0x1e9648cd, + 0xa51d5562, 0xcc645e07, 0x097a687d, 0x60036318, 0xdb887eb7, + 0xb2f175d2, 0x8ac51402, 0xe3bc1f67, 0x583702c8, 0x314e09ad, + 0xf4503fd7, 0x9d2934b2, 0x26a2291d, 0x4fdb2278, 0x1481b897, + 0x7df8b3f2, 0xc673ae5d, 0xaf0aa538, 0x6a149342, 0x036d9827, + 0xb8e68588, 0xd19f8eed, 0xe9abef3d, 0x80d2e458, 0x3b59f9f7, + 0x5220f292, 0x973ec4e8, 0xfe47cf8d, 0x45ccd222, 0x2cb5d947, + 0x35a41182, 0x5cdd1ae7, 0xe7560748, 0x8e2f0c2d, 0x4b313a57, + 0x22483132, 0x99c32c9d, 0xf0ba27f8, 0xc88e4628, 0xa1f74d4d, + 0x1a7c50e2, 0x73055b87, 0xb61b6dfd, 0xdf626698, 0x64e97b37, + 0x0d907052}, + {0x00000000, 0x7fc99b93, 0xff933726, 0x805aacb5, 0x2457680d, + 0x5b9ef39e, 0xdbc45f2b, 0xa40dc4b8, 0x48aed01a, 0x37674b89, + 0xb73de73c, 0xc8f47caf, 0x6cf9b817, 0x13302384, 0x936a8f31, + 0xeca314a2, 0x915da034, 0xee943ba7, 0x6ece9712, 0x11070c81, + 0xb50ac839, 0xcac353aa, 0x4a99ff1f, 0x3550648c, 0xd9f3702e, + 0xa63aebbd, 0x26604708, 0x59a9dc9b, 0xfda41823, 0x826d83b0, + 0x02372f05, 0x7dfeb496, 0xf9ca4629, 0x8603ddba, 0x0659710f, + 0x7990ea9c, 0xdd9d2e24, 0xa254b5b7, 0x220e1902, 0x5dc78291, + 0xb1649633, 0xcead0da0, 0x4ef7a115, 0x313e3a86, 0x9533fe3e, + 0xeafa65ad, 0x6aa0c918, 0x1569528b, 0x6897e61d, 0x175e7d8e, + 0x9704d13b, 0xe8cd4aa8, 0x4cc08e10, 0x33091583, 0xb353b936, + 0xcc9a22a5, 0x20393607, 0x5ff0ad94, 0xdfaa0121, 0xa0639ab2, + 0x046e5e0a, 0x7ba7c599, 0xfbfd692c, 0x8434f2bf, 0x28e58a13, + 0x572c1180, 0xd776bd35, 0xa8bf26a6, 0x0cb2e21e, 0x737b798d, + 0xf321d538, 0x8ce84eab, 0x604b5a09, 0x1f82c19a, 0x9fd86d2f, + 0xe011f6bc, 0x441c3204, 0x3bd5a997, 0xbb8f0522, 0xc4469eb1, + 0xb9b82a27, 0xc671b1b4, 0x462b1d01, 0x39e28692, 0x9def422a, + 0xe226d9b9, 0x627c750c, 0x1db5ee9f, 0xf116fa3d, 0x8edf61ae, + 0x0e85cd1b, 0x714c5688, 0xd5419230, 0xaa8809a3, 0x2ad2a516, + 0x551b3e85, 0xd12fcc3a, 0xaee657a9, 0x2ebcfb1c, 0x5175608f, + 0xf578a437, 0x8ab13fa4, 0x0aeb9311, 0x75220882, 0x99811c20, + 0xe64887b3, 0x66122b06, 0x19dbb095, 0xbdd6742d, 0xc21fefbe, + 0x4245430b, 0x3d8cd898, 0x40726c0e, 0x3fbbf79d, 0xbfe15b28, + 0xc028c0bb, 0x64250403, 0x1bec9f90, 0x9bb63325, 0xe47fa8b6, + 0x08dcbc14, 0x77152787, 0xf74f8b32, 0x888610a1, 0x2c8bd419, + 0x53424f8a, 0xd318e33f, 0xacd178ac, 0x51cb1426, 0x2e028fb5, + 0xae582300, 0xd191b893, 0x759c7c2b, 0x0a55e7b8, 0x8a0f4b0d, + 0xf5c6d09e, 0x1965c43c, 0x66ac5faf, 0xe6f6f31a, 0x993f6889, + 0x3d32ac31, 0x42fb37a2, 0xc2a19b17, 0xbd680084, 0xc096b412, + 0xbf5f2f81, 0x3f058334, 0x40cc18a7, 0xe4c1dc1f, 0x9b08478c, + 0x1b52eb39, 0x649b70aa, 0x88386408, 0xf7f1ff9b, 0x77ab532e, + 0x0862c8bd, 0xac6f0c05, 0xd3a69796, 0x53fc3b23, 0x2c35a0b0, + 0xa801520f, 0xd7c8c99c, 0x57926529, 0x285bfeba, 0x8c563a02, + 0xf39fa191, 0x73c50d24, 0x0c0c96b7, 0xe0af8215, 0x9f661986, + 0x1f3cb533, 0x60f52ea0, 0xc4f8ea18, 0xbb31718b, 0x3b6bdd3e, + 0x44a246ad, 0x395cf23b, 0x469569a8, 0xc6cfc51d, 0xb9065e8e, + 0x1d0b9a36, 0x62c201a5, 0xe298ad10, 0x9d513683, 0x71f22221, + 0x0e3bb9b2, 0x8e611507, 0xf1a88e94, 0x55a54a2c, 0x2a6cd1bf, + 0xaa367d0a, 0xd5ffe699, 0x792e9e35, 0x06e705a6, 0x86bda913, + 0xf9743280, 0x5d79f638, 0x22b06dab, 0xa2eac11e, 0xdd235a8d, + 0x31804e2f, 0x4e49d5bc, 0xce137909, 0xb1dae29a, 0x15d72622, + 0x6a1ebdb1, 0xea441104, 0x958d8a97, 0xe8733e01, 0x97baa592, + 0x17e00927, 0x682992b4, 0xcc24560c, 0xb3edcd9f, 0x33b7612a, + 0x4c7efab9, 0xa0ddee1b, 0xdf147588, 0x5f4ed93d, 0x208742ae, + 0x848a8616, 0xfb431d85, 0x7b19b130, 0x04d02aa3, 0x80e4d81c, + 0xff2d438f, 0x7f77ef3a, 0x00be74a9, 0xa4b3b011, 0xdb7a2b82, + 0x5b208737, 0x24e91ca4, 0xc84a0806, 0xb7839395, 0x37d93f20, + 0x4810a4b3, 0xec1d600b, 0x93d4fb98, 0x138e572d, 0x6c47ccbe, + 0x11b97828, 0x6e70e3bb, 0xee2a4f0e, 0x91e3d49d, 0x35ee1025, + 0x4a278bb6, 0xca7d2703, 0xb5b4bc90, 0x5917a832, 0x26de33a1, + 0xa6849f14, 0xd94d0487, 0x7d40c03f, 0x02895bac, 0x82d3f719, + 0xfd1a6c8a}, + {0x00000000, 0xa396284c, 0x9c5d56d9, 0x3fcb7e95, 0xe3cbabf3, + 0x405d83bf, 0x7f96fd2a, 0xdc00d566, 0x1ce651a7, 0xbf7079eb, + 0x80bb077e, 0x232d2f32, 0xff2dfa54, 0x5cbbd218, 0x6370ac8d, + 0xc0e684c1, 0x39cca34e, 0x9a5a8b02, 0xa591f597, 0x0607dddb, + 0xda0708bd, 0x799120f1, 0x465a5e64, 0xe5cc7628, 0x252af2e9, + 0x86bcdaa5, 0xb977a430, 0x1ae18c7c, 0xc6e1591a, 0x65777156, + 0x5abc0fc3, 0xf92a278f, 0x7399469c, 0xd00f6ed0, 0xefc41045, + 0x4c523809, 0x9052ed6f, 0x33c4c523, 0x0c0fbbb6, 0xaf9993fa, + 0x6f7f173b, 0xcce93f77, 0xf32241e2, 0x50b469ae, 0x8cb4bcc8, + 0x2f229484, 0x10e9ea11, 0xb37fc25d, 0x4a55e5d2, 0xe9c3cd9e, + 0xd608b30b, 0x759e9b47, 0xa99e4e21, 0x0a08666d, 0x35c318f8, + 0x965530b4, 0x56b3b475, 0xf5259c39, 0xcaeee2ac, 0x6978cae0, + 0xb5781f86, 0x16ee37ca, 0x2925495f, 0x8ab36113, 0xe7328d38, + 0x44a4a574, 0x7b6fdbe1, 0xd8f9f3ad, 0x04f926cb, 0xa76f0e87, + 0x98a47012, 0x3b32585e, 0xfbd4dc9f, 0x5842f4d3, 0x67898a46, + 0xc41fa20a, 0x181f776c, 0xbb895f20, 0x844221b5, 0x27d409f9, + 0xdefe2e76, 0x7d68063a, 0x42a378af, 0xe13550e3, 0x3d358585, + 0x9ea3adc9, 0xa168d35c, 0x02fefb10, 0xc2187fd1, 0x618e579d, + 0x5e452908, 0xfdd30144, 0x21d3d422, 0x8245fc6e, 0xbd8e82fb, + 0x1e18aab7, 0x94abcba4, 0x373de3e8, 0x08f69d7d, 0xab60b531, + 0x77606057, 0xd4f6481b, 0xeb3d368e, 0x48ab1ec2, 0x884d9a03, + 0x2bdbb24f, 0x1410ccda, 0xb786e496, 0x6b8631f0, 0xc81019bc, + 0xf7db6729, 0x544d4f65, 0xad6768ea, 0x0ef140a6, 0x313a3e33, + 0x92ac167f, 0x4eacc319, 0xed3aeb55, 0xd2f195c0, 0x7167bd8c, + 0xb181394d, 0x12171101, 0x2ddc6f94, 0x8e4a47d8, 0x524a92be, + 0xf1dcbaf2, 0xce17c467, 0x6d81ec2b, 0x15141c31, 0xb682347d, + 0x89494ae8, 0x2adf62a4, 0xf6dfb7c2, 0x55499f8e, 0x6a82e11b, + 0xc914c957, 0x09f24d96, 0xaa6465da, 0x95af1b4f, 0x36393303, + 0xea39e665, 0x49afce29, 0x7664b0bc, 0xd5f298f0, 0x2cd8bf7f, + 0x8f4e9733, 0xb085e9a6, 0x1313c1ea, 0xcf13148c, 0x6c853cc0, + 0x534e4255, 0xf0d86a19, 0x303eeed8, 0x93a8c694, 0xac63b801, + 0x0ff5904d, 0xd3f5452b, 0x70636d67, 0x4fa813f2, 0xec3e3bbe, + 0x668d5aad, 0xc51b72e1, 0xfad00c74, 0x59462438, 0x8546f15e, + 0x26d0d912, 0x191ba787, 0xba8d8fcb, 0x7a6b0b0a, 0xd9fd2346, + 0xe6365dd3, 0x45a0759f, 0x99a0a0f9, 0x3a3688b5, 0x05fdf620, + 0xa66bde6c, 0x5f41f9e3, 0xfcd7d1af, 0xc31caf3a, 0x608a8776, + 0xbc8a5210, 0x1f1c7a5c, 0x20d704c9, 0x83412c85, 0x43a7a844, + 0xe0318008, 0xdffafe9d, 0x7c6cd6d1, 0xa06c03b7, 0x03fa2bfb, + 0x3c31556e, 0x9fa77d22, 0xf2269109, 0x51b0b945, 0x6e7bc7d0, + 0xcdedef9c, 0x11ed3afa, 0xb27b12b6, 0x8db06c23, 0x2e26446f, + 0xeec0c0ae, 0x4d56e8e2, 0x729d9677, 0xd10bbe3b, 0x0d0b6b5d, + 0xae9d4311, 0x91563d84, 0x32c015c8, 0xcbea3247, 0x687c1a0b, + 0x57b7649e, 0xf4214cd2, 0x282199b4, 0x8bb7b1f8, 0xb47ccf6d, + 0x17eae721, 0xd70c63e0, 0x749a4bac, 0x4b513539, 0xe8c71d75, + 0x34c7c813, 0x9751e05f, 0xa89a9eca, 0x0b0cb686, 0x81bfd795, + 0x2229ffd9, 0x1de2814c, 0xbe74a900, 0x62747c66, 0xc1e2542a, + 0xfe292abf, 0x5dbf02f3, 0x9d598632, 0x3ecfae7e, 0x0104d0eb, + 0xa292f8a7, 0x7e922dc1, 0xdd04058d, 0xe2cf7b18, 0x41595354, + 0xb87374db, 0x1be55c97, 0x242e2202, 0x87b80a4e, 0x5bb8df28, + 0xf82ef764, 0xc7e589f1, 0x6473a1bd, 0xa495257c, 0x07030d30, + 0x38c873a5, 0x9b5e5be9, 0x475e8e8f, 0xe4c8a6c3, 0xdb03d856, + 0x7895f01a}, + {0x00000000, 0x2a283862, 0x545070c4, 0x7e7848a6, 0xa8a0e188, + 0x8288d9ea, 0xfcf0914c, 0xd6d8a92e, 0x8a30c551, 0xa018fd33, + 0xde60b595, 0xf4488df7, 0x229024d9, 0x08b81cbb, 0x76c0541d, + 0x5ce86c7f, 0xcf108ce3, 0xe538b481, 0x9b40fc27, 0xb168c445, + 0x67b06d6b, 0x4d985509, 0x33e01daf, 0x19c825cd, 0x452049b2, + 0x6f0871d0, 0x11703976, 0x3b580114, 0xed80a83a, 0xc7a89058, + 0xb9d0d8fe, 0x93f8e09c, 0x45501f87, 0x6f7827e5, 0x11006f43, + 0x3b285721, 0xedf0fe0f, 0xc7d8c66d, 0xb9a08ecb, 0x9388b6a9, + 0xcf60dad6, 0xe548e2b4, 0x9b30aa12, 0xb1189270, 0x67c03b5e, + 0x4de8033c, 0x33904b9a, 0x19b873f8, 0x8a409364, 0xa068ab06, + 0xde10e3a0, 0xf438dbc2, 0x22e072ec, 0x08c84a8e, 0x76b00228, + 0x5c983a4a, 0x00705635, 0x2a586e57, 0x542026f1, 0x7e081e93, + 0xa8d0b7bd, 0x82f88fdf, 0xfc80c779, 0xd6a8ff1b, 0x8aa03f0e, + 0xa088076c, 0xdef04fca, 0xf4d877a8, 0x2200de86, 0x0828e6e4, + 0x7650ae42, 0x5c789620, 0x0090fa5f, 0x2ab8c23d, 0x54c08a9b, + 0x7ee8b2f9, 0xa8301bd7, 0x821823b5, 0xfc606b13, 0xd6485371, + 0x45b0b3ed, 0x6f988b8f, 0x11e0c329, 0x3bc8fb4b, 0xed105265, + 0xc7386a07, 0xb94022a1, 0x93681ac3, 0xcf8076bc, 0xe5a84ede, + 0x9bd00678, 0xb1f83e1a, 0x67209734, 0x4d08af56, 0x3370e7f0, + 0x1958df92, 0xcff02089, 0xe5d818eb, 0x9ba0504d, 0xb188682f, + 0x6750c101, 0x4d78f963, 0x3300b1c5, 0x192889a7, 0x45c0e5d8, + 0x6fe8ddba, 0x1190951c, 0x3bb8ad7e, 0xed600450, 0xc7483c32, + 0xb9307494, 0x93184cf6, 0x00e0ac6a, 0x2ac89408, 0x54b0dcae, + 0x7e98e4cc, 0xa8404de2, 0x82687580, 0xfc103d26, 0xd6380544, + 0x8ad0693b, 0xa0f85159, 0xde8019ff, 0xf4a8219d, 0x227088b3, + 0x0858b0d1, 0x7620f877, 0x5c08c015, 0xce31785d, 0xe419403f, + 0x9a610899, 0xb04930fb, 0x669199d5, 0x4cb9a1b7, 0x32c1e911, + 0x18e9d173, 0x4401bd0c, 0x6e29856e, 0x1051cdc8, 0x3a79f5aa, + 0xeca15c84, 0xc68964e6, 0xb8f12c40, 0x92d91422, 0x0121f4be, + 0x2b09ccdc, 0x5571847a, 0x7f59bc18, 0xa9811536, 0x83a92d54, + 0xfdd165f2, 0xd7f95d90, 0x8b1131ef, 0xa139098d, 0xdf41412b, + 0xf5697949, 0x23b1d067, 0x0999e805, 0x77e1a0a3, 0x5dc998c1, + 0x8b6167da, 0xa1495fb8, 0xdf31171e, 0xf5192f7c, 0x23c18652, + 0x09e9be30, 0x7791f696, 0x5db9cef4, 0x0151a28b, 0x2b799ae9, + 0x5501d24f, 0x7f29ea2d, 0xa9f14303, 0x83d97b61, 0xfda133c7, + 0xd7890ba5, 0x4471eb39, 0x6e59d35b, 0x10219bfd, 0x3a09a39f, + 0xecd10ab1, 0xc6f932d3, 0xb8817a75, 0x92a94217, 0xce412e68, + 0xe469160a, 0x9a115eac, 0xb03966ce, 0x66e1cfe0, 0x4cc9f782, + 0x32b1bf24, 0x18998746, 0x44914753, 0x6eb97f31, 0x10c13797, + 0x3ae90ff5, 0xec31a6db, 0xc6199eb9, 0xb861d61f, 0x9249ee7d, + 0xcea18202, 0xe489ba60, 0x9af1f2c6, 0xb0d9caa4, 0x6601638a, + 0x4c295be8, 0x3251134e, 0x18792b2c, 0x8b81cbb0, 0xa1a9f3d2, + 0xdfd1bb74, 0xf5f98316, 0x23212a38, 0x0909125a, 0x77715afc, + 0x5d59629e, 0x01b10ee1, 0x2b993683, 0x55e17e25, 0x7fc94647, + 0xa911ef69, 0x8339d70b, 0xfd419fad, 0xd769a7cf, 0x01c158d4, + 0x2be960b6, 0x55912810, 0x7fb91072, 0xa961b95c, 0x8349813e, + 0xfd31c998, 0xd719f1fa, 0x8bf19d85, 0xa1d9a5e7, 0xdfa1ed41, + 0xf589d523, 0x23517c0d, 0x0979446f, 0x77010cc9, 0x5d2934ab, + 0xced1d437, 0xe4f9ec55, 0x9a81a4f3, 0xb0a99c91, 0x667135bf, + 0x4c590ddd, 0x3221457b, 0x18097d19, 0x44e11166, 0x6ec92904, + 0x10b161a2, 0x3a9959c0, 0xec41f0ee, 0xc669c88c, 0xb811802a, + 0x9239b848}, + {0x00000000, 0x4713f6fb, 0x8e27edf6, 0xc9341b0d, 0xc73eddad, + 0x802d2b56, 0x4919305b, 0x0e0ac6a0, 0x550cbd1b, 0x121f4be0, + 0xdb2b50ed, 0x9c38a616, 0x923260b6, 0xd521964d, 0x1c158d40, + 0x5b067bbb, 0xaa197a36, 0xed0a8ccd, 0x243e97c0, 0x632d613b, + 0x6d27a79b, 0x2a345160, 0xe3004a6d, 0xa413bc96, 0xff15c72d, + 0xb80631d6, 0x71322adb, 0x3621dc20, 0x382b1a80, 0x7f38ec7b, + 0xb60cf776, 0xf11f018d, 0x8f43f22d, 0xc85004d6, 0x01641fdb, + 0x4677e920, 0x487d2f80, 0x0f6ed97b, 0xc65ac276, 0x8149348d, + 0xda4f4f36, 0x9d5cb9cd, 0x5468a2c0, 0x137b543b, 0x1d71929b, + 0x5a626460, 0x93567f6d, 0xd4458996, 0x255a881b, 0x62497ee0, + 0xab7d65ed, 0xec6e9316, 0xe26455b6, 0xa577a34d, 0x6c43b840, + 0x2b504ebb, 0x70563500, 0x3745c3fb, 0xfe71d8f6, 0xb9622e0d, + 0xb768e8ad, 0xf07b1e56, 0x394f055b, 0x7e5cf3a0, 0xc5f6e21b, + 0x82e514e0, 0x4bd10fed, 0x0cc2f916, 0x02c83fb6, 0x45dbc94d, + 0x8cefd240, 0xcbfc24bb, 0x90fa5f00, 0xd7e9a9fb, 0x1eddb2f6, + 0x59ce440d, 0x57c482ad, 0x10d77456, 0xd9e36f5b, 0x9ef099a0, + 0x6fef982d, 0x28fc6ed6, 0xe1c875db, 0xa6db8320, 0xa8d14580, + 0xefc2b37b, 0x26f6a876, 0x61e55e8d, 0x3ae32536, 0x7df0d3cd, + 0xb4c4c8c0, 0xf3d73e3b, 0xfdddf89b, 0xbace0e60, 0x73fa156d, + 0x34e9e396, 0x4ab51036, 0x0da6e6cd, 0xc492fdc0, 0x83810b3b, + 0x8d8bcd9b, 0xca983b60, 0x03ac206d, 0x44bfd696, 0x1fb9ad2d, + 0x58aa5bd6, 0x919e40db, 0xd68db620, 0xd8877080, 0x9f94867b, + 0x56a09d76, 0x11b36b8d, 0xe0ac6a00, 0xa7bf9cfb, 0x6e8b87f6, + 0x2998710d, 0x2792b7ad, 0x60814156, 0xa9b55a5b, 0xeea6aca0, + 0xb5a0d71b, 0xf2b321e0, 0x3b873aed, 0x7c94cc16, 0x729e0ab6, + 0x358dfc4d, 0xfcb9e740, 0xbbaa11bb, 0x509cc277, 0x178f348c, + 0xdebb2f81, 0x99a8d97a, 0x97a21fda, 0xd0b1e921, 0x1985f22c, + 0x5e9604d7, 0x05907f6c, 0x42838997, 0x8bb7929a, 0xcca46461, + 0xc2aea2c1, 0x85bd543a, 0x4c894f37, 0x0b9ab9cc, 0xfa85b841, + 0xbd964eba, 0x74a255b7, 0x33b1a34c, 0x3dbb65ec, 0x7aa89317, + 0xb39c881a, 0xf48f7ee1, 0xaf89055a, 0xe89af3a1, 0x21aee8ac, + 0x66bd1e57, 0x68b7d8f7, 0x2fa42e0c, 0xe6903501, 0xa183c3fa, + 0xdfdf305a, 0x98ccc6a1, 0x51f8ddac, 0x16eb2b57, 0x18e1edf7, + 0x5ff21b0c, 0x96c60001, 0xd1d5f6fa, 0x8ad38d41, 0xcdc07bba, + 0x04f460b7, 0x43e7964c, 0x4ded50ec, 0x0afea617, 0xc3cabd1a, + 0x84d94be1, 0x75c64a6c, 0x32d5bc97, 0xfbe1a79a, 0xbcf25161, + 0xb2f897c1, 0xf5eb613a, 0x3cdf7a37, 0x7bcc8ccc, 0x20caf777, + 0x67d9018c, 0xaeed1a81, 0xe9feec7a, 0xe7f42ada, 0xa0e7dc21, + 0x69d3c72c, 0x2ec031d7, 0x956a206c, 0xd279d697, 0x1b4dcd9a, + 0x5c5e3b61, 0x5254fdc1, 0x15470b3a, 0xdc731037, 0x9b60e6cc, + 0xc0669d77, 0x87756b8c, 0x4e417081, 0x0952867a, 0x075840da, + 0x404bb621, 0x897fad2c, 0xce6c5bd7, 0x3f735a5a, 0x7860aca1, + 0xb154b7ac, 0xf6474157, 0xf84d87f7, 0xbf5e710c, 0x766a6a01, + 0x31799cfa, 0x6a7fe741, 0x2d6c11ba, 0xe4580ab7, 0xa34bfc4c, + 0xad413aec, 0xea52cc17, 0x2366d71a, 0x647521e1, 0x1a29d241, + 0x5d3a24ba, 0x940e3fb7, 0xd31dc94c, 0xdd170fec, 0x9a04f917, + 0x5330e21a, 0x142314e1, 0x4f256f5a, 0x083699a1, 0xc10282ac, + 0x86117457, 0x881bb2f7, 0xcf08440c, 0x063c5f01, 0x412fa9fa, + 0xb030a877, 0xf7235e8c, 0x3e174581, 0x7904b37a, 0x770e75da, + 0x301d8321, 0xf929982c, 0xbe3a6ed7, 0xe53c156c, 0xa22fe397, + 0x6b1bf89a, 0x2c080e61, 0x2202c8c1, 0x65113e3a, 0xac252537, + 0xeb36d3cc}, + {0x00000000, 0xa13984ee, 0x99020f9d, 0x383b8b73, 0xe975197b, + 0x484c9d95, 0x707716e6, 0xd14e9208, 0x099b34b7, 0xa8a2b059, + 0x90993b2a, 0x31a0bfc4, 0xe0ee2dcc, 0x41d7a922, 0x79ec2251, + 0xd8d5a6bf, 0x1336696e, 0xb20fed80, 0x8a3466f3, 0x2b0de21d, + 0xfa437015, 0x5b7af4fb, 0x63417f88, 0xc278fb66, 0x1aad5dd9, + 0xbb94d937, 0x83af5244, 0x2296d6aa, 0xf3d844a2, 0x52e1c04c, + 0x6ada4b3f, 0xcbe3cfd1, 0x266cd2dc, 0x87555632, 0xbf6edd41, + 0x1e5759af, 0xcf19cba7, 0x6e204f49, 0x561bc43a, 0xf72240d4, + 0x2ff7e66b, 0x8ece6285, 0xb6f5e9f6, 0x17cc6d18, 0xc682ff10, + 0x67bb7bfe, 0x5f80f08d, 0xfeb97463, 0x355abbb2, 0x94633f5c, + 0xac58b42f, 0x0d6130c1, 0xdc2fa2c9, 0x7d162627, 0x452dad54, + 0xe41429ba, 0x3cc18f05, 0x9df80beb, 0xa5c38098, 0x04fa0476, + 0xd5b4967e, 0x748d1290, 0x4cb699e3, 0xed8f1d0d, 0x4cd9a5b8, + 0xede02156, 0xd5dbaa25, 0x74e22ecb, 0xa5acbcc3, 0x0495382d, + 0x3caeb35e, 0x9d9737b0, 0x4542910f, 0xe47b15e1, 0xdc409e92, + 0x7d791a7c, 0xac378874, 0x0d0e0c9a, 0x353587e9, 0x940c0307, + 0x5fefccd6, 0xfed64838, 0xc6edc34b, 0x67d447a5, 0xb69ad5ad, + 0x17a35143, 0x2f98da30, 0x8ea15ede, 0x5674f861, 0xf74d7c8f, + 0xcf76f7fc, 0x6e4f7312, 0xbf01e11a, 0x1e3865f4, 0x2603ee87, + 0x873a6a69, 0x6ab57764, 0xcb8cf38a, 0xf3b778f9, 0x528efc17, + 0x83c06e1f, 0x22f9eaf1, 0x1ac26182, 0xbbfbe56c, 0x632e43d3, + 0xc217c73d, 0xfa2c4c4e, 0x5b15c8a0, 0x8a5b5aa8, 0x2b62de46, + 0x13595535, 0xb260d1db, 0x79831e0a, 0xd8ba9ae4, 0xe0811197, + 0x41b89579, 0x90f60771, 0x31cf839f, 0x09f408ec, 0xa8cd8c02, + 0x70182abd, 0xd121ae53, 0xe91a2520, 0x4823a1ce, 0x996d33c6, + 0x3854b728, 0x006f3c5b, 0xa156b8b5, 0x99b34b70, 0x388acf9e, + 0x00b144ed, 0xa188c003, 0x70c6520b, 0xd1ffd6e5, 0xe9c45d96, + 0x48fdd978, 0x90287fc7, 0x3111fb29, 0x092a705a, 0xa813f4b4, + 0x795d66bc, 0xd864e252, 0xe05f6921, 0x4166edcf, 0x8a85221e, + 0x2bbca6f0, 0x13872d83, 0xb2bea96d, 0x63f03b65, 0xc2c9bf8b, + 0xfaf234f8, 0x5bcbb016, 0x831e16a9, 0x22279247, 0x1a1c1934, + 0xbb259dda, 0x6a6b0fd2, 0xcb528b3c, 0xf369004f, 0x525084a1, + 0xbfdf99ac, 0x1ee61d42, 0x26dd9631, 0x87e412df, 0x56aa80d7, + 0xf7930439, 0xcfa88f4a, 0x6e910ba4, 0xb644ad1b, 0x177d29f5, + 0x2f46a286, 0x8e7f2668, 0x5f31b460, 0xfe08308e, 0xc633bbfd, + 0x670a3f13, 0xace9f0c2, 0x0dd0742c, 0x35ebff5f, 0x94d27bb1, + 0x459ce9b9, 0xe4a56d57, 0xdc9ee624, 0x7da762ca, 0xa572c475, + 0x044b409b, 0x3c70cbe8, 0x9d494f06, 0x4c07dd0e, 0xed3e59e0, + 0xd505d293, 0x743c567d, 0xd56aeec8, 0x74536a26, 0x4c68e155, + 0xed5165bb, 0x3c1ff7b3, 0x9d26735d, 0xa51df82e, 0x04247cc0, + 0xdcf1da7f, 0x7dc85e91, 0x45f3d5e2, 0xe4ca510c, 0x3584c304, + 0x94bd47ea, 0xac86cc99, 0x0dbf4877, 0xc65c87a6, 0x67650348, + 0x5f5e883b, 0xfe670cd5, 0x2f299edd, 0x8e101a33, 0xb62b9140, + 0x171215ae, 0xcfc7b311, 0x6efe37ff, 0x56c5bc8c, 0xf7fc3862, + 0x26b2aa6a, 0x878b2e84, 0xbfb0a5f7, 0x1e892119, 0xf3063c14, + 0x523fb8fa, 0x6a043389, 0xcb3db767, 0x1a73256f, 0xbb4aa181, + 0x83712af2, 0x2248ae1c, 0xfa9d08a3, 0x5ba48c4d, 0x639f073e, + 0xc2a683d0, 0x13e811d8, 0xb2d19536, 0x8aea1e45, 0x2bd39aab, + 0xe030557a, 0x4109d194, 0x79325ae7, 0xd80bde09, 0x09454c01, + 0xa87cc8ef, 0x9047439c, 0x317ec772, 0xe9ab61cd, 0x4892e523, + 0x70a96e50, 0xd190eabe, 0x00de78b6, 0xa1e7fc58, 0x99dc772b, + 0x38e5f3c5}, + {0x00000000, 0xe81790a1, 0x0b5e2703, 0xe349b7a2, 0x16bc4e06, + 0xfeabdea7, 0x1de26905, 0xf5f5f9a4, 0x2d789c0c, 0xc56f0cad, + 0x2626bb0f, 0xce312bae, 0x3bc4d20a, 0xd3d342ab, 0x309af509, + 0xd88d65a8, 0x5af13818, 0xb2e6a8b9, 0x51af1f1b, 0xb9b88fba, + 0x4c4d761e, 0xa45ae6bf, 0x4713511d, 0xaf04c1bc, 0x7789a414, + 0x9f9e34b5, 0x7cd78317, 0x94c013b6, 0x6135ea12, 0x89227ab3, + 0x6a6bcd11, 0x827c5db0, 0xb5e27030, 0x5df5e091, 0xbebc5733, + 0x56abc792, 0xa35e3e36, 0x4b49ae97, 0xa8001935, 0x40178994, + 0x989aec3c, 0x708d7c9d, 0x93c4cb3f, 0x7bd35b9e, 0x8e26a23a, + 0x6631329b, 0x85788539, 0x6d6f1598, 0xef134828, 0x0704d889, + 0xe44d6f2b, 0x0c5aff8a, 0xf9af062e, 0x11b8968f, 0xf2f1212d, + 0x1ae6b18c, 0xc26bd424, 0x2a7c4485, 0xc935f327, 0x21226386, + 0xd4d79a22, 0x3cc00a83, 0xdf89bd21, 0x379e2d80, 0xb0b5e621, + 0x58a27680, 0xbbebc122, 0x53fc5183, 0xa609a827, 0x4e1e3886, + 0xad578f24, 0x45401f85, 0x9dcd7a2d, 0x75daea8c, 0x96935d2e, + 0x7e84cd8f, 0x8b71342b, 0x6366a48a, 0x802f1328, 0x68388389, + 0xea44de39, 0x02534e98, 0xe11af93a, 0x090d699b, 0xfcf8903f, + 0x14ef009e, 0xf7a6b73c, 0x1fb1279d, 0xc73c4235, 0x2f2bd294, + 0xcc626536, 0x2475f597, 0xd1800c33, 0x39979c92, 0xdade2b30, + 0x32c9bb91, 0x05579611, 0xed4006b0, 0x0e09b112, 0xe61e21b3, + 0x13ebd817, 0xfbfc48b6, 0x18b5ff14, 0xf0a26fb5, 0x282f0a1d, + 0xc0389abc, 0x23712d1e, 0xcb66bdbf, 0x3e93441b, 0xd684d4ba, + 0x35cd6318, 0xdddaf3b9, 0x5fa6ae09, 0xb7b13ea8, 0x54f8890a, + 0xbcef19ab, 0x491ae00f, 0xa10d70ae, 0x4244c70c, 0xaa5357ad, + 0x72de3205, 0x9ac9a2a4, 0x79801506, 0x919785a7, 0x64627c03, + 0x8c75eca2, 0x6f3c5b00, 0x872bcba1, 0xba1aca03, 0x520d5aa2, + 0xb144ed00, 0x59537da1, 0xaca68405, 0x44b114a4, 0xa7f8a306, + 0x4fef33a7, 0x9762560f, 0x7f75c6ae, 0x9c3c710c, 0x742be1ad, + 0x81de1809, 0x69c988a8, 0x8a803f0a, 0x6297afab, 0xe0ebf21b, + 0x08fc62ba, 0xebb5d518, 0x03a245b9, 0xf657bc1d, 0x1e402cbc, + 0xfd099b1e, 0x151e0bbf, 0xcd936e17, 0x2584feb6, 0xc6cd4914, + 0x2edad9b5, 0xdb2f2011, 0x3338b0b0, 0xd0710712, 0x386697b3, + 0x0ff8ba33, 0xe7ef2a92, 0x04a69d30, 0xecb10d91, 0x1944f435, + 0xf1536494, 0x121ad336, 0xfa0d4397, 0x2280263f, 0xca97b69e, + 0x29de013c, 0xc1c9919d, 0x343c6839, 0xdc2bf898, 0x3f624f3a, + 0xd775df9b, 0x5509822b, 0xbd1e128a, 0x5e57a528, 0xb6403589, + 0x43b5cc2d, 0xaba25c8c, 0x48ebeb2e, 0xa0fc7b8f, 0x78711e27, + 0x90668e86, 0x732f3924, 0x9b38a985, 0x6ecd5021, 0x86dac080, + 0x65937722, 0x8d84e783, 0x0aaf2c22, 0xe2b8bc83, 0x01f10b21, + 0xe9e69b80, 0x1c136224, 0xf404f285, 0x174d4527, 0xff5ad586, + 0x27d7b02e, 0xcfc0208f, 0x2c89972d, 0xc49e078c, 0x316bfe28, + 0xd97c6e89, 0x3a35d92b, 0xd222498a, 0x505e143a, 0xb849849b, + 0x5b003339, 0xb317a398, 0x46e25a3c, 0xaef5ca9d, 0x4dbc7d3f, + 0xa5abed9e, 0x7d268836, 0x95311897, 0x7678af35, 0x9e6f3f94, + 0x6b9ac630, 0x838d5691, 0x60c4e133, 0x88d37192, 0xbf4d5c12, + 0x575accb3, 0xb4137b11, 0x5c04ebb0, 0xa9f11214, 0x41e682b5, + 0xa2af3517, 0x4ab8a5b6, 0x9235c01e, 0x7a2250bf, 0x996be71d, + 0x717c77bc, 0x84898e18, 0x6c9e1eb9, 0x8fd7a91b, 0x67c039ba, + 0xe5bc640a, 0x0dabf4ab, 0xeee24309, 0x06f5d3a8, 0xf3002a0c, + 0x1b17baad, 0xf85e0d0f, 0x10499dae, 0xc8c4f806, 0x20d368a7, + 0xc39adf05, 0x2b8d4fa4, 0xde78b600, 0x366f26a1, 0xd5269103, + 0x3d3101a2}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x0000000000000000, 0xa19017e800000000, 0x03275e0b00000000, + 0xa2b749e300000000, 0x064ebc1600000000, 0xa7deabfe00000000, + 0x0569e21d00000000, 0xa4f9f5f500000000, 0x0c9c782d00000000, + 0xad0c6fc500000000, 0x0fbb262600000000, 0xae2b31ce00000000, + 0x0ad2c43b00000000, 0xab42d3d300000000, 0x09f59a3000000000, + 0xa8658dd800000000, 0x1838f15a00000000, 0xb9a8e6b200000000, + 0x1b1faf5100000000, 0xba8fb8b900000000, 0x1e764d4c00000000, + 0xbfe65aa400000000, 0x1d51134700000000, 0xbcc104af00000000, + 0x14a4897700000000, 0xb5349e9f00000000, 0x1783d77c00000000, + 0xb613c09400000000, 0x12ea356100000000, 0xb37a228900000000, + 0x11cd6b6a00000000, 0xb05d7c8200000000, 0x3070e2b500000000, + 0x91e0f55d00000000, 0x3357bcbe00000000, 0x92c7ab5600000000, + 0x363e5ea300000000, 0x97ae494b00000000, 0x351900a800000000, + 0x9489174000000000, 0x3cec9a9800000000, 0x9d7c8d7000000000, + 0x3fcbc49300000000, 0x9e5bd37b00000000, 0x3aa2268e00000000, + 0x9b32316600000000, 0x3985788500000000, 0x98156f6d00000000, + 0x284813ef00000000, 0x89d8040700000000, 0x2b6f4de400000000, + 0x8aff5a0c00000000, 0x2e06aff900000000, 0x8f96b81100000000, + 0x2d21f1f200000000, 0x8cb1e61a00000000, 0x24d46bc200000000, + 0x85447c2a00000000, 0x27f335c900000000, 0x8663222100000000, + 0x229ad7d400000000, 0x830ac03c00000000, 0x21bd89df00000000, + 0x802d9e3700000000, 0x21e6b5b000000000, 0x8076a25800000000, + 0x22c1ebbb00000000, 0x8351fc5300000000, 0x27a809a600000000, + 0x86381e4e00000000, 0x248f57ad00000000, 0x851f404500000000, + 0x2d7acd9d00000000, 0x8ceada7500000000, 0x2e5d939600000000, + 0x8fcd847e00000000, 0x2b34718b00000000, 0x8aa4666300000000, + 0x28132f8000000000, 0x8983386800000000, 0x39de44ea00000000, + 0x984e530200000000, 0x3af91ae100000000, 0x9b690d0900000000, + 0x3f90f8fc00000000, 0x9e00ef1400000000, 0x3cb7a6f700000000, + 0x9d27b11f00000000, 0x35423cc700000000, 0x94d22b2f00000000, + 0x366562cc00000000, 0x97f5752400000000, 0x330c80d100000000, + 0x929c973900000000, 0x302bdeda00000000, 0x91bbc93200000000, + 0x1196570500000000, 0xb00640ed00000000, 0x12b1090e00000000, + 0xb3211ee600000000, 0x17d8eb1300000000, 0xb648fcfb00000000, + 0x14ffb51800000000, 0xb56fa2f000000000, 0x1d0a2f2800000000, + 0xbc9a38c000000000, 0x1e2d712300000000, 0xbfbd66cb00000000, + 0x1b44933e00000000, 0xbad484d600000000, 0x1863cd3500000000, + 0xb9f3dadd00000000, 0x09aea65f00000000, 0xa83eb1b700000000, + 0x0a89f85400000000, 0xab19efbc00000000, 0x0fe01a4900000000, + 0xae700da100000000, 0x0cc7444200000000, 0xad5753aa00000000, + 0x0532de7200000000, 0xa4a2c99a00000000, 0x0615807900000000, + 0xa785979100000000, 0x037c626400000000, 0xa2ec758c00000000, + 0x005b3c6f00000000, 0xa1cb2b8700000000, 0x03ca1aba00000000, + 0xa25a0d5200000000, 0x00ed44b100000000, 0xa17d535900000000, + 0x0584a6ac00000000, 0xa414b14400000000, 0x06a3f8a700000000, + 0xa733ef4f00000000, 0x0f56629700000000, 0xaec6757f00000000, + 0x0c713c9c00000000, 0xade12b7400000000, 0x0918de8100000000, + 0xa888c96900000000, 0x0a3f808a00000000, 0xabaf976200000000, + 0x1bf2ebe000000000, 0xba62fc0800000000, 0x18d5b5eb00000000, + 0xb945a20300000000, 0x1dbc57f600000000, 0xbc2c401e00000000, + 0x1e9b09fd00000000, 0xbf0b1e1500000000, 0x176e93cd00000000, + 0xb6fe842500000000, 0x1449cdc600000000, 0xb5d9da2e00000000, + 0x11202fdb00000000, 0xb0b0383300000000, 0x120771d000000000, + 0xb397663800000000, 0x33baf80f00000000, 0x922aefe700000000, + 0x309da60400000000, 0x910db1ec00000000, 0x35f4441900000000, + 0x946453f100000000, 0x36d31a1200000000, 0x97430dfa00000000, + 0x3f26802200000000, 0x9eb697ca00000000, 0x3c01de2900000000, + 0x9d91c9c100000000, 0x39683c3400000000, 0x98f82bdc00000000, + 0x3a4f623f00000000, 0x9bdf75d700000000, 0x2b82095500000000, + 0x8a121ebd00000000, 0x28a5575e00000000, 0x893540b600000000, + 0x2dccb54300000000, 0x8c5ca2ab00000000, 0x2eebeb4800000000, + 0x8f7bfca000000000, 0x271e717800000000, 0x868e669000000000, + 0x24392f7300000000, 0x85a9389b00000000, 0x2150cd6e00000000, + 0x80c0da8600000000, 0x2277936500000000, 0x83e7848d00000000, + 0x222caf0a00000000, 0x83bcb8e200000000, 0x210bf10100000000, + 0x809be6e900000000, 0x2462131c00000000, 0x85f204f400000000, + 0x27454d1700000000, 0x86d55aff00000000, 0x2eb0d72700000000, + 0x8f20c0cf00000000, 0x2d97892c00000000, 0x8c079ec400000000, + 0x28fe6b3100000000, 0x896e7cd900000000, 0x2bd9353a00000000, + 0x8a4922d200000000, 0x3a145e5000000000, 0x9b8449b800000000, + 0x3933005b00000000, 0x98a317b300000000, 0x3c5ae24600000000, + 0x9dcaf5ae00000000, 0x3f7dbc4d00000000, 0x9eedaba500000000, + 0x3688267d00000000, 0x9718319500000000, 0x35af787600000000, + 0x943f6f9e00000000, 0x30c69a6b00000000, 0x91568d8300000000, + 0x33e1c46000000000, 0x9271d38800000000, 0x125c4dbf00000000, + 0xb3cc5a5700000000, 0x117b13b400000000, 0xb0eb045c00000000, + 0x1412f1a900000000, 0xb582e64100000000, 0x1735afa200000000, + 0xb6a5b84a00000000, 0x1ec0359200000000, 0xbf50227a00000000, + 0x1de76b9900000000, 0xbc777c7100000000, 0x188e898400000000, + 0xb91e9e6c00000000, 0x1ba9d78f00000000, 0xba39c06700000000, + 0x0a64bce500000000, 0xabf4ab0d00000000, 0x0943e2ee00000000, + 0xa8d3f50600000000, 0x0c2a00f300000000, 0xadba171b00000000, + 0x0f0d5ef800000000, 0xae9d491000000000, 0x06f8c4c800000000, + 0xa768d32000000000, 0x05df9ac300000000, 0xa44f8d2b00000000, + 0x00b678de00000000, 0xa1266f3600000000, 0x039126d500000000, + 0xa201313d00000000}, + {0x0000000000000000, 0xee8439a100000000, 0x9d0f029900000000, + 0x738b3b3800000000, 0x7b1975e900000000, 0x959d4c4800000000, + 0xe616777000000000, 0x08924ed100000000, 0xb7349b0900000000, + 0x59b0a2a800000000, 0x2a3b999000000000, 0xc4bfa03100000000, + 0xcc2deee000000000, 0x22a9d74100000000, 0x5122ec7900000000, + 0xbfa6d5d800000000, 0x6e69361300000000, 0x80ed0fb200000000, + 0xf366348a00000000, 0x1de20d2b00000000, 0x157043fa00000000, + 0xfbf47a5b00000000, 0x887f416300000000, 0x66fb78c200000000, + 0xd95dad1a00000000, 0x37d994bb00000000, 0x4452af8300000000, + 0xaad6962200000000, 0xa244d8f300000000, 0x4cc0e15200000000, + 0x3f4bda6a00000000, 0xd1cfe3cb00000000, 0xdcd26c2600000000, + 0x3256558700000000, 0x41dd6ebf00000000, 0xaf59571e00000000, + 0xa7cb19cf00000000, 0x494f206e00000000, 0x3ac41b5600000000, + 0xd44022f700000000, 0x6be6f72f00000000, 0x8562ce8e00000000, + 0xf6e9f5b600000000, 0x186dcc1700000000, 0x10ff82c600000000, + 0xfe7bbb6700000000, 0x8df0805f00000000, 0x6374b9fe00000000, + 0xb2bb5a3500000000, 0x5c3f639400000000, 0x2fb458ac00000000, + 0xc130610d00000000, 0xc9a22fdc00000000, 0x2726167d00000000, + 0x54ad2d4500000000, 0xba2914e400000000, 0x058fc13c00000000, + 0xeb0bf89d00000000, 0x9880c3a500000000, 0x7604fa0400000000, + 0x7e96b4d500000000, 0x90128d7400000000, 0xe399b64c00000000, + 0x0d1d8fed00000000, 0xb8a5d94c00000000, 0x5621e0ed00000000, + 0x25aadbd500000000, 0xcb2ee27400000000, 0xc3bcaca500000000, + 0x2d38950400000000, 0x5eb3ae3c00000000, 0xb037979d00000000, + 0x0f91424500000000, 0xe1157be400000000, 0x929e40dc00000000, + 0x7c1a797d00000000, 0x748837ac00000000, 0x9a0c0e0d00000000, + 0xe987353500000000, 0x07030c9400000000, 0xd6ccef5f00000000, + 0x3848d6fe00000000, 0x4bc3edc600000000, 0xa547d46700000000, + 0xadd59ab600000000, 0x4351a31700000000, 0x30da982f00000000, + 0xde5ea18e00000000, 0x61f8745600000000, 0x8f7c4df700000000, + 0xfcf776cf00000000, 0x12734f6e00000000, 0x1ae101bf00000000, + 0xf465381e00000000, 0x87ee032600000000, 0x696a3a8700000000, + 0x6477b56a00000000, 0x8af38ccb00000000, 0xf978b7f300000000, + 0x17fc8e5200000000, 0x1f6ec08300000000, 0xf1eaf92200000000, + 0x8261c21a00000000, 0x6ce5fbbb00000000, 0xd3432e6300000000, + 0x3dc717c200000000, 0x4e4c2cfa00000000, 0xa0c8155b00000000, + 0xa85a5b8a00000000, 0x46de622b00000000, 0x3555591300000000, + 0xdbd160b200000000, 0x0a1e837900000000, 0xe49abad800000000, + 0x971181e000000000, 0x7995b84100000000, 0x7107f69000000000, + 0x9f83cf3100000000, 0xec08f40900000000, 0x028ccda800000000, + 0xbd2a187000000000, 0x53ae21d100000000, 0x20251ae900000000, + 0xcea1234800000000, 0xc6336d9900000000, 0x28b7543800000000, + 0x5b3c6f0000000000, 0xb5b856a100000000, 0x704bb39900000000, + 0x9ecf8a3800000000, 0xed44b10000000000, 0x03c088a100000000, + 0x0b52c67000000000, 0xe5d6ffd100000000, 0x965dc4e900000000, + 0x78d9fd4800000000, 0xc77f289000000000, 0x29fb113100000000, + 0x5a702a0900000000, 0xb4f413a800000000, 0xbc665d7900000000, + 0x52e264d800000000, 0x21695fe000000000, 0xcfed664100000000, + 0x1e22858a00000000, 0xf0a6bc2b00000000, 0x832d871300000000, + 0x6da9beb200000000, 0x653bf06300000000, 0x8bbfc9c200000000, + 0xf834f2fa00000000, 0x16b0cb5b00000000, 0xa9161e8300000000, + 0x4792272200000000, 0x34191c1a00000000, 0xda9d25bb00000000, + 0xd20f6b6a00000000, 0x3c8b52cb00000000, 0x4f0069f300000000, + 0xa184505200000000, 0xac99dfbf00000000, 0x421de61e00000000, + 0x3196dd2600000000, 0xdf12e48700000000, 0xd780aa5600000000, + 0x390493f700000000, 0x4a8fa8cf00000000, 0xa40b916e00000000, + 0x1bad44b600000000, 0xf5297d1700000000, 0x86a2462f00000000, + 0x68267f8e00000000, 0x60b4315f00000000, 0x8e3008fe00000000, + 0xfdbb33c600000000, 0x133f0a6700000000, 0xc2f0e9ac00000000, + 0x2c74d00d00000000, 0x5fffeb3500000000, 0xb17bd29400000000, + 0xb9e99c4500000000, 0x576da5e400000000, 0x24e69edc00000000, + 0xca62a77d00000000, 0x75c472a500000000, 0x9b404b0400000000, + 0xe8cb703c00000000, 0x064f499d00000000, 0x0edd074c00000000, + 0xe0593eed00000000, 0x93d205d500000000, 0x7d563c7400000000, + 0xc8ee6ad500000000, 0x266a537400000000, 0x55e1684c00000000, + 0xbb6551ed00000000, 0xb3f71f3c00000000, 0x5d73269d00000000, + 0x2ef81da500000000, 0xc07c240400000000, 0x7fdaf1dc00000000, + 0x915ec87d00000000, 0xe2d5f34500000000, 0x0c51cae400000000, + 0x04c3843500000000, 0xea47bd9400000000, 0x99cc86ac00000000, + 0x7748bf0d00000000, 0xa6875cc600000000, 0x4803656700000000, + 0x3b885e5f00000000, 0xd50c67fe00000000, 0xdd9e292f00000000, + 0x331a108e00000000, 0x40912bb600000000, 0xae15121700000000, + 0x11b3c7cf00000000, 0xff37fe6e00000000, 0x8cbcc55600000000, + 0x6238fcf700000000, 0x6aaab22600000000, 0x842e8b8700000000, + 0xf7a5b0bf00000000, 0x1921891e00000000, 0x143c06f300000000, + 0xfab83f5200000000, 0x8933046a00000000, 0x67b73dcb00000000, + 0x6f25731a00000000, 0x81a14abb00000000, 0xf22a718300000000, + 0x1cae482200000000, 0xa3089dfa00000000, 0x4d8ca45b00000000, + 0x3e079f6300000000, 0xd083a6c200000000, 0xd811e81300000000, + 0x3695d1b200000000, 0x451eea8a00000000, 0xab9ad32b00000000, + 0x7a5530e000000000, 0x94d1094100000000, 0xe75a327900000000, + 0x09de0bd800000000, 0x014c450900000000, 0xefc87ca800000000, + 0x9c43479000000000, 0x72c77e3100000000, 0xcd61abe900000000, + 0x23e5924800000000, 0x506ea97000000000, 0xbeea90d100000000, + 0xb678de0000000000, 0x58fce7a100000000, 0x2b77dc9900000000, + 0xc5f3e53800000000}, + {0x0000000000000000, 0xfbf6134700000000, 0xf6ed278e00000000, + 0x0d1b34c900000000, 0xaddd3ec700000000, 0x562b2d8000000000, + 0x5b30194900000000, 0xa0c60a0e00000000, 0x1bbd0c5500000000, + 0xe04b1f1200000000, 0xed502bdb00000000, 0x16a6389c00000000, + 0xb660329200000000, 0x4d9621d500000000, 0x408d151c00000000, + 0xbb7b065b00000000, 0x367a19aa00000000, 0xcd8c0aed00000000, + 0xc0973e2400000000, 0x3b612d6300000000, 0x9ba7276d00000000, + 0x6051342a00000000, 0x6d4a00e300000000, 0x96bc13a400000000, + 0x2dc715ff00000000, 0xd63106b800000000, 0xdb2a327100000000, + 0x20dc213600000000, 0x801a2b3800000000, 0x7bec387f00000000, + 0x76f70cb600000000, 0x8d011ff100000000, 0x2df2438f00000000, + 0xd60450c800000000, 0xdb1f640100000000, 0x20e9774600000000, + 0x802f7d4800000000, 0x7bd96e0f00000000, 0x76c25ac600000000, + 0x8d34498100000000, 0x364f4fda00000000, 0xcdb95c9d00000000, + 0xc0a2685400000000, 0x3b547b1300000000, 0x9b92711d00000000, + 0x6064625a00000000, 0x6d7f569300000000, 0x968945d400000000, + 0x1b885a2500000000, 0xe07e496200000000, 0xed657dab00000000, + 0x16936eec00000000, 0xb65564e200000000, 0x4da377a500000000, + 0x40b8436c00000000, 0xbb4e502b00000000, 0x0035567000000000, + 0xfbc3453700000000, 0xf6d871fe00000000, 0x0d2e62b900000000, + 0xade868b700000000, 0x561e7bf000000000, 0x5b054f3900000000, + 0xa0f35c7e00000000, 0x1be2f6c500000000, 0xe014e58200000000, + 0xed0fd14b00000000, 0x16f9c20c00000000, 0xb63fc80200000000, + 0x4dc9db4500000000, 0x40d2ef8c00000000, 0xbb24fccb00000000, + 0x005ffa9000000000, 0xfba9e9d700000000, 0xf6b2dd1e00000000, + 0x0d44ce5900000000, 0xad82c45700000000, 0x5674d71000000000, + 0x5b6fe3d900000000, 0xa099f09e00000000, 0x2d98ef6f00000000, + 0xd66efc2800000000, 0xdb75c8e100000000, 0x2083dba600000000, + 0x8045d1a800000000, 0x7bb3c2ef00000000, 0x76a8f62600000000, + 0x8d5ee56100000000, 0x3625e33a00000000, 0xcdd3f07d00000000, + 0xc0c8c4b400000000, 0x3b3ed7f300000000, 0x9bf8ddfd00000000, + 0x600eceba00000000, 0x6d15fa7300000000, 0x96e3e93400000000, + 0x3610b54a00000000, 0xcde6a60d00000000, 0xc0fd92c400000000, + 0x3b0b818300000000, 0x9bcd8b8d00000000, 0x603b98ca00000000, + 0x6d20ac0300000000, 0x96d6bf4400000000, 0x2dadb91f00000000, + 0xd65baa5800000000, 0xdb409e9100000000, 0x20b68dd600000000, + 0x807087d800000000, 0x7b86949f00000000, 0x769da05600000000, + 0x8d6bb31100000000, 0x006aace000000000, 0xfb9cbfa700000000, + 0xf6878b6e00000000, 0x0d71982900000000, 0xadb7922700000000, + 0x5641816000000000, 0x5b5ab5a900000000, 0xa0aca6ee00000000, + 0x1bd7a0b500000000, 0xe021b3f200000000, 0xed3a873b00000000, + 0x16cc947c00000000, 0xb60a9e7200000000, 0x4dfc8d3500000000, + 0x40e7b9fc00000000, 0xbb11aabb00000000, 0x77c29c5000000000, + 0x8c348f1700000000, 0x812fbbde00000000, 0x7ad9a89900000000, + 0xda1fa29700000000, 0x21e9b1d000000000, 0x2cf2851900000000, + 0xd704965e00000000, 0x6c7f900500000000, 0x9789834200000000, + 0x9a92b78b00000000, 0x6164a4cc00000000, 0xc1a2aec200000000, + 0x3a54bd8500000000, 0x374f894c00000000, 0xccb99a0b00000000, + 0x41b885fa00000000, 0xba4e96bd00000000, 0xb755a27400000000, + 0x4ca3b13300000000, 0xec65bb3d00000000, 0x1793a87a00000000, + 0x1a889cb300000000, 0xe17e8ff400000000, 0x5a0589af00000000, + 0xa1f39ae800000000, 0xace8ae2100000000, 0x571ebd6600000000, + 0xf7d8b76800000000, 0x0c2ea42f00000000, 0x013590e600000000, + 0xfac383a100000000, 0x5a30dfdf00000000, 0xa1c6cc9800000000, + 0xacddf85100000000, 0x572beb1600000000, 0xf7ede11800000000, + 0x0c1bf25f00000000, 0x0100c69600000000, 0xfaf6d5d100000000, + 0x418dd38a00000000, 0xba7bc0cd00000000, 0xb760f40400000000, + 0x4c96e74300000000, 0xec50ed4d00000000, 0x17a6fe0a00000000, + 0x1abdcac300000000, 0xe14bd98400000000, 0x6c4ac67500000000, + 0x97bcd53200000000, 0x9aa7e1fb00000000, 0x6151f2bc00000000, + 0xc197f8b200000000, 0x3a61ebf500000000, 0x377adf3c00000000, + 0xcc8ccc7b00000000, 0x77f7ca2000000000, 0x8c01d96700000000, + 0x811aedae00000000, 0x7aecfee900000000, 0xda2af4e700000000, + 0x21dce7a000000000, 0x2cc7d36900000000, 0xd731c02e00000000, + 0x6c206a9500000000, 0x97d679d200000000, 0x9acd4d1b00000000, + 0x613b5e5c00000000, 0xc1fd545200000000, 0x3a0b471500000000, + 0x371073dc00000000, 0xcce6609b00000000, 0x779d66c000000000, + 0x8c6b758700000000, 0x8170414e00000000, 0x7a86520900000000, + 0xda40580700000000, 0x21b64b4000000000, 0x2cad7f8900000000, + 0xd75b6cce00000000, 0x5a5a733f00000000, 0xa1ac607800000000, + 0xacb754b100000000, 0x574147f600000000, 0xf7874df800000000, + 0x0c715ebf00000000, 0x016a6a7600000000, 0xfa9c793100000000, + 0x41e77f6a00000000, 0xba116c2d00000000, 0xb70a58e400000000, + 0x4cfc4ba300000000, 0xec3a41ad00000000, 0x17cc52ea00000000, + 0x1ad7662300000000, 0xe121756400000000, 0x41d2291a00000000, + 0xba243a5d00000000, 0xb73f0e9400000000, 0x4cc91dd300000000, + 0xec0f17dd00000000, 0x17f9049a00000000, 0x1ae2305300000000, + 0xe114231400000000, 0x5a6f254f00000000, 0xa199360800000000, + 0xac8202c100000000, 0x5774118600000000, 0xf7b21b8800000000, + 0x0c4408cf00000000, 0x015f3c0600000000, 0xfaa92f4100000000, + 0x77a830b000000000, 0x8c5e23f700000000, 0x8145173e00000000, + 0x7ab3047900000000, 0xda750e7700000000, 0x21831d3000000000, + 0x2c9829f900000000, 0xd76e3abe00000000, 0x6c153ce500000000, + 0x97e32fa200000000, 0x9af81b6b00000000, 0x610e082c00000000, + 0xc1c8022200000000, 0x3a3e116500000000, 0x372525ac00000000, + 0xccd336eb00000000}, + {0x0000000000000000, 0x6238282a00000000, 0xc470505400000000, + 0xa648787e00000000, 0x88e1a0a800000000, 0xead9888200000000, + 0x4c91f0fc00000000, 0x2ea9d8d600000000, 0x51c5308a00000000, + 0x33fd18a000000000, 0x95b560de00000000, 0xf78d48f400000000, + 0xd924902200000000, 0xbb1cb80800000000, 0x1d54c07600000000, + 0x7f6ce85c00000000, 0xe38c10cf00000000, 0x81b438e500000000, + 0x27fc409b00000000, 0x45c468b100000000, 0x6b6db06700000000, + 0x0955984d00000000, 0xaf1de03300000000, 0xcd25c81900000000, + 0xb249204500000000, 0xd071086f00000000, 0x7639701100000000, + 0x1401583b00000000, 0x3aa880ed00000000, 0x5890a8c700000000, + 0xfed8d0b900000000, 0x9ce0f89300000000, 0x871f504500000000, + 0xe527786f00000000, 0x436f001100000000, 0x2157283b00000000, + 0x0ffef0ed00000000, 0x6dc6d8c700000000, 0xcb8ea0b900000000, + 0xa9b6889300000000, 0xd6da60cf00000000, 0xb4e248e500000000, + 0x12aa309b00000000, 0x709218b100000000, 0x5e3bc06700000000, + 0x3c03e84d00000000, 0x9a4b903300000000, 0xf873b81900000000, + 0x6493408a00000000, 0x06ab68a000000000, 0xa0e310de00000000, + 0xc2db38f400000000, 0xec72e02200000000, 0x8e4ac80800000000, + 0x2802b07600000000, 0x4a3a985c00000000, 0x3556700000000000, + 0x576e582a00000000, 0xf126205400000000, 0x931e087e00000000, + 0xbdb7d0a800000000, 0xdf8ff88200000000, 0x79c780fc00000000, + 0x1bffa8d600000000, 0x0e3fa08a00000000, 0x6c0788a000000000, + 0xca4ff0de00000000, 0xa877d8f400000000, 0x86de002200000000, + 0xe4e6280800000000, 0x42ae507600000000, 0x2096785c00000000, + 0x5ffa900000000000, 0x3dc2b82a00000000, 0x9b8ac05400000000, + 0xf9b2e87e00000000, 0xd71b30a800000000, 0xb523188200000000, + 0x136b60fc00000000, 0x715348d600000000, 0xedb3b04500000000, + 0x8f8b986f00000000, 0x29c3e01100000000, 0x4bfbc83b00000000, + 0x655210ed00000000, 0x076a38c700000000, 0xa12240b900000000, + 0xc31a689300000000, 0xbc7680cf00000000, 0xde4ea8e500000000, + 0x7806d09b00000000, 0x1a3ef8b100000000, 0x3497206700000000, + 0x56af084d00000000, 0xf0e7703300000000, 0x92df581900000000, + 0x8920f0cf00000000, 0xeb18d8e500000000, 0x4d50a09b00000000, + 0x2f6888b100000000, 0x01c1506700000000, 0x63f9784d00000000, + 0xc5b1003300000000, 0xa789281900000000, 0xd8e5c04500000000, + 0xbadde86f00000000, 0x1c95901100000000, 0x7eadb83b00000000, + 0x500460ed00000000, 0x323c48c700000000, 0x947430b900000000, + 0xf64c189300000000, 0x6aace00000000000, 0x0894c82a00000000, + 0xaedcb05400000000, 0xcce4987e00000000, 0xe24d40a800000000, + 0x8075688200000000, 0x263d10fc00000000, 0x440538d600000000, + 0x3b69d08a00000000, 0x5951f8a000000000, 0xff1980de00000000, + 0x9d21a8f400000000, 0xb388702200000000, 0xd1b0580800000000, + 0x77f8207600000000, 0x15c0085c00000000, 0x5d7831ce00000000, + 0x3f4019e400000000, 0x9908619a00000000, 0xfb3049b000000000, + 0xd599916600000000, 0xb7a1b94c00000000, 0x11e9c13200000000, + 0x73d1e91800000000, 0x0cbd014400000000, 0x6e85296e00000000, + 0xc8cd511000000000, 0xaaf5793a00000000, 0x845ca1ec00000000, + 0xe66489c600000000, 0x402cf1b800000000, 0x2214d99200000000, + 0xbef4210100000000, 0xdccc092b00000000, 0x7a84715500000000, + 0x18bc597f00000000, 0x361581a900000000, 0x542da98300000000, + 0xf265d1fd00000000, 0x905df9d700000000, 0xef31118b00000000, + 0x8d0939a100000000, 0x2b4141df00000000, 0x497969f500000000, + 0x67d0b12300000000, 0x05e8990900000000, 0xa3a0e17700000000, + 0xc198c95d00000000, 0xda67618b00000000, 0xb85f49a100000000, + 0x1e1731df00000000, 0x7c2f19f500000000, 0x5286c12300000000, + 0x30bee90900000000, 0x96f6917700000000, 0xf4ceb95d00000000, + 0x8ba2510100000000, 0xe99a792b00000000, 0x4fd2015500000000, + 0x2dea297f00000000, 0x0343f1a900000000, 0x617bd98300000000, + 0xc733a1fd00000000, 0xa50b89d700000000, 0x39eb714400000000, + 0x5bd3596e00000000, 0xfd9b211000000000, 0x9fa3093a00000000, + 0xb10ad1ec00000000, 0xd332f9c600000000, 0x757a81b800000000, + 0x1742a99200000000, 0x682e41ce00000000, 0x0a1669e400000000, + 0xac5e119a00000000, 0xce6639b000000000, 0xe0cfe16600000000, + 0x82f7c94c00000000, 0x24bfb13200000000, 0x4687991800000000, + 0x5347914400000000, 0x317fb96e00000000, 0x9737c11000000000, + 0xf50fe93a00000000, 0xdba631ec00000000, 0xb99e19c600000000, + 0x1fd661b800000000, 0x7dee499200000000, 0x0282a1ce00000000, + 0x60ba89e400000000, 0xc6f2f19a00000000, 0xa4cad9b000000000, + 0x8a63016600000000, 0xe85b294c00000000, 0x4e13513200000000, + 0x2c2b791800000000, 0xb0cb818b00000000, 0xd2f3a9a100000000, + 0x74bbd1df00000000, 0x1683f9f500000000, 0x382a212300000000, + 0x5a12090900000000, 0xfc5a717700000000, 0x9e62595d00000000, + 0xe10eb10100000000, 0x8336992b00000000, 0x257ee15500000000, + 0x4746c97f00000000, 0x69ef11a900000000, 0x0bd7398300000000, + 0xad9f41fd00000000, 0xcfa769d700000000, 0xd458c10100000000, + 0xb660e92b00000000, 0x1028915500000000, 0x7210b97f00000000, + 0x5cb961a900000000, 0x3e81498300000000, 0x98c931fd00000000, + 0xfaf119d700000000, 0x859df18b00000000, 0xe7a5d9a100000000, + 0x41eda1df00000000, 0x23d589f500000000, 0x0d7c512300000000, + 0x6f44790900000000, 0xc90c017700000000, 0xab34295d00000000, + 0x37d4d1ce00000000, 0x55ecf9e400000000, 0xf3a4819a00000000, + 0x919ca9b000000000, 0xbf35716600000000, 0xdd0d594c00000000, + 0x7b45213200000000, 0x197d091800000000, 0x6611e14400000000, + 0x0429c96e00000000, 0xa261b11000000000, 0xc059993a00000000, + 0xeef041ec00000000, 0x8cc869c600000000, 0x2a8011b800000000, + 0x48b8399200000000}, + {0x0000000000000000, 0x4c2896a300000000, 0xd9565d9c00000000, + 0x957ecb3f00000000, 0xf3abcbe300000000, 0xbf835d4000000000, + 0x2afd967f00000000, 0x66d500dc00000000, 0xa751e61c00000000, + 0xeb7970bf00000000, 0x7e07bb8000000000, 0x322f2d2300000000, + 0x54fa2dff00000000, 0x18d2bb5c00000000, 0x8dac706300000000, + 0xc184e6c000000000, 0x4ea3cc3900000000, 0x028b5a9a00000000, + 0x97f591a500000000, 0xdbdd070600000000, 0xbd0807da00000000, + 0xf120917900000000, 0x645e5a4600000000, 0x2876cce500000000, + 0xe9f22a2500000000, 0xa5dabc8600000000, 0x30a477b900000000, + 0x7c8ce11a00000000, 0x1a59e1c600000000, 0x5671776500000000, + 0xc30fbc5a00000000, 0x8f272af900000000, 0x9c46997300000000, + 0xd06e0fd000000000, 0x4510c4ef00000000, 0x0938524c00000000, + 0x6fed529000000000, 0x23c5c43300000000, 0xb6bb0f0c00000000, + 0xfa9399af00000000, 0x3b177f6f00000000, 0x773fe9cc00000000, + 0xe24122f300000000, 0xae69b45000000000, 0xc8bcb48c00000000, + 0x8494222f00000000, 0x11eae91000000000, 0x5dc27fb300000000, + 0xd2e5554a00000000, 0x9ecdc3e900000000, 0x0bb308d600000000, + 0x479b9e7500000000, 0x214e9ea900000000, 0x6d66080a00000000, + 0xf818c33500000000, 0xb430559600000000, 0x75b4b35600000000, + 0x399c25f500000000, 0xace2eeca00000000, 0xe0ca786900000000, + 0x861f78b500000000, 0xca37ee1600000000, 0x5f49252900000000, + 0x1361b38a00000000, 0x388d32e700000000, 0x74a5a44400000000, + 0xe1db6f7b00000000, 0xadf3f9d800000000, 0xcb26f90400000000, + 0x870e6fa700000000, 0x1270a49800000000, 0x5e58323b00000000, + 0x9fdcd4fb00000000, 0xd3f4425800000000, 0x468a896700000000, + 0x0aa21fc400000000, 0x6c771f1800000000, 0x205f89bb00000000, + 0xb521428400000000, 0xf909d42700000000, 0x762efede00000000, + 0x3a06687d00000000, 0xaf78a34200000000, 0xe35035e100000000, + 0x8585353d00000000, 0xc9ada39e00000000, 0x5cd368a100000000, + 0x10fbfe0200000000, 0xd17f18c200000000, 0x9d578e6100000000, + 0x0829455e00000000, 0x4401d3fd00000000, 0x22d4d32100000000, + 0x6efc458200000000, 0xfb828ebd00000000, 0xb7aa181e00000000, + 0xa4cbab9400000000, 0xe8e33d3700000000, 0x7d9df60800000000, + 0x31b560ab00000000, 0x5760607700000000, 0x1b48f6d400000000, + 0x8e363deb00000000, 0xc21eab4800000000, 0x039a4d8800000000, + 0x4fb2db2b00000000, 0xdacc101400000000, 0x96e486b700000000, + 0xf031866b00000000, 0xbc1910c800000000, 0x2967dbf700000000, + 0x654f4d5400000000, 0xea6867ad00000000, 0xa640f10e00000000, + 0x333e3a3100000000, 0x7f16ac9200000000, 0x19c3ac4e00000000, + 0x55eb3aed00000000, 0xc095f1d200000000, 0x8cbd677100000000, + 0x4d3981b100000000, 0x0111171200000000, 0x946fdc2d00000000, + 0xd8474a8e00000000, 0xbe924a5200000000, 0xf2badcf100000000, + 0x67c417ce00000000, 0x2bec816d00000000, 0x311c141500000000, + 0x7d3482b600000000, 0xe84a498900000000, 0xa462df2a00000000, + 0xc2b7dff600000000, 0x8e9f495500000000, 0x1be1826a00000000, + 0x57c914c900000000, 0x964df20900000000, 0xda6564aa00000000, + 0x4f1baf9500000000, 0x0333393600000000, 0x65e639ea00000000, + 0x29ceaf4900000000, 0xbcb0647600000000, 0xf098f2d500000000, + 0x7fbfd82c00000000, 0x33974e8f00000000, 0xa6e985b000000000, + 0xeac1131300000000, 0x8c1413cf00000000, 0xc03c856c00000000, + 0x55424e5300000000, 0x196ad8f000000000, 0xd8ee3e3000000000, + 0x94c6a89300000000, 0x01b863ac00000000, 0x4d90f50f00000000, + 0x2b45f5d300000000, 0x676d637000000000, 0xf213a84f00000000, + 0xbe3b3eec00000000, 0xad5a8d6600000000, 0xe1721bc500000000, + 0x740cd0fa00000000, 0x3824465900000000, 0x5ef1468500000000, + 0x12d9d02600000000, 0x87a71b1900000000, 0xcb8f8dba00000000, + 0x0a0b6b7a00000000, 0x4623fdd900000000, 0xd35d36e600000000, + 0x9f75a04500000000, 0xf9a0a09900000000, 0xb588363a00000000, + 0x20f6fd0500000000, 0x6cde6ba600000000, 0xe3f9415f00000000, + 0xafd1d7fc00000000, 0x3aaf1cc300000000, 0x76878a6000000000, + 0x10528abc00000000, 0x5c7a1c1f00000000, 0xc904d72000000000, + 0x852c418300000000, 0x44a8a74300000000, 0x088031e000000000, + 0x9dfefadf00000000, 0xd1d66c7c00000000, 0xb7036ca000000000, + 0xfb2bfa0300000000, 0x6e55313c00000000, 0x227da79f00000000, + 0x099126f200000000, 0x45b9b05100000000, 0xd0c77b6e00000000, + 0x9cefedcd00000000, 0xfa3aed1100000000, 0xb6127bb200000000, + 0x236cb08d00000000, 0x6f44262e00000000, 0xaec0c0ee00000000, + 0xe2e8564d00000000, 0x77969d7200000000, 0x3bbe0bd100000000, + 0x5d6b0b0d00000000, 0x11439dae00000000, 0x843d569100000000, + 0xc815c03200000000, 0x4732eacb00000000, 0x0b1a7c6800000000, + 0x9e64b75700000000, 0xd24c21f400000000, 0xb499212800000000, + 0xf8b1b78b00000000, 0x6dcf7cb400000000, 0x21e7ea1700000000, + 0xe0630cd700000000, 0xac4b9a7400000000, 0x3935514b00000000, + 0x751dc7e800000000, 0x13c8c73400000000, 0x5fe0519700000000, + 0xca9e9aa800000000, 0x86b60c0b00000000, 0x95d7bf8100000000, + 0xd9ff292200000000, 0x4c81e21d00000000, 0x00a974be00000000, + 0x667c746200000000, 0x2a54e2c100000000, 0xbf2a29fe00000000, + 0xf302bf5d00000000, 0x3286599d00000000, 0x7eaecf3e00000000, + 0xebd0040100000000, 0xa7f892a200000000, 0xc12d927e00000000, + 0x8d0504dd00000000, 0x187bcfe200000000, 0x5453594100000000, + 0xdb7473b800000000, 0x975ce51b00000000, 0x02222e2400000000, + 0x4e0ab88700000000, 0x28dfb85b00000000, 0x64f72ef800000000, + 0xf189e5c700000000, 0xbda1736400000000, 0x7c2595a400000000, + 0x300d030700000000, 0xa573c83800000000, 0xe95b5e9b00000000, + 0x8f8e5e4700000000, 0xc3a6c8e400000000, 0x56d803db00000000, + 0x1af0957800000000}, + {0x0000000000000000, 0x939bc97f00000000, 0x263793ff00000000, + 0xb5ac5a8000000000, 0x0d68572400000000, 0x9ef39e5b00000000, + 0x2b5fc4db00000000, 0xb8c40da400000000, 0x1ad0ae4800000000, + 0x894b673700000000, 0x3ce73db700000000, 0xaf7cf4c800000000, + 0x17b8f96c00000000, 0x8423301300000000, 0x318f6a9300000000, + 0xa214a3ec00000000, 0x34a05d9100000000, 0xa73b94ee00000000, + 0x1297ce6e00000000, 0x810c071100000000, 0x39c80ab500000000, + 0xaa53c3ca00000000, 0x1fff994a00000000, 0x8c64503500000000, + 0x2e70f3d900000000, 0xbdeb3aa600000000, 0x0847602600000000, + 0x9bdca95900000000, 0x2318a4fd00000000, 0xb0836d8200000000, + 0x052f370200000000, 0x96b4fe7d00000000, 0x2946caf900000000, + 0xbadd038600000000, 0x0f71590600000000, 0x9cea907900000000, + 0x242e9ddd00000000, 0xb7b554a200000000, 0x02190e2200000000, + 0x9182c75d00000000, 0x339664b100000000, 0xa00dadce00000000, + 0x15a1f74e00000000, 0x863a3e3100000000, 0x3efe339500000000, + 0xad65faea00000000, 0x18c9a06a00000000, 0x8b52691500000000, + 0x1de6976800000000, 0x8e7d5e1700000000, 0x3bd1049700000000, + 0xa84acde800000000, 0x108ec04c00000000, 0x8315093300000000, + 0x36b953b300000000, 0xa5229acc00000000, 0x0736392000000000, + 0x94adf05f00000000, 0x2101aadf00000000, 0xb29a63a000000000, + 0x0a5e6e0400000000, 0x99c5a77b00000000, 0x2c69fdfb00000000, + 0xbff2348400000000, 0x138ae52800000000, 0x80112c5700000000, + 0x35bd76d700000000, 0xa626bfa800000000, 0x1ee2b20c00000000, + 0x8d797b7300000000, 0x38d521f300000000, 0xab4ee88c00000000, + 0x095a4b6000000000, 0x9ac1821f00000000, 0x2f6dd89f00000000, + 0xbcf611e000000000, 0x04321c4400000000, 0x97a9d53b00000000, + 0x22058fbb00000000, 0xb19e46c400000000, 0x272ab8b900000000, + 0xb4b171c600000000, 0x011d2b4600000000, 0x9286e23900000000, + 0x2a42ef9d00000000, 0xb9d926e200000000, 0x0c757c6200000000, + 0x9feeb51d00000000, 0x3dfa16f100000000, 0xae61df8e00000000, + 0x1bcd850e00000000, 0x88564c7100000000, 0x309241d500000000, + 0xa30988aa00000000, 0x16a5d22a00000000, 0x853e1b5500000000, + 0x3acc2fd100000000, 0xa957e6ae00000000, 0x1cfbbc2e00000000, + 0x8f60755100000000, 0x37a478f500000000, 0xa43fb18a00000000, + 0x1193eb0a00000000, 0x8208227500000000, 0x201c819900000000, + 0xb38748e600000000, 0x062b126600000000, 0x95b0db1900000000, + 0x2d74d6bd00000000, 0xbeef1fc200000000, 0x0b43454200000000, + 0x98d88c3d00000000, 0x0e6c724000000000, 0x9df7bb3f00000000, + 0x285be1bf00000000, 0xbbc028c000000000, 0x0304256400000000, + 0x909fec1b00000000, 0x2533b69b00000000, 0xb6a87fe400000000, + 0x14bcdc0800000000, 0x8727157700000000, 0x328b4ff700000000, + 0xa110868800000000, 0x19d48b2c00000000, 0x8a4f425300000000, + 0x3fe318d300000000, 0xac78d1ac00000000, 0x2614cb5100000000, + 0xb58f022e00000000, 0x002358ae00000000, 0x93b891d100000000, + 0x2b7c9c7500000000, 0xb8e7550a00000000, 0x0d4b0f8a00000000, + 0x9ed0c6f500000000, 0x3cc4651900000000, 0xaf5fac6600000000, + 0x1af3f6e600000000, 0x89683f9900000000, 0x31ac323d00000000, + 0xa237fb4200000000, 0x179ba1c200000000, 0x840068bd00000000, + 0x12b496c000000000, 0x812f5fbf00000000, 0x3483053f00000000, + 0xa718cc4000000000, 0x1fdcc1e400000000, 0x8c47089b00000000, + 0x39eb521b00000000, 0xaa709b6400000000, 0x0864388800000000, + 0x9bfff1f700000000, 0x2e53ab7700000000, 0xbdc8620800000000, + 0x050c6fac00000000, 0x9697a6d300000000, 0x233bfc5300000000, + 0xb0a0352c00000000, 0x0f5201a800000000, 0x9cc9c8d700000000, + 0x2965925700000000, 0xbafe5b2800000000, 0x023a568c00000000, + 0x91a19ff300000000, 0x240dc57300000000, 0xb7960c0c00000000, + 0x1582afe000000000, 0x8619669f00000000, 0x33b53c1f00000000, + 0xa02ef56000000000, 0x18eaf8c400000000, 0x8b7131bb00000000, + 0x3edd6b3b00000000, 0xad46a24400000000, 0x3bf25c3900000000, + 0xa869954600000000, 0x1dc5cfc600000000, 0x8e5e06b900000000, + 0x369a0b1d00000000, 0xa501c26200000000, 0x10ad98e200000000, + 0x8336519d00000000, 0x2122f27100000000, 0xb2b93b0e00000000, + 0x0715618e00000000, 0x948ea8f100000000, 0x2c4aa55500000000, + 0xbfd16c2a00000000, 0x0a7d36aa00000000, 0x99e6ffd500000000, + 0x359e2e7900000000, 0xa605e70600000000, 0x13a9bd8600000000, + 0x803274f900000000, 0x38f6795d00000000, 0xab6db02200000000, + 0x1ec1eaa200000000, 0x8d5a23dd00000000, 0x2f4e803100000000, + 0xbcd5494e00000000, 0x097913ce00000000, 0x9ae2dab100000000, + 0x2226d71500000000, 0xb1bd1e6a00000000, 0x041144ea00000000, + 0x978a8d9500000000, 0x013e73e800000000, 0x92a5ba9700000000, + 0x2709e01700000000, 0xb492296800000000, 0x0c5624cc00000000, + 0x9fcdedb300000000, 0x2a61b73300000000, 0xb9fa7e4c00000000, + 0x1beedda000000000, 0x887514df00000000, 0x3dd94e5f00000000, + 0xae42872000000000, 0x16868a8400000000, 0x851d43fb00000000, + 0x30b1197b00000000, 0xa32ad00400000000, 0x1cd8e48000000000, + 0x8f432dff00000000, 0x3aef777f00000000, 0xa974be0000000000, + 0x11b0b3a400000000, 0x822b7adb00000000, 0x3787205b00000000, + 0xa41ce92400000000, 0x06084ac800000000, 0x959383b700000000, + 0x203fd93700000000, 0xb3a4104800000000, 0x0b601dec00000000, + 0x98fbd49300000000, 0x2d578e1300000000, 0xbecc476c00000000, + 0x2878b91100000000, 0xbbe3706e00000000, 0x0e4f2aee00000000, + 0x9dd4e39100000000, 0x2510ee3500000000, 0xb68b274a00000000, + 0x03277dca00000000, 0x90bcb4b500000000, 0x32a8175900000000, + 0xa133de2600000000, 0x149f84a600000000, 0x87044dd900000000, + 0x3fc0407d00000000, 0xac5b890200000000, 0x19f7d38200000000, + 0x8a6c1afd00000000}, + {0x0000000000000000, 0x650b796900000000, 0xca16f2d200000000, + 0xaf1d8bbb00000000, 0xd52b957e00000000, 0xb020ec1700000000, + 0x1f3d67ac00000000, 0x7a361ec500000000, 0xaa572afd00000000, + 0xcf5c539400000000, 0x6041d82f00000000, 0x054aa14600000000, + 0x7f7cbf8300000000, 0x1a77c6ea00000000, 0xb56a4d5100000000, + 0xd061343800000000, 0x15a9252100000000, 0x70a25c4800000000, + 0xdfbfd7f300000000, 0xbab4ae9a00000000, 0xc082b05f00000000, + 0xa589c93600000000, 0x0a94428d00000000, 0x6f9f3be400000000, + 0xbffe0fdc00000000, 0xdaf576b500000000, 0x75e8fd0e00000000, + 0x10e3846700000000, 0x6ad59aa200000000, 0x0fdee3cb00000000, + 0xa0c3687000000000, 0xc5c8111900000000, 0x2a524b4200000000, + 0x4f59322b00000000, 0xe044b99000000000, 0x854fc0f900000000, + 0xff79de3c00000000, 0x9a72a75500000000, 0x356f2cee00000000, + 0x5064558700000000, 0x800561bf00000000, 0xe50e18d600000000, + 0x4a13936d00000000, 0x2f18ea0400000000, 0x552ef4c100000000, + 0x30258da800000000, 0x9f38061300000000, 0xfa337f7a00000000, + 0x3ffb6e6300000000, 0x5af0170a00000000, 0xf5ed9cb100000000, + 0x90e6e5d800000000, 0xead0fb1d00000000, 0x8fdb827400000000, + 0x20c609cf00000000, 0x45cd70a600000000, 0x95ac449e00000000, + 0xf0a73df700000000, 0x5fbab64c00000000, 0x3ab1cf2500000000, + 0x4087d1e000000000, 0x258ca88900000000, 0x8a91233200000000, + 0xef9a5a5b00000000, 0x54a4968400000000, 0x31afefed00000000, + 0x9eb2645600000000, 0xfbb91d3f00000000, 0x818f03fa00000000, + 0xe4847a9300000000, 0x4b99f12800000000, 0x2e92884100000000, + 0xfef3bc7900000000, 0x9bf8c51000000000, 0x34e54eab00000000, + 0x51ee37c200000000, 0x2bd8290700000000, 0x4ed3506e00000000, + 0xe1cedbd500000000, 0x84c5a2bc00000000, 0x410db3a500000000, + 0x2406cacc00000000, 0x8b1b417700000000, 0xee10381e00000000, + 0x942626db00000000, 0xf12d5fb200000000, 0x5e30d40900000000, + 0x3b3bad6000000000, 0xeb5a995800000000, 0x8e51e03100000000, + 0x214c6b8a00000000, 0x444712e300000000, 0x3e710c2600000000, + 0x5b7a754f00000000, 0xf467fef400000000, 0x916c879d00000000, + 0x7ef6ddc600000000, 0x1bfda4af00000000, 0xb4e02f1400000000, + 0xd1eb567d00000000, 0xabdd48b800000000, 0xced631d100000000, + 0x61cbba6a00000000, 0x04c0c30300000000, 0xd4a1f73b00000000, + 0xb1aa8e5200000000, 0x1eb705e900000000, 0x7bbc7c8000000000, + 0x018a624500000000, 0x64811b2c00000000, 0xcb9c909700000000, + 0xae97e9fe00000000, 0x6b5ff8e700000000, 0x0e54818e00000000, + 0xa1490a3500000000, 0xc442735c00000000, 0xbe746d9900000000, + 0xdb7f14f000000000, 0x74629f4b00000000, 0x1169e62200000000, + 0xc108d21a00000000, 0xa403ab7300000000, 0x0b1e20c800000000, + 0x6e1559a100000000, 0x1423476400000000, 0x71283e0d00000000, + 0xde35b5b600000000, 0xbb3eccdf00000000, 0xe94e5cd200000000, + 0x8c4525bb00000000, 0x2358ae0000000000, 0x4653d76900000000, + 0x3c65c9ac00000000, 0x596eb0c500000000, 0xf6733b7e00000000, + 0x9378421700000000, 0x4319762f00000000, 0x26120f4600000000, + 0x890f84fd00000000, 0xec04fd9400000000, 0x9632e35100000000, + 0xf3399a3800000000, 0x5c24118300000000, 0x392f68ea00000000, + 0xfce779f300000000, 0x99ec009a00000000, 0x36f18b2100000000, + 0x53faf24800000000, 0x29ccec8d00000000, 0x4cc795e400000000, + 0xe3da1e5f00000000, 0x86d1673600000000, 0x56b0530e00000000, + 0x33bb2a6700000000, 0x9ca6a1dc00000000, 0xf9add8b500000000, + 0x839bc67000000000, 0xe690bf1900000000, 0x498d34a200000000, + 0x2c864dcb00000000, 0xc31c179000000000, 0xa6176ef900000000, + 0x090ae54200000000, 0x6c019c2b00000000, 0x163782ee00000000, + 0x733cfb8700000000, 0xdc21703c00000000, 0xb92a095500000000, + 0x694b3d6d00000000, 0x0c40440400000000, 0xa35dcfbf00000000, + 0xc656b6d600000000, 0xbc60a81300000000, 0xd96bd17a00000000, + 0x76765ac100000000, 0x137d23a800000000, 0xd6b532b100000000, + 0xb3be4bd800000000, 0x1ca3c06300000000, 0x79a8b90a00000000, + 0x039ea7cf00000000, 0x6695dea600000000, 0xc988551d00000000, + 0xac832c7400000000, 0x7ce2184c00000000, 0x19e9612500000000, + 0xb6f4ea9e00000000, 0xd3ff93f700000000, 0xa9c98d3200000000, + 0xccc2f45b00000000, 0x63df7fe000000000, 0x06d4068900000000, + 0xbdeaca5600000000, 0xd8e1b33f00000000, 0x77fc388400000000, + 0x12f741ed00000000, 0x68c15f2800000000, 0x0dca264100000000, + 0xa2d7adfa00000000, 0xc7dcd49300000000, 0x17bde0ab00000000, + 0x72b699c200000000, 0xddab127900000000, 0xb8a06b1000000000, + 0xc29675d500000000, 0xa79d0cbc00000000, 0x0880870700000000, + 0x6d8bfe6e00000000, 0xa843ef7700000000, 0xcd48961e00000000, + 0x62551da500000000, 0x075e64cc00000000, 0x7d687a0900000000, + 0x1863036000000000, 0xb77e88db00000000, 0xd275f1b200000000, + 0x0214c58a00000000, 0x671fbce300000000, 0xc802375800000000, + 0xad094e3100000000, 0xd73f50f400000000, 0xb234299d00000000, + 0x1d29a22600000000, 0x7822db4f00000000, 0x97b8811400000000, + 0xf2b3f87d00000000, 0x5dae73c600000000, 0x38a50aaf00000000, + 0x4293146a00000000, 0x27986d0300000000, 0x8885e6b800000000, + 0xed8e9fd100000000, 0x3defabe900000000, 0x58e4d28000000000, + 0xf7f9593b00000000, 0x92f2205200000000, 0xe8c43e9700000000, + 0x8dcf47fe00000000, 0x22d2cc4500000000, 0x47d9b52c00000000, + 0x8211a43500000000, 0xe71add5c00000000, 0x480756e700000000, + 0x2d0c2f8e00000000, 0x573a314b00000000, 0x3231482200000000, + 0x9d2cc39900000000, 0xf827baf000000000, 0x28468ec800000000, + 0x4d4df7a100000000, 0xe2507c1a00000000, 0x875b057300000000, + 0xfd6d1bb600000000, 0x986662df00000000, 0x377be96400000000, + 0x5270900d00000000}, + {0x0000000000000000, 0xdcecb13d00000000, 0xb8d9637b00000000, + 0x6435d24600000000, 0x70b3c7f600000000, 0xac5f76cb00000000, + 0xc86aa48d00000000, 0x148615b000000000, 0xa160fe3600000000, + 0x7d8c4f0b00000000, 0x19b99d4d00000000, 0xc5552c7000000000, + 0xd1d339c000000000, 0x0d3f88fd00000000, 0x690a5abb00000000, + 0xb5e6eb8600000000, 0x42c1fc6d00000000, 0x9e2d4d5000000000, + 0xfa189f1600000000, 0x26f42e2b00000000, 0x32723b9b00000000, + 0xee9e8aa600000000, 0x8aab58e000000000, 0x5647e9dd00000000, + 0xe3a1025b00000000, 0x3f4db36600000000, 0x5b78612000000000, + 0x8794d01d00000000, 0x9312c5ad00000000, 0x4ffe749000000000, + 0x2bcba6d600000000, 0xf72717eb00000000, 0x8482f9db00000000, + 0x586e48e600000000, 0x3c5b9aa000000000, 0xe0b72b9d00000000, + 0xf4313e2d00000000, 0x28dd8f1000000000, 0x4ce85d5600000000, + 0x9004ec6b00000000, 0x25e207ed00000000, 0xf90eb6d000000000, + 0x9d3b649600000000, 0x41d7d5ab00000000, 0x5551c01b00000000, + 0x89bd712600000000, 0xed88a36000000000, 0x3164125d00000000, + 0xc64305b600000000, 0x1aafb48b00000000, 0x7e9a66cd00000000, + 0xa276d7f000000000, 0xb6f0c24000000000, 0x6a1c737d00000000, + 0x0e29a13b00000000, 0xd2c5100600000000, 0x6723fb8000000000, + 0xbbcf4abd00000000, 0xdffa98fb00000000, 0x031629c600000000, + 0x17903c7600000000, 0xcb7c8d4b00000000, 0xaf495f0d00000000, + 0x73a5ee3000000000, 0x4903826c00000000, 0x95ef335100000000, + 0xf1dae11700000000, 0x2d36502a00000000, 0x39b0459a00000000, + 0xe55cf4a700000000, 0x816926e100000000, 0x5d8597dc00000000, + 0xe8637c5a00000000, 0x348fcd6700000000, 0x50ba1f2100000000, + 0x8c56ae1c00000000, 0x98d0bbac00000000, 0x443c0a9100000000, + 0x2009d8d700000000, 0xfce569ea00000000, 0x0bc27e0100000000, + 0xd72ecf3c00000000, 0xb31b1d7a00000000, 0x6ff7ac4700000000, + 0x7b71b9f700000000, 0xa79d08ca00000000, 0xc3a8da8c00000000, + 0x1f446bb100000000, 0xaaa2803700000000, 0x764e310a00000000, + 0x127be34c00000000, 0xce97527100000000, 0xda1147c100000000, + 0x06fdf6fc00000000, 0x62c824ba00000000, 0xbe24958700000000, + 0xcd817bb700000000, 0x116dca8a00000000, 0x755818cc00000000, + 0xa9b4a9f100000000, 0xbd32bc4100000000, 0x61de0d7c00000000, + 0x05ebdf3a00000000, 0xd9076e0700000000, 0x6ce1858100000000, + 0xb00d34bc00000000, 0xd438e6fa00000000, 0x08d457c700000000, + 0x1c52427700000000, 0xc0bef34a00000000, 0xa48b210c00000000, + 0x7867903100000000, 0x8f4087da00000000, 0x53ac36e700000000, + 0x3799e4a100000000, 0xeb75559c00000000, 0xfff3402c00000000, + 0x231ff11100000000, 0x472a235700000000, 0x9bc6926a00000000, + 0x2e2079ec00000000, 0xf2ccc8d100000000, 0x96f91a9700000000, + 0x4a15abaa00000000, 0x5e93be1a00000000, 0x827f0f2700000000, + 0xe64add6100000000, 0x3aa66c5c00000000, 0x920604d900000000, + 0x4eeab5e400000000, 0x2adf67a200000000, 0xf633d69f00000000, + 0xe2b5c32f00000000, 0x3e59721200000000, 0x5a6ca05400000000, + 0x8680116900000000, 0x3366faef00000000, 0xef8a4bd200000000, + 0x8bbf999400000000, 0x575328a900000000, 0x43d53d1900000000, + 0x9f398c2400000000, 0xfb0c5e6200000000, 0x27e0ef5f00000000, + 0xd0c7f8b400000000, 0x0c2b498900000000, 0x681e9bcf00000000, + 0xb4f22af200000000, 0xa0743f4200000000, 0x7c988e7f00000000, + 0x18ad5c3900000000, 0xc441ed0400000000, 0x71a7068200000000, + 0xad4bb7bf00000000, 0xc97e65f900000000, 0x1592d4c400000000, + 0x0114c17400000000, 0xddf8704900000000, 0xb9cda20f00000000, + 0x6521133200000000, 0x1684fd0200000000, 0xca684c3f00000000, + 0xae5d9e7900000000, 0x72b12f4400000000, 0x66373af400000000, + 0xbadb8bc900000000, 0xdeee598f00000000, 0x0202e8b200000000, + 0xb7e4033400000000, 0x6b08b20900000000, 0x0f3d604f00000000, + 0xd3d1d17200000000, 0xc757c4c200000000, 0x1bbb75ff00000000, + 0x7f8ea7b900000000, 0xa362168400000000, 0x5445016f00000000, + 0x88a9b05200000000, 0xec9c621400000000, 0x3070d32900000000, + 0x24f6c69900000000, 0xf81a77a400000000, 0x9c2fa5e200000000, + 0x40c314df00000000, 0xf525ff5900000000, 0x29c94e6400000000, + 0x4dfc9c2200000000, 0x91102d1f00000000, 0x859638af00000000, + 0x597a899200000000, 0x3d4f5bd400000000, 0xe1a3eae900000000, + 0xdb0586b500000000, 0x07e9378800000000, 0x63dce5ce00000000, + 0xbf3054f300000000, 0xabb6414300000000, 0x775af07e00000000, + 0x136f223800000000, 0xcf83930500000000, 0x7a65788300000000, + 0xa689c9be00000000, 0xc2bc1bf800000000, 0x1e50aac500000000, + 0x0ad6bf7500000000, 0xd63a0e4800000000, 0xb20fdc0e00000000, + 0x6ee36d3300000000, 0x99c47ad800000000, 0x4528cbe500000000, + 0x211d19a300000000, 0xfdf1a89e00000000, 0xe977bd2e00000000, + 0x359b0c1300000000, 0x51aede5500000000, 0x8d426f6800000000, + 0x38a484ee00000000, 0xe44835d300000000, 0x807de79500000000, + 0x5c9156a800000000, 0x4817431800000000, 0x94fbf22500000000, + 0xf0ce206300000000, 0x2c22915e00000000, 0x5f877f6e00000000, + 0x836bce5300000000, 0xe75e1c1500000000, 0x3bb2ad2800000000, + 0x2f34b89800000000, 0xf3d809a500000000, 0x97eddbe300000000, + 0x4b016ade00000000, 0xfee7815800000000, 0x220b306500000000, + 0x463ee22300000000, 0x9ad2531e00000000, 0x8e5446ae00000000, + 0x52b8f79300000000, 0x368d25d500000000, 0xea6194e800000000, + 0x1d46830300000000, 0xc1aa323e00000000, 0xa59fe07800000000, + 0x7973514500000000, 0x6df544f500000000, 0xb119f5c800000000, + 0xd52c278e00000000, 0x09c096b300000000, 0xbc267d3500000000, + 0x60cacc0800000000, 0x04ff1e4e00000000, 0xd813af7300000000, + 0xcc95bac300000000, 0x10790bfe00000000, 0x744cd9b800000000, + 0xa8a0688500000000}}; + +#else /* W == 4 */ + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0x81256527, 0xd93bcc0f, 0x581ea928, 0x69069e5f, + 0xe823fb78, 0xb03d5250, 0x31183777, 0xd20d3cbe, 0x53285999, + 0x0b36f0b1, 0x8a139596, 0xbb0ba2e1, 0x3a2ec7c6, 0x62306eee, + 0xe3150bc9, 0x7f6b7f3d, 0xfe4e1a1a, 0xa650b332, 0x2775d615, + 0x166de162, 0x97488445, 0xcf562d6d, 0x4e73484a, 0xad664383, + 0x2c4326a4, 0x745d8f8c, 0xf578eaab, 0xc460dddc, 0x4545b8fb, + 0x1d5b11d3, 0x9c7e74f4, 0xfed6fe7a, 0x7ff39b5d, 0x27ed3275, + 0xa6c85752, 0x97d06025, 0x16f50502, 0x4eebac2a, 0xcfcec90d, + 0x2cdbc2c4, 0xadfea7e3, 0xf5e00ecb, 0x74c56bec, 0x45dd5c9b, + 0xc4f839bc, 0x9ce69094, 0x1dc3f5b3, 0x81bd8147, 0x0098e460, + 0x58864d48, 0xd9a3286f, 0xe8bb1f18, 0x699e7a3f, 0x3180d317, + 0xb0a5b630, 0x53b0bdf9, 0xd295d8de, 0x8a8b71f6, 0x0bae14d1, + 0x3ab623a6, 0xbb934681, 0xe38defa9, 0x62a88a8e, 0x26dcfab5, + 0xa7f99f92, 0xffe736ba, 0x7ec2539d, 0x4fda64ea, 0xceff01cd, + 0x96e1a8e5, 0x17c4cdc2, 0xf4d1c60b, 0x75f4a32c, 0x2dea0a04, + 0xaccf6f23, 0x9dd75854, 0x1cf23d73, 0x44ec945b, 0xc5c9f17c, + 0x59b78588, 0xd892e0af, 0x808c4987, 0x01a92ca0, 0x30b11bd7, + 0xb1947ef0, 0xe98ad7d8, 0x68afb2ff, 0x8bbab936, 0x0a9fdc11, + 0x52817539, 0xd3a4101e, 0xe2bc2769, 0x6399424e, 0x3b87eb66, + 0xbaa28e41, 0xd80a04cf, 0x592f61e8, 0x0131c8c0, 0x8014ade7, + 0xb10c9a90, 0x3029ffb7, 0x6837569f, 0xe91233b8, 0x0a073871, + 0x8b225d56, 0xd33cf47e, 0x52199159, 0x6301a62e, 0xe224c309, + 0xba3a6a21, 0x3b1f0f06, 0xa7617bf2, 0x26441ed5, 0x7e5ab7fd, + 0xff7fd2da, 0xce67e5ad, 0x4f42808a, 0x175c29a2, 0x96794c85, + 0x756c474c, 0xf449226b, 0xac578b43, 0x2d72ee64, 0x1c6ad913, + 0x9d4fbc34, 0xc551151c, 0x4474703b, 0x4db9f56a, 0xcc9c904d, + 0x94823965, 0x15a75c42, 0x24bf6b35, 0xa59a0e12, 0xfd84a73a, + 0x7ca1c21d, 0x9fb4c9d4, 0x1e91acf3, 0x468f05db, 0xc7aa60fc, + 0xf6b2578b, 0x779732ac, 0x2f899b84, 0xaeacfea3, 0x32d28a57, + 0xb3f7ef70, 0xebe94658, 0x6acc237f, 0x5bd41408, 0xdaf1712f, + 0x82efd807, 0x03cabd20, 0xe0dfb6e9, 0x61fad3ce, 0x39e47ae6, + 0xb8c11fc1, 0x89d928b6, 0x08fc4d91, 0x50e2e4b9, 0xd1c7819e, + 0xb36f0b10, 0x324a6e37, 0x6a54c71f, 0xeb71a238, 0xda69954f, + 0x5b4cf068, 0x03525940, 0x82773c67, 0x616237ae, 0xe0475289, + 0xb859fba1, 0x397c9e86, 0x0864a9f1, 0x8941ccd6, 0xd15f65fe, + 0x507a00d9, 0xcc04742d, 0x4d21110a, 0x153fb822, 0x941add05, + 0xa502ea72, 0x24278f55, 0x7c39267d, 0xfd1c435a, 0x1e094893, + 0x9f2c2db4, 0xc732849c, 0x4617e1bb, 0x770fd6cc, 0xf62ab3eb, + 0xae341ac3, 0x2f117fe4, 0x6b650fdf, 0xea406af8, 0xb25ec3d0, + 0x337ba6f7, 0x02639180, 0x8346f4a7, 0xdb585d8f, 0x5a7d38a8, + 0xb9683361, 0x384d5646, 0x6053ff6e, 0xe1769a49, 0xd06ead3e, + 0x514bc819, 0x09556131, 0x88700416, 0x140e70e2, 0x952b15c5, + 0xcd35bced, 0x4c10d9ca, 0x7d08eebd, 0xfc2d8b9a, 0xa43322b2, + 0x25164795, 0xc6034c5c, 0x4726297b, 0x1f388053, 0x9e1de574, + 0xaf05d203, 0x2e20b724, 0x763e1e0c, 0xf71b7b2b, 0x95b3f1a5, + 0x14969482, 0x4c883daa, 0xcdad588d, 0xfcb56ffa, 0x7d900add, + 0x258ea3f5, 0xa4abc6d2, 0x47becd1b, 0xc69ba83c, 0x9e850114, + 0x1fa06433, 0x2eb85344, 0xaf9d3663, 0xf7839f4b, 0x76a6fa6c, + 0xead88e98, 0x6bfdebbf, 0x33e34297, 0xb2c627b0, 0x83de10c7, + 0x02fb75e0, 0x5ae5dcc8, 0xdbc0b9ef, 0x38d5b226, 0xb9f0d701, + 0xe1ee7e29, 0x60cb1b0e, 0x51d32c79, 0xd0f6495e, 0x88e8e076, + 0x09cd8551}, + {0x00000000, 0x9b73ead4, 0xed96d3e9, 0x76e5393d, 0x005ca193, + 0x9b2f4b47, 0xedca727a, 0x76b998ae, 0x00b94326, 0x9bcaa9f2, + 0xed2f90cf, 0x765c7a1b, 0x00e5e2b5, 0x9b960861, 0xed73315c, + 0x7600db88, 0x0172864c, 0x9a016c98, 0xece455a5, 0x7797bf71, + 0x012e27df, 0x9a5dcd0b, 0xecb8f436, 0x77cb1ee2, 0x01cbc56a, + 0x9ab82fbe, 0xec5d1683, 0x772efc57, 0x019764f9, 0x9ae48e2d, + 0xec01b710, 0x77725dc4, 0x02e50c98, 0x9996e64c, 0xef73df71, + 0x740035a5, 0x02b9ad0b, 0x99ca47df, 0xef2f7ee2, 0x745c9436, + 0x025c4fbe, 0x992fa56a, 0xefca9c57, 0x74b97683, 0x0200ee2d, + 0x997304f9, 0xef963dc4, 0x74e5d710, 0x03978ad4, 0x98e46000, + 0xee01593d, 0x7572b3e9, 0x03cb2b47, 0x98b8c193, 0xee5df8ae, + 0x752e127a, 0x032ec9f2, 0x985d2326, 0xeeb81a1b, 0x75cbf0cf, + 0x03726861, 0x980182b5, 0xeee4bb88, 0x7597515c, 0x05ca1930, + 0x9eb9f3e4, 0xe85ccad9, 0x732f200d, 0x0596b8a3, 0x9ee55277, + 0xe8006b4a, 0x7373819e, 0x05735a16, 0x9e00b0c2, 0xe8e589ff, + 0x7396632b, 0x052ffb85, 0x9e5c1151, 0xe8b9286c, 0x73cac2b8, + 0x04b89f7c, 0x9fcb75a8, 0xe92e4c95, 0x725da641, 0x04e43eef, + 0x9f97d43b, 0xe972ed06, 0x720107d2, 0x0401dc5a, 0x9f72368e, + 0xe9970fb3, 0x72e4e567, 0x045d7dc9, 0x9f2e971d, 0xe9cbae20, + 0x72b844f4, 0x072f15a8, 0x9c5cff7c, 0xeab9c641, 0x71ca2c95, + 0x0773b43b, 0x9c005eef, 0xeae567d2, 0x71968d06, 0x0796568e, + 0x9ce5bc5a, 0xea008567, 0x71736fb3, 0x07caf71d, 0x9cb91dc9, + 0xea5c24f4, 0x712fce20, 0x065d93e4, 0x9d2e7930, 0xebcb400d, + 0x70b8aad9, 0x06013277, 0x9d72d8a3, 0xeb97e19e, 0x70e40b4a, + 0x06e4d0c2, 0x9d973a16, 0xeb72032b, 0x7001e9ff, 0x06b87151, + 0x9dcb9b85, 0xeb2ea2b8, 0x705d486c, 0x0b943260, 0x90e7d8b4, + 0xe602e189, 0x7d710b5d, 0x0bc893f3, 0x90bb7927, 0xe65e401a, + 0x7d2daace, 0x0b2d7146, 0x905e9b92, 0xe6bba2af, 0x7dc8487b, + 0x0b71d0d5, 0x90023a01, 0xe6e7033c, 0x7d94e9e8, 0x0ae6b42c, + 0x91955ef8, 0xe77067c5, 0x7c038d11, 0x0aba15bf, 0x91c9ff6b, + 0xe72cc656, 0x7c5f2c82, 0x0a5ff70a, 0x912c1dde, 0xe7c924e3, + 0x7cbace37, 0x0a035699, 0x9170bc4d, 0xe7958570, 0x7ce66fa4, + 0x09713ef8, 0x9202d42c, 0xe4e7ed11, 0x7f9407c5, 0x092d9f6b, + 0x925e75bf, 0xe4bb4c82, 0x7fc8a656, 0x09c87dde, 0x92bb970a, + 0xe45eae37, 0x7f2d44e3, 0x0994dc4d, 0x92e73699, 0xe4020fa4, + 0x7f71e570, 0x0803b8b4, 0x93705260, 0xe5956b5d, 0x7ee68189, + 0x085f1927, 0x932cf3f3, 0xe5c9cace, 0x7eba201a, 0x08bafb92, + 0x93c91146, 0xe52c287b, 0x7e5fc2af, 0x08e65a01, 0x9395b0d5, + 0xe57089e8, 0x7e03633c, 0x0e5e2b50, 0x952dc184, 0xe3c8f8b9, + 0x78bb126d, 0x0e028ac3, 0x95716017, 0xe394592a, 0x78e7b3fe, + 0x0ee76876, 0x959482a2, 0xe371bb9f, 0x7802514b, 0x0ebbc9e5, + 0x95c82331, 0xe32d1a0c, 0x785ef0d8, 0x0f2cad1c, 0x945f47c8, + 0xe2ba7ef5, 0x79c99421, 0x0f700c8f, 0x9403e65b, 0xe2e6df66, + 0x799535b2, 0x0f95ee3a, 0x94e604ee, 0xe2033dd3, 0x7970d707, + 0x0fc94fa9, 0x94baa57d, 0xe25f9c40, 0x792c7694, 0x0cbb27c8, + 0x97c8cd1c, 0xe12df421, 0x7a5e1ef5, 0x0ce7865b, 0x97946c8f, + 0xe17155b2, 0x7a02bf66, 0x0c0264ee, 0x97718e3a, 0xe194b707, + 0x7ae75dd3, 0x0c5ec57d, 0x972d2fa9, 0xe1c81694, 0x7abbfc40, + 0x0dc9a184, 0x96ba4b50, 0xe05f726d, 0x7b2c98b9, 0x0d950017, + 0x96e6eac3, 0xe003d3fe, 0x7b70392a, 0x0d70e2a2, 0x96030876, + 0xe0e6314b, 0x7b95db9f, 0x0d2c4331, 0x965fa9e5, 0xe0ba90d8, + 0x7bc97a0c}, + {0x00000000, 0x172864c0, 0x2e50c980, 0x3978ad40, 0x5ca19300, + 0x4b89f7c0, 0x72f15a80, 0x65d93e40, 0xb9432600, 0xae6b42c0, + 0x9713ef80, 0x803b8b40, 0xe5e2b500, 0xf2cad1c0, 0xcbb27c80, + 0xdc9a1840, 0xa9f74a41, 0xbedf2e81, 0x87a783c1, 0x908fe701, + 0xf556d941, 0xe27ebd81, 0xdb0610c1, 0xcc2e7401, 0x10b46c41, + 0x079c0881, 0x3ee4a5c1, 0x29ccc101, 0x4c15ff41, 0x5b3d9b81, + 0x624536c1, 0x756d5201, 0x889f92c3, 0x9fb7f603, 0xa6cf5b43, + 0xb1e73f83, 0xd43e01c3, 0xc3166503, 0xfa6ec843, 0xed46ac83, + 0x31dcb4c3, 0x26f4d003, 0x1f8c7d43, 0x08a41983, 0x6d7d27c3, + 0x7a554303, 0x432dee43, 0x54058a83, 0x2168d882, 0x3640bc42, + 0x0f381102, 0x181075c2, 0x7dc94b82, 0x6ae12f42, 0x53998202, + 0x44b1e6c2, 0x982bfe82, 0x8f039a42, 0xb67b3702, 0xa15353c2, + 0xc48a6d82, 0xd3a20942, 0xeadaa402, 0xfdf2c0c2, 0xca4e23c7, + 0xdd664707, 0xe41eea47, 0xf3368e87, 0x96efb0c7, 0x81c7d407, + 0xb8bf7947, 0xaf971d87, 0x730d05c7, 0x64256107, 0x5d5dcc47, + 0x4a75a887, 0x2fac96c7, 0x3884f207, 0x01fc5f47, 0x16d43b87, + 0x63b96986, 0x74910d46, 0x4de9a006, 0x5ac1c4c6, 0x3f18fa86, + 0x28309e46, 0x11483306, 0x066057c6, 0xdafa4f86, 0xcdd22b46, + 0xf4aa8606, 0xe382e2c6, 0x865bdc86, 0x9173b846, 0xa80b1506, + 0xbf2371c6, 0x42d1b104, 0x55f9d5c4, 0x6c817884, 0x7ba91c44, + 0x1e702204, 0x095846c4, 0x3020eb84, 0x27088f44, 0xfb929704, + 0xecbaf3c4, 0xd5c25e84, 0xc2ea3a44, 0xa7330404, 0xb01b60c4, + 0x8963cd84, 0x9e4ba944, 0xeb26fb45, 0xfc0e9f85, 0xc57632c5, + 0xd25e5605, 0xb7876845, 0xa0af0c85, 0x99d7a1c5, 0x8effc505, + 0x5265dd45, 0x454db985, 0x7c3514c5, 0x6b1d7005, 0x0ec44e45, + 0x19ec2a85, 0x209487c5, 0x37bce305, 0x4fed41cf, 0x58c5250f, + 0x61bd884f, 0x7695ec8f, 0x134cd2cf, 0x0464b60f, 0x3d1c1b4f, + 0x2a347f8f, 0xf6ae67cf, 0xe186030f, 0xd8feae4f, 0xcfd6ca8f, + 0xaa0ff4cf, 0xbd27900f, 0x845f3d4f, 0x9377598f, 0xe61a0b8e, + 0xf1326f4e, 0xc84ac20e, 0xdf62a6ce, 0xbabb988e, 0xad93fc4e, + 0x94eb510e, 0x83c335ce, 0x5f592d8e, 0x4871494e, 0x7109e40e, + 0x662180ce, 0x03f8be8e, 0x14d0da4e, 0x2da8770e, 0x3a8013ce, + 0xc772d30c, 0xd05ab7cc, 0xe9221a8c, 0xfe0a7e4c, 0x9bd3400c, + 0x8cfb24cc, 0xb583898c, 0xa2abed4c, 0x7e31f50c, 0x691991cc, + 0x50613c8c, 0x4749584c, 0x2290660c, 0x35b802cc, 0x0cc0af8c, + 0x1be8cb4c, 0x6e85994d, 0x79adfd8d, 0x40d550cd, 0x57fd340d, + 0x32240a4d, 0x250c6e8d, 0x1c74c3cd, 0x0b5ca70d, 0xd7c6bf4d, + 0xc0eedb8d, 0xf99676cd, 0xeebe120d, 0x8b672c4d, 0x9c4f488d, + 0xa537e5cd, 0xb21f810d, 0x85a36208, 0x928b06c8, 0xabf3ab88, + 0xbcdbcf48, 0xd902f108, 0xce2a95c8, 0xf7523888, 0xe07a5c48, + 0x3ce04408, 0x2bc820c8, 0x12b08d88, 0x0598e948, 0x6041d708, + 0x7769b3c8, 0x4e111e88, 0x59397a48, 0x2c542849, 0x3b7c4c89, + 0x0204e1c9, 0x152c8509, 0x70f5bb49, 0x67dddf89, 0x5ea572c9, + 0x498d1609, 0x95170e49, 0x823f6a89, 0xbb47c7c9, 0xac6fa309, + 0xc9b69d49, 0xde9ef989, 0xe7e654c9, 0xf0ce3009, 0x0d3cf0cb, + 0x1a14940b, 0x236c394b, 0x34445d8b, 0x519d63cb, 0x46b5070b, + 0x7fcdaa4b, 0x68e5ce8b, 0xb47fd6cb, 0xa357b20b, 0x9a2f1f4b, + 0x8d077b8b, 0xe8de45cb, 0xfff6210b, 0xc68e8c4b, 0xd1a6e88b, + 0xa4cbba8a, 0xb3e3de4a, 0x8a9b730a, 0x9db317ca, 0xf86a298a, + 0xef424d4a, 0xd63ae00a, 0xc11284ca, 0x1d889c8a, 0x0aa0f84a, + 0x33d8550a, 0x24f031ca, 0x41290f8a, 0x56016b4a, 0x6f79c60a, + 0x7851a2ca}, + {0x00000000, 0x9fda839e, 0xe4c4017d, 0x7b1e82e3, 0x12f904bb, + 0x8d238725, 0xf63d05c6, 0x69e78658, 0x25f20976, 0xba288ae8, + 0xc136080b, 0x5eec8b95, 0x370b0dcd, 0xa8d18e53, 0xd3cf0cb0, + 0x4c158f2e, 0x4be412ec, 0xd43e9172, 0xaf201391, 0x30fa900f, + 0x591d1657, 0xc6c795c9, 0xbdd9172a, 0x220394b4, 0x6e161b9a, + 0xf1cc9804, 0x8ad21ae7, 0x15089979, 0x7cef1f21, 0xe3359cbf, + 0x982b1e5c, 0x07f19dc2, 0x97c825d8, 0x0812a646, 0x730c24a5, + 0xecd6a73b, 0x85312163, 0x1aeba2fd, 0x61f5201e, 0xfe2fa380, + 0xb23a2cae, 0x2de0af30, 0x56fe2dd3, 0xc924ae4d, 0xa0c32815, + 0x3f19ab8b, 0x44072968, 0xdbddaaf6, 0xdc2c3734, 0x43f6b4aa, + 0x38e83649, 0xa732b5d7, 0xced5338f, 0x510fb011, 0x2a1132f2, + 0xb5cbb16c, 0xf9de3e42, 0x6604bddc, 0x1d1a3f3f, 0x82c0bca1, + 0xeb273af9, 0x74fdb967, 0x0fe33b84, 0x9039b81a, 0xf4e14df1, + 0x6b3bce6f, 0x10254c8c, 0x8fffcf12, 0xe618494a, 0x79c2cad4, + 0x02dc4837, 0x9d06cba9, 0xd1134487, 0x4ec9c719, 0x35d745fa, + 0xaa0dc664, 0xc3ea403c, 0x5c30c3a2, 0x272e4141, 0xb8f4c2df, + 0xbf055f1d, 0x20dfdc83, 0x5bc15e60, 0xc41bddfe, 0xadfc5ba6, + 0x3226d838, 0x49385adb, 0xd6e2d945, 0x9af7566b, 0x052dd5f5, + 0x7e335716, 0xe1e9d488, 0x880e52d0, 0x17d4d14e, 0x6cca53ad, + 0xf310d033, 0x63296829, 0xfcf3ebb7, 0x87ed6954, 0x1837eaca, + 0x71d06c92, 0xee0aef0c, 0x95146def, 0x0aceee71, 0x46db615f, + 0xd901e2c1, 0xa21f6022, 0x3dc5e3bc, 0x542265e4, 0xcbf8e67a, + 0xb0e66499, 0x2f3ce707, 0x28cd7ac5, 0xb717f95b, 0xcc097bb8, + 0x53d3f826, 0x3a347e7e, 0xa5eefde0, 0xdef07f03, 0x412afc9d, + 0x0d3f73b3, 0x92e5f02d, 0xe9fb72ce, 0x7621f150, 0x1fc67708, + 0x801cf496, 0xfb027675, 0x64d8f5eb, 0x32b39da3, 0xad691e3d, + 0xd6779cde, 0x49ad1f40, 0x204a9918, 0xbf901a86, 0xc48e9865, + 0x5b541bfb, 0x174194d5, 0x889b174b, 0xf38595a8, 0x6c5f1636, + 0x05b8906e, 0x9a6213f0, 0xe17c9113, 0x7ea6128d, 0x79578f4f, + 0xe68d0cd1, 0x9d938e32, 0x02490dac, 0x6bae8bf4, 0xf474086a, + 0x8f6a8a89, 0x10b00917, 0x5ca58639, 0xc37f05a7, 0xb8618744, + 0x27bb04da, 0x4e5c8282, 0xd186011c, 0xaa9883ff, 0x35420061, + 0xa57bb87b, 0x3aa13be5, 0x41bfb906, 0xde653a98, 0xb782bcc0, + 0x28583f5e, 0x5346bdbd, 0xcc9c3e23, 0x8089b10d, 0x1f533293, + 0x644db070, 0xfb9733ee, 0x9270b5b6, 0x0daa3628, 0x76b4b4cb, + 0xe96e3755, 0xee9faa97, 0x71452909, 0x0a5babea, 0x95812874, + 0xfc66ae2c, 0x63bc2db2, 0x18a2af51, 0x87782ccf, 0xcb6da3e1, + 0x54b7207f, 0x2fa9a29c, 0xb0732102, 0xd994a75a, 0x464e24c4, + 0x3d50a627, 0xa28a25b9, 0xc652d052, 0x598853cc, 0x2296d12f, + 0xbd4c52b1, 0xd4abd4e9, 0x4b715777, 0x306fd594, 0xafb5560a, + 0xe3a0d924, 0x7c7a5aba, 0x0764d859, 0x98be5bc7, 0xf159dd9f, + 0x6e835e01, 0x159ddce2, 0x8a475f7c, 0x8db6c2be, 0x126c4120, + 0x6972c3c3, 0xf6a8405d, 0x9f4fc605, 0x0095459b, 0x7b8bc778, + 0xe45144e6, 0xa844cbc8, 0x379e4856, 0x4c80cab5, 0xd35a492b, + 0xbabdcf73, 0x25674ced, 0x5e79ce0e, 0xc1a34d90, 0x519af58a, + 0xce407614, 0xb55ef4f7, 0x2a847769, 0x4363f131, 0xdcb972af, + 0xa7a7f04c, 0x387d73d2, 0x7468fcfc, 0xebb27f62, 0x90acfd81, + 0x0f767e1f, 0x6691f847, 0xf94b7bd9, 0x8255f93a, 0x1d8f7aa4, + 0x1a7ee766, 0x85a464f8, 0xfebae61b, 0x61606585, 0x0887e3dd, + 0x975d6043, 0xec43e2a0, 0x7399613e, 0x3f8cee10, 0xa0566d8e, + 0xdb48ef6d, 0x44926cf3, 0x2d75eaab, 0xb2af6935, 0xc9b1ebd6, + 0x566b6848}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x00000000, 0x9e83da9f, 0x7d01c4e4, 0xe3821e7b, 0xbb04f912, + 0x2587238d, 0xc6053df6, 0x5886e769, 0x7609f225, 0xe88a28ba, + 0x0b0836c1, 0x958bec5e, 0xcd0d0b37, 0x538ed1a8, 0xb00ccfd3, + 0x2e8f154c, 0xec12e44b, 0x72913ed4, 0x911320af, 0x0f90fa30, + 0x57161d59, 0xc995c7c6, 0x2a17d9bd, 0xb4940322, 0x9a1b166e, + 0x0498ccf1, 0xe71ad28a, 0x79990815, 0x211fef7c, 0xbf9c35e3, + 0x5c1e2b98, 0xc29df107, 0xd825c897, 0x46a61208, 0xa5240c73, + 0x3ba7d6ec, 0x63213185, 0xfda2eb1a, 0x1e20f561, 0x80a32ffe, + 0xae2c3ab2, 0x30afe02d, 0xd32dfe56, 0x4dae24c9, 0x1528c3a0, + 0x8bab193f, 0x68290744, 0xf6aadddb, 0x34372cdc, 0xaab4f643, + 0x4936e838, 0xd7b532a7, 0x8f33d5ce, 0x11b00f51, 0xf232112a, + 0x6cb1cbb5, 0x423edef9, 0xdcbd0466, 0x3f3f1a1d, 0xa1bcc082, + 0xf93a27eb, 0x67b9fd74, 0x843be30f, 0x1ab83990, 0xf14de1f4, + 0x6fce3b6b, 0x8c4c2510, 0x12cfff8f, 0x4a4918e6, 0xd4cac279, + 0x3748dc02, 0xa9cb069d, 0x874413d1, 0x19c7c94e, 0xfa45d735, + 0x64c60daa, 0x3c40eac3, 0xa2c3305c, 0x41412e27, 0xdfc2f4b8, + 0x1d5f05bf, 0x83dcdf20, 0x605ec15b, 0xfedd1bc4, 0xa65bfcad, + 0x38d82632, 0xdb5a3849, 0x45d9e2d6, 0x6b56f79a, 0xf5d52d05, + 0x1657337e, 0x88d4e9e1, 0xd0520e88, 0x4ed1d417, 0xad53ca6c, + 0x33d010f3, 0x29682963, 0xb7ebf3fc, 0x5469ed87, 0xcaea3718, + 0x926cd071, 0x0cef0aee, 0xef6d1495, 0x71eece0a, 0x5f61db46, + 0xc1e201d9, 0x22601fa2, 0xbce3c53d, 0xe4652254, 0x7ae6f8cb, + 0x9964e6b0, 0x07e73c2f, 0xc57acd28, 0x5bf917b7, 0xb87b09cc, + 0x26f8d353, 0x7e7e343a, 0xe0fdeea5, 0x037ff0de, 0x9dfc2a41, + 0xb3733f0d, 0x2df0e592, 0xce72fbe9, 0x50f12176, 0x0877c61f, + 0x96f41c80, 0x757602fb, 0xebf5d864, 0xa39db332, 0x3d1e69ad, + 0xde9c77d6, 0x401fad49, 0x18994a20, 0x861a90bf, 0x65988ec4, + 0xfb1b545b, 0xd5944117, 0x4b179b88, 0xa89585f3, 0x36165f6c, + 0x6e90b805, 0xf013629a, 0x13917ce1, 0x8d12a67e, 0x4f8f5779, + 0xd10c8de6, 0x328e939d, 0xac0d4902, 0xf48bae6b, 0x6a0874f4, + 0x898a6a8f, 0x1709b010, 0x3986a55c, 0xa7057fc3, 0x448761b8, + 0xda04bb27, 0x82825c4e, 0x1c0186d1, 0xff8398aa, 0x61004235, + 0x7bb87ba5, 0xe53ba13a, 0x06b9bf41, 0x983a65de, 0xc0bc82b7, + 0x5e3f5828, 0xbdbd4653, 0x233e9ccc, 0x0db18980, 0x9332531f, + 0x70b04d64, 0xee3397fb, 0xb6b57092, 0x2836aa0d, 0xcbb4b476, + 0x55376ee9, 0x97aa9fee, 0x09294571, 0xeaab5b0a, 0x74288195, + 0x2cae66fc, 0xb22dbc63, 0x51afa218, 0xcf2c7887, 0xe1a36dcb, + 0x7f20b754, 0x9ca2a92f, 0x022173b0, 0x5aa794d9, 0xc4244e46, + 0x27a6503d, 0xb9258aa2, 0x52d052c6, 0xcc538859, 0x2fd19622, + 0xb1524cbd, 0xe9d4abd4, 0x7757714b, 0x94d56f30, 0x0a56b5af, + 0x24d9a0e3, 0xba5a7a7c, 0x59d86407, 0xc75bbe98, 0x9fdd59f1, + 0x015e836e, 0xe2dc9d15, 0x7c5f478a, 0xbec2b68d, 0x20416c12, + 0xc3c37269, 0x5d40a8f6, 0x05c64f9f, 0x9b459500, 0x78c78b7b, + 0xe64451e4, 0xc8cb44a8, 0x56489e37, 0xb5ca804c, 0x2b495ad3, + 0x73cfbdba, 0xed4c6725, 0x0ece795e, 0x904da3c1, 0x8af59a51, + 0x147640ce, 0xf7f45eb5, 0x6977842a, 0x31f16343, 0xaf72b9dc, + 0x4cf0a7a7, 0xd2737d38, 0xfcfc6874, 0x627fb2eb, 0x81fdac90, + 0x1f7e760f, 0x47f89166, 0xd97b4bf9, 0x3af95582, 0xa47a8f1d, + 0x66e77e1a, 0xf864a485, 0x1be6bafe, 0x85656061, 0xdde38708, + 0x43605d97, 0xa0e243ec, 0x3e619973, 0x10ee8c3f, 0x8e6d56a0, + 0x6def48db, 0xf36c9244, 0xabea752d, 0x3569afb2, 0xd6ebb1c9, + 0x48686b56}, + {0x00000000, 0xc0642817, 0x80c9502e, 0x40ad7839, 0x0093a15c, + 0xc0f7894b, 0x805af172, 0x403ed965, 0x002643b9, 0xc0426bae, + 0x80ef1397, 0x408b3b80, 0x00b5e2e5, 0xc0d1caf2, 0x807cb2cb, + 0x40189adc, 0x414af7a9, 0x812edfbe, 0xc183a787, 0x01e78f90, + 0x41d956f5, 0x81bd7ee2, 0xc11006db, 0x01742ecc, 0x416cb410, + 0x81089c07, 0xc1a5e43e, 0x01c1cc29, 0x41ff154c, 0x819b3d5b, + 0xc1364562, 0x01526d75, 0xc3929f88, 0x03f6b79f, 0x435bcfa6, + 0x833fe7b1, 0xc3013ed4, 0x036516c3, 0x43c86efa, 0x83ac46ed, + 0xc3b4dc31, 0x03d0f426, 0x437d8c1f, 0x8319a408, 0xc3277d6d, + 0x0343557a, 0x43ee2d43, 0x838a0554, 0x82d86821, 0x42bc4036, + 0x0211380f, 0xc2751018, 0x824bc97d, 0x422fe16a, 0x02829953, + 0xc2e6b144, 0x82fe2b98, 0x429a038f, 0x02377bb6, 0xc25353a1, + 0x826d8ac4, 0x4209a2d3, 0x02a4daea, 0xc2c0f2fd, 0xc7234eca, + 0x074766dd, 0x47ea1ee4, 0x878e36f3, 0xc7b0ef96, 0x07d4c781, + 0x4779bfb8, 0x871d97af, 0xc7050d73, 0x07612564, 0x47cc5d5d, + 0x87a8754a, 0xc796ac2f, 0x07f28438, 0x475ffc01, 0x873bd416, + 0x8669b963, 0x460d9174, 0x06a0e94d, 0xc6c4c15a, 0x86fa183f, + 0x469e3028, 0x06334811, 0xc6576006, 0x864ffada, 0x462bd2cd, + 0x0686aaf4, 0xc6e282e3, 0x86dc5b86, 0x46b87391, 0x06150ba8, + 0xc67123bf, 0x04b1d142, 0xc4d5f955, 0x8478816c, 0x441ca97b, + 0x0422701e, 0xc4465809, 0x84eb2030, 0x448f0827, 0x049792fb, + 0xc4f3baec, 0x845ec2d5, 0x443aeac2, 0x040433a7, 0xc4601bb0, + 0x84cd6389, 0x44a94b9e, 0x45fb26eb, 0x859f0efc, 0xc53276c5, + 0x05565ed2, 0x456887b7, 0x850cafa0, 0xc5a1d799, 0x05c5ff8e, + 0x45dd6552, 0x85b94d45, 0xc514357c, 0x05701d6b, 0x454ec40e, + 0x852aec19, 0xc5879420, 0x05e3bc37, 0xcf41ed4f, 0x0f25c558, + 0x4f88bd61, 0x8fec9576, 0xcfd24c13, 0x0fb66404, 0x4f1b1c3d, + 0x8f7f342a, 0xcf67aef6, 0x0f0386e1, 0x4faefed8, 0x8fcad6cf, + 0xcff40faa, 0x0f9027bd, 0x4f3d5f84, 0x8f597793, 0x8e0b1ae6, + 0x4e6f32f1, 0x0ec24ac8, 0xcea662df, 0x8e98bbba, 0x4efc93ad, + 0x0e51eb94, 0xce35c383, 0x8e2d595f, 0x4e497148, 0x0ee40971, + 0xce802166, 0x8ebef803, 0x4edad014, 0x0e77a82d, 0xce13803a, + 0x0cd372c7, 0xccb75ad0, 0x8c1a22e9, 0x4c7e0afe, 0x0c40d39b, + 0xcc24fb8c, 0x8c8983b5, 0x4cedaba2, 0x0cf5317e, 0xcc911969, + 0x8c3c6150, 0x4c584947, 0x0c669022, 0xcc02b835, 0x8cafc00c, + 0x4ccbe81b, 0x4d99856e, 0x8dfdad79, 0xcd50d540, 0x0d34fd57, + 0x4d0a2432, 0x8d6e0c25, 0xcdc3741c, 0x0da75c0b, 0x4dbfc6d7, + 0x8ddbeec0, 0xcd7696f9, 0x0d12beee, 0x4d2c678b, 0x8d484f9c, + 0xcde537a5, 0x0d811fb2, 0x0862a385, 0xc8068b92, 0x88abf3ab, + 0x48cfdbbc, 0x08f102d9, 0xc8952ace, 0x883852f7, 0x485c7ae0, + 0x0844e03c, 0xc820c82b, 0x888db012, 0x48e99805, 0x08d74160, + 0xc8b36977, 0x881e114e, 0x487a3959, 0x4928542c, 0x894c7c3b, + 0xc9e10402, 0x09852c15, 0x49bbf570, 0x89dfdd67, 0xc972a55e, + 0x09168d49, 0x490e1795, 0x896a3f82, 0xc9c747bb, 0x09a36fac, + 0x499db6c9, 0x89f99ede, 0xc954e6e7, 0x0930cef0, 0xcbf03c0d, + 0x0b94141a, 0x4b396c23, 0x8b5d4434, 0xcb639d51, 0x0b07b546, + 0x4baacd7f, 0x8bcee568, 0xcbd67fb4, 0x0bb257a3, 0x4b1f2f9a, + 0x8b7b078d, 0xcb45dee8, 0x0b21f6ff, 0x4b8c8ec6, 0x8be8a6d1, + 0x8abacba4, 0x4adee3b3, 0x0a739b8a, 0xca17b39d, 0x8a296af8, + 0x4a4d42ef, 0x0ae03ad6, 0xca8412c1, 0x8a9c881d, 0x4af8a00a, + 0x0a55d833, 0xca31f024, 0x8a0f2941, 0x4a6b0156, 0x0ac6796f, + 0xcaa25178}, + {0x00000000, 0xd4ea739b, 0xe9d396ed, 0x3d39e576, 0x93a15c00, + 0x474b2f9b, 0x7a72caed, 0xae98b976, 0x2643b900, 0xf2a9ca9b, + 0xcf902fed, 0x1b7a5c76, 0xb5e2e500, 0x6108969b, 0x5c3173ed, + 0x88db0076, 0x4c867201, 0x986c019a, 0xa555e4ec, 0x71bf9777, + 0xdf272e01, 0x0bcd5d9a, 0x36f4b8ec, 0xe21ecb77, 0x6ac5cb01, + 0xbe2fb89a, 0x83165dec, 0x57fc2e77, 0xf9649701, 0x2d8ee49a, + 0x10b701ec, 0xc45d7277, 0x980ce502, 0x4ce69699, 0x71df73ef, + 0xa5350074, 0x0badb902, 0xdf47ca99, 0xe27e2fef, 0x36945c74, + 0xbe4f5c02, 0x6aa52f99, 0x579ccaef, 0x8376b974, 0x2dee0002, + 0xf9047399, 0xc43d96ef, 0x10d7e574, 0xd48a9703, 0x0060e498, + 0x3d5901ee, 0xe9b37275, 0x472bcb03, 0x93c1b898, 0xaef85dee, + 0x7a122e75, 0xf2c92e03, 0x26235d98, 0x1b1ab8ee, 0xcff0cb75, + 0x61687203, 0xb5820198, 0x88bbe4ee, 0x5c519775, 0x3019ca05, + 0xe4f3b99e, 0xd9ca5ce8, 0x0d202f73, 0xa3b89605, 0x7752e59e, + 0x4a6b00e8, 0x9e817373, 0x165a7305, 0xc2b0009e, 0xff89e5e8, + 0x2b639673, 0x85fb2f05, 0x51115c9e, 0x6c28b9e8, 0xb8c2ca73, + 0x7c9fb804, 0xa875cb9f, 0x954c2ee9, 0x41a65d72, 0xef3ee404, + 0x3bd4979f, 0x06ed72e9, 0xd2070172, 0x5adc0104, 0x8e36729f, + 0xb30f97e9, 0x67e5e472, 0xc97d5d04, 0x1d972e9f, 0x20aecbe9, + 0xf444b872, 0xa8152f07, 0x7cff5c9c, 0x41c6b9ea, 0x952cca71, + 0x3bb47307, 0xef5e009c, 0xd267e5ea, 0x068d9671, 0x8e569607, + 0x5abce59c, 0x678500ea, 0xb36f7371, 0x1df7ca07, 0xc91db99c, + 0xf4245cea, 0x20ce2f71, 0xe4935d06, 0x30792e9d, 0x0d40cbeb, + 0xd9aab870, 0x77320106, 0xa3d8729d, 0x9ee197eb, 0x4a0be470, + 0xc2d0e406, 0x163a979d, 0x2b0372eb, 0xffe90170, 0x5171b806, + 0x859bcb9d, 0xb8a22eeb, 0x6c485d70, 0x6032940b, 0xb4d8e790, + 0x89e102e6, 0x5d0b717d, 0xf393c80b, 0x2779bb90, 0x1a405ee6, + 0xceaa2d7d, 0x46712d0b, 0x929b5e90, 0xafa2bbe6, 0x7b48c87d, + 0xd5d0710b, 0x013a0290, 0x3c03e7e6, 0xe8e9947d, 0x2cb4e60a, + 0xf85e9591, 0xc56770e7, 0x118d037c, 0xbf15ba0a, 0x6bffc991, + 0x56c62ce7, 0x822c5f7c, 0x0af75f0a, 0xde1d2c91, 0xe324c9e7, + 0x37ceba7c, 0x9956030a, 0x4dbc7091, 0x708595e7, 0xa46fe67c, + 0xf83e7109, 0x2cd40292, 0x11ede7e4, 0xc507947f, 0x6b9f2d09, + 0xbf755e92, 0x824cbbe4, 0x56a6c87f, 0xde7dc809, 0x0a97bb92, + 0x37ae5ee4, 0xe3442d7f, 0x4ddc9409, 0x9936e792, 0xa40f02e4, + 0x70e5717f, 0xb4b80308, 0x60527093, 0x5d6b95e5, 0x8981e67e, + 0x27195f08, 0xf3f32c93, 0xcecac9e5, 0x1a20ba7e, 0x92fbba08, + 0x4611c993, 0x7b282ce5, 0xafc25f7e, 0x015ae608, 0xd5b09593, + 0xe88970e5, 0x3c63037e, 0x502b5e0e, 0x84c12d95, 0xb9f8c8e3, + 0x6d12bb78, 0xc38a020e, 0x17607195, 0x2a5994e3, 0xfeb3e778, + 0x7668e70e, 0xa2829495, 0x9fbb71e3, 0x4b510278, 0xe5c9bb0e, + 0x3123c895, 0x0c1a2de3, 0xd8f05e78, 0x1cad2c0f, 0xc8475f94, + 0xf57ebae2, 0x2194c979, 0x8f0c700f, 0x5be60394, 0x66dfe6e2, + 0xb2359579, 0x3aee950f, 0xee04e694, 0xd33d03e2, 0x07d77079, + 0xa94fc90f, 0x7da5ba94, 0x409c5fe2, 0x94762c79, 0xc827bb0c, + 0x1ccdc897, 0x21f42de1, 0xf51e5e7a, 0x5b86e70c, 0x8f6c9497, + 0xb25571e1, 0x66bf027a, 0xee64020c, 0x3a8e7197, 0x07b794e1, + 0xd35de77a, 0x7dc55e0c, 0xa92f2d97, 0x9416c8e1, 0x40fcbb7a, + 0x84a1c90d, 0x504bba96, 0x6d725fe0, 0xb9982c7b, 0x1700950d, + 0xc3eae696, 0xfed303e0, 0x2a39707b, 0xa2e2700d, 0x76080396, + 0x4b31e6e0, 0x9fdb957b, 0x31432c0d, 0xe5a95f96, 0xd890bae0, + 0x0c7ac97b}, + {0x00000000, 0x27652581, 0x0fcc3bd9, 0x28a91e58, 0x5f9e0669, + 0x78fb23e8, 0x50523db0, 0x77371831, 0xbe3c0dd2, 0x99592853, + 0xb1f0360b, 0x9695138a, 0xe1a20bbb, 0xc6c72e3a, 0xee6e3062, + 0xc90b15e3, 0x3d7f6b7f, 0x1a1a4efe, 0x32b350a6, 0x15d67527, + 0x62e16d16, 0x45844897, 0x6d2d56cf, 0x4a48734e, 0x834366ad, + 0xa426432c, 0x8c8f5d74, 0xabea78f5, 0xdcdd60c4, 0xfbb84545, + 0xd3115b1d, 0xf4747e9c, 0x7afed6fe, 0x5d9bf37f, 0x7532ed27, + 0x5257c8a6, 0x2560d097, 0x0205f516, 0x2aaceb4e, 0x0dc9cecf, + 0xc4c2db2c, 0xe3a7fead, 0xcb0ee0f5, 0xec6bc574, 0x9b5cdd45, + 0xbc39f8c4, 0x9490e69c, 0xb3f5c31d, 0x4781bd81, 0x60e49800, + 0x484d8658, 0x6f28a3d9, 0x181fbbe8, 0x3f7a9e69, 0x17d38031, + 0x30b6a5b0, 0xf9bdb053, 0xded895d2, 0xf6718b8a, 0xd114ae0b, + 0xa623b63a, 0x814693bb, 0xa9ef8de3, 0x8e8aa862, 0xb5fadc26, + 0x929ff9a7, 0xba36e7ff, 0x9d53c27e, 0xea64da4f, 0xcd01ffce, + 0xe5a8e196, 0xc2cdc417, 0x0bc6d1f4, 0x2ca3f475, 0x040aea2d, + 0x236fcfac, 0x5458d79d, 0x733df21c, 0x5b94ec44, 0x7cf1c9c5, + 0x8885b759, 0xafe092d8, 0x87498c80, 0xa02ca901, 0xd71bb130, + 0xf07e94b1, 0xd8d78ae9, 0xffb2af68, 0x36b9ba8b, 0x11dc9f0a, + 0x39758152, 0x1e10a4d3, 0x6927bce2, 0x4e429963, 0x66eb873b, + 0x418ea2ba, 0xcf040ad8, 0xe8612f59, 0xc0c83101, 0xe7ad1480, + 0x909a0cb1, 0xb7ff2930, 0x9f563768, 0xb83312e9, 0x7138070a, + 0x565d228b, 0x7ef43cd3, 0x59911952, 0x2ea60163, 0x09c324e2, + 0x216a3aba, 0x060f1f3b, 0xf27b61a7, 0xd51e4426, 0xfdb75a7e, + 0xdad27fff, 0xade567ce, 0x8a80424f, 0xa2295c17, 0x854c7996, + 0x4c476c75, 0x6b2249f4, 0x438b57ac, 0x64ee722d, 0x13d96a1c, + 0x34bc4f9d, 0x1c1551c5, 0x3b707444, 0x6af5b94d, 0x4d909ccc, + 0x65398294, 0x425ca715, 0x356bbf24, 0x120e9aa5, 0x3aa784fd, + 0x1dc2a17c, 0xd4c9b49f, 0xf3ac911e, 0xdb058f46, 0xfc60aac7, + 0x8b57b2f6, 0xac329777, 0x849b892f, 0xa3feacae, 0x578ad232, + 0x70eff7b3, 0x5846e9eb, 0x7f23cc6a, 0x0814d45b, 0x2f71f1da, + 0x07d8ef82, 0x20bdca03, 0xe9b6dfe0, 0xced3fa61, 0xe67ae439, + 0xc11fc1b8, 0xb628d989, 0x914dfc08, 0xb9e4e250, 0x9e81c7d1, + 0x100b6fb3, 0x376e4a32, 0x1fc7546a, 0x38a271eb, 0x4f9569da, + 0x68f04c5b, 0x40595203, 0x673c7782, 0xae376261, 0x895247e0, + 0xa1fb59b8, 0x869e7c39, 0xf1a96408, 0xd6cc4189, 0xfe655fd1, + 0xd9007a50, 0x2d7404cc, 0x0a11214d, 0x22b83f15, 0x05dd1a94, + 0x72ea02a5, 0x558f2724, 0x7d26397c, 0x5a431cfd, 0x9348091e, + 0xb42d2c9f, 0x9c8432c7, 0xbbe11746, 0xccd60f77, 0xebb32af6, + 0xc31a34ae, 0xe47f112f, 0xdf0f656b, 0xf86a40ea, 0xd0c35eb2, + 0xf7a67b33, 0x80916302, 0xa7f44683, 0x8f5d58db, 0xa8387d5a, + 0x613368b9, 0x46564d38, 0x6eff5360, 0x499a76e1, 0x3ead6ed0, + 0x19c84b51, 0x31615509, 0x16047088, 0xe2700e14, 0xc5152b95, + 0xedbc35cd, 0xcad9104c, 0xbdee087d, 0x9a8b2dfc, 0xb22233a4, + 0x95471625, 0x5c4c03c6, 0x7b292647, 0x5380381f, 0x74e51d9e, + 0x03d205af, 0x24b7202e, 0x0c1e3e76, 0x2b7b1bf7, 0xa5f1b395, + 0x82949614, 0xaa3d884c, 0x8d58adcd, 0xfa6fb5fc, 0xdd0a907d, + 0xf5a38e25, 0xd2c6aba4, 0x1bcdbe47, 0x3ca89bc6, 0x1401859e, + 0x3364a01f, 0x4453b82e, 0x63369daf, 0x4b9f83f7, 0x6cfaa676, + 0x988ed8ea, 0xbfebfd6b, 0x9742e333, 0xb027c6b2, 0xc710de83, + 0xe075fb02, 0xc8dce55a, 0xefb9c0db, 0x26b2d538, 0x01d7f0b9, + 0x297eeee1, 0x0e1bcb60, 0x792cd351, 0x5e49f6d0, 0x76e0e888, + 0x5185cd09}}; + +#endif + +#endif + +#endif + +local const z_crc_t FAR x2n_table[] = { + 0x40000000, 0x20000000, 0x08000000, 0x00800000, 0x00008000, + 0xedb88320, 0xb1e6b092, 0xa06a2517, 0xed627dae, 0x88d14467, + 0xd7bbfe6a, 0xec447f11, 0x8e7ea170, 0x6427800e, 0x4d47bae0, + 0x09fe548f, 0x83852d0f, 0x30362f1a, 0x7b5a9cc3, 0x31fec169, + 0x9fec022a, 0x6c8dedc4, 0x15d6874d, 0x5fde7a4e, 0xbad90e37, + 0x2e4e5eef, 0x4eaba214, 0xa8a472c0, 0x429a969e, 0x148d302a, + 0xc40ba6d0, 0xc4e22c3c}; diff --git a/deps/exla/cache/xla_extension/include/external/zlib/deflate.h b/deps/exla/cache/xla_extension/include/external/zlib/deflate.h new file mode 100644 index 0000000000000000000000000000000000000000..300c6ada62b82e4984dd59a931c694db8636bd8f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/zlib/deflate.h @@ -0,0 +1,377 @@ +/* deflate.h -- internal compression state + * Copyright (C) 1995-2024 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef DEFLATE_H +#define DEFLATE_H + +#include "zutil.h" + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer creation by deflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip encoding + should be left enabled. */ +#ifndef NO_GZIP +# define GZIP +#endif + +/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at + the cost of a larger memory footprint */ +/* #define LIT_MEM */ + +/* =========================================================================== + * Internal compression state. + */ + +#define LENGTH_CODES 29 +/* number of length codes, not counting the special END_BLOCK code */ + +#define LITERALS 256 +/* number of literal bytes 0..255 */ + +#define L_CODES (LITERALS+1+LENGTH_CODES) +/* number of Literal or Length codes, including the END_BLOCK code */ + +#define D_CODES 30 +/* number of distance codes */ + +#define BL_CODES 19 +/* number of codes used to transfer the bit lengths */ + +#define HEAP_SIZE (2*L_CODES+1) +/* maximum heap size */ + +#define MAX_BITS 15 +/* All codes must not exceed MAX_BITS bits */ + +#define Buf_size 16 +/* size of bit buffer in bi_buf */ + +#define INIT_STATE 42 /* zlib header -> BUSY_STATE */ +#ifdef GZIP +# define GZIP_STATE 57 /* gzip header -> BUSY_STATE | EXTRA_STATE */ +#endif +#define EXTRA_STATE 69 /* gzip extra block -> NAME_STATE */ +#define NAME_STATE 73 /* gzip file name -> COMMENT_STATE */ +#define COMMENT_STATE 91 /* gzip comment -> HCRC_STATE */ +#define HCRC_STATE 103 /* gzip header CRC -> BUSY_STATE */ +#define BUSY_STATE 113 /* deflate -> FINISH_STATE */ +#define FINISH_STATE 666 /* stream complete */ +/* Stream status */ + + +/* Data structure describing a single value and its code string. */ +typedef struct ct_data_s { + union { + ush freq; /* frequency count */ + ush code; /* bit string */ + } fc; + union { + ush dad; /* father node in Huffman tree */ + ush len; /* length of bit string */ + } dl; +} FAR ct_data; + +#define Freq fc.freq +#define Code fc.code +#define Dad dl.dad +#define Len dl.len + +typedef struct static_tree_desc_s static_tree_desc; + +typedef struct tree_desc_s { + ct_data *dyn_tree; /* the dynamic tree */ + int max_code; /* largest code with non zero frequency */ + const static_tree_desc *stat_desc; /* the corresponding static tree */ +} FAR tree_desc; + +typedef ush Pos; +typedef Pos FAR Posf; +typedef unsigned IPos; + +/* A Pos is an index in the character window. We use short instead of int to + * save space in the various tables. IPos is used only for parameter passing. + */ + +typedef struct internal_state { + z_streamp strm; /* pointer back to this zlib stream */ + int status; /* as the name implies */ + Bytef *pending_buf; /* output still pending */ + ulg pending_buf_size; /* size of pending_buf */ + Bytef *pending_out; /* next pending byte to output to the stream */ + ulg pending; /* nb of bytes in the pending buffer */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + gz_headerp gzhead; /* gzip header information to write */ + ulg gzindex; /* where in extra, name, or comment */ + Byte method; /* can only be DEFLATED */ + int last_flush; /* value of flush param for previous deflate call */ + + /* used by deflate.c: */ + + uInt w_size; /* LZ77 window size (32K by default) */ + uInt w_bits; /* log2(w_size) (8..16) */ + uInt w_mask; /* w_size - 1 */ + + Bytef *window; + /* Sliding window. Input bytes are read into the second half of the window, + * and move to the first half later to keep a dictionary of at least wSize + * bytes. With this organization, matches are limited to a distance of + * wSize-MAX_MATCH bytes, but this ensures that IO is always + * performed with a length multiple of the block size. Also, it limits + * the window size to 64K, which is quite useful on MSDOS. + * To do: use the user input buffer as sliding window. + */ + + ulg window_size; + /* Actual size of window: 2*wSize, except when the user input buffer + * is directly used as sliding window. + */ + + Posf *prev; + /* Link to older string with same hash index. To limit the size of this + * array to 64K, this link is maintained only for the last 32K strings. + * An index in this array is thus a window index modulo 32K. + */ + + Posf *head; /* Heads of the hash chains or NIL. */ + + uInt ins_h; /* hash index of string to be inserted */ + uInt hash_size; /* number of elements in hash table */ + uInt hash_bits; /* log2(hash_size) */ + uInt hash_mask; /* hash_size-1 */ + + uInt hash_shift; + /* Number of bits by which ins_h must be shifted at each input + * step. It must be such that after MIN_MATCH steps, the oldest + * byte no longer takes part in the hash key, that is: + * hash_shift * MIN_MATCH >= hash_bits + */ + + long block_start; + /* Window position at the beginning of the current output block. Gets + * negative when the window is moved backwards. + */ + + uInt match_length; /* length of best match */ + IPos prev_match; /* previous match */ + int match_available; /* set if previous match exists */ + uInt strstart; /* start of string to insert */ + uInt match_start; /* start of matching string */ + uInt lookahead; /* number of valid bytes ahead in window */ + + uInt prev_length; + /* Length of the best match at previous step. Matches not greater than this + * are discarded. This is used in the lazy match evaluation. + */ + + uInt max_chain_length; + /* To speed up deflation, hash chains are never searched beyond this + * length. A higher limit improves compression ratio but degrades the + * speed. + */ + + uInt max_lazy_match; + /* Attempt to find a better match only when the current match is strictly + * smaller than this value. This mechanism is used only for compression + * levels >= 4. + */ +# define max_insert_length max_lazy_match + /* Insert new strings in the hash table only if the match length is not + * greater than this length. This saves time but degrades compression. + * max_insert_length is used only for compression levels <= 3. + */ + + int level; /* compression level (1..9) */ + int strategy; /* favor or force Huffman coding*/ + + uInt good_match; + /* Use a faster search when the previous match is longer than this */ + + int nice_match; /* Stop searching when current match exceeds this */ + + /* used by trees.c: */ + /* Didn't use ct_data typedef below to suppress compiler warning */ + struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ + struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ + struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ + + struct tree_desc_s l_desc; /* desc. for literal tree */ + struct tree_desc_s d_desc; /* desc. for distance tree */ + struct tree_desc_s bl_desc; /* desc. for bit length tree */ + + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ + int heap_len; /* number of elements in the heap */ + int heap_max; /* element of largest frequency */ + /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + * The same heap array is used to build all trees. + */ + + uch depth[2*L_CODES+1]; + /* Depth of each subtree used as tie breaker for trees of equal frequency + */ + +#ifdef LIT_MEM +# define LIT_BUFS 5 + ushf *d_buf; /* buffer for distances */ + uchf *l_buf; /* buffer for literals/lengths */ +#else +# define LIT_BUFS 4 + uchf *sym_buf; /* buffer for distances and literals/lengths */ +#endif + + uInt lit_bufsize; + /* Size of match buffer for literals/lengths. There are 4 reasons for + * limiting lit_bufsize to 64K: + * - frequencies can be kept in 16 bit counters + * - if compression is not successful for the first block, all input + * data is still in the window so we can still emit a stored block even + * when input comes from standard input. (This can also be done for + * all blocks if lit_bufsize is not greater than 32K.) + * - if compression is not successful for a file smaller than 64K, we can + * even emit a stored file instead of a stored block (saving 5 bytes). + * This is applicable only for zip (not gzip or zlib). + * - creating new Huffman trees less frequently may not provide fast + * adaptation to changes in the input data statistics. (Take for + * example a binary file with poorly compressible code followed by + * a highly compressible string table.) Smaller buffer sizes give + * fast adaptation but have of course the overhead of transmitting + * trees more frequently. + * - I can't count above 4 + */ + + uInt sym_next; /* running index in symbol buffer */ + uInt sym_end; /* symbol table full when sym_next reaches this */ + + ulg opt_len; /* bit length of current block with optimal trees */ + ulg static_len; /* bit length of current block with static trees */ + uInt matches; /* number of string matches in current block */ + uInt insert; /* bytes at end of window left to insert */ + +#ifdef ZLIB_DEBUG + ulg compressed_len; /* total bit length of compressed file mod 2^32 */ + ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ +#endif + + ush bi_buf; + /* Output buffer. bits are inserted starting at the bottom (least + * significant bits). + */ + int bi_valid; + /* Number of valid bits in bi_buf. All bits above the last valid bit + * are always zero. + */ + + ulg high_water; + /* High water mark offset in window for initialized bytes -- bytes above + * this are set to zero in order to avoid memory check warnings when + * longest match routines access bytes past the input. This is then + * updated to the new high water mark. + */ + +} FAR deflate_state; + +/* Output a byte on the stream. + * IN assertion: there is enough room in pending_buf. + */ +#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);} + + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) +/* In order to simplify the code, particularly on 16 bit machines, match + * distances are limited to MAX_DIST instead of WSIZE. + */ + +#define WIN_INIT MAX_MATCH +/* Number of bytes after end of data in window to initialize in order to avoid + memory checker errors from longest match routines */ + + /* in trees.c */ +void ZLIB_INTERNAL _tr_init(deflate_state *s); +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc); +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, + ulg stored_len, int last); +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s); +void ZLIB_INTERNAL _tr_align(deflate_state *s); +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, + ulg stored_len, int last); + +#define d_code(dist) \ + ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) +/* Mapping from a distance to a distance code. dist is the distance - 1 and + * must not have side effects. _dist_code[256] and _dist_code[257] are never + * used. + */ + +#ifndef ZLIB_DEBUG +/* Inline versions of _tr_tally for speed: */ + +#if defined(GEN_TREES_H) || !defined(STDC) + extern uch ZLIB_INTERNAL _length_code[]; + extern uch ZLIB_INTERNAL _dist_code[]; +#else + extern const uch ZLIB_INTERNAL _length_code[]; + extern const uch ZLIB_INTERNAL _dist_code[]; +#endif + +#ifdef LIT_MEM +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->sym_next] = 0; \ + s->l_buf[s->sym_next++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (uch)(length); \ + ush dist = (ush)(distance); \ + s->d_buf[s->sym_next] = dist; \ + s->l_buf[s->sym_next++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +#else +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->sym_buf[s->sym_next++] = 0; \ + s->sym_buf[s->sym_next++] = 0; \ + s->sym_buf[s->sym_next++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (uch)(length); \ + ush dist = (ush)(distance); \ + s->sym_buf[s->sym_next++] = (uch)dist; \ + s->sym_buf[s->sym_next++] = (uch)(dist >> 8); \ + s->sym_buf[s->sym_next++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +#endif +#else +# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) +# define _tr_tally_dist(s, distance, length, flush) \ + flush = _tr_tally(s, distance, length) +#endif + +#endif /* DEFLATE_H */ diff --git a/deps/exla/cache/xla_extension/include/external/zlib/gzguts.h b/deps/exla/cache/xla_extension/include/external/zlib/gzguts.h new file mode 100644 index 0000000000000000000000000000000000000000..eba72085bb756bc4fac374c59e8f5fdd1e660eab --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/zlib/gzguts.h @@ -0,0 +1,214 @@ +/* gzguts.h -- zlib internal header definitions for gz* operations + * Copyright (C) 2004-2024 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#ifdef _LARGEFILE64_SOURCE +# ifndef _LARGEFILE_SOURCE +# define _LARGEFILE_SOURCE 1 +# endif +# undef _FILE_OFFSET_BITS +# undef _TIME_BITS +#endif + +#ifdef HAVE_HIDDEN +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) +#else +# define ZLIB_INTERNAL +#endif + +#include +#include "zlib.h" +#ifdef STDC +# include +# include +# include +#endif + +#ifndef _POSIX_SOURCE +# define _POSIX_SOURCE +#endif +#include + +#ifdef _WIN32 +# include +#endif + +#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) +# include +#endif + +#if defined(_WIN32) +# define WIDECHAR +#endif + +#ifdef WINAPI_FAMILY +# define open _open +# define read _read +# define write _write +# define close _close +#endif + +#ifdef NO_DEFLATE /* for compatibility with old definition */ +# define NO_GZCOMPRESS +#endif + +#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif + +#if defined(__CYGWIN__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif + +#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif + +#ifndef HAVE_VSNPRINTF +# ifdef MSDOS +/* vsnprintf may exist on some MS-DOS compilers (DJGPP?), + but for now we just assume it doesn't. */ +# define NO_vsnprintf +# endif +# ifdef __TURBOC__ +# define NO_vsnprintf +# endif +# ifdef WIN32 +/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ +# if !defined(vsnprintf) && !defined(NO_vsnprintf) +# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) +# define vsnprintf _vsnprintf +# endif +# endif +# endif +# ifdef __SASC +# define NO_vsnprintf +# endif +# ifdef VMS +# define NO_vsnprintf +# endif +# ifdef __OS400__ +# define NO_vsnprintf +# endif +# ifdef __MVS__ +# define NO_vsnprintf +# endif +#endif + +/* unlike snprintf (which is required in C99), _snprintf does not guarantee + null termination of the result -- however this is only used in gzlib.c where + the result is assured to fit in the space provided */ +#if defined(_MSC_VER) && _MSC_VER < 1900 +# define snprintf _snprintf +#endif + +#ifndef local +# define local static +#endif +/* since "static" is used to mean two completely different things in C, we + define "local" for the non-static meaning of "static", for readability + (compile with -Dlocal if your debugger can't find static symbols) */ + +/* gz* functions always use library allocation functions */ +#ifndef STDC + extern voidp malloc(uInt size); + extern void free(voidpf ptr); +#endif + +/* get errno and strerror definition */ +#if defined UNDER_CE +# include +# define zstrerror() gz_strwinerror((DWORD)GetLastError()) +#else +# ifndef NO_STRERROR +# include +# define zstrerror() strerror(errno) +# else +# define zstrerror() "stdio error (consult errno)" +# endif +#endif + +/* provide prototypes for these when building zlib without LFS */ +#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); +#endif + +/* default memLevel */ +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif + +/* default i/o buffer size -- double this for output when reading (this and + twice this must be able to fit in an unsigned type) */ +#define GZBUFSIZE 8192 + +/* gzip modes, also provide a little integrity check on the passed structure */ +#define GZ_NONE 0 +#define GZ_READ 7247 +#define GZ_WRITE 31153 +#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ + +/* values for gz_state how */ +#define LOOK 0 /* look for a gzip header */ +#define COPY 1 /* copy input directly */ +#define GZIP 2 /* decompress a gzip stream */ + +/* internal gzip file state data structure */ +typedef struct { + /* exposed contents for gzgetc() macro */ + struct gzFile_s x; /* "x" for exposed */ + /* x.have: number of bytes available at x.next */ + /* x.next: next output data to deliver or write */ + /* x.pos: current position in uncompressed data */ + /* used for both reading and writing */ + int mode; /* see gzip modes above */ + int fd; /* file descriptor */ + char *path; /* path or fd for error messages */ + unsigned size; /* buffer size, zero if not allocated yet */ + unsigned want; /* requested buffer size, default is GZBUFSIZE */ + unsigned char *in; /* input buffer (double-sized when writing) */ + unsigned char *out; /* output buffer (double-sized when reading) */ + int direct; /* 0 if processing gzip, 1 if transparent */ + /* just for reading */ + int how; /* 0: get header, 1: copy, 2: decompress */ + z_off64_t start; /* where the gzip data started, for rewinding */ + int eof; /* true if end of input file reached */ + int past; /* true if read requested past end */ + /* just for writing */ + int level; /* compression level */ + int strategy; /* compression strategy */ + int reset; /* true if a reset is pending after a Z_FINISH */ + /* seek request */ + z_off64_t skip; /* amount to skip (already rewound if backwards) */ + int seek; /* true if seek request pending */ + /* error information */ + int err; /* error code */ + char *msg; /* error message */ + /* zlib inflate or deflate stream */ + z_stream strm; /* stream structure in-place (not a pointer) */ +} gz_state; +typedef gz_state FAR *gz_statep; + +/* shared functions */ +void ZLIB_INTERNAL gz_error(gz_statep, int, const char *); +#if defined UNDER_CE +char ZLIB_INTERNAL *gz_strwinerror(DWORD error); +#endif + +/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t + value -- needed when comparing unsigned to z_off64_t, which is signed + (possible z_off64_t types off_t, off64_t, and long are all signed) */ +unsigned ZLIB_INTERNAL gz_intmax(void); +#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) diff --git a/deps/exla/cache/xla_extension/include/external/zlib/inffast.h b/deps/exla/cache/xla_extension/include/external/zlib/inffast.h new file mode 100644 index 0000000000000000000000000000000000000000..49c6d156c5c652dbd9e2e6aff90e20eb279a2b37 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/zlib/inffast.h @@ -0,0 +1,11 @@ +/* inffast.h -- header to use inffast.c + * Copyright (C) 1995-2003, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start); diff --git a/deps/exla/cache/xla_extension/include/external/zlib/inffixed.h b/deps/exla/cache/xla_extension/include/external/zlib/inffixed.h new file mode 100644 index 0000000000000000000000000000000000000000..d6283277694802ce7938f537f12990d6eead4924 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/zlib/inffixed.h @@ -0,0 +1,94 @@ + /* inffixed.h -- table for decoding fixed codes + * Generated automatically by makefixed(). + */ + + /* WARNING: this file should *not* be used by applications. + It is part of the implementation of this library and is + subject to change. Applications should only use zlib.h. + */ + + static const code lenfix[512] = { + {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, + {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, + {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, + {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, + {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, + {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, + {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, + {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, + {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, + {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, + {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, + {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, + {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, + {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, + {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, + {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, + {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, + {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, + {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, + {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, + {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, + {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, + {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, + {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, + {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, + {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, + {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, + {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, + {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, + {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, + {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, + {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, + {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, + {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, + {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, + {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, + {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, + {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, + {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, + {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, + {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, + {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, + {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, + {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, + {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, + {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, + {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, + {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, + {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, + {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, + {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, + {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, + {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, + {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, + {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, + {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, + {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, + {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, + {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, + {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, + {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, + {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, + {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, + {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, + {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, + {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, + {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, + {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, + {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, + {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, + {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, + {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, + {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, + {0,9,255} + }; + + static const code distfix[32] = { + {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, + {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, + {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, + {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, + {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, + {22,5,193},{64,5,0} + }; diff --git a/deps/exla/cache/xla_extension/include/external/zlib/inflate.h b/deps/exla/cache/xla_extension/include/external/zlib/inflate.h new file mode 100644 index 0000000000000000000000000000000000000000..f127b6b1fa5f7d0266e3b502701948dfd3c6abc8 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/zlib/inflate.h @@ -0,0 +1,126 @@ +/* inflate.h -- internal inflate state definition + * Copyright (C) 1995-2019 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer decoding by inflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip decoding + should be left enabled. */ +#ifndef NO_GZIP +# define GUNZIP +#endif + +/* Possible inflate modes between inflate() calls */ +typedef enum { + HEAD = 16180, /* i: waiting for magic header */ + FLAGS, /* i: waiting for method and flags (gzip) */ + TIME, /* i: waiting for modification time (gzip) */ + OS, /* i: waiting for extra flags and operating system (gzip) */ + EXLEN, /* i: waiting for extra length (gzip) */ + EXTRA, /* i: waiting for extra bytes (gzip) */ + NAME, /* i: waiting for end of file name (gzip) */ + COMMENT, /* i: waiting for end of comment (gzip) */ + HCRC, /* i: waiting for header crc (gzip) */ + DICTID, /* i: waiting for dictionary check value */ + DICT, /* waiting for inflateSetDictionary() call */ + TYPE, /* i: waiting for type bits, including last-flag bit */ + TYPEDO, /* i: same, but skip check to exit inflate on new block */ + STORED, /* i: waiting for stored size (length and complement) */ + COPY_, /* i/o: same as COPY below, but only first time in */ + COPY, /* i/o: waiting for input or output to copy stored block */ + TABLE, /* i: waiting for dynamic block table lengths */ + LENLENS, /* i: waiting for code length code lengths */ + CODELENS, /* i: waiting for length/lit and distance code lengths */ + LEN_, /* i: same as LEN below, but only first time in */ + LEN, /* i: waiting for length/lit/eob code */ + LENEXT, /* i: waiting for length extra bits */ + DIST, /* i: waiting for distance code */ + DISTEXT, /* i: waiting for distance extra bits */ + MATCH, /* o: waiting for output space to copy string */ + LIT, /* o: waiting for output space to write literal */ + CHECK, /* i: waiting for 32-bit check value */ + LENGTH, /* i: waiting for 32-bit length (gzip) */ + DONE, /* finished check, done -- remain here until reset */ + BAD, /* got a data error -- remain here until reset */ + MEM, /* got an inflate() memory error -- remain here until reset */ + SYNC /* looking for synchronization bytes to restart inflate() */ +} inflate_mode; + +/* + State transitions between above modes - + + (most modes can go to BAD or MEM on error -- not shown for clarity) + + Process header: + HEAD -> (gzip) or (zlib) or (raw) + (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> + HCRC -> TYPE + (zlib) -> DICTID or TYPE + DICTID -> DICT -> TYPE + (raw) -> TYPEDO + Read deflate blocks: + TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK + STORED -> COPY_ -> COPY -> TYPE + TABLE -> LENLENS -> CODELENS -> LEN_ + LEN_ -> LEN + Read deflate codes in fixed or dynamic block: + LEN -> LENEXT or LIT or TYPE + LENEXT -> DIST -> DISTEXT -> MATCH -> LEN + LIT -> LEN + Process trailer: + CHECK -> LENGTH -> DONE + */ + +/* State maintained between inflate() calls -- approximately 7K bytes, not + including the allocated sliding window, which is up to 32K bytes. */ +struct inflate_state { + z_streamp strm; /* pointer back to this zlib stream */ + inflate_mode mode; /* current inflate mode */ + int last; /* true if processing last block */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip, + bit 2 true to validate check value */ + int havedict; /* true if dictionary provided */ + int flags; /* gzip header method and flags, 0 if zlib, or + -1 if raw or no header yet */ + unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ + unsigned long check; /* protected copy of check value */ + unsigned long total; /* protected copy of output count */ + gz_headerp head; /* where to save gzip header information */ + /* sliding window */ + unsigned wbits; /* log base 2 of requested window size */ + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned wnext; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if needed */ + /* bit accumulator */ + unsigned long hold; /* input bit accumulator */ + unsigned bits; /* number of bits in "in" */ + /* for string and stored block copying */ + unsigned length; /* literal or length of data to copy */ + unsigned offset; /* distance back to copy string from */ + /* for table and code decoding */ + unsigned extra; /* extra bits needed */ + /* fixed and dynamic code tables */ + code const FAR *lencode; /* starting table for length/literal codes */ + code const FAR *distcode; /* starting table for distance codes */ + unsigned lenbits; /* index bits for lencode */ + unsigned distbits; /* index bits for distcode */ + /* dynamic table building */ + unsigned ncode; /* number of code length code lengths */ + unsigned nlen; /* number of length code lengths */ + unsigned ndist; /* number of distance code lengths */ + unsigned have; /* number of code lengths in lens[] */ + code FAR *next; /* next available space in codes[] */ + unsigned short lens[320]; /* temporary storage for code lengths */ + unsigned short work[288]; /* work area for code table building */ + code codes[ENOUGH]; /* space for code tables */ + int sane; /* if false, allow invalid distance too far */ + int back; /* bits back of last unprocessed length/lit */ + unsigned was; /* initial length of match */ +}; diff --git a/deps/exla/cache/xla_extension/include/external/zlib/inftrees.h b/deps/exla/cache/xla_extension/include/external/zlib/inftrees.h new file mode 100644 index 0000000000000000000000000000000000000000..396f74b5da798ab1daf8039d748c5334735fed58 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/zlib/inftrees.h @@ -0,0 +1,62 @@ +/* inftrees.h -- header to use inftrees.c + * Copyright (C) 1995-2005, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* Structure for decoding tables. Each entry provides either the + information needed to do the operation requested by the code that + indexed that table entry, or it provides a pointer to another + table that indexes more bits of the code. op indicates whether + the entry is a pointer to another table, a literal, a length or + distance, an end-of-block, or an invalid code. For a table + pointer, the low four bits of op is the number of index bits of + that table. For a length or distance, the low four bits of op + is the number of extra bits to get after the code. bits is + the number of bits in this code or part of the code to drop off + of the bit buffer. val is the actual byte to output in the case + of a literal, the base length or distance, or the offset from + the current table to the next table. Each entry is four bytes. */ +typedef struct { + unsigned char op; /* operation, extra bits, table bits */ + unsigned char bits; /* bits in this part of the code */ + unsigned short val; /* offset in table or code value */ +} code; + +/* op values as set by inflate_table(): + 00000000 - literal + 0000tttt - table link, tttt != 0 is the number of table index bits + 0001eeee - length or distance, eeee is the number of extra bits + 01100000 - end of block + 01000000 - invalid code + */ + +/* Maximum size of the dynamic table. The maximum number of code structures is + 1444, which is the sum of 852 for literal/length codes and 592 for distance + codes. These values were found by exhaustive searches using the program + examples/enough.c found in the zlib distribution. The arguments to that + program are the number of symbols, the initial root table size, and the + maximum bit length of a code. "enough 286 9 15" for literal/length codes + returns 852, and "enough 30 6 15" for distance codes returns 592. The + initial root table size (9 or 6) is found in the fifth argument of the + inflate_table() calls in inflate.c and infback.c. If the root table size is + changed, then these maximum sizes would be need to be recalculated and + updated. */ +#define ENOUGH_LENS 852 +#define ENOUGH_DISTS 592 +#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) + +/* Type of code to build for inflate_table() */ +typedef enum { + CODES, + LENS, + DISTS +} codetype; + +int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work); diff --git a/deps/exla/cache/xla_extension/include/external/zlib/trees.h b/deps/exla/cache/xla_extension/include/external/zlib/trees.h new file mode 100644 index 0000000000000000000000000000000000000000..d35639d82a27807e49ea35c334f8bbcf64720f82 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/zlib/trees.h @@ -0,0 +1,128 @@ +/* header created automatically with -DGEN_TREES_H */ + +local const ct_data static_ltree[L_CODES+2] = { +{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, +{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, +{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, +{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, +{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, +{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, +{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, +{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, +{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, +{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, +{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, +{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, +{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, +{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, +{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, +{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, +{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, +{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, +{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, +{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, +{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, +{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, +{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, +{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, +{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, +{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, +{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, +{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, +{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, +{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, +{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, +{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, +{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, +{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, +{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, +{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, +{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, +{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, +{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, +{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, +{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, +{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, +{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, +{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, +{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, +{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, +{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, +{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, +{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, +{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, +{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, +{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, +{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, +{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, +{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, +{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, +{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, +{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} +}; + +local const ct_data static_dtree[D_CODES] = { +{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, +{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, +{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, +{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, +{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, +{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} +}; + +const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, + 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, +10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, +11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, +12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, +18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 +}; + +const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, +13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, +17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, +19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, +21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, +22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 +}; + +local const int base_length[LENGTH_CODES] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, +64, 80, 96, 112, 128, 160, 192, 224, 0 +}; + +local const int base_dist[D_CODES] = { + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, + 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, + 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 +}; + diff --git a/deps/exla/cache/xla_extension/include/external/zlib/zconf.h b/deps/exla/cache/xla_extension/include/external/zlib/zconf.h new file mode 100644 index 0000000000000000000000000000000000000000..62adc8d8431f2f9149ae0b1583915e21a28dd8b5 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/zlib/zconf.h @@ -0,0 +1,543 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". + */ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ +# define Z_PREFIX_SET + +/* all linked symbols and init macros */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_bits z__tr_flush_bits +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# define adler32_z z_adler32_z +# ifndef Z_SOLO +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# endif +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 +# define crc32_combine_gen z_crc32_combine_gen +# define crc32_combine_gen64 z_crc32_combine_gen64 +# define crc32_combine_op z_crc32_combine_op +# define crc32_z z_crc32_z +# define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy +# define deflateEnd z_deflateEnd +# define deflateGetDictionary z_deflateGetDictionary +# define deflateInit z_deflateInit +# define deflateInit2 z_deflateInit2 +# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflateParams z_deflateParams +# define deflatePending z_deflatePending +# define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateResetKeep z_deflateResetKeep +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# ifndef Z_SOLO +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzfread z_gzfread +# define gzfwrite z_gzfwrite +# define gzgetc z_gzgetc +# define gzgetc_ z_gzgetc_ +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# ifdef _WIN32 +# define gzopen_w z_gzopen_w +# endif +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzvprintf z_gzvprintf +# define gzwrite z_gzwrite +# endif +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit z_inflateBackInit +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCodesUsed z_inflateCodesUsed +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetDictionary z_inflateGetDictionary +# define inflateGetHeader z_inflateGetHeader +# define inflateInit z_inflateInit +# define inflateInit2 z_inflateInit2 +# define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 +# define inflateResetKeep z_inflateResetKeep +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateUndermine z_inflateUndermine +# define inflateValidate z_inflateValidate +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table +# ifndef Z_SOLO +# define uncompress z_uncompress +# define uncompress2 z_uncompress2 +# endif +# define zError z_zError +# ifndef Z_SOLO +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# endif +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion + +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef +# define alloc_func z_alloc_func +# define charf z_charf +# define free_func z_free_func +# ifndef Z_SOLO +# define gzFile z_gzFile +# endif +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp +# define in_func z_in_func +# define intf z_intf +# define out_func z_out_func +# define uInt z_uInt +# define uIntf z_uIntf +# define uLong z_uLong +# define uLongf z_uLongf +# define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +#if defined(ZLIB_CONST) && !defined(z_const) +# define z_const const +#else +# define z_const +#endif + +#ifdef Z_SOLO +# ifdef _WIN64 + typedef unsigned long long z_size_t; +# else + typedef unsigned long z_size_t; +# endif +#else +# define z_longlong long long +# if defined(NO_SIZE_T) + typedef unsigned NO_SIZE_T z_size_t; +# elif defined(STDC) +# include + typedef size_t z_size_t; +# else + typedef unsigned long z_size_t; +# endif +# undef z_longlong +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus about 7 kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) +# include +# if (UINT_MAX == 0xffffffffUL) +# define Z_U4 unsigned +# elif (ULONG_MAX == 0xffffffffUL) +# define Z_U4 unsigned long +# elif (USHRT_MAX == 0xffffffffUL) +# define Z_U4 unsigned short +# endif +#endif + +#ifdef Z_U4 + typedef Z_U4 z_crc_t; +#else + typedef unsigned long z_crc_t; +#endif + +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_STDARG_H +#endif + +#ifdef STDC +# ifndef Z_SOLO +# include /* for off_t */ +# endif +#endif + +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +# include /* for va_list */ +# endif +#endif + +#ifdef _WIN32 +# ifndef Z_SOLO +# include /* for wchar_t */ +# endif +#endif + +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even + * though the former does not conform to the LFS document), but considering + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as + * equivalently requesting no 64-bit operations + */ +#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 +# undef _LARGEFILE64_SOURCE +#endif + +#ifndef Z_HAVE_UNISTD_H +# ifdef __WATCOMC__ +# define Z_HAVE_UNISTD_H +# endif +#endif +#ifndef Z_HAVE_UNISTD_H +# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32) +# define Z_HAVE_UNISTD_H +# endif +#endif +#ifndef Z_SOLO +# if defined(Z_HAVE_UNISTD_H) +# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +# ifdef VMS +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif +# endif +#endif + +#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 +# define Z_LFS64 +#endif + +#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) +# define Z_LARGE64 +#endif + +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) +# define Z_WANT64 +#endif + +#if !defined(SEEK_SET) && !defined(Z_SOLO) +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif + +#ifndef z_off_t +# define z_off_t long +#endif + +#if !defined(_WIN32) && defined(Z_LARGE64) +# define z_off64_t off64_t +#else +# if defined(_WIN32) && !defined(__GNUC__) +# define z_off64_t __int64 +# else +# define z_off64_t z_off_t +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/deps/exla/cache/xla_extension/include/external/zlib/zlib.h b/deps/exla/cache/xla_extension/include/external/zlib/zlib.h new file mode 100644 index 0000000000000000000000000000000000000000..8d4b932eaf6a0fbb8133b3ab49ba5ef587059fa0 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/zlib/zlib.h @@ -0,0 +1,1938 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.3.1, January 22nd, 2024 + + Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 + (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.3.1" +#define ZLIB_VERNUM 0x1310 +#define ZLIB_VER_MAJOR 1 +#define ZLIB_VER_MINOR 3 +#define ZLIB_VER_REVISION 1 +#define ZLIB_VER_SUBREVISION 0 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed data. + This version of the library supports only one compression method (deflation) + but other algorithms will be added later and will have the same stream + interface. + + Compression can be done in a single step if the buffers are large enough, + or can be done by repeated calls of the compression function. In the latter + case, the application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip and raw deflate streams in + memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never crash + even in the case of corrupted input. +*/ + +typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size); +typedef void (*free_func)(voidpf opaque, voidpf address); + +struct internal_state; + +typedef struct z_stream_s { + z_const Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total number of input bytes read so far */ + + Bytef *next_out; /* next output byte will go here */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total number of bytes output so far */ + + z_const char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text + for deflate, or the decoding state for inflate */ + uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has dropped + to zero. It must update next_out and avail_out when avail_out has dropped + to zero. The application must initialize zalloc, zfree and opaque before + calling the init function. All other fields are set by the compression + library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. In that case, zlib is thread-safe. When zalloc and zfree are + Z_NULL on entry to the initialization function, they are set to internal + routines that use the standard library functions malloc() and free(). + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this if + the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers + returned by zalloc for objects of exactly 65536 bytes *must* have their + offset normalized to zero. The default allocation function provided by this + library ensures this (see zutil.c). To reduce memory requirements and avoid + any allocation of 64K objects, at the expense of compression ratio, compile + the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or progress + reports. After compression, total_in holds the total size of the + uncompressed data and may be saved for use by the decompressor (particularly + if the decompressor wants to decompress everything in a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +#define Z_TREES 6 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field for deflate() */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion(void); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is not + compatible with the zlib.h header file used by the application. This check + is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. If + zalloc and zfree are set to Z_NULL, deflateInit updates them to use default + allocation functions. total_in, total_out, adler, and msg are initialized. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at all + (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION + requests a default compromise between speed and compression (currently + equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if level is not a valid compression level, or + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). msg is set to null + if there is no error message. deflateInit does not perform any compression: + this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate(z_streamp strm, int flush); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Generate more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary. Some output may be provided even if + flush is zero. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating avail_in or avail_out accordingly; avail_out should + never be zero before the call. The application can consume the compressed + output when it wants, for example when the output buffer is full (avail_out + == 0), or after each call of deflate(). If deflate returns Z_OK and with + zero avail_out, it must be called again after making room in the output + buffer because there might be more output pending. See deflatePending(), + which can be used if desired to determine whether or not there is more output + in that case. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumulate before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In + particular avail_in is zero after the call if enough output space has been + provided before the call.) Flushing may degrade compression for some + compression algorithms and so it should be used only when necessary. This + completes the current deflate block and follows it with an empty stored block + that is three bits plus filler bits to the next byte, followed by four bytes + (00 00 ff ff). + + If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the + output buffer, but the output is not aligned to a byte boundary. All of the + input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. + This completes the current deflate block and follows it with an empty fixed + codes block that is 10 bits long. This assures that enough bytes are output + in order for the decompressor to finish the block before the empty fixed + codes block. + + If flush is set to Z_BLOCK, a deflate block is completed and emitted, as + for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to + seven bits of the current block are held to be written as the next byte after + the next deflate block is completed. In this case, the decompressor may not + be provided enough bits at this point in order to complete decompression of + the data provided so far to the compressor. It may need to wait for the next + block to be emitted. This is for advanced applications that need to control + the emission of deflate blocks. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six when the flush marker begins, in order to avoid + repeated flush markers upon calling deflate() again when avail_out == 0. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there was + enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this + function must be called again with Z_FINISH and more output space (updated + avail_out) but no more input data, until it returns with Z_STREAM_END or an + error. After deflate has returned Z_STREAM_END, the only possible operations + on the stream are deflateReset or deflateEnd. + + Z_FINISH can be used in the first deflate call after deflateInit if all the + compression is to be done in a single step. In order to complete in one + call, avail_out must be at least the value returned by deflateBound (see + below). Then deflate is guaranteed to return Z_STREAM_END. If not enough + output space is provided, deflate will not return Z_STREAM_END, and it must + be called again as described above. + + deflate() sets strm->adler to the Adler-32 checksum of all input read + so far (that is, total_in bytes). If a gzip stream is being generated, then + strm->adler will be the CRC-32 checksum of the input read so far. (See + deflateInit2 below.) + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is + considered binary. This field is only for information purposes and does not + affect the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was Z_NULL or the state was inadvertently written over + by the application), or Z_BUF_ERROR if no progress is possible (for example + avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and + deflate() can be called again with more input and more output space to + continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd(z_streamp strm); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, msg + may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit(z_streamp strm); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. In the current version of inflate, the provided input is not + read or consumed. The allocation of a sliding window will be deferred to + the first call of inflate (if the decompression does not complete on the + first call). If zalloc and zfree are set to Z_NULL, inflateInit updates + them to use default allocation functions. total_in, total_out, adler, and + msg are initialized. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit does not perform any decompression. + Actual decompression will be done by inflate(). So next_in, and avail_in, + next_out, and avail_out are unused and unchanged. The current + implementation of inflateInit() does not process any header information -- + that is deferred until inflate() is called. +*/ + + +ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), then next_in and avail_in are updated + accordingly, and processing will resume at this point for the next call of + inflate(). + + - Generate more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there is + no more input data or no more space in the output buffer (see below about + the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating the next_* and avail_* values accordingly. If the + caller of inflate() does not provide both available input and available + output space, it is possible that there will be no progress made. The + application can consume the uncompressed output when it wants, for example + when the output buffer is full (avail_out == 0), or after each call of + inflate(). If inflate returns Z_OK and with zero avail_out, it must be + called again after making room in the output buffer because there might be + more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, + Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() + stop if and when it gets to the next deflate block boundary. When decoding + the zlib or gzip format, this will cause inflate() to return immediately + after the header and before the first block. When doing a raw inflate, + inflate() will go ahead and process the first block, and will return when it + gets to the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + To assist in this, on return inflate() always sets strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 if + inflate() is currently decoding the last block in the deflate stream, plus + 128 if inflate() returned immediately after decoding an end-of-block code or + decoding the complete header up to just before the first byte of the deflate + stream. The end-of-block will not be indicated until all of the uncompressed + data from that block has been written to strm->next_out. The number of + unused bits may in general be greater than seven, except when bit 7 of + data_type is set, in which case the number of unused bits will be less than + eight. data_type is set as noted here every time inflate() returns for all + flush options, and so can be used to determine the amount of currently + consumed input in bits. + + The Z_TREES option behaves as Z_BLOCK does, but it also returns when the + end of each deflate block header is reached, before any actual data in that + block is decoded. This allows the caller to determine the length of the + deflate block header for later use in random access within a deflate block. + 256 is added to the value of strm->data_type when inflate() returns + immediately after reaching the end of the deflate block header. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step (a + single call of inflate), the parameter flush should be set to Z_FINISH. In + this case all pending input is processed and all pending output is flushed; + avail_out must be large enough to hold all of the uncompressed data for the + operation to complete. (The size of the uncompressed data may have been + saved by the compressor for this purpose.) The use of Z_FINISH is not + required to perform an inflation in one step. However it may be used to + inform inflate that a faster approach can be used for the single inflate() + call. Z_FINISH also informs inflate to not maintain a sliding window if the + stream completes, which reduces inflate's memory footprint. If the stream + does not complete, either because not all of the stream is provided or not + enough output space is provided, then a sliding window will be allocated and + inflate() can be called again to continue the operation as if Z_NO_FLUSH had + been used. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the effects of the flush parameter in this implementation are + on the return value of inflate() as noted below, when inflate() returns early + when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of + memory for a sliding window when Z_FINISH is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the Adler-32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the Adler-32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed Adler-32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() can decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically, if requested when + initializing with inflateInit2(). Any information contained in the gzip + header is not retained unless inflateGetHeader() is used. When processing + gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output + produced so far. The CRC-32 is checked against the gzip trailer, as is the + uncompressed length, modulo 2^32. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value, in which case strm->msg points to a string with a more specific + error), Z_STREAM_ERROR if the stream structure was inconsistent (for example + next_in or next_out was Z_NULL, or the state was inadvertently written over + by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR + if no progress was possible or if there was not enough room in the output + buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may + then call inflateSync() to look for a good compression block if a partial + recovery of the data is to be attempted. +*/ + + +ZEXTERN int ZEXPORT inflateEnd(z_streamp strm); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state + was inconsistent. +*/ + + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2(z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy); + + This is another version of deflateInit with more compression options. The + fields zalloc, zfree and opaque must be initialized before by the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + For the current implementation of deflate(), a windowBits value of 8 (a + window size of 256 bytes) is not supported. As a result, a request for 8 + will result in 9 (a 512-byte window). In that case, providing 8 to + inflateInit2() will result in an error when the zlib header with 9 is + checked against the initialization of inflate(). The remedy is to not use 8 + with deflateInit2() with this initialization, or at least in that case use 9 + with inflateInit2(). + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute a check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), no + header crc, and the operating system will be set to the appropriate value, + if the operating system was determined at compile time. If a gzip stream is + being written, strm->adler is a CRC-32 instead of an Adler-32. + + For raw deflate or gzip encoding, a request for a 256-byte window is + rejected as invalid, since only the zlib header provides a means of + transmitting the window size to the decompressor. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but is + slow and reduces compression ratio; memLevel=9 uses maximum memory for + optimal speed. The default value is 8. See zconf.h for total memory usage + as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as + fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The + strategy parameter only affects the compression ratio but not the + correctness of the compressed output even if it is not set appropriately. + Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler + decoder for special applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid + method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is + incompatible with the version assumed by the caller (ZLIB_VERSION). msg is + set to null if there is no error message. deflateInit2 does not perform any + compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm, + const Bytef *dictionary, + uInt dictLength); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. When using the zlib format, this + function must be called immediately after deflateInit, deflateInit2 or + deflateReset, and before any call of deflate. When doing raw deflate, this + function must be called either before any call of deflate, or immediately + after the completion of a deflate block, i.e. after all input has been + consumed and all output has been delivered when using any of the flush + options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The + compressor and decompressor must use exactly the same dictionary (see + inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size + provided in deflateInit or deflateInit2. Thus the strings most likely to be + useful should be put at the end of the dictionary, not at the front. In + addition, the current implementation of deflate will use at most the window + size minus 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the Adler-32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler-32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + Adler-32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if not at a block boundary for raw deflate). deflateSetDictionary does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm, + Bytef *dictionary, + uInt *dictLength); +/* + Returns the sliding dictionary being maintained by deflate. dictLength is + set to the number of bytes in the dictionary, and that many bytes are copied + to dictionary. dictionary must have enough space, where 32768 bytes is + always enough. If deflateGetDictionary() is called with dictionary equal to + Z_NULL, then only the dictionary length is returned, and nothing is copied. + Similarly, if dictLength is Z_NULL, then it is not set. + + deflateGetDictionary() may return a length less than the window size, even + when more than the window size in input has been provided. It may return up + to 258 bytes less in that case, due to how zlib's implementation of deflate + manages the sliding window and lookahead for matches, where matches can be + up to 258 bytes long. If the application needs the last window-size bytes of + input, then that would need to be saved by the application outside of zlib. + + deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the + stream state is inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateCopy(z_streamp dest, + z_streamp source); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and can + consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset(z_streamp strm); +/* + This function is equivalent to deflateEnd followed by deflateInit, but + does not free and reallocate the internal compression state. The stream + will leave the compression level and any other attributes that may have been + set unchanged. total_in, total_out, adler, and msg are initialized. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams(z_streamp strm, + int level, + int strategy); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2(). This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different strategy. + If the compression approach (which is a function of the level) or the + strategy is changed, and if there have been any deflate() calls since the + state was initialized or reset, then the input available so far is + compressed with the old level and strategy using deflate(strm, Z_BLOCK). + There are three approaches for the compression levels 0, 1..3, and 4..9 + respectively. The new level and strategy will take effect at the next call + of deflate(). + + If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does + not have enough output space to complete, then the parameter change will not + take effect. In this case, deflateParams() can be called again with the + same parameters and more output space to try again. + + In order to assure a change in the parameters on the first try, the + deflate stream should be flushed using deflate() with Z_BLOCK or other flush + request until strm.avail_out is not zero, before calling deflateParams(). + Then no more input data should be provided before the deflateParams() call. + If this is done, the old level and strategy will be applied to the data + compressed before deflateParams(), and the new level and strategy will be + applied to the data compressed after deflateParams(). + + deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream + state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if + there was not enough output space to complete the compression of the + available input data before a change in the strategy or approach. Note that + in the case of a Z_BUF_ERROR, the parameters are not changed. A return + value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be + retried with more output space. +*/ + +ZEXTERN int ZEXPORT deflateTune(z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, + uLong sourceLen); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() or + deflateInit2(), and after deflateSetHeader(), if used. This would be used + to allocate an output buffer for deflation in a single pass, and so would be + called before deflate(). If that first deflate() call is provided the + sourceLen input bytes, an output buffer allocated to the size returned by + deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed + to return Z_STREAM_END. Note that it is possible for the compressed size to + be larger than the value returned by deflateBound() if flush options other + than Z_FINISH or Z_NO_FLUSH are used. +*/ + +ZEXTERN int ZEXPORT deflatePending(z_streamp strm, + unsigned *pending, + int *bits); +/* + deflatePending() returns the number of bytes and bits of output that have + been generated, but not yet provided in the available output. The bytes not + provided would be due to the available output space having being consumed. + The number of bits of output not provided are between 0 and 7, where they + await more bits to join them in order to fill out a full byte. If pending + or bits are Z_NULL, then those values are not set. + + deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. + */ + +ZEXTERN int ZEXPORT deflatePrime(z_streamp strm, + int bits, + int value); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the bits + leftover from a previous deflate stream when appending to it. As such, this + function can only be used for raw deflate, and must be used before the first + deflate() call after a deflateInit2() or deflateReset(). bits must be less + than or equal to 16, and that many of the least significant bits of value + will be inserted in the output. + + deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough + room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader(z_streamp strm, + gz_headerp head); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to the current operating system, with no + extra, name, or comment fields. The gzip header is returned to the default + state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2(z_streamp strm, + int windowBits); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be zero to request that inflate use the window size in + the zlib header of the compressed stream. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an Adler-32 or a CRC-32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a + CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see + below), inflate() will *not* automatically decode concatenated gzip members. + inflate() will return Z_STREAM_END at the end of the gzip member. The state + would need to be reset to continue decoding a subsequent gzip member. This + *must* be done if there is more data after a gzip member, in order for the + decompression to be compliant with the gzip standard (RFC 1952). + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit2 does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit2() does not process any header information -- that is + deferred until inflate() is called. +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm, + const Bytef *dictionary, + uInt dictLength); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler-32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called at any + time to set the dictionary. If the provided dictionary is smaller than the + window and there is already data in the window, then the provided dictionary + will amend what's there. The application must insure that the dictionary + that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler-32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm, + Bytef *dictionary, + uInt *dictLength); +/* + Returns the sliding dictionary being maintained by inflate. dictLength is + set to the number of bytes in the dictionary, and that many bytes are copied + to dictionary. dictionary must have enough space, where 32768 bytes is + always enough. If inflateGetDictionary() is called with dictionary equal to + Z_NULL, then only the dictionary length is returned, and nothing is copied. + Similarly, if dictLength is Z_NULL, then it is not set. + + inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the + stream state is inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateSync(z_streamp strm); +/* + Skips invalid compressed data until a possible full flush point (see above + for the description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync searches for a 00 00 FF FF pattern in the compressed data. + All full flush points have this pattern, but not all occurrences of this + pattern are full flush points. + + inflateSync returns Z_OK if a possible full flush point has been found, + Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point + has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. + In the success case, the application may save the current value of total_in + which indicates where valid compressed data was found. In the error case, + the application may repeatedly call inflateSync, providing more input each + time, until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy(z_streamp dest, + z_streamp source); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset(z_streamp strm); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate the internal decompression state. The + stream will keep attributes that may have been set by inflateInit2. + total_in, total_out, adler, and msg are initialized. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT inflateReset2(z_streamp strm, + int windowBits); +/* + This function is the same as inflateReset, but it also permits changing + the wrap and window size requests. The windowBits parameter is interpreted + the same as it is for inflateInit2. If the window size is changed, then the + memory allocated for the window is freed, and the window will be reallocated + by inflate() if needed. + + inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL), or if + the windowBits parameter is invalid. +*/ + +ZEXTERN int ZEXPORT inflatePrime(z_streamp strm, + int bits, + int value); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + If bits is negative, then the input stream bit buffer is emptied. Then + inflatePrime() can be called again to put bits in the buffer. This is used + to clear out bits leftover after feeding inflate a block description prior + to feeding inflate codes. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN long ZEXPORT inflateMark(z_streamp strm); +/* + This function returns two values, one in the lower 16 bits of the return + value, and the other in the remaining upper bits, obtained by shifting the + return value down 16 bits. If the upper value is -1 and the lower value is + zero, then inflate() is currently decoding information outside of a block. + If the upper value is -1 and the lower value is non-zero, then inflate is in + the middle of a stored block, with the lower value equaling the number of + bytes from the input remaining to copy. If the upper value is not -1, then + it is the number of bits back from the current bit position in the input of + the code (literal or length/distance pair) currently being processed. In + that case the lower value is the number of bytes already emitted for that + code. + + A code is being processed if inflate is waiting for more input to complete + decoding of the code, or if it has completed decoding but is waiting for + more output space to write the literal or match data. + + inflateMark() is used to mark locations in the input data for random + access, which may be at bit positions, and to note those cases where the + output of a code may span boundaries of random access blocks. The current + location in the input stream can be determined from avail_in and data_type + as noted in the description for the Z_BLOCK flush parameter for inflate. + + inflateMark returns the value noted above, or -65536 if the provided + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm, + gz_headerp head); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be + used to force inflate() to return immediately after header processing is + complete and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When any + of extra, name, or comment are not Z_NULL and the respective field is not + present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit(z_streamp strm, int windowBits, + unsigned char FAR *window); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the parameters are invalid, Z_MEM_ERROR if the internal state could not be + allocated, or Z_VERSION_ERROR if the version of the library does not match + the version of the header file. +*/ + +typedef unsigned (*in_func)(void FAR *, + z_const unsigned char FAR * FAR *); +typedef int (*out_func)(void FAR *, unsigned char FAR *, unsigned); + +ZEXTERN int ZEXPORT inflateBack(z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is potentially more efficient than + inflate() for file i/o applications, in that it avoids copying between the + output and the sliding window by simply making the window itself the output + buffer. inflate() can be faster on modern CPUs when used with large + buffers. inflateBack() trusts the application to not change the output + buffer passed by the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free the + allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects only + the raw deflate stream to decompress. This is different from the default + behavior of inflate(), which expects a zlib header and trailer around the + deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero -- buf is ignored in that + case -- and inflateBack() will return a buffer error. inflateBack() will + call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. + out() should return zero on success, or non-zero on failure. If out() + returns non-zero, inflateBack() will return with an error. Neither in() nor + out() are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format error + in the deflate stream (in which case strm->msg is set to indicate the nature + of the error), or Z_STREAM_ERROR if the stream was not properly initialized. + In the case of Z_BUF_ERROR, an input or output error can be distinguished + using strm->next_in which will be Z_NULL only if in() returned an error. If + strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning + non-zero. (in() will always be called before out(), so strm->next_in is + assured to be defined if out() returns non-zero.) Note that inflateBack() + cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd(z_streamp strm); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags(void); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: ZLIB_DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + +#ifndef Z_SOLO + + /* utility functions */ + +/* + The following utility functions are implemented on top of the basic + stream-oriented functions. To simplify the interface, some default options + are assumed (compression level and memory usage, standard memory allocation + functions). The source code of these utility functions can be modified if + you need special options. +*/ + +ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed data. compress() is equivalent to compress2() with a level + parameter of Z_DEFAULT_COMPRESSION. + + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed data. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before a + compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be large enough to hold the entire + uncompressed data. (The size of the uncompressed data must have been saved + previously by the compressor and transmitted to the decompressor by some + mechanism outside the scope of this compression library.) Upon exit, destLen + is the actual size of the uncompressed data. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In + the case where there is not enough room, uncompress() will fill the output + buffer with the uncompressed data up to that point. +*/ + +ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong *sourceLen); +/* + Same as uncompress, except that sourceLen is a pointer, where the + length of the source is *sourceLen. On return, *sourceLen is the number of + source bytes consumed. +*/ + + /* gzip file access functions */ + +/* + This library supports reading and writing files in gzip (.gz) format with + an interface similar to that of stdio, using the functions that start with + "gz". The gzip format is different from the zlib format. gzip is a gzip + wrapper, documented in RFC 1952, wrapped around a deflate stream. +*/ + +typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ + +/* +ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode); + + Open the gzip (.gz) file at path for reading and decompressing, or + compressing and writing. The mode parameter is as in fopen ("rb" or "wb") + but can also include a compression level ("wb9") or a strategy: 'f' for + filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", + 'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression + as in "wb9F". (See the description of deflateInit2 for more information + about the strategy parameter.) 'T' will request transparent writing or + appending with no compression and not using the gzip format. + + "a" can be used instead of "w" to request that the gzip stream that will + be written be appended to the file. "+" will result in an error, since + reading and writing to the same gzip file is not supported. The addition of + "x" when writing will create the file exclusively, which fails if the file + already exists. On systems that support it, the addition of "e" when + reading or writing will set the flag to close the file on an execve() call. + + These functions, as well as gzip, will read and decode a sequence of gzip + streams in a file. The append function of gzopen() can be used to create + such a file. (Also see gzflush() for another way to do this.) When + appending, gzopen does not test whether the file begins with a gzip stream, + nor does it look for the end of the gzip streams to begin appending. gzopen + will simply append a gzip stream to the existing file. + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. When + reading, this will be detected automatically by looking for the magic two- + byte gzip header. + + gzopen returns NULL if the file could not be opened, if there was + insufficient memory to allocate the gzFile state, or if an invalid mode was + specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). + errno can be checked to determine if the reason gzopen failed was that the + file could not be opened. +*/ + +ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode); +/* + Associate a gzFile with the file descriptor fd. File descriptors are + obtained from calls like open, dup, creat, pipe or fileno (if the file has + been previously opened with fopen). The mode parameter is as in gzopen. + + The next call of gzclose on the returned gzFile will also close the file + descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor + fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, + mode);. The duplicated descriptor should be saved to avoid a leak, since + gzdopen does not close fd if it fails. If you are using fileno() to get the + file descriptor from a FILE *, then you will have to use dup() to avoid + double-close()ing the file descriptor. Both gzclose() and fclose() will + close the associated file descriptor, so they need to have different file + descriptors. + + gzdopen returns NULL if there was insufficient memory to allocate the + gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not + provided, or '+' was provided), or if fd is -1. The file descriptor is not + used until the next gz* read, write, seek, or close operation, so gzdopen + will not detect if fd is invalid (unless fd is -1). +*/ + +ZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size); +/* + Set the internal buffer size used by this library's functions for file to + size. The default buffer size is 8192 bytes. This function must be called + after gzopen() or gzdopen(), and before any other calls that read or write + the file. The buffer memory allocation is always deferred to the first read + or write. Three times that size in buffer space is allocated. A larger + buffer size of, for example, 64K or 128K bytes will noticeably increase the + speed of decompression (reading). + + The new buffer size also affects the maximum length for gzprintf(). + + gzbuffer() returns 0 on success, or -1 on failure, such as being called + too late. +*/ + +ZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy); +/* + Dynamically update the compression level and strategy for file. See the + description of deflateInit2 for the meaning of these parameters. Previously + provided data is flushed before applying the parameter changes. + + gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not + opened for writing, Z_ERRNO if there is an error writing the flushed data, + or Z_MEM_ERROR if there is a memory allocation error. +*/ + +ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len); +/* + Read and decompress up to len uncompressed bytes from file into buf. If + the input file is not in gzip format, gzread copies the given number of + bytes into the buffer directly from the file. + + After reaching the end of a gzip stream in the input, gzread will continue + to read, looking for another gzip stream. Any number of gzip streams may be + concatenated in the input file, and will all be decompressed by gzread(). + If something other than a gzip stream is encountered after a gzip stream, + that remaining trailing garbage is ignored (and no error is returned). + + gzread can be used to read a gzip file that is being concurrently written. + Upon reaching the end of the input, gzread will return with the available + data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then + gzclearerr can be used to clear the end of file indicator in order to permit + gzread to be tried again. Z_OK indicates that a gzip stream was completed + on the last gzread. Z_BUF_ERROR indicates that the input file ended in the + middle of a gzip stream. Note that gzread does not return -1 in the event + of an incomplete gzip stream. This error is deferred until gzclose(), which + will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip + stream. Alternatively, gzerror can be used before gzclose to detect this + case. + + gzread returns the number of uncompressed bytes actually read, less than + len for end of file, or -1 for error. If len is too large to fit in an int, + then nothing is read, -1 is returned, and the error state is set to + Z_STREAM_ERROR. +*/ + +ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, + gzFile file); +/* + Read and decompress up to nitems items of size size from file into buf, + otherwise operating as gzread() does. This duplicates the interface of + stdio's fread(), with size_t request and return types. If the library + defines size_t, then z_size_t is identical to size_t. If not, then z_size_t + is an unsigned integer type that can contain a pointer. + + gzfread() returns the number of full items read of size size, or zero if + the end of the file was reached and a full item could not be read, or if + there was an error. gzerror() must be consulted if zero is returned in + order to determine if there was an error. If the multiplication of size and + nitems overflows, i.e. the product does not fit in a z_size_t, then nothing + is read, zero is returned, and the error state is set to Z_STREAM_ERROR. + + In the event that the end of file is reached and only a partial item is + available at the end, i.e. the remaining uncompressed data length is not a + multiple of size, then the final partial item is nevertheless read into buf + and the end-of-file flag is set. The length of the partial item read is not + provided, but could be inferred from the result of gztell(). This behavior + is the same as the behavior of fread() implementations in common libraries, + but it prevents the direct use of gzfread() to read a concurrently written + file, resetting and retrying on end-of-file, when size is not 1. +*/ + +ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len); +/* + Compress and write the len uncompressed bytes at buf to file. gzwrite + returns the number of uncompressed bytes written or 0 in case of error. +*/ + +ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, + z_size_t nitems, gzFile file); +/* + Compress and write nitems items of size size from buf to file, duplicating + the interface of stdio's fwrite(), with size_t request and return types. If + the library defines size_t, then z_size_t is identical to size_t. If not, + then z_size_t is an unsigned integer type that can contain a pointer. + + gzfwrite() returns the number of full items written of size size, or zero + if there was an error. If the multiplication of size and nitems overflows, + i.e. the product does not fit in a z_size_t, then nothing is written, zero + is returned, and the error state is set to Z_STREAM_ERROR. +*/ + +ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...); +/* + Convert, format, compress, and write the arguments (...) to file under + control of the string format, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written, or a negative zlib error code in case + of error. The number of uncompressed bytes written is limited to 8191, or + one less than the buffer size given to gzbuffer(). The caller should assure + that this limit is not exceeded. If it is exceeded, then gzprintf() will + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf(), + because the secure snprintf() or vsnprintf() functions were not available. + This can be determined using zlibCompileFlags(). +*/ + +ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s); +/* + Compress and write the given null-terminated string s to file, excluding + the terminating null character. + + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len); +/* + Read and decompress bytes from file into buf, until len-1 characters are + read, or until a newline character is read and transferred to buf, or an + end-of-file condition is encountered. If any characters are read or if len + is one, the string is terminated with a null character. If no characters + are read due to an end-of-file or len is less than one, then the buffer is + left untouched. + + gzgets returns buf which is a null-terminated string, or it returns NULL + for end-of-file or in case of error. If there was an error, the contents at + buf are indeterminate. +*/ + +ZEXTERN int ZEXPORT gzputc(gzFile file, int c); +/* + Compress and write c, converted to an unsigned char, into file. gzputc + returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc(gzFile file); +/* + Read and decompress one byte from file. gzgetc returns this byte or -1 + in case of end of file or error. This is implemented as a macro for speed. + As such, it does not do all of the checking the other functions do. I.e. + it does not check to see if file is NULL, nor whether the structure file + points to has been clobbered or not. +*/ + +ZEXTERN int ZEXPORT gzungetc(int c, gzFile file); +/* + Push c back onto the stream for file to be read as the first character on + the next read. At least one character of push-back is always allowed. + gzungetc() returns the character pushed, or -1 on failure. gzungetc() will + fail if c is -1, and may fail if a character has been pushed but not read + yet. If gzungetc is used immediately after gzopen or gzdopen, at least the + output buffer size of pushed characters is allowed. (See gzbuffer above.) + The pushed character will be discarded if the stream is repositioned with + gzseek() or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush(gzFile file, int flush); +/* + Flush all pending output to file. The parameter flush is as in the + deflate() function. The return value is the zlib error number (see function + gzerror below). gzflush is only permitted when writing. + + If the flush parameter is Z_FINISH, the remaining data is written and the + gzip stream is completed in the output. If gzwrite() is called again, a new + gzip stream will be started in the output. gzread() is able to read such + concatenated gzip streams. + + gzflush should be called only when strictly necessary because it will + degrade compression if called too often. +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzseek(gzFile file, + z_off_t offset, int whence); + + Set the starting position to offset relative to whence for the next gzread + or gzwrite on file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind(gzFile file); +/* + Rewind file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). +*/ + +/* +ZEXTERN z_off_t ZEXPORT gztell(gzFile file); + + Return the starting position for the next gzread or gzwrite on file. + This position represents a number of bytes in the uncompressed data stream, + and is zero when starting, even if appending or reading a gzip stream from + the middle of a file using gzdopen(). + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzoffset(gzFile file); + + Return the current compressed (actual) read or write offset of file. This + offset includes the count of bytes that precede the gzip stream, for example + when appending or when using gzdopen() for reading. When reading, the + offset does not include as yet unused buffered input. This information can + be used for a progress indicator. On error, gzoffset() returns -1. +*/ + +ZEXTERN int ZEXPORT gzeof(gzFile file); +/* + Return true (1) if the end-of-file indicator for file has been set while + reading, false (0) otherwise. Note that the end-of-file indicator is set + only if the read tried to go past the end of the input, but came up short. + Therefore, just like feof(), gzeof() may return false even if there is no + more data to read, in the event that the last read request was for the exact + number of bytes remaining in the input file. This will happen if the input + file size is an exact multiple of the buffer size. + + If gzeof() returns true, then the read functions will return no more data, + unless the end-of-file indicator is reset by gzclearerr() and the input file + has grown since the previous end of file was detected. +*/ + +ZEXTERN int ZEXPORT gzdirect(gzFile file); +/* + Return true (1) if file is being copied directly while reading, or false + (0) if file is a gzip stream being decompressed. + + If the input file is empty, gzdirect() will return true, since the input + does not contain a gzip stream. + + If gzdirect() is used immediately after gzopen() or gzdopen() it will + cause buffers to be allocated to allow reading the file to determine if it + is a gzip file. Therefore if gzbuffer() is used, it should be called before + gzdirect(). + + When writing, gzdirect() returns true (1) if transparent writing was + requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: + gzdirect() is not needed when writing. Transparent writing must be + explicitly requested, so the application already knows the answer. When + linking statically, using gzdirect() will include all of the zlib code for + gzip file reading and decompression, which may not be desired.) +*/ + +ZEXTERN int ZEXPORT gzclose(gzFile file); +/* + Flush all pending output for file, if necessary, close file and + deallocate the (de)compression state. Note that once file is closed, you + cannot call gzerror with file, since its structures have been deallocated. + gzclose must not be called more than once on the same file, just as free + must not be called more than once on the same allocation. + + gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a + file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the + last read ended in the middle of a gzip stream, or Z_OK on success. +*/ + +ZEXTERN int ZEXPORT gzclose_r(gzFile file); +ZEXTERN int ZEXPORT gzclose_w(gzFile file); +/* + Same as gzclose(), but gzclose_r() is only for use when reading, and + gzclose_w() is only for use when writing or appending. The advantage to + using these instead of gzclose() is that they avoid linking in zlib + compression or decompression code that is not used when only reading or only + writing respectively. If gzclose() is used, then both compression and + decompression code will be included the application when linking to a static + zlib library. +*/ + +ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum); +/* + Return the error message for the last error which occurred on file. + errnum is set to zlib error number. If an error occurred in the file system + and not in the compression library, errnum is set to Z_ERRNO and the + application may consult errno to get the exact error code. + + The application must not modify the returned string. Future calls to + this function may invalidate the previously returned string. If file is + closed, then the string previously returned by gzerror will no longer be + available. + + gzerror() should be used to distinguish errors from end-of-file for those + functions above that do not distinguish those cases in their return values. +*/ + +ZEXTERN void ZEXPORT gzclearerr(gzFile file); +/* + Clear the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + +#endif /* !Z_SOLO */ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the compression + library. +*/ + +ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. An Adler-32 value is in the range of a 32-bit + unsigned integer. If buf is Z_NULL, this function returns the required + initial value for the checksum. + + An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed + much faster. + + Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, + z_size_t len); +/* + Same as adler32(), but with a size_t length. +*/ + +/* +ZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, + z_off_t len2); + + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note + that the z_off_t type (like off_t) is a signed integer. If len2 is + negative, the result has no meaning or utility. +*/ + +ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. + If buf is Z_NULL, this function returns the required initial value for the + crc. Pre- and post-conditioning (one's complement) is performed within this + function so it shouldn't be done by the application. + + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf, + z_size_t len); +/* + Same as crc32(), but with a size_t length. +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2); + + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. len2 must be non-negative. +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2); + + Return the operator corresponding to length len2, to be used with + crc32_combine_op(). len2 must be non-negative. +*/ + +ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op); +/* + Give the same result as crc32_combine(), using op in place of len2. op is + is generated from len2 by crc32_combine_gen(). This will be faster than + crc32_combine() if the generated op is used more than once. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_(z_streamp strm, int level, + const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateInit_(z_streamp strm, + const char *version, int stream_size); +ZEXTERN int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size); +ZEXTERN int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, + const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size); +#ifdef Z_PREFIX_SET +# define z_deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ + (int)sizeof(z_stream)) +# define z_inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, (int)sizeof(z_stream)) +#else +# define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) +# define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) +# define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) +# define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ + (int)sizeof(z_stream)) +# define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, (int)sizeof(z_stream)) +#endif + +#ifndef Z_SOLO + +/* gzgetc() macro and its supporting function and exposed data structure. Note + * that the real internal state is much larger than the exposed structure. + * This abbreviated structure exposes just enough for the gzgetc() macro. The + * user should not mess with these exposed elements, since their names or + * behavior could change in the future, perhaps even capriciously. They can + * only be used by the gzgetc() macro. You have been warned. + */ +struct gzFile_s { + unsigned have; + unsigned char *next; + z_off64_t pos; +}; +ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ +#ifdef Z_PREFIX_SET +# undef z_gzgetc +# define z_gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) +#else +# define gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) +#endif + +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if + * both are true, the application gets the *64 functions, and the regular + * functions are changed to 64 bits) -- in case these are set on systems + * without large file support, _LFS64_LARGEFILE must also be true + */ +#ifdef Z_LARGE64 + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t); +#endif + +#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) +# ifdef Z_PREFIX_SET +# define z_gzopen z_gzopen64 +# define z_gzseek z_gzseek64 +# define z_gztell z_gztell64 +# define z_gzoffset z_gzoffset64 +# define z_adler32_combine z_adler32_combine64 +# define z_crc32_combine z_crc32_combine64 +# define z_crc32_combine_gen z_crc32_combine_gen64 +# else +# define gzopen gzopen64 +# define gzseek gzseek64 +# define gztell gztell64 +# define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# define crc32_combine_gen crc32_combine_gen64 +# endif +# ifndef Z_LARGE64 + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); +# endif +#else + ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); +#endif + +#else /* Z_SOLO */ + + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); + +#endif /* !Z_SOLO */ + +/* undocumented functions */ +ZEXTERN const char * ZEXPORT zError(int); +ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp); +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void); +ZEXTERN int ZEXPORT inflateUndermine(z_streamp, int); +ZEXTERN int ZEXPORT inflateValidate(z_streamp, int); +ZEXTERN unsigned long ZEXPORT inflateCodesUsed(z_streamp); +ZEXTERN int ZEXPORT inflateResetKeep(z_streamp); +ZEXTERN int ZEXPORT deflateResetKeep(z_streamp); +#if defined(_WIN32) && !defined(Z_SOLO) +ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, + const char *mode); +#endif +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, + const char *format, + va_list va); +# endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/deps/exla/cache/xla_extension/include/external/zlib/zutil.h b/deps/exla/cache/xla_extension/include/external/zlib/zutil.h new file mode 100644 index 0000000000000000000000000000000000000000..48dd7febae65eeeaad7794f0a9317bcd054c107f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/external/zlib/zutil.h @@ -0,0 +1,254 @@ +/* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef ZUTIL_H +#define ZUTIL_H + +#ifdef HAVE_HIDDEN +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) +#else +# define ZLIB_INTERNAL +#endif + +#include "zlib.h" + +#if defined(STDC) && !defined(Z_SOLO) +# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) +# include +# endif +# include +# include +#endif + +#ifndef local +# define local static +#endif +/* since "static" is used to mean two completely different things in C, we + define "local" for the non-static meaning of "static", for readability + (compile with -Dlocal if your debugger can't find static symbols) */ + +typedef unsigned char uch; +typedef uch FAR uchf; +typedef unsigned short ush; +typedef ush FAR ushf; +typedef unsigned long ulg; + +#if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC) +# include +# if (ULONG_MAX == 0xffffffffffffffff) +# define Z_U8 unsigned long +# elif (ULLONG_MAX == 0xffffffffffffffff) +# define Z_U8 unsigned long long +# elif (UINT_MAX == 0xffffffffffffffff) +# define Z_U8 unsigned +# endif +#endif + +extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ +/* (size given to avoid silly warnings with Visual C++) */ + +#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)] + +#define ERR_RETURN(strm,err) \ + return (strm->msg = ERR_MSG(err), (err)) +/* To be used only when the state is known to be valid */ + + /* common constants */ + +#ifndef DEF_WBITS +# define DEF_WBITS MAX_WBITS +#endif +/* default windowBits for decompression. MAX_WBITS is for compression only */ + +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +/* default memLevel */ + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ + + /* target dependencies */ + +#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) +# define OS_CODE 0x00 +# ifndef Z_SOLO +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include +# endif +# else /* MSC or DJGPP */ +# include +# endif +# endif +#endif + +#ifdef AMIGA +# define OS_CODE 1 +#endif + +#if defined(VAXC) || defined(VMS) +# define OS_CODE 2 +# define F_OPEN(name, mode) \ + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +#endif + +#ifdef __370__ +# if __TARGET_LIB__ < 0x20000000 +# define OS_CODE 4 +# elif __TARGET_LIB__ < 0x40000000 +# define OS_CODE 11 +# else +# define OS_CODE 8 +# endif +#endif + +#if defined(ATARI) || defined(atarist) +# define OS_CODE 5 +#endif + +#ifdef OS2 +# define OS_CODE 6 +# if defined(M_I86) && !defined(Z_SOLO) +# include +# endif +#endif + +#if defined(MACOS) +# define OS_CODE 7 +#endif + +#ifdef __acorn +# define OS_CODE 13 +#endif + +#if defined(WIN32) && !defined(__CYGWIN__) +# define OS_CODE 10 +#endif + +#ifdef _BEOS_ +# define OS_CODE 16 +#endif + +#ifdef __TOS_OS400__ +# define OS_CODE 18 +#endif + +#ifdef __APPLE__ +# define OS_CODE 19 +#endif + +#if defined(__BORLANDC__) && !defined(MSDOS) + #pragma warn -8004 + #pragma warn -8008 + #pragma warn -8066 +#endif + +/* provide prototypes for these when building zlib without LFS */ +#if !defined(_WIN32) && \ + (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); +#endif + + /* common defaults */ + +#ifndef OS_CODE +# define OS_CODE 3 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) fopen((name), (mode)) +#endif + + /* functions */ + +#if defined(pyr) || defined(Z_SOLO) +# define NO_MEMCPY +#endif +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) + /* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY +#endif +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) +# define HAVE_MEMCPY +#endif +#ifdef HAVE_MEMCPY +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy memcpy +# define zmemcmp memcmp +# define zmemzero(dest, len) memset(dest, 0, len) +# endif +#else + void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len); + int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len); + void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len); +#endif + +/* Diagnostic functions */ +#ifdef ZLIB_DEBUG +# include + extern int ZLIB_INTERNAL z_verbose; + extern void ZLIB_INTERNAL z_error(char *m); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + +#ifndef Z_SOLO + voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, + unsigned size); + void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr); +#endif + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + +/* Reverse the bytes in a 32-bit value */ +#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ + (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) + +#endif /* ZUTIL_H */ diff --git a/deps/exla/cache/xla_extension/include/farmhash.h b/deps/exla/cache/xla_extension/include/farmhash.h new file mode 100644 index 0000000000000000000000000000000000000000..4997bb715a0fc02a72531978e5a4a6626090a0e2 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/farmhash.h @@ -0,0 +1,328 @@ +// Copyright (c) 2014 Google, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// FarmHash, by Geoff Pike + +// +// http://code.google.com/p/farmhash/ +// +// This file provides a few functions for hashing strings and other +// data. All of them are high-quality functions in the sense that +// they do well on standard tests such as Austin Appleby's SMHasher. +// They're also fast. FarmHash is the successor to CityHash. +// +// Functions in the FarmHash family are not suitable for cryptography. +// +// WARNING: This code has been only lightly tested on big-endian platforms! +// It is known to work well on little-endian platforms that have a small penalty +// for unaligned reads, such as current Intel and AMD moderate-to-high-end CPUs. +// It should work on all 32-bit and 64-bit platforms that allow unaligned reads; +// bug reports are welcome. +// +// By the way, for some hash functions, given strings a and b, the hash +// of a+b is easily derived from the hashes of a and b. This property +// doesn't hold for any hash functions in this file. + +#ifndef FARM_HASH_H_ +#define FARM_HASH_H_ + +#include +#include +#include +#include // for memcpy and memset +#include + +#ifndef NAMESPACE_FOR_HASH_FUNCTIONS +#define NAMESPACE_FOR_HASH_FUNCTIONS util +#endif + +namespace NAMESPACE_FOR_HASH_FUNCTIONS { + +#if defined(FARMHASH_UINT128_T_DEFINED) +#if defined(__clang__) +#if !defined(uint128_t) +#define uint128_t __uint128_t +#endif +#endif +inline uint64_t Uint128Low64(const uint128_t x) { + return static_cast(x); +} +inline uint64_t Uint128High64(const uint128_t x) { + return static_cast(x >> 64); +} +inline uint128_t Uint128(uint64_t lo, uint64_t hi) { + return lo + (((uint128_t)hi) << 64); +} +#else +typedef std::pair uint128_t; +inline uint64_t Uint128Low64(const uint128_t x) { return x.first; } +inline uint64_t Uint128High64(const uint128_t x) { return x.second; } +inline uint128_t Uint128(uint64_t lo, uint64_t hi) { return uint128_t(lo, hi); } +#endif + + +// BASIC STRING HASHING + +// Hash function for a byte array. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +size_t Hash(const char* s, size_t len); + +// Hash function for a byte array. Most useful in 32-bit binaries. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint32_t Hash32(const char* s, size_t len); + +// Hash function for a byte array. For convenience, a 32-bit seed is also +// hashed into the result. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed); + +// Hash function for a byte array. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint64_t Hash64(const char* s, size_t len); + +// Hash function for a byte array. For convenience, a 64-bit seed is also +// hashed into the result. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed); + +// Hash function for a byte array. For convenience, two seeds are also +// hashed into the result. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint64_t Hash64WithSeeds(const char* s, size_t len, + uint64_t seed0, uint64_t seed1); + +// Hash function for a byte array. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint128_t Hash128(const char* s, size_t len); + +// Hash function for a byte array. For convenience, a 128-bit seed is also +// hashed into the result. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed); + +// BASIC NON-STRING HASHING + +// Hash 128 input bits down to 64 bits of output. +// This is intended to be a reasonably good hash function. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +inline uint64_t Hash128to64(uint128_t x) { + // Murmur-inspired hashing. + const uint64_t kMul = 0x9ddfea08eb382d69ULL; + uint64_t a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul; + a ^= (a >> 47); + uint64_t b = (Uint128High64(x) ^ a) * kMul; + b ^= (b >> 47); + b *= kMul; + return b; +} + +// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions) + +// Fingerprint function for a byte array. Most useful in 32-bit binaries. +uint32_t Fingerprint32(const char* s, size_t len); + +// Fingerprint function for a byte array. +uint64_t Fingerprint64(const char* s, size_t len); + +// Fingerprint function for a byte array. +uint128_t Fingerprint128(const char* s, size_t len); + +// This is intended to be a good fingerprinting primitive. +// See below for more overloads. +inline uint64_t Fingerprint(uint128_t x) { + // Murmur-inspired hashing. + const uint64_t kMul = 0x9ddfea08eb382d69ULL; + uint64_t a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul; + a ^= (a >> 47); + uint64_t b = (Uint128High64(x) ^ a) * kMul; + b ^= (b >> 44); + b *= kMul; + b ^= (b >> 41); + b *= kMul; + return b; +} + +// This is intended to be a good fingerprinting primitive. +inline uint64_t Fingerprint(uint64_t x) { + // Murmur-inspired hashing. + const uint64_t kMul = 0x9ddfea08eb382d69ULL; + uint64_t b = x * kMul; + b ^= (b >> 44); + b *= kMul; + b ^= (b >> 41); + b *= kMul; + return b; +} + +#ifndef FARMHASH_NO_CXX_STRING + +// Convenience functions to hash or fingerprint C++ strings. +// These require that Str::data() return a pointer to the first char +// (as a const char*) and that Str::length() return the string's length; +// they work with std::string, for example. + +// Hash function for a byte array. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +template +inline size_t Hash(const Str& s) { + assert(sizeof(s[0]) == 1); + return Hash(s.data(), s.length()); +} + +// Hash function for a byte array. Most useful in 32-bit binaries. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +template +inline uint32_t Hash32(const Str& s) { + assert(sizeof(s[0]) == 1); + return Hash32(s.data(), s.length()); +} + +// Hash function for a byte array. For convenience, a 32-bit seed is also +// hashed into the result. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +template +inline uint32_t Hash32WithSeed(const Str& s, uint32_t seed) { + assert(sizeof(s[0]) == 1); + return Hash32WithSeed(s.data(), s.length(), seed); +} + +// Hash 128 input bits down to 64 bits of output. +// Hash function for a byte array. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +template +inline uint64_t Hash64(const Str& s) { + assert(sizeof(s[0]) == 1); + return Hash64(s.data(), s.length()); +} + +// Hash function for a byte array. For convenience, a 64-bit seed is also +// hashed into the result. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +template +inline uint64_t Hash64WithSeed(const Str& s, uint64_t seed) { + assert(sizeof(s[0]) == 1); + return Hash64WithSeed(s.data(), s.length(), seed); +} + +// Hash function for a byte array. For convenience, two seeds are also +// hashed into the result. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +template +inline uint64_t Hash64WithSeeds(const Str& s, uint64_t seed0, uint64_t seed1) { + assert(sizeof(s[0]) == 1); + return Hash64WithSeeds(s.data(), s.length(), seed0, seed1); +} + +// Hash function for a byte array. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +template +inline uint128_t Hash128(const Str& s) { + assert(sizeof(s[0]) == 1); + return Hash128(s.data(), s.length()); +} + +// Hash function for a byte array. For convenience, a 128-bit seed is also +// hashed into the result. +// May change from time to time, may differ on different platforms, may differ +// depending on NDEBUG. +template +inline uint128_t Hash128WithSeed(const Str& s, uint128_t seed) { + assert(sizeof(s[0]) == 1); + return Hash128(s.data(), s.length(), seed); +} + +// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions) + +// Fingerprint function for a byte array. Most useful in 32-bit binaries. +template +inline uint32_t Fingerprint32(const Str& s) { + assert(sizeof(s[0]) == 1); + return Fingerprint32(s.data(), s.length()); +} + +// Fingerprint 128 input bits down to 64 bits of output. +// Fingerprint function for a byte array. +template +inline uint64_t Fingerprint64(const Str& s) { + assert(sizeof(s[0]) == 1); + return Fingerprint64(s.data(), s.length()); +} + +// Fingerprint function for a byte array. +template +inline uint128_t Fingerprint128(const Str& s) { + assert(sizeof(s[0]) == 1); + return Fingerprint128(s.data(), s.length()); +} + +#endif + +} // namespace NAMESPACE_FOR_HASH_FUNCTIONS + +/* gently define FARMHASH_BIG_ENDIAN when detected big-endian machine */ +#if defined(__BIG_ENDIAN__) + #if !defined(FARMHASH_BIG_ENDIAN) + #define FARMHASH_BIG_ENDIAN + #endif +#elif defined(__LITTLE_ENDIAN__) + // nothing for little-endian +#elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER == __ORDER_LITTLE_ENDIAN__) + // nothing for little-endian +#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER == __ORDER_BIG_ENDIAN__) + #if !defined(FARMHASH_BIG_ENDIAN) + #define FARMHASH_BIG_ENDIAN + #endif +#elif defined(__linux__) || defined(__CYGWIN__) || defined( __GNUC__ ) && !defined(_WIN32) || defined( __GNU_LIBRARY__ ) + #include // libc6-dev, GLIBC + #if BYTE_ORDER == BIG_ENDIAN + #if !defined(FARMHASH_BIG_ENDIAN) + #define FARMHASH_BIG_ENDIAN + #endif + #endif +#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__s390x__) + #include + #if BYTE_ORDER == BIG_ENDIAN + #if !defined(FARMHASH_BIG_ENDIAN) + #define FARMHASH_BIG_ENDIAN + #endif + #endif +#elif defined(_WIN32) + // Windows is (currently) little-endian +#else + #error "Unable to determine endianness!" +#endif /* __BIG_ENDIAN__ */ + +#endif // FARM_HASH_H_ diff --git a/deps/exla/cache/xla_extension/include/grpc++/alarm.h b/deps/exla/cache/xla_extension/include/grpc++/alarm.h new file mode 100644 index 0000000000000000000000000000000000000000..dce742ee884513b874feaa41e7a8d3f2656e1c40 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/alarm.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_ALARM_H +#define GRPCXX_ALARM_H + +#include + +#endif // GRPCXX_ALARM_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/channel.h b/deps/exla/cache/xla_extension/include/grpc++/channel.h new file mode 100644 index 0000000000000000000000000000000000000000..b1154cefb34b8e7c3591e75a0c90655e065168e9 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/channel.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_CHANNEL_H +#define GRPCXX_CHANNEL_H + +#include + +#endif // GRPCXX_CHANNEL_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/client_context.h b/deps/exla/cache/xla_extension/include/grpc++/client_context.h new file mode 100644 index 0000000000000000000000000000000000000000..4b23644059626663b3874e015ca8dc796214c287 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/client_context.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_CLIENT_CONTEXT_H +#define GRPCXX_CLIENT_CONTEXT_H + +#include + +#endif // GRPCXX_CLIENT_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/completion_queue.h b/deps/exla/cache/xla_extension/include/grpc++/completion_queue.h new file mode 100644 index 0000000000000000000000000000000000000000..98ef18f0f65a306b28711409a6059b0259b11916 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/completion_queue.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_COMPLETION_QUEUE_H +#define GRPCXX_COMPLETION_QUEUE_H + +#include + +#endif // GRPCXX_COMPLETION_QUEUE_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/create_channel.h b/deps/exla/cache/xla_extension/include/grpc++/create_channel.h new file mode 100644 index 0000000000000000000000000000000000000000..d95f3a97972b0ae83eddd6d27139fbdc90396911 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/create_channel.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_CREATE_CHANNEL_H +#define GRPCXX_CREATE_CHANNEL_H + +#include + +#endif // GRPCXX_CREATE_CHANNEL_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/create_channel_posix.h b/deps/exla/cache/xla_extension/include/grpc++/create_channel_posix.h new file mode 100644 index 0000000000000000000000000000000000000000..8c8983ba60612fafe33b2d486f48fe14df132624 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/create_channel_posix.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_CREATE_CHANNEL_POSIX_H +#define GRPCXX_CREATE_CHANNEL_POSIX_H + +#include + +#endif // GRPCXX_CREATE_CHANNEL_POSIX_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/ext/health_check_service_server_builder_option.h b/deps/exla/cache/xla_extension/include/grpc++/ext/health_check_service_server_builder_option.h new file mode 100644 index 0000000000000000000000000000000000000000..cb82fc03b6b734dcf0bc8a96e2cea84aba181a62 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/ext/health_check_service_server_builder_option.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H +#define GRPCXX_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H + +#include + +#endif // GRPCXX_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/generic/async_generic_service.h b/deps/exla/cache/xla_extension/include/grpc++/generic/async_generic_service.h new file mode 100644 index 0000000000000000000000000000000000000000..d3283fac6f4fb4b067976ca83111784f89e6a990 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/generic/async_generic_service.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_GENERIC_ASYNC_GENERIC_SERVICE_H +#define GRPCXX_GENERIC_ASYNC_GENERIC_SERVICE_H + +#include + +#endif // GRPCXX_GENERIC_ASYNC_GENERIC_SERVICE_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/generic/generic_stub.h b/deps/exla/cache/xla_extension/include/grpc++/generic/generic_stub.h new file mode 100644 index 0000000000000000000000000000000000000000..502953b5de997c8ae3e0c42d8cf6bfbcc02f2763 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/generic/generic_stub.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_GENERIC_GENERIC_STUB_H +#define GRPCXX_GENERIC_GENERIC_STUB_H + +#include + +#endif // GRPCXX_GENERIC_GENERIC_STUB_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/grpc++.h b/deps/exla/cache/xla_extension/include/grpc++/grpc++.h new file mode 100644 index 0000000000000000000000000000000000000000..9f1d7b1bc1ebaf7cd216dea4f194f214a7b46d82 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/grpc++.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_GRPCXX_H +#define GRPCXX_GRPCXX_H + +#include + +#endif // GRPCXX_GRPCXX_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/health_check_service_interface.h b/deps/exla/cache/xla_extension/include/grpc++/health_check_service_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..0cb0668e48d8cb9870671d546464f3f1a025042d --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/health_check_service_interface.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_HEALTH_CHECK_SERVICE_INTERFACE_H +#define GRPCXX_HEALTH_CHECK_SERVICE_INTERFACE_H + +#include + +#endif // GRPCXX_HEALTH_CHECK_SERVICE_INTERFACE_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/call.h b/deps/exla/cache/xla_extension/include/grpc++/impl/call.h new file mode 100644 index 0000000000000000000000000000000000000000..b1da2b6358d61e4585bf340ff56763b941168dd4 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/call.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CALL_H +#define GRPCXX_IMPL_CALL_H + +#include + +#endif // GRPCXX_IMPL_CALL_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/channel_argument_option.h b/deps/exla/cache/xla_extension/include/grpc++/impl/channel_argument_option.h new file mode 100644 index 0000000000000000000000000000000000000000..3468378de6efc9ec1d878c84dc446b8a8b0fa202 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/channel_argument_option.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CHANNEL_ARGUMENT_OPTION_H +#define GRPCXX_IMPL_CHANNEL_ARGUMENT_OPTION_H + +#include + +#endif // GRPCXX_IMPL_CHANNEL_ARGUMENT_OPTION_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/client_unary_call.h b/deps/exla/cache/xla_extension/include/grpc++/impl/client_unary_call.h new file mode 100644 index 0000000000000000000000000000000000000000..75e656071f44896ac3d1b67eae0d6d1752f2f800 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/client_unary_call.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CLIENT_UNARY_CALL_H +#define GRPCXX_IMPL_CLIENT_UNARY_CALL_H + +#include + +#endif // GRPCXX_IMPL_CLIENT_UNARY_CALL_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/async_stream.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/async_stream.h new file mode 100644 index 0000000000000000000000000000000000000000..a034470a707ea3f77771e0d63b4602220df299ea --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/async_stream.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_ASYNC_STREAM_H +#define GRPCXX_IMPL_CODEGEN_ASYNC_STREAM_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_ASYNC_STREAM_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/async_unary_call.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/async_unary_call.h new file mode 100644 index 0000000000000000000000000000000000000000..2b08920a3042a1715489e486896b84d89bc43176 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/async_unary_call.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_ASYNC_UNARY_CALL_H +#define GRPCXX_IMPL_CODEGEN_ASYNC_UNARY_CALL_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_ASYNC_UNARY_CALL_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/byte_buffer.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/byte_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..b754fa24e9caeef963dcf32f99a757a8c5bfea11 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/byte_buffer.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_BYTE_BUFFER_H +#define GRPCXX_IMPL_CODEGEN_BYTE_BUFFER_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_BYTE_BUFFER_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/call.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/call.h new file mode 100644 index 0000000000000000000000000000000000000000..dadab5454ab71f05c29d919dfd78a6d07e7737e2 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/call.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_CALL_H +#define GRPCXX_IMPL_CODEGEN_CALL_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_CALL_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/call_hook.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/call_hook.h new file mode 100644 index 0000000000000000000000000000000000000000..cf5ed571b2df097a17cbb17efd45acb055e960a0 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/call_hook.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_CALL_HOOK_H +#define GRPCXX_IMPL_CODEGEN_CALL_HOOK_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_CALL_HOOK_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/channel_interface.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/channel_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..c6e782e9c41abccf2b03c96c3ce5797b3249f2e6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/channel_interface.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_CHANNEL_INTERFACE_H +#define GRPCXX_IMPL_CODEGEN_CHANNEL_INTERFACE_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_CHANNEL_INTERFACE_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/client_context.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/client_context.h new file mode 100644 index 0000000000000000000000000000000000000000..107532cb6b6782f44f1e4e365b0b215cc67ad224 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/client_context.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_CLIENT_CONTEXT_H +#define GRPCXX_IMPL_CODEGEN_CLIENT_CONTEXT_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_CLIENT_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/client_unary_call.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/client_unary_call.h new file mode 100644 index 0000000000000000000000000000000000000000..f7dff1f1f05dc69ce0cdc4c3b94cedde6c3e1c51 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/client_unary_call.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_CLIENT_UNARY_CALL_H +#define GRPCXX_IMPL_CODEGEN_CLIENT_UNARY_CALL_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_CLIENT_UNARY_CALL_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/completion_queue.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/completion_queue.h new file mode 100644 index 0000000000000000000000000000000000000000..107549550bd1166ef256acb90e192940bfab0b25 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/completion_queue.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_H +#define GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/completion_queue_tag.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/completion_queue_tag.h new file mode 100644 index 0000000000000000000000000000000000000000..994fa2a904a4000d387f31aa6466212961d7be9e --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/completion_queue_tag.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_TAG_H +#define GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_TAG_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_COMPLETION_QUEUE_TAG_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/config.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/config.h new file mode 100644 index 0000000000000000000000000000000000000000..237bf38d3ed249c153fd6ffbcd53a4a474a534b1 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/config.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_CONFIG_H +#define GRPCXX_IMPL_CODEGEN_CONFIG_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_CONFIG_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/config_protobuf.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/config_protobuf.h new file mode 100644 index 0000000000000000000000000000000000000000..debd74aae793190991fdea52fb1966ae95c3179a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/config_protobuf.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H +#define GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/core_codegen.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/core_codegen.h new file mode 100644 index 0000000000000000000000000000000000000000..ee600a9d1258416e2d0262ab7e1a30d6be1b94fc --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/core_codegen.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H +#define GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/core_codegen_interface.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/core_codegen_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..03b3f675e19894ff4883ebbc6829289a3f8dab9a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/core_codegen_interface.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H +#define GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/create_auth_context.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/create_auth_context.h new file mode 100644 index 0000000000000000000000000000000000000000..ef89229f4d23c7b491bab9211afe8a9ee6ed5429 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/create_auth_context.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_CREATE_AUTH_CONTEXT_H +#define GRPCXX_IMPL_CODEGEN_CREATE_AUTH_CONTEXT_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_CREATE_AUTH_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/grpc_library.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/grpc_library.h new file mode 100644 index 0000000000000000000000000000000000000000..33c3e2546c592d35a7109923a1be34df18c4f4ec --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/grpc_library.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H +#define GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/metadata_map.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/metadata_map.h new file mode 100644 index 0000000000000000000000000000000000000000..41c5ad375e159f8370d7f3facbb9e09e857ff8b1 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/metadata_map.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_METADATA_MAP_H +#define GRPCXX_IMPL_CODEGEN_METADATA_MAP_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_METADATA_MAP_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/method_handler_impl.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/method_handler_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..0bdb620616bd84dd120309339ae720acf1ca980d --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/method_handler_impl.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H +#define GRPCXX_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/proto_utils.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/proto_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..1f47884abc38da3ccb35b99c6cbb1c72891f6d6a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/proto_utils.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_PROTO_UTILS_H +#define GRPCXX_IMPL_CODEGEN_PROTO_UTILS_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_PROTO_UTILS_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/rpc_method.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/rpc_method.h new file mode 100644 index 0000000000000000000000000000000000000000..2906c74dda70c0d72cd634ea7187cd13727dc4c0 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/rpc_method.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_RPC_METHOD_H +#define GRPCXX_IMPL_CODEGEN_RPC_METHOD_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_RPC_METHOD_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/rpc_service_method.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/rpc_service_method.h new file mode 100644 index 0000000000000000000000000000000000000000..999c0d5e935fcfbf58487f710026003c1b283515 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/rpc_service_method.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_RPC_SERVICE_METHOD_H +#define GRPCXX_IMPL_CODEGEN_RPC_SERVICE_METHOD_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_RPC_SERVICE_METHOD_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/security/auth_context.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/security/auth_context.h new file mode 100644 index 0000000000000000000000000000000000000000..b4663739a6a1130f402dd542bca1a704110e69ac --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/security/auth_context.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H +#define GRPCXX_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/serialization_traits.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/serialization_traits.h new file mode 100644 index 0000000000000000000000000000000000000000..480575d10998bee5e6ce5e9abf88bdb26724d7c0 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/serialization_traits.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_SERIALIZATION_TRAITS_H +#define GRPCXX_IMPL_CODEGEN_SERIALIZATION_TRAITS_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_SERIALIZATION_TRAITS_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/server_context.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/server_context.h new file mode 100644 index 0000000000000000000000000000000000000000..1c3342d5d4b3b533e64a1778c3f1d168f63a5530 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/server_context.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_SERVER_CONTEXT_H +#define GRPCXX_IMPL_CODEGEN_SERVER_CONTEXT_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_SERVER_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/server_interface.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/server_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..ceea44c50cb6e9edd35270638053ae85130c7b76 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/server_interface.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_SERVER_INTERFACE_H +#define GRPCXX_IMPL_CODEGEN_SERVER_INTERFACE_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_SERVER_INTERFACE_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/service_type.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/service_type.h new file mode 100644 index 0000000000000000000000000000000000000000..be02b75bae4f531082dcbfdd54f963f3641a5a4a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/service_type.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_SERVICE_TYPE_H +#define GRPCXX_IMPL_CODEGEN_SERVICE_TYPE_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_SERVICE_TYPE_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/slice.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/slice.h new file mode 100644 index 0000000000000000000000000000000000000000..6714badc37d9b0905665f7e8e5693c781330be0a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/slice.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_SLICE_H +#define GRPCXX_IMPL_CODEGEN_SLICE_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_SLICE_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/status.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/status.h new file mode 100644 index 0000000000000000000000000000000000000000..6cf9459fff29257ee88054cbc97c58251f4e0a8b --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/status.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_STATUS_H +#define GRPCXX_IMPL_CODEGEN_STATUS_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_STATUS_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/status_code_enum.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/status_code_enum.h new file mode 100644 index 0000000000000000000000000000000000000000..7503eaeeca6cffacf1ed7f4348f6744370c2123b --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/status_code_enum.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_STATUS_CODE_ENUM_H +#define GRPCXX_IMPL_CODEGEN_STATUS_CODE_ENUM_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_STATUS_CODE_ENUM_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/string_ref.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/string_ref.h new file mode 100644 index 0000000000000000000000000000000000000000..66e250efddbcea4bbf187f60ec11c83ee3f1cc40 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/string_ref.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_STRING_REF_H +#define GRPCXX_IMPL_CODEGEN_STRING_REF_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_STRING_REF_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/stub_options.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/stub_options.h new file mode 100644 index 0000000000000000000000000000000000000000..07cb4417b7ab694eb77ef5d8e1ba1a96430a8052 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/stub_options.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_STUB_OPTIONS_H +#define GRPCXX_IMPL_CODEGEN_STUB_OPTIONS_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_STUB_OPTIONS_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/sync_stream.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/sync_stream.h new file mode 100644 index 0000000000000000000000000000000000000000..1e6ba27bf51da4acc1adfe6ae98a6ff38689412a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/sync_stream.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_SYNC_STREAM_H +#define GRPCXX_IMPL_CODEGEN_SYNC_STREAM_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_SYNC_STREAM_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/time.h b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/time.h new file mode 100644 index 0000000000000000000000000000000000000000..f9b70f831356eec4843a231baf05cd41c4e978de --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/codegen/time.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_CODEGEN_TIME_H +#define GRPCXX_IMPL_CODEGEN_TIME_H + +#include + +#endif // GRPCXX_IMPL_CODEGEN_TIME_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/grpc_library.h b/deps/exla/cache/xla_extension/include/grpc++/impl/grpc_library.h new file mode 100644 index 0000000000000000000000000000000000000000..f34a281ac3912f9b921f05260783bb95c1554d79 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/grpc_library.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_GRPC_LIBRARY_H +#define GRPCXX_IMPL_GRPC_LIBRARY_H + +#include + +#endif // GRPCXX_IMPL_GRPC_LIBRARY_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/method_handler_impl.h b/deps/exla/cache/xla_extension/include/grpc++/impl/method_handler_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..3840f48742f8c4165e8413e4abe56ed26d07cc14 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/method_handler_impl.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_METHOD_HANDLER_IMPL_H +#define GRPCXX_IMPL_METHOD_HANDLER_IMPL_H + +#include + +#endif // GRPCXX_IMPL_METHOD_HANDLER_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/rpc_method.h b/deps/exla/cache/xla_extension/include/grpc++/impl/rpc_method.h new file mode 100644 index 0000000000000000000000000000000000000000..7cba7c40c4598b3faeaec8ca65f3462f51f92e6a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/rpc_method.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_RPC_METHOD_H +#define GRPCXX_IMPL_RPC_METHOD_H + +#include + +#endif // GRPCXX_IMPL_RPC_METHOD_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/rpc_service_method.h b/deps/exla/cache/xla_extension/include/grpc++/impl/rpc_service_method.h new file mode 100644 index 0000000000000000000000000000000000000000..2c75087b7c8f1aba10beb875724bf85c8521ce46 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/rpc_service_method.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_RPC_SERVICE_METHOD_H +#define GRPCXX_IMPL_RPC_SERVICE_METHOD_H + +#include + +#endif // GRPCXX_IMPL_RPC_SERVICE_METHOD_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/serialization_traits.h b/deps/exla/cache/xla_extension/include/grpc++/impl/serialization_traits.h new file mode 100644 index 0000000000000000000000000000000000000000..33b3a0bb31e9fe3960a37f9fa8a4d96d8bd8ae40 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/serialization_traits.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_SERIALIZATION_TRAITS_H +#define GRPCXX_IMPL_SERIALIZATION_TRAITS_H + +#include + +#endif // GRPCXX_IMPL_SERIALIZATION_TRAITS_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/server_builder_option.h b/deps/exla/cache/xla_extension/include/grpc++/impl/server_builder_option.h new file mode 100644 index 0000000000000000000000000000000000000000..833f8db772f9b52ea96e1ba87ffd6dcc90d2579d --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/server_builder_option.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_SERVER_BUILDER_OPTION_H +#define GRPCXX_IMPL_SERVER_BUILDER_OPTION_H + +#include + +#endif // GRPCXX_IMPL_SERVER_BUILDER_OPTION_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/server_builder_plugin.h b/deps/exla/cache/xla_extension/include/grpc++/impl/server_builder_plugin.h new file mode 100644 index 0000000000000000000000000000000000000000..844d32c55f1bc556bbca23ba80229d8c1e94444e --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/server_builder_plugin.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_SERVER_BUILDER_PLUGIN_H +#define GRPCXX_IMPL_SERVER_BUILDER_PLUGIN_H + +#include + +#endif // GRPCXX_IMPL_SERVER_BUILDER_PLUGIN_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/server_initializer.h b/deps/exla/cache/xla_extension/include/grpc++/impl/server_initializer.h new file mode 100644 index 0000000000000000000000000000000000000000..6a1669ccf574f1fb8a70dd27ef15de4f59480554 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/server_initializer.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_SERVER_INITIALIZER_H +#define GRPCXX_IMPL_SERVER_INITIALIZER_H + +#include + +#endif // GRPCXX_IMPL_SERVER_INITIALIZER_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/service_type.h b/deps/exla/cache/xla_extension/include/grpc++/impl/service_type.h new file mode 100644 index 0000000000000000000000000000000000000000..86422160d4d5a25256ee82a6c00662005bc205cd --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/service_type.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_SERVICE_TYPE_H +#define GRPCXX_IMPL_SERVICE_TYPE_H + +#include + +#endif // GRPCXX_IMPL_SERVICE_TYPE_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/sync_cxx11.h b/deps/exla/cache/xla_extension/include/grpc++/impl/sync_cxx11.h new file mode 100644 index 0000000000000000000000000000000000000000..8bcfb2ce81860ac4b183619cf11f5df8c940bce8 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/sync_cxx11.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_SYNC_CXX11_H +#define GRPCXX_IMPL_SYNC_CXX11_H + +#include + +#endif // GRPCXX_IMPL_SYNC_CXX11_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/impl/sync_no_cxx11.h b/deps/exla/cache/xla_extension/include/grpc++/impl/sync_no_cxx11.h new file mode 100644 index 0000000000000000000000000000000000000000..5264567387a39de340ba5ab9a8483f8eafc66b46 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/impl/sync_no_cxx11.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_IMPL_SYNC_NO_CXX11_H +#define GRPCXX_IMPL_SYNC_NO_CXX11_H + +#include + +#endif // GRPCXX_IMPL_SYNC_NO_CXX11_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/resource_quota.h b/deps/exla/cache/xla_extension/include/grpc++/resource_quota.h new file mode 100644 index 0000000000000000000000000000000000000000..aad1b5659fdc56fa74ccef42c860ccce65b80071 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/resource_quota.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_RESOURCE_QUOTA_H +#define GRPCXX_RESOURCE_QUOTA_H + +#include + +#endif // GRPCXX_RESOURCE_QUOTA_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/security/auth_context.h b/deps/exla/cache/xla_extension/include/grpc++/security/auth_context.h new file mode 100644 index 0000000000000000000000000000000000000000..9fe59d448e3b96c2e3eb1b9d127d945af2d15aba --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/security/auth_context.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SECURITY_AUTH_CONTEXT_H +#define GRPCXX_SECURITY_AUTH_CONTEXT_H + +#include + +#endif // GRPCXX_SECURITY_AUTH_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/security/auth_metadata_processor.h b/deps/exla/cache/xla_extension/include/grpc++/security/auth_metadata_processor.h new file mode 100644 index 0000000000000000000000000000000000000000..d04531396552a588f565d4a67ec3eb94c059f3b3 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/security/auth_metadata_processor.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SECURITY_AUTH_METADATA_PROCESSOR_H +#define GRPCXX_SECURITY_AUTH_METADATA_PROCESSOR_H + +#include + +#endif // GRPCXX_SECURITY_AUTH_METADATA_PROCESSOR_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/security/credentials.h b/deps/exla/cache/xla_extension/include/grpc++/security/credentials.h new file mode 100644 index 0000000000000000000000000000000000000000..940441827dba434fdd9a1e7090b587a443506f96 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/security/credentials.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SECURITY_CREDENTIALS_H +#define GRPCXX_SECURITY_CREDENTIALS_H + +#include + +#endif // GRPCXX_SECURITY_CREDENTIALS_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/security/server_credentials.h b/deps/exla/cache/xla_extension/include/grpc++/security/server_credentials.h new file mode 100644 index 0000000000000000000000000000000000000000..c6d1c4f0e4c504388dbe860616f74c45bba3a731 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/security/server_credentials.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SECURITY_SERVER_CREDENTIALS_H +#define GRPCXX_SECURITY_SERVER_CREDENTIALS_H + +#include + +#endif // GRPCXX_SECURITY_SERVER_CREDENTIALS_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/server.h b/deps/exla/cache/xla_extension/include/grpc++/server.h new file mode 100644 index 0000000000000000000000000000000000000000..086c24cc699fb216af48ad11c39b288a6f3c7978 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/server.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SERVER_H +#define GRPCXX_SERVER_H + +#include + +#endif // GRPCXX_SERVER_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/server_builder.h b/deps/exla/cache/xla_extension/include/grpc++/server_builder.h new file mode 100644 index 0000000000000000000000000000000000000000..2c6dab44453b06a177f2312aae41c9629537f19a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/server_builder.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SERVER_BUILDER_H +#define GRPCXX_SERVER_BUILDER_H + +#include + +#endif // GRPCXX_SERVER_BUILDER_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/server_context.h b/deps/exla/cache/xla_extension/include/grpc++/server_context.h new file mode 100644 index 0000000000000000000000000000000000000000..672ccdca6d9f8dc256aae9627c1842b4eb96d5f8 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/server_context.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SERVER_CONTEXT_H +#define GRPCXX_SERVER_CONTEXT_H + +#include + +#endif // GRPCXX_SERVER_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/server_posix.h b/deps/exla/cache/xla_extension/include/grpc++/server_posix.h new file mode 100644 index 0000000000000000000000000000000000000000..d2866d96402bf1b54e750d6dd307460f954a15c6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/server_posix.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SERVER_POSIX_H +#define GRPCXX_SERVER_POSIX_H + +#include + +#endif // GRPCXX_SERVER_POSIX_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/support/async_stream.h b/deps/exla/cache/xla_extension/include/grpc++/support/async_stream.h new file mode 100644 index 0000000000000000000000000000000000000000..9bb2b725c3cb7b98a6129e686e876456e2681671 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/support/async_stream.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SUPPORT_ASYNC_STREAM_H +#define GRPCXX_SUPPORT_ASYNC_STREAM_H + +#include + +#endif // GRPCXX_SUPPORT_ASYNC_STREAM_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/support/async_unary_call.h b/deps/exla/cache/xla_extension/include/grpc++/support/async_unary_call.h new file mode 100644 index 0000000000000000000000000000000000000000..56fbf31417e7ac06d0bbaf17cd8e6d925627d09f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/support/async_unary_call.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SUPPORT_ASYNC_UNARY_CALL_H +#define GRPCXX_SUPPORT_ASYNC_UNARY_CALL_H + +#include + +#endif // GRPCXX_SUPPORT_ASYNC_UNARY_CALL_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/support/byte_buffer.h b/deps/exla/cache/xla_extension/include/grpc++/support/byte_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..ec607ee01aac1faf905b7d776cc98e6e1d6ff2f6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/support/byte_buffer.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SUPPORT_BYTE_BUFFER_H +#define GRPCXX_SUPPORT_BYTE_BUFFER_H + +#include + +#endif // GRPCXX_SUPPORT_BYTE_BUFFER_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/support/channel_arguments.h b/deps/exla/cache/xla_extension/include/grpc++/support/channel_arguments.h new file mode 100644 index 0000000000000000000000000000000000000000..6d5300ccb795c940778f6b369f2c14e9dc3a9d6a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/support/channel_arguments.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SUPPORT_CHANNEL_ARGUMENTS_H +#define GRPCXX_SUPPORT_CHANNEL_ARGUMENTS_H + +#include + +#endif // GRPCXX_SUPPORT_CHANNEL_ARGUMENTS_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/support/config.h b/deps/exla/cache/xla_extension/include/grpc++/support/config.h new file mode 100644 index 0000000000000000000000000000000000000000..f8eee5075a8adef127ab18bd4a022141388b8b32 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/support/config.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SUPPORT_CONFIG_H +#define GRPCXX_SUPPORT_CONFIG_H + +#include + +#endif // GRPCXX_SUPPORT_CONFIG_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/support/slice.h b/deps/exla/cache/xla_extension/include/grpc++/support/slice.h new file mode 100644 index 0000000000000000000000000000000000000000..b02b1a977eda5f57ca3ece26e235957dea975435 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/support/slice.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SUPPORT_SLICE_H +#define GRPCXX_SUPPORT_SLICE_H + +#include + +#endif // GRPCXX_SUPPORT_SLICE_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/support/status.h b/deps/exla/cache/xla_extension/include/grpc++/support/status.h new file mode 100644 index 0000000000000000000000000000000000000000..e58a18bdf99719f8b7efad5554fcb853135f5724 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/support/status.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SUPPORT_STATUS_H +#define GRPCXX_SUPPORT_STATUS_H + +#include + +#endif // GRPCXX_SUPPORT_STATUS_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/support/status_code_enum.h b/deps/exla/cache/xla_extension/include/grpc++/support/status_code_enum.h new file mode 100644 index 0000000000000000000000000000000000000000..c278add0c65d2333bc7bb63697180316f2b620b1 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/support/status_code_enum.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SUPPORT_STATUS_CODE_ENUM_H +#define GRPCXX_SUPPORT_STATUS_CODE_ENUM_H + +#include + +#endif // GRPCXX_SUPPORT_STATUS_CODE_ENUM_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/support/string_ref.h b/deps/exla/cache/xla_extension/include/grpc++/support/string_ref.h new file mode 100644 index 0000000000000000000000000000000000000000..49de6dafce92cd5a5b353dbd5566f26fcfc0116e --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/support/string_ref.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SUPPORT_STRING_REF_H +#define GRPCXX_SUPPORT_STRING_REF_H + +#include + +#endif // GRPCXX_SUPPORT_STRING_REF_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/support/stub_options.h b/deps/exla/cache/xla_extension/include/grpc++/support/stub_options.h new file mode 100644 index 0000000000000000000000000000000000000000..a712ce8716c173d5683f2e1909c2a3bfe87c0e93 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/support/stub_options.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SUPPORT_STUB_OPTIONS_H +#define GRPCXX_SUPPORT_STUB_OPTIONS_H + +#include + +#endif // GRPCXX_SUPPORT_STUB_OPTIONS_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/support/sync_stream.h b/deps/exla/cache/xla_extension/include/grpc++/support/sync_stream.h new file mode 100644 index 0000000000000000000000000000000000000000..c118df9f7b46e8bc7066615f368b1cae6b0573aa --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/support/sync_stream.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SUPPORT_SYNC_STREAM_H +#define GRPCXX_SUPPORT_SYNC_STREAM_H + +#include + +#endif // GRPCXX_SUPPORT_SYNC_STREAM_H diff --git a/deps/exla/cache/xla_extension/include/grpc++/support/time.h b/deps/exla/cache/xla_extension/include/grpc++/support/time.h new file mode 100644 index 0000000000000000000000000000000000000000..d356b910013e7d6c3aeb77acd371dade981785f8 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpc++/support/time.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// DEPRECATED: The headers in include/grpc++ are deprecated. Please include the +// headers in include/grpcpp instead. This header exists only for backwards +// compatibility. + +#ifndef GRPCXX_SUPPORT_TIME_H +#define GRPCXX_SUPPORT_TIME_H + +#include + +#endif // GRPCXX_SUPPORT_TIME_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/alarm.h b/deps/exla/cache/xla_extension/include/grpcpp/alarm.h new file mode 100644 index 0000000000000000000000000000000000000000..2343c1149c5abf21c4a88e9e61c03d56a2b6f431 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/alarm.h @@ -0,0 +1,29 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_ALARM_H +#define GRPCPP_ALARM_H + +#include + +namespace grpc { + +typedef ::grpc_impl::Alarm Alarm; +} + +#endif // GRPCPP_ALARM_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/alarm_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/alarm_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..cd37882e0886199bb666dd295484614b80f6c53a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/alarm_impl.h @@ -0,0 +1,125 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/// An Alarm posts the user-provided tag to its associated completion queue or +/// invokes the user-provided function on expiry or cancellation. +#ifndef GRPCPP_ALARM_IMPL_H +#define GRPCPP_ALARM_IMPL_H + +#include + +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +class Alarm : private ::grpc::GrpcLibraryCodegen { + public: + /// Create an unset completion queue alarm + Alarm(); + + /// Destroy the given completion queue alarm, cancelling it in the process. + ~Alarm(); + + /// DEPRECATED: Create and set a completion queue alarm instance associated to + /// \a cq. + /// This form is deprecated because it is inherently racy. + /// \internal We rely on the presence of \a cq for grpc initialization. If \a + /// cq were ever to be removed, a reference to a static + /// internal::GrpcLibraryInitializer instance would need to be introduced + /// here. \endinternal. + template + Alarm(::grpc::CompletionQueue* cq, const T& deadline, void* tag) : Alarm() { + SetInternal(cq, ::grpc::TimePoint(deadline).raw_time(), tag); + } + + /// Trigger an alarm instance on completion queue \a cq at the specified time. + /// Once the alarm expires (at \a deadline) or it's cancelled (see \a Cancel), + /// an event with tag \a tag will be added to \a cq. If the alarm expired, the + /// event's success bit will be true, false otherwise (ie, upon cancellation). + template + void Set(::grpc::CompletionQueue* cq, const T& deadline, void* tag) { + SetInternal(cq, ::grpc::TimePoint(deadline).raw_time(), tag); + } + + /// Alarms aren't copyable. + Alarm(const Alarm&) = delete; + Alarm& operator=(const Alarm&) = delete; + + /// Alarms are movable. + Alarm(Alarm&& rhs) : alarm_(rhs.alarm_) { rhs.alarm_ = nullptr; } + Alarm& operator=(Alarm&& rhs) { + alarm_ = rhs.alarm_; + rhs.alarm_ = nullptr; + return *this; + } + + /// Cancel a completion queue alarm. Calling this function over an alarm that + /// has already fired has no effect. + void Cancel(); + +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL + /// Set an alarm to invoke callback \a f. The argument to the callback + /// states whether the alarm expired at \a deadline (true) or was cancelled + /// (false) + template + void Set(const T& deadline, std::function f) { + SetInternal(::grpc::TimePoint(deadline).raw_time(), std::move(f)); + } +#endif + + /// NOTE: class experimental_type is not part of the public API of this class + /// TODO(vjpai): Move these contents to the public API of Alarm when + /// they are no longer experimental + class experimental_type { + public: + explicit experimental_type(Alarm* alarm) : alarm_(alarm) {} + + /// Set an alarm to invoke callback \a f. The argument to the callback + /// states whether the alarm expired at \a deadline (true) or was cancelled + /// (false) + template + void Set(const T& deadline, std::function f) { + alarm_->SetInternal(::grpc::TimePoint(deadline).raw_time(), + std::move(f)); + } + + private: + Alarm* alarm_; + }; + + /// NOTE: The function experimental() is not stable public API. It is a view + /// to the experimental components of this class. It may be changed or removed + /// at any time. + experimental_type experimental() { return experimental_type(this); } + + private: + void SetInternal(::grpc::CompletionQueue* cq, gpr_timespec deadline, + void* tag); + void SetInternal(gpr_timespec deadline, std::function f); + + ::grpc::internal::CompletionQueueTag* alarm_; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_ALARM_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/channel.h b/deps/exla/cache/xla_extension/include/grpcpp/channel.h new file mode 100644 index 0000000000000000000000000000000000000000..163c804ffbe3d1837b31b4b3d85d562436efbd51 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/channel.h @@ -0,0 +1,37 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_CHANNEL_H +#define GRPCPP_CHANNEL_H + +#include + +namespace grpc { + +typedef ::grpc_impl::Channel Channel; + +namespace experimental { +/// Resets the channel's connection backoff. +/// TODO(roth): Once we see whether this proves useful, either create a gRFC +/// and change this to be a method of the Channel class, or remove it. +void ChannelResetConnectionBackoff(Channel* channel); +} // namespace experimental + +} // namespace grpc + +#endif // GRPCPP_CHANNEL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/channel_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/channel_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..4ec913ae5238d32e90025545f7912747195dcc55 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/channel_impl.h @@ -0,0 +1,126 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_CHANNEL_IMPL_H +#define GRPCPP_CHANNEL_IMPL_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +struct grpc_channel; + +namespace grpc { + +std::shared_ptr<::grpc_impl::Channel> CreateChannelInternal( + const grpc::string& host, grpc_channel* c_channel, + std::vector< + std::unique_ptr> + interceptor_creators); +} // namespace grpc +namespace grpc_impl { + +namespace experimental { +/// Resets the channel's connection backoff. +/// TODO(roth): Once we see whether this proves useful, either create a gRFC +/// and change this to be a method of the Channel class, or remove it. +void ChannelResetConnectionBackoff(Channel* channel); +} // namespace experimental + +/// Channels represent a connection to an endpoint. Created by \a CreateChannel. +class Channel final : public ::grpc::ChannelInterface, + public ::grpc::internal::CallHook, + public std::enable_shared_from_this, + private ::grpc::GrpcLibraryCodegen { + public: + ~Channel(); + + /// Get the current channel state. If the channel is in IDLE and + /// \a try_to_connect is set to true, try to connect. + grpc_connectivity_state GetState(bool try_to_connect) override; + + /// Returns the LB policy name, or the empty string if not yet available. + grpc::string GetLoadBalancingPolicyName() const; + + /// Returns the service config in JSON form, or the empty string if + /// not available. + grpc::string GetServiceConfigJSON() const; + + private: + template + friend class ::grpc::internal::BlockingUnaryCallImpl; + friend void experimental::ChannelResetConnectionBackoff(Channel* channel); + friend std::shared_ptr grpc::CreateChannelInternal( + const grpc::string& host, grpc_channel* c_channel, + std::vector> + interceptor_creators); + friend class ::grpc::internal::InterceptedChannel; + Channel(const grpc::string& host, grpc_channel* c_channel, + std::vector> + interceptor_creators); + + ::grpc::internal::Call CreateCall(const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + ::grpc_impl::CompletionQueue* cq) override; + void PerformOpsOnCall(::grpc::internal::CallOpSetInterface* ops, + ::grpc::internal::Call* call) override; + void* RegisterMethod(const char* method) override; + + void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline, + ::grpc_impl::CompletionQueue* cq, + void* tag) override; + bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline) override; + + ::grpc_impl::CompletionQueue* CallbackCQ() override; + + ::grpc::internal::Call CreateCallInternal( + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, ::grpc_impl::CompletionQueue* cq, + size_t interceptor_pos) override; + + const grpc::string host_; + grpc_channel* const c_channel_; // owned + + // mu_ protects callback_cq_ (the per-channel callbackable completion queue) + grpc::internal::Mutex mu_; + + // callback_cq_ references the callbackable completion queue associated + // with this channel (if any). It is set on the first call to CallbackCQ(). + // It is _not owned_ by the channel; ownership belongs with its internal + // shutdown callback tag (invoked when the CQ is fully shutdown). + ::grpc_impl::CompletionQueue* callback_cq_ = nullptr; + + std::vector< + std::unique_ptr<::grpc::experimental::ClientInterceptorFactoryInterface>> + interceptor_creators_; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_CHANNEL_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/client_context.h b/deps/exla/cache/xla_extension/include/grpcpp/client_context.h new file mode 100644 index 0000000000000000000000000000000000000000..1994fcc6bc8f2a0ab2ae0a5e5e06fabbd5325171 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/client_context.h @@ -0,0 +1,39 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/// A ClientContext allows the person implementing a service client to: +/// +/// - Add custom metadata key-value pairs that will propagated to the server +/// side. +/// - Control call settings such as compression and authentication. +/// - Initial and trailing metadata coming from the server. +/// - Get performance metrics (ie, census). +/// +/// Context settings are only relevant to the call they are invoked with, that +/// is to say, they aren't sticky. Some of these settings, such as the +/// compression options, can be made persistent at channel construction time +/// (see \a grpc::CreateCustomChannel). +/// +/// \warning ClientContext instances should \em not be reused across rpcs. + +#ifndef GRPCPP_CLIENT_CONTEXT_H +#define GRPCPP_CLIENT_CONTEXT_H + +#include + +#endif // GRPCPP_CLIENT_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/completion_queue.h b/deps/exla/cache/xla_extension/include/grpcpp/completion_queue.h new file mode 100644 index 0000000000000000000000000000000000000000..123b277f5f0cb850f08ce1c0fef9c7dcec24d8bc --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/completion_queue.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_COMPLETION_QUEUE_H +#define GRPCPP_COMPLETION_QUEUE_H + +#include + +#endif // GRPCPP_COMPLETION_QUEUE_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/completion_queue_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/completion_queue_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..b6fb2b4f9900e19b4d6d33932b8622c9329e37cf --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/completion_queue_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_COMPLETION_QUEUE_IMPL_H +#define GRPCPP_COMPLETION_QUEUE_IMPL_H + +#include + +#endif // GRPCPP_COMPLETION_QUEUE_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/create_channel.h b/deps/exla/cache/xla_extension/include/grpcpp/create_channel.h new file mode 100644 index 0000000000000000000000000000000000000000..9b257ace9456170d239dba9875143c1cb3920ce4 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/create_channel.h @@ -0,0 +1,57 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_CREATE_CHANNEL_H +#define GRPCPP_CREATE_CHANNEL_H + +#include +#include + +namespace grpc { + +static inline std::shared_ptr<::grpc::Channel> CreateChannel( + const grpc::string& target, + const std::shared_ptr& creds) { + return ::grpc_impl::CreateChannelImpl(target, creds); +} + +static inline std::shared_ptr<::grpc::Channel> CreateCustomChannel( + const grpc::string& target, + const std::shared_ptr& creds, + const ChannelArguments& args) { + return ::grpc_impl::CreateCustomChannelImpl(target, creds, args); +} + +namespace experimental { + +static inline std::shared_ptr<::grpc::Channel> +CreateCustomChannelWithInterceptors( + const grpc::string& target, + const std::shared_ptr& creds, + const ChannelArguments& args, + std::vector< + std::unique_ptr> + interceptor_creators) { + return ::grpc_impl::experimental::CreateCustomChannelWithInterceptors( + target, creds, args, std::move(interceptor_creators)); +} + +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_CREATE_CHANNEL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/create_channel_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/create_channel_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..02896e66444ec2d0052f888f310aa10eed333a13 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/create_channel_impl.h @@ -0,0 +1,78 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_CREATE_CHANNEL_IMPL_H +#define GRPCPP_CREATE_CHANNEL_IMPL_H + +#include + +#include +#include +#include +#include +#include + +namespace grpc_impl { +/// Create a new \a Channel pointing to \a target. +/// +/// \param target The URI of the endpoint to connect to. +/// \param creds Credentials to use for the created channel. If it does not +/// hold an object or is invalid, a lame channel (one on which all operations +/// fail) is returned. +std::shared_ptr<::grpc::Channel> CreateChannelImpl( + const grpc::string& target, + const std::shared_ptr<::grpc::ChannelCredentials>& creds); + +/// Create a new \em custom \a Channel pointing to \a target. +/// +/// \warning For advanced use and testing ONLY. Override default channel +/// arguments only if necessary. +/// +/// \param target The URI of the endpoint to connect to. +/// \param creds Credentials to use for the created channel. If it does not +/// hold an object or is invalid, a lame channel (one on which all operations +/// fail) is returned. +/// \param args Options for channel creation. +std::shared_ptr<::grpc::Channel> CreateCustomChannelImpl( + const grpc::string& target, + const std::shared_ptr<::grpc::ChannelCredentials>& creds, + const ::grpc::ChannelArguments& args); + +namespace experimental { +/// Create a new \em custom \a Channel pointing to \a target with \a +/// interceptors being invoked per call. +/// +/// \warning For advanced use and testing ONLY. Override default channel +/// arguments only if necessary. +/// +/// \param target The URI of the endpoint to connect to. +/// \param creds Credentials to use for the created channel. If it does not +/// hold an object or is invalid, a lame channel (one on which all operations +/// fail) is returned. +/// \param args Options for channel creation. +std::shared_ptr<::grpc::Channel> CreateCustomChannelWithInterceptors( + const grpc::string& target, + const std::shared_ptr& creds, + const ::grpc::ChannelArguments& args, + std::vector< + std::unique_ptr> + interceptor_creators); +} // namespace experimental +} // namespace grpc_impl + +#endif // GRPCPP_CREATE_CHANNEL_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/create_channel_posix.h b/deps/exla/cache/xla_extension/include/grpcpp/create_channel_posix.h new file mode 100644 index 0000000000000000000000000000000000000000..b8a1f5e5c46a89da12f54ca07e707d93534913c7 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/create_channel_posix.h @@ -0,0 +1,57 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_CREATE_CHANNEL_POSIX_H +#define GRPCPP_CREATE_CHANNEL_POSIX_H + +#include + +namespace grpc { + +#ifdef GPR_SUPPORT_CHANNELS_FROM_FD + +static inline std::shared_ptr CreateInsecureChannelFromFd( + const grpc::string& target, int fd) { + return ::grpc_impl::CreateInsecureChannelFromFd(target, fd); +} + +static inline std::shared_ptr CreateCustomInsecureChannelFromFd( + const grpc::string& target, int fd, const ChannelArguments& args) { + return ::grpc_impl::CreateCustomInsecureChannelFromFd(target, fd, args); +} + +namespace experimental { + +static inline std::shared_ptr +CreateCustomInsecureChannelWithInterceptorsFromFd( + const grpc::string& target, int fd, const ChannelArguments& args, + std::unique_ptr>> + interceptor_creators) { + return ::grpc_impl::experimental:: + CreateCustomInsecureChannelWithInterceptorsFromFd( + target, fd, args, std::move(interceptor_creators)); +} + +} // namespace experimental + +#endif // GPR_SUPPORT_CHANNELS_FROM_FD + +} // namespace grpc + +#endif // GRPCPP_CREATE_CHANNEL_POSIX_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/create_channel_posix_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/create_channel_posix_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..5c11120611a842256bbe7ec36ebe17864eb4f632 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/create_channel_posix_impl.h @@ -0,0 +1,70 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_CREATE_CHANNEL_POSIX_IMPL_H +#define GRPCPP_CREATE_CHANNEL_POSIX_IMPL_H + +#include + +#include +#include +#include + +namespace grpc_impl { + +#ifdef GPR_SUPPORT_CHANNELS_FROM_FD + +/// Create a new \a Channel communicating over the given file descriptor. +/// +/// \param target The name of the target. +/// \param fd The file descriptor representing a socket. +std::shared_ptr CreateInsecureChannelFromFd( + const grpc::string& target, int fd); + +/// Create a new \a Channel communicating over given file descriptor with custom +/// channel arguments. +/// +/// \param target The name of the target. +/// \param fd The file descriptor representing a socket. +/// \param args Options for channel creation. +std::shared_ptr CreateCustomInsecureChannelFromFd( + const grpc::string& target, int fd, const grpc::ChannelArguments& args); + +namespace experimental { + +/// Create a new \a Channel communicating over given file descriptor with custom +/// channel arguments. +/// +/// \param target The name of the target. +/// \param fd The file descriptor representing a socket. +/// \param args Options for channel creation. +/// \param interceptor_creators Vector of interceptor factory objects. +std::shared_ptr +CreateCustomInsecureChannelWithInterceptorsFromFd( + const grpc::string& target, int fd, const grpc::ChannelArguments& args, + std::unique_ptr>> + interceptor_creators); + +} // namespace experimental + +#endif // GPR_SUPPORT_CHANNELS_FROM_FD + +} // namespace grpc_impl + +#endif // GRPCPP_CREATE_CHANNEL_POSIX_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/ext/health_check_service_server_builder_option.h b/deps/exla/cache/xla_extension/include/grpcpp/ext/health_check_service_server_builder_option.h new file mode 100644 index 0000000000000000000000000000000000000000..dd43b05ef0769f524f2f2063a5d94497c21e906a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/ext/health_check_service_server_builder_option.h @@ -0,0 +1,47 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H +#define GRPCPP_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H + +#include + +#include +#include +#include + +namespace grpc { + +class HealthCheckServiceServerBuilderOption : public ServerBuilderOption { + public: + /// The ownership of \a hc will be taken and transferred to the grpc server. + /// To explicitly disable default service, pass in a nullptr. + explicit HealthCheckServiceServerBuilderOption( + std::unique_ptr hc); + ~HealthCheckServiceServerBuilderOption() override {} + void UpdateArguments(ChannelArguments* args) override; + void UpdatePlugins( + std::vector>* plugins) override; + + private: + std::unique_ptr hc_; +}; + +} // namespace grpc + +#endif // GRPCPP_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/generic/async_generic_service.h b/deps/exla/cache/xla_extension/include/grpcpp/generic/async_generic_service.h new file mode 100644 index 0000000000000000000000000000000000000000..2c67edc5170225a090b2c04548c66b51595df08c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/generic/async_generic_service.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_GENERIC_ASYNC_GENERIC_SERVICE_H +#define GRPCPP_GENERIC_ASYNC_GENERIC_SERVICE_H + +#include + +#endif // GRPCPP_GENERIC_ASYNC_GENERIC_SERVICE_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/generic/generic_stub.h b/deps/exla/cache/xla_extension/include/grpcpp/generic/generic_stub.h new file mode 100644 index 0000000000000000000000000000000000000000..f4c4664f53cf0ce32e8c5326390506e4579c1865 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/generic/generic_stub.h @@ -0,0 +1,30 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_GENERIC_GENERIC_STUB_H +#define GRPCPP_GENERIC_GENERIC_STUB_H + +#include + +namespace grpc { + +typedef ::grpc_impl::GenericStub GenericStub; + +} // namespace grpc + +#endif // GRPCPP_GENERIC_GENERIC_STUB_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/generic/generic_stub_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/generic/generic_stub_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..4aca1cd5393a52356e4d1ebcca202c0fbb3d0f39 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/generic/generic_stub_impl.h @@ -0,0 +1,179 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_GENERIC_GENERIC_STUB_IMPL_H +#define GRPCPP_GENERIC_GENERIC_STUB_IMPL_H + +#include + +#include +#include +#include +#include +#include +#include + +namespace grpc { + +typedef ::grpc_impl::ClientAsyncReaderWriter + GenericClientAsyncReaderWriter; +typedef ::grpc_impl::ClientAsyncResponseReader + GenericClientAsyncResponseReader; +} // namespace grpc +namespace grpc_impl { +class CompletionQueue; + +/// Generic stubs provide a type-unsafe interface to call gRPC methods +/// by name. +class GenericStub final { + public: + explicit GenericStub(std::shared_ptr channel) + : channel_(channel) {} + + /// Setup a call to a named method \a method using \a context, but don't + /// start it. Let it be started explicitly with StartCall and a tag. + /// The return value only indicates whether or not registration of the call + /// succeeded (i.e. the call won't proceed if the return value is nullptr). + std::unique_ptr PrepareCall( + grpc::ClientContext* context, const grpc::string& method, + CompletionQueue* cq); + + /// Setup a unary call to a named method \a method using \a context, and don't + /// start it. Let it be started explicitly with StartCall. + /// The return value only indicates whether or not registration of the call + /// succeeded (i.e. the call won't proceed if the return value is nullptr). + std::unique_ptr PrepareUnaryCall( + grpc_impl::ClientContext* context, const grpc::string& method, + const grpc::ByteBuffer& request, CompletionQueue* cq); + + /// DEPRECATED for multi-threaded use + /// Begin a call to a named method \a method using \a context. + /// A tag \a tag will be delivered to \a cq when the call has been started + /// (i.e, initial metadata has been sent). + /// The return value only indicates whether or not registration of the call + /// succeeded (i.e. the call won't proceed if the return value is nullptr). + std::unique_ptr Call( + grpc_impl::ClientContext* context, const grpc::string& method, + CompletionQueue* cq, void* tag); + +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL + /// Setup and start a unary call to a named method \a method using + /// \a context and specifying the \a request and \a response buffers. + void UnaryCall(grpc_impl::ClientContext* context, const grpc::string& method, + const grpc::ByteBuffer* request, grpc::ByteBuffer* response, + std::function on_completion) { + UnaryCallInternal(context, method, request, response, + std::move(on_completion)); + } + + /// Setup a unary call to a named method \a method using + /// \a context and specifying the \a request and \a response buffers. + /// Like any other reactor-based RPC, it will not be activated until + /// StartCall is invoked on its reactor. + void PrepareUnaryCall(grpc_impl::ClientContext* context, + const grpc::string& method, + const grpc::ByteBuffer* request, + grpc::ByteBuffer* response, + grpc_impl::ClientUnaryReactor* reactor) { + PrepareUnaryCallInternal(context, method, request, response, reactor); + } + + /// Setup a call to a named method \a method using \a context and tied to + /// \a reactor . Like any other bidi streaming RPC, it will not be activated + /// until StartCall is invoked on its reactor. + void PrepareBidiStreamingCall( + grpc_impl::ClientContext* context, const grpc::string& method, + grpc_impl::ClientBidiReactor* + reactor) { + PrepareBidiStreamingCallInternal(context, method, reactor); + } +#endif + + /// NOTE: class experimental_type is not part of the public API of this class + /// TODO(vjpai): Move these contents to the public API of GenericStub when + /// they are no longer experimental + class experimental_type { + public: + explicit experimental_type(GenericStub* stub) : stub_(stub) {} + + /// Setup and start a unary call to a named method \a method using + /// \a context and specifying the \a request and \a response buffers. + void UnaryCall(grpc_impl::ClientContext* context, + const grpc::string& method, const grpc::ByteBuffer* request, + grpc::ByteBuffer* response, + std::function on_completion) { + stub_->UnaryCallInternal(context, method, request, response, + std::move(on_completion)); + } + + /// Setup a unary call to a named method \a method using + /// \a context and specifying the \a request and \a response buffers. + /// Like any other reactor-based RPC, it will not be activated until + /// StartCall is invoked on its reactor. + void PrepareUnaryCall(grpc_impl::ClientContext* context, + const grpc::string& method, + const grpc::ByteBuffer* request, + grpc::ByteBuffer* response, + grpc_impl::ClientUnaryReactor* reactor) { + stub_->PrepareUnaryCallInternal(context, method, request, response, + reactor); + } + + /// Setup a call to a named method \a method using \a context and tied to + /// \a reactor . Like any other bidi streaming RPC, it will not be activated + /// until StartCall is invoked on its reactor. + void PrepareBidiStreamingCall( + grpc_impl::ClientContext* context, const grpc::string& method, + grpc_impl::ClientBidiReactor* + reactor) { + stub_->PrepareBidiStreamingCallInternal(context, method, reactor); + } + + private: + GenericStub* stub_; + }; + + /// NOTE: The function experimental() is not stable public API. It is a view + /// to the experimental components of this class. It may be changed or removed + /// at any time. + experimental_type experimental() { return experimental_type(this); } + + private: + std::shared_ptr channel_; + + void UnaryCallInternal(grpc_impl::ClientContext* context, + const grpc::string& method, + const grpc::ByteBuffer* request, + grpc::ByteBuffer* response, + std::function on_completion); + + void PrepareUnaryCallInternal(grpc_impl::ClientContext* context, + const grpc::string& method, + const grpc::ByteBuffer* request, + grpc::ByteBuffer* response, + grpc_impl::ClientUnaryReactor* reactor); + + void PrepareBidiStreamingCallInternal( + grpc_impl::ClientContext* context, const grpc::string& method, + grpc_impl::ClientBidiReactor* + reactor); +}; + +} // namespace grpc_impl + +#endif // GRPCPP_GENERIC_GENERIC_STUB_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/grpcpp.h b/deps/exla/cache/xla_extension/include/grpcpp/grpcpp.h new file mode 100644 index 0000000000000000000000000000000000000000..aa8a24203bce680999859b03dae38d3382f6e604 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/grpcpp.h @@ -0,0 +1,68 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/// \mainpage gRPC C++ API +/// +/// The gRPC C++ API mainly consists of the following classes: +///
+/// - grpc::Channel, which represents the connection to an endpoint. See [the +/// gRPC Concepts page](https://grpc.io/docs/guides/concepts.html) for more +/// details. Channels are created by the factory function grpc::CreateChannel. +/// +/// - grpc::CompletionQueue, the producer-consumer queue used for all +/// asynchronous communication with the gRPC runtime. +/// +/// - grpc::ClientContext and grpc::ServerContext, where optional configuration +/// for an RPC can be set, such as setting custom metadata to be conveyed to the +/// peer, compression settings, authentication, etc. +/// +/// - grpc::Server, representing a gRPC server, created by grpc::ServerBuilder. +/// +/// Streaming calls are handled with the streaming classes in +/// \ref sync_stream.h and +/// \ref async_stream.h. +/// +/// Refer to the +/// [examples](https://github.com/grpc/grpc/blob/master/examples/cpp) +/// for code putting these pieces into play. + +#ifndef GRPCPP_GRPCPP_H +#define GRPCPP_GRPCPP_H + +// Pragma for http://include-what-you-use.org/ tool, tells that following +// headers are not private for grpcpp.h and are part of its interface. +// IWYU pragma: begin_exports +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +// IWYU pragma: end_exports + +namespace grpc { +/// Return gRPC library version. +grpc::string Version(); +} // namespace grpc + +#endif // GRPCPP_GRPCPP_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/health_check_service_interface.h b/deps/exla/cache/xla_extension/include/grpcpp/health_check_service_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..a51b0d18bba0a8faa2e2f4beada01d1fde4c3df5 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/health_check_service_interface.h @@ -0,0 +1,41 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_HEALTH_CHECK_SERVICE_INTERFACE_H +#define GRPCPP_HEALTH_CHECK_SERVICE_INTERFACE_H + +#include + +namespace grpc { + +const char kHealthCheckServiceInterfaceArg[] = + "grpc.health_check_service_interface"; + +typedef ::grpc_impl::HealthCheckServiceInterface HealthCheckServiceInterface; + +static inline void EnableDefaultHealthCheckService(bool enable) { + ::grpc_impl::EnableDefaultHealthCheckService(enable); +} + +static inline bool DefaultHealthCheckServiceEnabled() { + return ::grpc_impl::DefaultHealthCheckServiceEnabled(); +} + +} // namespace grpc + +#endif // GRPCPP_HEALTH_CHECK_SERVICE_INTERFACE_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/health_check_service_interface_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/health_check_service_interface_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..025dadb4e59a27d8d06f0f5c339278d215f360c5 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/health_check_service_interface_impl.h @@ -0,0 +1,55 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_HEALTH_CHECK_SERVICE_INTERFACE_IMPL_H +#define GRPCPP_HEALTH_CHECK_SERVICE_INTERFACE_IMPL_H + +#include + +namespace grpc_impl { + +/// The gRPC server uses this interface to expose the health checking service +/// without depending on protobuf. +class HealthCheckServiceInterface { + public: + virtual ~HealthCheckServiceInterface() {} + + /// Set or change the serving status of the given \a service_name. + virtual void SetServingStatus(const grpc::string& service_name, + bool serving) = 0; + /// Apply to all registered service names. + virtual void SetServingStatus(bool serving) = 0; + + /// Set all registered service names to not serving and prevent future + /// state changes. + virtual void Shutdown() {} +}; + +/// Enable/disable the default health checking service. This applies to all C++ +/// servers created afterwards. For each server, user can override the default +/// with a HealthCheckServiceServerBuilderOption. +/// NOT thread safe. +void EnableDefaultHealthCheckService(bool enable); + +/// Returns whether the default health checking service is enabled. +/// NOT thread safe. +bool DefaultHealthCheckServiceEnabled(); + +} // namespace grpc_impl + +#endif // GRPCPP_HEALTH_CHECK_SERVICE_INTERFACE_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/call.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/call.h new file mode 100644 index 0000000000000000000000000000000000000000..a6b13126934b8c7d32b254075009976e1847980f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/call.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CALL_H +#define GRPCPP_IMPL_CALL_H + +#include + +#endif // GRPCPP_IMPL_CALL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/channel_argument_option.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/channel_argument_option.h new file mode 100644 index 0000000000000000000000000000000000000000..0c4882478e2d8bab10ea47f77b6d5a0c5473581b --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/channel_argument_option.h @@ -0,0 +1,37 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CHANNEL_ARGUMENT_OPTION_H +#define GRPCPP_IMPL_CHANNEL_ARGUMENT_OPTION_H + +#include +#include + +#include +#include + +namespace grpc { + +std::unique_ptr MakeChannelArgumentOption( + const grpc::string& name, const grpc::string& value); +std::unique_ptr MakeChannelArgumentOption( + const grpc::string& name, int value); + +} // namespace grpc + +#endif // GRPCPP_IMPL_CHANNEL_ARGUMENT_OPTION_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/client_unary_call.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/client_unary_call.h new file mode 100644 index 0000000000000000000000000000000000000000..378482c54038f09cc754dc5e739ac225994d85b8 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/client_unary_call.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CLIENT_UNARY_CALL_H +#define GRPCPP_IMPL_CLIENT_UNARY_CALL_H + +#include + +#endif // GRPCPP_IMPL_CLIENT_UNARY_CALL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_generic_service.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_generic_service.h new file mode 100644 index 0000000000000000000000000000000000000000..05f10c67f2571edbcdd6424726ce80b817b03256 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_generic_service.h @@ -0,0 +1,163 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_ASYNC_GENERIC_SERVICE_H +#define GRPCPP_IMPL_CODEGEN_ASYNC_GENERIC_SERVICE_H + +#include + +#include +#include +#include +#include + +struct grpc_server; + +namespace grpc { + +typedef ::grpc_impl::ServerAsyncReaderWriter + GenericServerAsyncReaderWriter; +typedef ::grpc_impl::ServerAsyncResponseWriter + GenericServerAsyncResponseWriter; +typedef ::grpc_impl::ServerAsyncReader + GenericServerAsyncReader; +typedef ::grpc_impl::ServerAsyncWriter GenericServerAsyncWriter; + +class GenericServerContext final : public ::grpc_impl::ServerContext { + public: + const grpc::string& method() const { return method_; } + const grpc::string& host() const { return host_; } + + private: + friend class grpc_impl::Server; + friend class grpc::ServerInterface; + + void Clear() { + method_.clear(); + host_.clear(); + ::grpc_impl::ServerContext::Clear(); + } + + grpc::string method_; + grpc::string host_; +}; + +// A generic service at the server side accepts all RPC methods and hosts. It is +// typically used in proxies. The generic service can be registered to a server +// which also has other services. +// Sample usage: +// ServerBuilder builder; +// auto cq = builder.AddCompletionQueue(); +// AsyncGenericService generic_service; +// builder.RegisterAsyncGenericService(&generic_service); +// auto server = builder.BuildAndStart(); +// +// // request a new call +// GenericServerContext context; +// GenericServerAsyncReaderWriter stream; +// generic_service.RequestCall(&context, &stream, cq.get(), cq.get(), tag); +// +// When tag is retrieved from cq->Next(), context.method() can be used to look +// at the method and the RPC can be handled accordingly. +class AsyncGenericService final { + public: + AsyncGenericService() : server_(nullptr) {} + + void RequestCall(GenericServerContext* ctx, + GenericServerAsyncReaderWriter* reader_writer, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag); + + private: + friend class grpc_impl::Server; + grpc_impl::Server* server_; +}; + +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL +namespace experimental { +#endif + +/// \a ServerGenericBidiReactor is the reactor class for bidi streaming RPCs +/// invoked on a CallbackGenericService. It is just a ServerBidi reactor with +/// ByteBuffer arguments. +using ServerGenericBidiReactor = + ::grpc_impl::ServerBidiReactor; + +class GenericCallbackServerContext final + : public ::grpc_impl::CallbackServerContext { + public: + const grpc::string& method() const { return method_; } + const grpc::string& host() const { return host_; } + + private: + friend class ::grpc_impl::Server; + friend class ::grpc::ServerInterface; + + void Clear() { + method_.clear(); + host_.clear(); + ::grpc_impl::CallbackServerContext::Clear(); + } + + grpc::string method_; + grpc::string host_; +}; + +/// \a CallbackGenericService is the base class for generic services implemented +/// using the callback API and registered through the ServerBuilder using +/// RegisterCallbackGenericService. +class CallbackGenericService { + public: + CallbackGenericService() {} + virtual ~CallbackGenericService() {} + + /// The "method handler" for the generic API. This function should be + /// overridden to provide a ServerGenericBidiReactor that implements the + /// application-level interface for this RPC. Unimplemented by default. + virtual ServerGenericBidiReactor* CreateReactor( + GenericCallbackServerContext* /*ctx*/) { + class Reactor : public ServerGenericBidiReactor { + public: + Reactor() { this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); } + void OnDone() override { delete this; } + }; + return new Reactor; + } + + private: + friend class ::grpc_impl::Server; + + ::grpc_impl::internal::CallbackBidiHandler* + Handler() { + return new ::grpc_impl::internal::CallbackBidiHandler( + [this](::grpc_impl::CallbackServerContext* ctx) { + return CreateReactor(static_cast(ctx)); + }); + } + + grpc_impl::Server* server_{nullptr}; +}; + +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL +} // namespace experimental +#endif +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_ASYNC_GENERIC_SERVICE_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_stream.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_stream.h new file mode 100644 index 0000000000000000000000000000000000000000..d76a8982a4b9cef8ad2cfec6da8a15dd4ebe86c3 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_stream.h @@ -0,0 +1,95 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H +#define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H + +#include + +namespace grpc { + +namespace internal { + +typedef ::grpc_impl::internal::ClientAsyncStreamingInterface + ClientAsyncStreamingInterface; + +template +using AsyncReaderInterface = ::grpc_impl::internal::AsyncReaderInterface; + +template +using AsyncWriterInterface = ::grpc_impl::internal::AsyncWriterInterface; + +} // namespace internal + +template +using ClientAsyncReaderInterface = ::grpc_impl::ClientAsyncReaderInterface; + +template +using ClientAsyncReader = ::grpc_impl::ClientAsyncReader; + +template +using ClientAsyncWriterInterface = ::grpc_impl::ClientAsyncWriterInterface; + +template +using ClientAsyncWriter = ::grpc_impl::ClientAsyncWriter; + +template +using ClientAsyncReaderWriterInterface = + ::grpc_impl::ClientAsyncReaderWriterInterface; + +template +using ClientAsyncReaderWriter = ::grpc_impl::ClientAsyncReaderWriter; + +template +using ServerAsyncReaderInterface = + ::grpc_impl::ServerAsyncReaderInterface; + +template +using ServerAsyncReader = ::grpc_impl::ServerAsyncReader; + +template +using ServerAsyncWriterInterface = ::grpc_impl::ServerAsyncWriterInterface; + +template +using ServerAsyncWriter = ::grpc_impl::ServerAsyncWriter; + +template +using ServerAsyncReaderWriterInterface = + ::grpc_impl::ServerAsyncReaderWriterInterface; + +template +using ServerAsyncReaderWriter = ::grpc_impl::ServerAsyncReaderWriter; + +namespace internal { +template +using ClientAsyncReaderFactory = + ::grpc_impl::internal::ClientAsyncReaderFactory; + +template +using ClientAsyncWriterFactory = + ::grpc_impl::internal::ClientAsyncWriterFactory; + +template +using ClientAsyncReaderWriterFactory = + ::grpc_impl::internal::ClientAsyncReaderWriterFactory; + +} // namespace internal + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_stream_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_stream_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..f832f5e457a4ca90c6eaf81647b06b995d5c94da --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_stream_impl.h @@ -0,0 +1,1134 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_IMPL_H +#define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_IMPL_H + +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +namespace internal { +/// Common interface for all client side asynchronous streaming. +class ClientAsyncStreamingInterface { + public: + virtual ~ClientAsyncStreamingInterface() {} + + /// Start the call that was set up by the constructor, but only if the + /// constructor was invoked through the "Prepare" API which doesn't actually + /// start the call + virtual void StartCall(void* tag) = 0; + + /// Request notification of the reading of the initial metadata. Completion + /// will be notified by \a tag on the associated completion queue. + /// This call is optional, but if it is used, it cannot be used concurrently + /// with or after the \a AsyncReaderInterface::Read method. + /// + /// \param[in] tag Tag identifying this request. + virtual void ReadInitialMetadata(void* tag) = 0; + + /// Indicate that the stream is to be finished and request notification for + /// when the call has been ended. + /// Should not be used concurrently with other operations. + /// + /// It is appropriate to call this method exactly once when both: + /// * the client side has no more message to send + /// (this can be declared implicitly by calling this method, or + /// explicitly through an earlier call to the WritesDone method + /// of the class in use, e.g. \a ClientAsyncWriterInterface::WritesDone or + /// \a ClientAsyncReaderWriterInterface::WritesDone). + /// * there are no more messages to be received from the server (this can + /// be known implicitly by the calling code, or explicitly from an + /// earlier call to \a AsyncReaderInterface::Read that yielded a failed + /// result, e.g. cq->Next(&read_tag, &ok) filled in 'ok' with 'false'). + /// + /// The tag will be returned when either: + /// - all incoming messages have been read and the server has returned + /// a status. + /// - the server has returned a non-OK status. + /// - the call failed for some reason and the library generated a + /// status. + /// + /// Note that implementations of this method attempt to receive initial + /// metadata from the server if initial metadata hasn't yet been received. + /// + /// \param[in] tag Tag identifying this request. + /// \param[out] status To be updated with the operation status. + virtual void Finish(::grpc::Status* status, void* tag) = 0; +}; + +/// An interface that yields a sequence of messages of type \a R. +template +class AsyncReaderInterface { + public: + virtual ~AsyncReaderInterface() {} + + /// Read a message of type \a R into \a msg. Completion will be notified by \a + /// tag on the associated completion queue. + /// This is thread-safe with respect to \a Write or \a WritesDone methods. It + /// should not be called concurrently with other streaming APIs + /// on the same stream. It is not meaningful to call it concurrently + /// with another \a AsyncReaderInterface::Read on the same stream since reads + /// on the same stream are delivered in order. + /// + /// \param[out] msg Where to eventually store the read message. + /// \param[in] tag The tag identifying the operation. + /// + /// Side effect: note that this method attempt to receive initial metadata for + /// a stream if it hasn't yet been received. + virtual void Read(R* msg, void* tag) = 0; +}; + +/// An interface that can be fed a sequence of messages of type \a W. +template +class AsyncWriterInterface { + public: + virtual ~AsyncWriterInterface() {} + + /// Request the writing of \a msg with identifying tag \a tag. + /// + /// Only one write may be outstanding at any given time. This means that + /// after calling Write, one must wait to receive \a tag from the completion + /// queue BEFORE calling Write again. + /// This is thread-safe with respect to \a AsyncReaderInterface::Read + /// + /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to + /// to deallocate once Write returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] tag The tag identifying the operation. + virtual void Write(const W& msg, void* tag) = 0; + + /// Request the writing of \a msg using WriteOptions \a options with + /// identifying tag \a tag. + /// + /// Only one write may be outstanding at any given time. This means that + /// after calling Write, one must wait to receive \a tag from the completion + /// queue BEFORE calling Write again. + /// WriteOptions \a options is used to set the write options of this message. + /// This is thread-safe with respect to \a AsyncReaderInterface::Read + /// + /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to + /// to deallocate once Write returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] options The WriteOptions to be used to write this message. + /// \param[in] tag The tag identifying the operation. + virtual void Write(const W& msg, ::grpc::WriteOptions options, void* tag) = 0; + + /// Request the writing of \a msg and coalesce it with the writing + /// of trailing metadata, using WriteOptions \a options with + /// identifying tag \a tag. + /// + /// For client, WriteLast is equivalent of performing Write and + /// WritesDone in a single step. + /// For server, WriteLast buffers the \a msg. The writing of \a msg is held + /// until Finish is called, where \a msg and trailing metadata are coalesced + /// and write is initiated. Note that WriteLast can only buffer \a msg up to + /// the flow control window size. If \a msg size is larger than the window + /// size, it will be sent on wire without buffering. + /// + /// gRPC doesn't take ownership or a reference to \a msg, so it is safe to + /// to deallocate once Write returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] options The WriteOptions to be used to write this message. + /// \param[in] tag The tag identifying the operation. + void WriteLast(const W& msg, ::grpc::WriteOptions options, void* tag) { + Write(msg, options.set_last_message(), tag); + } +}; + +} // namespace internal + +template +class ClientAsyncReaderInterface + : public internal::ClientAsyncStreamingInterface, + public internal::AsyncReaderInterface {}; + +namespace internal { +template +class ClientAsyncReaderFactory { + public: + /// Create a stream object. + /// Write the first request out if \a start is set. + /// \a tag will be notified on \a cq when the call has been started and + /// \a request has been written out. If \a start is not set, \a tag must be + /// nullptr and the actual call must be initiated by StartCall + /// Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + template + static ClientAsyncReader* Create(::grpc::ChannelInterface* channel, + ::grpc_impl::CompletionQueue* cq, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const W& request, bool start, void* tag) { + ::grpc::internal::Call call = channel->CreateCall(method, context, cq); + return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientAsyncReader))) + ClientAsyncReader(call, context, request, start, tag); + } +}; +} // namespace internal + +/// Async client-side API for doing server-streaming RPCs, +/// where the incoming message stream coming from the server has +/// messages of type \a R. +template +class ClientAsyncReader final : public ClientAsyncReaderInterface { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* /*ptr*/, std::size_t size) { + GPR_CODEGEN_ASSERT(size == sizeof(ClientAsyncReader)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } + + void StartCall(void* tag) override { + GPR_CODEGEN_ASSERT(!started_); + started_ = true; + StartCallInternal(tag); + } + + /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata + /// method for semantics. + /// + /// Side effect: + /// - upon receiving initial metadata from the server, + /// the \a ClientContext associated with this call is updated, and the + /// calling code can access the received metadata through the + /// \a ClientContext. + void ReadInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(started_); + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) override { + GPR_CODEGEN_ASSERT(started_); + read_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + read_ops_.RecvInitialMetadata(context_); + } + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata received from the server. + void Finish(::grpc::Status* status, void* tag) override { + GPR_CODEGEN_ASSERT(started_); + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + friend class internal::ClientAsyncReaderFactory; + template + ClientAsyncReader(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, const W& request, + bool start, void* tag) + : context_(context), call_(call), started_(start) { + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok()); + init_ops_.ClientSendClose(); + if (start) { + StartCallInternal(tag); + } else { + GPR_CODEGEN_ASSERT(tag == nullptr); + } + } + + void StartCallInternal(void* tag) { + init_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + init_ops_.set_output_tag(tag); + call_.PerformOps(&init_ops_); + } + + ::grpc_impl::ClientContext* context_; + ::grpc::internal::Call call_; + bool started_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + init_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage> + read_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpClientRecvStatus> + finish_ops_; +}; + +/// Common interface for client side asynchronous writing. +template +class ClientAsyncWriterInterface + : public internal::ClientAsyncStreamingInterface, + public internal::AsyncWriterInterface { + public: + /// Signal the client is done with the writes (half-close the client stream). + /// Thread-safe with respect to \a AsyncReaderInterface::Read + /// + /// \param[in] tag The tag identifying the operation. + virtual void WritesDone(void* tag) = 0; +}; + +namespace internal { +template +class ClientAsyncWriterFactory { + public: + /// Create a stream object. + /// Start the RPC if \a start is set + /// \a tag will be notified on \a cq when the call has been started (i.e. + /// intitial metadata sent) and \a request has been written out. + /// If \a start is not set, \a tag must be nullptr and the actual call + /// must be initiated by StartCall + /// Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + /// \a response will be filled in with the single expected response + /// message from the server upon a successful call to the \a Finish + /// method of this instance. + template + static ClientAsyncWriter* Create(::grpc::ChannelInterface* channel, + ::grpc_impl::CompletionQueue* cq, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + R* response, bool start, void* tag) { + ::grpc::internal::Call call = channel->CreateCall(method, context, cq); + return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientAsyncWriter))) + ClientAsyncWriter(call, context, response, start, tag); + } +}; +} // namespace internal + +/// Async API on the client side for doing client-streaming RPCs, +/// where the outgoing message stream going to the server contains +/// messages of type \a W. +template +class ClientAsyncWriter final : public ClientAsyncWriterInterface { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* /*ptr*/, std::size_t size) { + GPR_CODEGEN_ASSERT(size == sizeof(ClientAsyncWriter)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } + + void StartCall(void* tag) override { + GPR_CODEGEN_ASSERT(!started_); + started_ = true; + StartCallInternal(tag); + } + + /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata method for + /// semantics. + /// + /// Side effect: + /// - upon receiving initial metadata from the server, the \a ClientContext + /// associated with this call is updated, and the calling code can access + /// the received metadata through the \a ClientContext. + void ReadInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(started_); + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Write(const W& msg, void* tag) override { + GPR_CODEGEN_ASSERT(started_); + write_ops_.set_output_tag(tag); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override { + GPR_CODEGEN_ASSERT(started_); + write_ops_.set_output_tag(tag); + if (options.is_last_message()) { + options.set_buffer_hint(); + write_ops_.ClientSendClose(); + } + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WritesDone(void* tag) override { + GPR_CODEGEN_ASSERT(started_); + write_ops_.set_output_tag(tag); + write_ops_.ClientSendClose(); + call_.PerformOps(&write_ops_); + } + + /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata received from the server. + /// - attempts to fill in the \a response parameter passed to this class's + /// constructor with the server's response message. + void Finish(::grpc::Status* status, void* tag) override { + GPR_CODEGEN_ASSERT(started_); + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + friend class internal::ClientAsyncWriterFactory; + template + ClientAsyncWriter(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, R* response, + bool start, void* tag) + : context_(context), call_(call), started_(start) { + finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); + if (start) { + StartCallInternal(tag); + } else { + GPR_CODEGEN_ASSERT(tag == nullptr); + } + } + + void StartCallInternal(void* tag) { + write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + // if corked bit is set in context, we just keep the initial metadata + // buffered up to coalesce with later message send. No op is performed. + if (!context_->initial_metadata_corked_) { + write_ops_.set_output_tag(tag); + call_.PerformOps(&write_ops_); + } + } + + ::grpc_impl::ClientContext* context_; + ::grpc::internal::Call call_; + bool started_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + write_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpGenericRecvMessage, + ::grpc::internal::CallOpClientRecvStatus> + finish_ops_; +}; + +/// Async client-side interface for bi-directional streaming, +/// where the client-to-server message stream has messages of type \a W, +/// and the server-to-client message stream has messages of type \a R. +template +class ClientAsyncReaderWriterInterface + : public internal::ClientAsyncStreamingInterface, + public internal::AsyncWriterInterface, + public internal::AsyncReaderInterface { + public: + /// Signal the client is done with the writes (half-close the client stream). + /// Thread-safe with respect to \a AsyncReaderInterface::Read + /// + /// \param[in] tag The tag identifying the operation. + virtual void WritesDone(void* tag) = 0; +}; + +namespace internal { +template +class ClientAsyncReaderWriterFactory { + public: + /// Create a stream object. + /// Start the RPC request if \a start is set. + /// \a tag will be notified on \a cq when the call has been started (i.e. + /// intitial metadata sent). If \a start is not set, \a tag must be + /// nullptr and the actual call must be initiated by StartCall + /// Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + static ClientAsyncReaderWriter* Create( + ::grpc::ChannelInterface* channel, ::grpc_impl::CompletionQueue* cq, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, bool start, void* tag) { + ::grpc::internal::Call call = channel->CreateCall(method, context, cq); + + return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientAsyncReaderWriter))) + ClientAsyncReaderWriter(call, context, start, tag); + } +}; +} // namespace internal + +/// Async client-side interface for bi-directional streaming, +/// where the outgoing message stream going to the server +/// has messages of type \a W, and the incoming message stream coming +/// from the server has messages of type \a R. +template +class ClientAsyncReaderWriter final + : public ClientAsyncReaderWriterInterface { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* /*ptr*/, std::size_t size) { + GPR_CODEGEN_ASSERT(size == sizeof(ClientAsyncReaderWriter)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } + + void StartCall(void* tag) override { + GPR_CODEGEN_ASSERT(!started_); + started_ = true; + StartCallInternal(tag); + } + + /// See the \a ClientAsyncStreamingInterface.ReadInitialMetadata method + /// for semantics of this method. + /// + /// Side effect: + /// - upon receiving initial metadata from the server, the \a ClientContext + /// is updated with it, and then the receiving initial metadata can + /// be accessed through this \a ClientContext. + void ReadInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(started_); + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) override { + GPR_CODEGEN_ASSERT(started_); + read_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + read_ops_.RecvInitialMetadata(context_); + } + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Write(const W& msg, void* tag) override { + GPR_CODEGEN_ASSERT(started_); + write_ops_.set_output_tag(tag); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override { + GPR_CODEGEN_ASSERT(started_); + write_ops_.set_output_tag(tag); + if (options.is_last_message()) { + options.set_buffer_hint(); + write_ops_.ClientSendClose(); + } + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WritesDone(void* tag) override { + GPR_CODEGEN_ASSERT(started_); + write_ops_.set_output_tag(tag); + write_ops_.ClientSendClose(); + call_.PerformOps(&write_ops_); + } + + /// See the \a ClientAsyncStreamingInterface.Finish method for semantics. + /// Side effect + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata sent from the server. + void Finish(::grpc::Status* status, void* tag) override { + GPR_CODEGEN_ASSERT(started_); + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + friend class internal::ClientAsyncReaderWriterFactory; + ClientAsyncReaderWriter(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, bool start, + void* tag) + : context_(context), call_(call), started_(start) { + if (start) { + StartCallInternal(tag); + } else { + GPR_CODEGEN_ASSERT(tag == nullptr); + } + } + + void StartCallInternal(void* tag) { + write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + // if corked bit is set in context, we just keep the initial metadata + // buffered up to coalesce with later message send. No op is performed. + if (!context_->initial_metadata_corked_) { + write_ops_.set_output_tag(tag); + call_.PerformOps(&write_ops_); + } + } + + ::grpc_impl::ClientContext* context_; + ::grpc::internal::Call call_; + bool started_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage> + read_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + write_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpClientRecvStatus> + finish_ops_; +}; + +template +class ServerAsyncReaderInterface + : public ::grpc::internal::ServerAsyncStreamingInterface, + public internal::AsyncReaderInterface { + public: + /// Indicate that the stream is to be finished with a certain status code + /// and also send out \a msg response to the client. + /// Request notification for when the server has sent the response and the + /// appropriate signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// It is appropriate to call this method when: + /// * all messages from the client have been received (either known + /// implictly, or explicitly because a previous + /// \a AsyncReaderInterface::Read operation with a non-ok result, + /// e.g., cq->Next(&read_tag, &ok) filled in 'ok' with 'false'). + /// + /// This operation will end when the server has finished sending out initial + /// metadata (if not sent already), response message, and status, or if + /// some failure occurred when trying to do so. + /// + /// gRPC doesn't take ownership or a reference to \a msg or \a status, so it + /// is safe to deallocate once Finish returns. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of this call. + /// \param[in] msg To be sent to the client as the response for this call. + virtual void Finish(const W& msg, const ::grpc::Status& status, + void* tag) = 0; + + /// Indicate that the stream is to be finished with a certain + /// non-OK status code. + /// Request notification for when the server has sent the appropriate + /// signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// This call is meant to end the call with some error, and can be called at + /// any point that the server would like to "fail" the call (though note + /// this shouldn't be called concurrently with any other "sending" call, like + /// \a AsyncWriterInterface::Write). + /// + /// This operation will end when the server has finished sending out initial + /// metadata (if not sent already), and status, or if some failure occurred + /// when trying to do so. + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once FinishWithError returns. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of this call. + /// - Note: \a status must have a non-OK code. + virtual void FinishWithError(const ::grpc::Status& status, void* tag) = 0; +}; + +/// Async server-side API for doing client-streaming RPCs, +/// where the incoming message stream from the client has messages of type \a R, +/// and the single response message sent from the server is type \a W. +template +class ServerAsyncReader final : public ServerAsyncReaderInterface { + public: + explicit ServerAsyncReader(::grpc_impl::ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. + /// + /// Implicit input parameter: + /// - The initial metadata that will be sent to the client from this op will + /// be taken from the \a ServerContext associated with the call. + void SendInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) override { + read_ops_.set_output_tag(tag); + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + /// See the \a ServerAsyncReaderInterface.Read method for semantics + /// + /// Side effect: + /// - also sends initial metadata if not alreay sent. + /// - uses the \a ServerContext associated with this call to send possible + /// initial and trailing metadata. + /// + /// Note: \a msg is not sent if \a status has a non-OK code. + /// + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once Finish returns. + void Finish(const W& msg, const ::grpc::Status& status, void* tag) override { + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (status.ok()) { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_ops_.SendMessage(msg)); + } else { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + } + call_.PerformOps(&finish_ops_); + } + + /// See the \a ServerAsyncReaderInterface.Read method for semantics + /// + /// Side effect: + /// - also sends initial metadata if not alreay sent. + /// - uses the \a ServerContext associated with this call to send possible + /// initial and trailing metadata. + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once FinishWithError returns. + void FinishWithError(const ::grpc::Status& status, void* tag) override { + GPR_CODEGEN_ASSERT(!status.ok()); + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + void BindCall(::grpc::internal::Call* call) override { call_ = *call; } + + ::grpc::internal::Call call_; + ::grpc_impl::ServerContext* ctx_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> read_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; +}; + +template +class ServerAsyncWriterInterface + : public ::grpc::internal::ServerAsyncStreamingInterface, + public internal::AsyncWriterInterface { + public: + /// Indicate that the stream is to be finished with a certain status code. + /// Request notification for when the server has sent the appropriate + /// signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// It is appropriate to call this method when either: + /// * all messages from the client have been received (either known + /// implictly, or explicitly because a previous \a + /// AsyncReaderInterface::Read operation with a non-ok + /// result (e.g., cq->Next(&read_tag, &ok) filled in 'ok' with 'false'. + /// * it is desired to end the call early with some non-OK status code. + /// + /// This operation will end when the server has finished sending out initial + /// metadata (if not sent already), response message, and status, or if + /// some failure occurred when trying to do so. + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once Finish returns. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of this call. + virtual void Finish(const ::grpc::Status& status, void* tag) = 0; + + /// Request the writing of \a msg and coalesce it with trailing metadata which + /// contains \a status, using WriteOptions options with + /// identifying tag \a tag. + /// + /// WriteAndFinish is equivalent of performing WriteLast and Finish + /// in a single step. + /// + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once WriteAndFinish returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] options The WriteOptions to be used to write this message. + /// \param[in] status The Status that server returns to client. + /// \param[in] tag The tag identifying the operation. + virtual void WriteAndFinish(const W& msg, ::grpc::WriteOptions options, + const ::grpc::Status& status, void* tag) = 0; +}; + +/// Async server-side API for doing server streaming RPCs, +/// where the outgoing message stream from the server has messages of type \a W. +template +class ServerAsyncWriter final : public ServerAsyncWriterInterface { + public: + explicit ServerAsyncWriter(::grpc_impl::ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. + /// + /// Implicit input parameter: + /// - The initial metadata that will be sent to the client from this op will + /// be taken from the \a ServerContext associated with the call. + /// + /// \param[in] tag Tag identifying this request. + void SendInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Write(const W& msg, void* tag) override { + write_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&write_ops_); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override { + write_ops_.set_output_tag(tag); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + + EnsureInitialMetadataSent(&write_ops_); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + call_.PerformOps(&write_ops_); + } + + /// See the \a ServerAsyncWriterInterface.WriteAndFinish method for semantics. + /// + /// Implicit input parameter: + /// - the \a ServerContext associated with this call is used + /// for sending trailing (and initial) metadata to the client. + /// + /// Note: \a status must have an OK code. + /// + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once WriteAndFinish returns. + void WriteAndFinish(const W& msg, ::grpc::WriteOptions options, + const ::grpc::Status& status, void* tag) override { + write_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&write_ops_); + options.set_buffer_hint(); + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&write_ops_); + } + + /// See the \a ServerAsyncWriterInterface.Finish method for semantics. + /// + /// Implicit input parameter: + /// - the \a ServerContext associated with this call is used for sending + /// trailing (and initial if not already sent) metadata to the client. + /// + /// Note: there are no restrictions are the code of + /// \a status,it may be non-OK + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once Finish returns. + void Finish(const ::grpc::Status& status, void* tag) override { + finish_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&finish_ops_); + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + void BindCall(::grpc::internal::Call* call) override { call_ = *call; } + + template + void EnsureInitialMetadataSent(T* ops) { + if (!ctx_->sent_initial_metadata_) { + ops->SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops->set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + } + + ::grpc::internal::Call call_; + ::grpc_impl::ServerContext* ctx_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + write_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; +}; + +/// Server-side interface for asynchronous bi-directional streaming. +template +class ServerAsyncReaderWriterInterface + : public ::grpc::internal::ServerAsyncStreamingInterface, + public internal::AsyncWriterInterface, + public internal::AsyncReaderInterface { + public: + /// Indicate that the stream is to be finished with a certain status code. + /// Request notification for when the server has sent the appropriate + /// signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// It is appropriate to call this method when either: + /// * all messages from the client have been received (either known + /// implictly, or explicitly because a previous \a + /// AsyncReaderInterface::Read operation + /// with a non-ok result (e.g., cq->Next(&read_tag, &ok) filled in 'ok' + /// with 'false'. + /// * it is desired to end the call early with some non-OK status code. + /// + /// This operation will end when the server has finished sending out initial + /// metadata (if not sent already), response message, and status, or if some + /// failure occurred when trying to do so. + /// + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once Finish returns. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of this call. + virtual void Finish(const ::grpc::Status& status, void* tag) = 0; + + /// Request the writing of \a msg and coalesce it with trailing metadata which + /// contains \a status, using WriteOptions options with + /// identifying tag \a tag. + /// + /// WriteAndFinish is equivalent of performing WriteLast and Finish in a + /// single step. + /// + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once WriteAndFinish returns. + /// + /// \param[in] msg The message to be written. + /// \param[in] options The WriteOptions to be used to write this message. + /// \param[in] status The Status that server returns to client. + /// \param[in] tag The tag identifying the operation. + virtual void WriteAndFinish(const W& msg, ::grpc::WriteOptions options, + const ::grpc::Status& status, void* tag) = 0; +}; + +/// Async server-side API for doing bidirectional streaming RPCs, +/// where the incoming message stream coming from the client has messages of +/// type \a R, and the outgoing message stream coming from the server has +/// messages of type \a W. +template +class ServerAsyncReaderWriter final + : public ServerAsyncReaderWriterInterface { + public: + explicit ServerAsyncReaderWriter(::grpc_impl::ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. + /// + /// Implicit input parameter: + /// - The initial metadata that will be sent to the client from this op will + /// be taken from the \a ServerContext associated with the call. + /// + /// \param[in] tag Tag identifying this request. + void SendInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) override { + read_ops_.set_output_tag(tag); + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Write(const W& msg, void* tag) override { + write_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&write_ops_); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override { + write_ops_.set_output_tag(tag); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + EnsureInitialMetadataSent(&write_ops_); + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + call_.PerformOps(&write_ops_); + } + + /// See the \a ServerAsyncReaderWriterInterface.WriteAndFinish + /// method for semantics. + /// + /// Implicit input parameter: + /// - the \a ServerContext associated with this call is used + /// for sending trailing (and initial) metadata to the client. + /// + /// Note: \a status must have an OK code. + // + /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it + /// is safe to deallocate once WriteAndFinish returns. + void WriteAndFinish(const W& msg, ::grpc::WriteOptions options, + const ::grpc::Status& status, void* tag) override { + write_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&write_ops_); + options.set_buffer_hint(); + GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok()); + write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&write_ops_); + } + + /// See the \a ServerAsyncReaderWriterInterface.Finish method for semantics. + /// + /// Implicit input parameter: + /// - the \a ServerContext associated with this call is used for sending + /// trailing (and initial if not already sent) metadata to the client. + /// + /// Note: there are no restrictions are the code of \a status, + /// it may be non-OK + // + /// gRPC doesn't take ownership or a reference to \a status, so it is safe to + /// to deallocate once Finish returns. + void Finish(const ::grpc::Status& status, void* tag) override { + finish_ops_.set_output_tag(tag); + EnsureInitialMetadataSent(&finish_ops_); + + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + friend class ::grpc_impl::Server; + + void BindCall(::grpc::internal::Call* call) override { call_ = *call; } + + template + void EnsureInitialMetadataSent(T* ops) { + if (!ctx_->sent_initial_metadata_) { + ops->SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops->set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + } + + ::grpc::internal::Call call_; + ::grpc_impl::ServerContext* ctx_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> read_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + write_ops_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; +}; + +} // namespace grpc_impl +#endif // GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_unary_call.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_unary_call.h new file mode 100644 index 0000000000000000000000000000000000000000..cbbe70172c8eb57e18c5889d83ed54ccbaef00b0 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_unary_call.h @@ -0,0 +1,46 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H +#define GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H + +#include + +namespace grpc { + +template +using ClientAsyncResponseReaderInterface = + grpc_impl::ClientAsyncResponseReaderInterface; + +template +using ClientAsyncResponseReader = grpc_impl::ClientAsyncResponseReader; + +template +using ServerAsyncResponseWriter = ::grpc_impl::ServerAsyncResponseWriter; + +namespace internal { + +template +using ClientAsyncResponseReaderFactory = + ::grpc_impl::internal::ClientAsyncResponseReaderFactory; + +} // namespace internal + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_unary_call_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_unary_call_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..e7a2101226df327360116097534e9b9b6206d44f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/async_unary_call_impl.h @@ -0,0 +1,314 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_IMPL_H +#define GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_IMPL_H + +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +/// An interface relevant for async client side unary RPCs (which send +/// one request message to a server and receive one response message). +template +class ClientAsyncResponseReaderInterface { + public: + virtual ~ClientAsyncResponseReaderInterface() {} + + /// Start the call that was set up by the constructor, but only if the + /// constructor was invoked through the "Prepare" API which doesn't actually + /// start the call + virtual void StartCall() = 0; + + /// Request notification of the reading of initial metadata. Completion + /// will be notified by \a tag on the associated completion queue. + /// This call is optional, but if it is used, it cannot be used concurrently + /// with or after the \a Finish method. + /// + /// \param[in] tag Tag identifying this request. + virtual void ReadInitialMetadata(void* tag) = 0; + + /// Request to receive the server's response \a msg and final \a status for + /// the call, and to notify \a tag on this call's completion queue when + /// finished. + /// + /// This function will return when either: + /// - when the server's response message and status have been received. + /// - when the server has returned a non-OK status (no message expected in + /// this case). + /// - when the call failed for some reason and the library generated a + /// non-OK status. + /// + /// \param[in] tag Tag identifying this request. + /// \param[out] status To be updated with the operation status. + /// \param[out] msg To be filled in with the server's response message. + virtual void Finish(R* msg, ::grpc::Status* status, void* tag) = 0; +}; + +namespace internal { +template +class ClientAsyncResponseReaderFactory { + public: + /// Start a call and write the request out if \a start is set. + /// \a tag will be notified on \a cq when the call has been started (i.e. + /// intitial metadata sent) and \a request has been written out. + /// If \a start is not set, the actual call must be initiated by StartCall + /// Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + template + static ClientAsyncResponseReader* Create( + ::grpc::ChannelInterface* channel, ::grpc_impl::CompletionQueue* cq, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, const W& request, bool start) { + ::grpc::internal::Call call = channel->CreateCall(method, context, cq); + return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientAsyncResponseReader))) + ClientAsyncResponseReader(call, context, request, start); + } +}; +} // namespace internal + +/// Async API for client-side unary RPCs, where the message response +/// received from the server is of type \a R. +template +class ClientAsyncResponseReader final + : public ClientAsyncResponseReaderInterface { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* /*ptr*/, std::size_t size) { + GPR_CODEGEN_ASSERT(size == sizeof(ClientAsyncResponseReader)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } + + void StartCall() override { + GPR_CODEGEN_ASSERT(!started_); + started_ = true; + StartCallInternal(); + } + + /// See \a ClientAsyncResponseReaderInterface::ReadInitialMetadata for + /// semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata sent from the server. + void ReadInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(started_); + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + single_buf.set_output_tag(tag); + single_buf.RecvInitialMetadata(context_); + call_.PerformOps(&single_buf); + initial_metadata_read_ = true; + } + + /// See \a ClientAysncResponseReaderInterface::Finish for semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible initial and trailing metadata sent from the server. + void Finish(R* msg, ::grpc::Status* status, void* tag) override { + GPR_CODEGEN_ASSERT(started_); + if (initial_metadata_read_) { + finish_buf.set_output_tag(tag); + finish_buf.RecvMessage(msg); + finish_buf.AllowNoMessage(); + finish_buf.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_buf); + } else { + single_buf.set_output_tag(tag); + single_buf.RecvInitialMetadata(context_); + single_buf.RecvMessage(msg); + single_buf.AllowNoMessage(); + single_buf.ClientRecvStatus(context_, status); + call_.PerformOps(&single_buf); + } + } + + private: + friend class internal::ClientAsyncResponseReaderFactory; + ::grpc_impl::ClientContext* const context_; + ::grpc::internal::Call call_; + bool started_; + bool initial_metadata_read_ = false; + + template + ClientAsyncResponseReader(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, + const W& request, bool start) + : context_(context), call_(call), started_(start) { + // Bind the metadata at time of StartCallInternal but set up the rest here + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(single_buf.SendMessage(request).ok()); + single_buf.ClientSendClose(); + if (start) StartCallInternal(); + } + + void StartCallInternal() { + single_buf.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + } + + // disable operator new + static void* operator new(std::size_t size); + static void* operator new(std::size_t /*size*/, void* p) { return p; } + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose, + ::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage, + ::grpc::internal::CallOpClientRecvStatus> + single_buf; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage, + ::grpc::internal::CallOpClientRecvStatus> + finish_buf; +}; + +/// Async server-side API for handling unary calls, where the single +/// response message sent to the client is of type \a W. +template +class ServerAsyncResponseWriter final + : public ::grpc::internal::ServerAsyncStreamingInterface { + public: + explicit ServerAsyncResponseWriter(::grpc_impl::ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics. + /// + /// Side effect: + /// The initial metadata that will be sent to the client from this op will + /// be taken from the \a ServerContext associated with the call. + /// + /// \param[in] tag Tag identifying this request. + void SendInitialMetadata(void* tag) override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + meta_buf_.set_output_tag(tag); + meta_buf_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_buf_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_buf_); + } + + /// Indicate that the stream is to be finished and request notification + /// when the server has sent the appropriate signals to the client to + /// end the call. Should not be used concurrently with other operations. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of the call. + /// \param[in] msg Message to be sent to the client. + /// + /// Side effect: + /// - also sends initial metadata if not already sent (using the + /// \a ServerContext associated with this call). + /// + /// Note: if \a status has a non-OK code, then \a msg will not be sent, + /// and the client will receive only the status with possible trailing + /// metadata. + void Finish(const W& msg, const ::grpc::Status& status, void* tag) { + finish_buf_.set_output_tag(tag); + finish_buf_.set_core_cq_tag(&finish_buf_); + if (!ctx_->sent_initial_metadata_) { + finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_buf_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (status.ok()) { + finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_buf_.SendMessage(msg)); + } else { + finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, status); + } + call_.PerformOps(&finish_buf_); + } + + /// Indicate that the stream is to be finished with a non-OK status, + /// and request notification for when the server has finished sending the + /// appropriate signals to the client to end the call. + /// Should not be used concurrently with other operations. + /// + /// \param[in] tag Tag identifying this request. + /// \param[in] status To be sent to the client as the result of the call. + /// - Note: \a status must have a non-OK code. + /// + /// Side effect: + /// - also sends initial metadata if not already sent (using the + /// \a ServerContext associated with this call). + void FinishWithError(const ::grpc::Status& status, void* tag) { + GPR_CODEGEN_ASSERT(!status.ok()); + finish_buf_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_buf_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_buf_); + } + + private: + void BindCall(::grpc::internal::Call* call) override { call_ = *call; } + + ::grpc::internal::Call call_; + ::grpc_impl::ServerContext* ctx_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_buf_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_buf_; +}; + +} // namespace grpc_impl + +namespace std { +template +class default_delete<::grpc_impl::ClientAsyncResponseReader> { + public: + void operator()(void* /*p*/) {} +}; +template +class default_delete<::grpc_impl::ClientAsyncResponseReaderInterface> { + public: + void operator()(void* /*p*/) {} +}; +} // namespace std + +#endif // GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/byte_buffer.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/byte_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..54886ae808616fcf7062064779dafc008d9d1759 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/byte_buffer.h @@ -0,0 +1,233 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_BYTE_BUFFER_H +#define GRPCPP_IMPL_CODEGEN_BYTE_BUFFER_H + +#include + +#include +#include +#include +#include +#include + +#include + +namespace grpc_impl { +namespace internal { + +template +class CallbackUnaryHandler; +template +class CallbackServerStreamingHandler; +template +class RpcMethodHandler; +template +class ServerStreamingHandler; +template <::grpc::StatusCode code> +class ErrorMethodHandler; + +} // namespace internal +} // namespace grpc_impl + +namespace grpc { + +class ServerInterface; +class ByteBuffer; +class ServerInterface; + +namespace internal { +class CallOpSendMessage; +template +class CallOpRecvMessage; +class CallOpGenericRecvMessage; +class ExternalConnectionAcceptorImpl; +template +class DeserializeFuncType; +class GrpcByteBufferPeer; + +} // namespace internal +/// A sequence of bytes. +class ByteBuffer final { + public: + /// Constuct an empty buffer. + ByteBuffer() : buffer_(nullptr) {} + + /// Construct buffer from \a slices, of which there are \a nslices. + ByteBuffer(const Slice* slices, size_t nslices) { + // The following assertions check that the representation of a grpc::Slice + // is identical to that of a grpc_slice: it has a grpc_slice field, and + // nothing else. + static_assert(std::is_same::value, + "Slice must have same representation as grpc_slice"); + static_assert(sizeof(Slice) == sizeof(grpc_slice), + "Slice must have same representation as grpc_slice"); + // The following assertions check that the representation of a ByteBuffer is + // identical to grpc_byte_buffer*: it has a grpc_byte_buffer* field, + // and nothing else. + static_assert(std::is_same::value, + "ByteBuffer must have same representation as " + "grpc_byte_buffer*"); + static_assert(sizeof(ByteBuffer) == sizeof(grpc_byte_buffer*), + "ByteBuffer must have same representation as " + "grpc_byte_buffer*"); + // The const_cast is legal if grpc_raw_byte_buffer_create() does no more + // than its advertised side effect of increasing the reference count of the + // slices it processes, and such an increase does not affect the semantics + // seen by the caller of this constructor. + buffer_ = g_core_codegen_interface->grpc_raw_byte_buffer_create( + reinterpret_cast(const_cast(slices)), nslices); + } + + /// Constuct a byte buffer by referencing elements of existing buffer + /// \a buf. Wrapper of core function grpc_byte_buffer_copy . This is not + /// a deep copy; it is just a referencing. As a result, its performance is + /// size-independent. + ByteBuffer(const ByteBuffer& buf) : buffer_(nullptr) { operator=(buf); } + + ~ByteBuffer() { + if (buffer_) { + g_core_codegen_interface->grpc_byte_buffer_destroy(buffer_); + } + } + + /// Wrapper of core function grpc_byte_buffer_copy . This is not + /// a deep copy; it is just a referencing. As a result, its performance is + /// size-independent. + ByteBuffer& operator=(const ByteBuffer& buf) { + if (this != &buf) { + Clear(); // first remove existing data + } + if (buf.buffer_) { + // then copy + buffer_ = g_core_codegen_interface->grpc_byte_buffer_copy(buf.buffer_); + } + return *this; + } + + /// Dump (read) the buffer contents into \a slices. + Status Dump(std::vector* slices) const; + + /// Remove all data. + void Clear() { + if (buffer_) { + g_core_codegen_interface->grpc_byte_buffer_destroy(buffer_); + buffer_ = nullptr; + } + } + + /// Make a duplicate copy of the internals of this byte + /// buffer so that we have our own owned version of it. + /// bbuf.Duplicate(); is equivalent to bbuf=bbuf; but is actually readable. + /// This is not a deep copy; it is a referencing and its performance + /// is size-independent. + void Duplicate() { + buffer_ = g_core_codegen_interface->grpc_byte_buffer_copy(buffer_); + } + + /// Forget underlying byte buffer without destroying + /// Use this only for un-owned byte buffers + void Release() { buffer_ = nullptr; } + + /// Buffer size in bytes. + size_t Length() const { + return buffer_ == nullptr + ? 0 + : g_core_codegen_interface->grpc_byte_buffer_length(buffer_); + } + + /// Swap the state of *this and *other. + void Swap(ByteBuffer* other) { + grpc_byte_buffer* tmp = other->buffer_; + other->buffer_ = buffer_; + buffer_ = tmp; + } + + /// Is this ByteBuffer valid? + bool Valid() const { return (buffer_ != nullptr); } + + private: + friend class SerializationTraits; + friend class ServerInterface; + friend class internal::CallOpSendMessage; + template + friend class internal::CallOpRecvMessage; + friend class internal::CallOpGenericRecvMessage; + template + friend class ::grpc_impl::internal::RpcMethodHandler; + template + friend class ::grpc_impl::internal::ServerStreamingHandler; + template + friend class ::grpc_impl::internal::CallbackUnaryHandler; + template + friend class ::grpc_impl::internal::CallbackServerStreamingHandler; + template + friend class ::grpc_impl::internal::ErrorMethodHandler; + template + friend class internal::DeserializeFuncType; + friend class ProtoBufferReader; + friend class ProtoBufferWriter; + friend class internal::GrpcByteBufferPeer; + friend class internal::ExternalConnectionAcceptorImpl; + + grpc_byte_buffer* buffer_; + + // takes ownership + void set_buffer(grpc_byte_buffer* buf) { + if (buffer_) { + Clear(); + } + buffer_ = buf; + } + + grpc_byte_buffer* c_buffer() { return buffer_; } + grpc_byte_buffer** c_buffer_ptr() { return &buffer_; } + + class ByteBufferPointer { + public: + ByteBufferPointer(const ByteBuffer* b) + : bbuf_(const_cast(b)) {} + operator ByteBuffer*() { return bbuf_; } + operator grpc_byte_buffer*() { return bbuf_->buffer_; } + operator grpc_byte_buffer**() { return &bbuf_->buffer_; } + + private: + ByteBuffer* bbuf_; + }; + ByteBufferPointer bbuf_ptr() const { return ByteBufferPointer(this); } +}; + +template <> +class SerializationTraits { + public: + static Status Deserialize(ByteBuffer* byte_buffer, ByteBuffer* dest) { + dest->set_buffer(byte_buffer->buffer_); + return Status::OK; + } + static Status Serialize(const ByteBuffer& source, ByteBuffer* buffer, + bool* own_buffer) { + *buffer = source; + *own_buffer = true; + return g_core_codegen_interface->ok(); + } +}; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_BYTE_BUFFER_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/call.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/call.h new file mode 100644 index 0000000000000000000000000000000000000000..eefa4a7f9cdde628c5e4ad11b66de0e9955a9fc3 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/call.h @@ -0,0 +1,96 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef GRPCPP_IMPL_CODEGEN_CALL_H +#define GRPCPP_IMPL_CODEGEN_CALL_H + +#include +#include + +namespace grpc_impl { +class CompletionQueue; +} + +namespace grpc { +namespace experimental { +class ClientRpcInfo; +class ServerRpcInfo; +} // namespace experimental +namespace internal { +class CallHook; +class CallOpSetInterface; + +/// Straightforward wrapping of the C call object +class Call final { + public: + Call() + : call_hook_(nullptr), + cq_(nullptr), + call_(nullptr), + max_receive_message_size_(-1) {} + /** call is owned by the caller */ + Call(grpc_call* call, CallHook* call_hook, ::grpc_impl::CompletionQueue* cq) + : call_hook_(call_hook), + cq_(cq), + call_(call), + max_receive_message_size_(-1) {} + + Call(grpc_call* call, CallHook* call_hook, ::grpc_impl::CompletionQueue* cq, + experimental::ClientRpcInfo* rpc_info) + : call_hook_(call_hook), + cq_(cq), + call_(call), + max_receive_message_size_(-1), + client_rpc_info_(rpc_info) {} + + Call(grpc_call* call, CallHook* call_hook, ::grpc_impl::CompletionQueue* cq, + int max_receive_message_size, experimental::ServerRpcInfo* rpc_info) + : call_hook_(call_hook), + cq_(cq), + call_(call), + max_receive_message_size_(max_receive_message_size), + server_rpc_info_(rpc_info) {} + + void PerformOps(CallOpSetInterface* ops) { + call_hook_->PerformOpsOnCall(ops, this); + } + + grpc_call* call() const { return call_; } + ::grpc_impl::CompletionQueue* cq() const { return cq_; } + + int max_receive_message_size() const { return max_receive_message_size_; } + + experimental::ClientRpcInfo* client_rpc_info() const { + return client_rpc_info_; + } + + experimental::ServerRpcInfo* server_rpc_info() const { + return server_rpc_info_; + } + + private: + CallHook* call_hook_; + ::grpc_impl::CompletionQueue* cq_; + grpc_call* call_; + int max_receive_message_size_; + experimental::ClientRpcInfo* client_rpc_info_ = nullptr; + experimental::ServerRpcInfo* server_rpc_info_ = nullptr; +}; +} // namespace internal +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CALL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/call_hook.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/call_hook.h new file mode 100644 index 0000000000000000000000000000000000000000..4f7d370c4f77e043b6ab4ff4f37a05436a873686 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/call_hook.h @@ -0,0 +1,39 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CALL_HOOK_H +#define GRPCPP_IMPL_CODEGEN_CALL_HOOK_H + +namespace grpc { + +namespace internal { +class CallOpSetInterface; +class Call; + +/// This is an interface that Channel and Server implement to allow them to hook +/// performing ops. +class CallHook { + public: + virtual ~CallHook() {} + virtual void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) = 0; +}; +} // namespace internal + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CALL_HOOK_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/call_op_set.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/call_op_set.h new file mode 100644 index 0000000000000000000000000000000000000000..e6d7b900ca1c02527c82985b92f9816211f9284d --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/call_op_set.h @@ -0,0 +1,1007 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CALL_OP_SET_H +#define GRPCPP_IMPL_CODEGEN_CALL_OP_SET_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace grpc { + +extern CoreCodegenInterface* g_core_codegen_interface; + +namespace internal { +class Call; +class CallHook; + +// TODO(yangg) if the map is changed before we send, the pointers will be a +// mess. Make sure it does not happen. +inline grpc_metadata* FillMetadataArray( + const std::multimap& metadata, + size_t* metadata_count, const grpc::string& optional_error_details) { + *metadata_count = metadata.size() + (optional_error_details.empty() ? 0 : 1); + if (*metadata_count == 0) { + return nullptr; + } + grpc_metadata* metadata_array = + (grpc_metadata*)(g_core_codegen_interface->gpr_malloc( + (*metadata_count) * sizeof(grpc_metadata))); + size_t i = 0; + for (auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i) { + metadata_array[i].key = SliceReferencingString(iter->first); + metadata_array[i].value = SliceReferencingString(iter->second); + } + if (!optional_error_details.empty()) { + metadata_array[i].key = + g_core_codegen_interface->grpc_slice_from_static_buffer( + kBinaryErrorDetailsKey, sizeof(kBinaryErrorDetailsKey) - 1); + metadata_array[i].value = SliceReferencingString(optional_error_details); + } + return metadata_array; +} +} // namespace internal + +/// Per-message write options. +class WriteOptions { + public: + WriteOptions() : flags_(0), last_message_(false) {} + WriteOptions(const WriteOptions& other) + : flags_(other.flags_), last_message_(other.last_message_) {} + + /// Default assignment operator + WriteOptions& operator=(const WriteOptions& other) = default; + + /// Clear all flags. + inline void Clear() { flags_ = 0; } + + /// Returns raw flags bitset. + inline uint32_t flags() const { return flags_; } + + /// Sets flag for the disabling of compression for the next message write. + /// + /// \sa GRPC_WRITE_NO_COMPRESS + inline WriteOptions& set_no_compression() { + SetBit(GRPC_WRITE_NO_COMPRESS); + return *this; + } + + /// Clears flag for the disabling of compression for the next message write. + /// + /// \sa GRPC_WRITE_NO_COMPRESS + inline WriteOptions& clear_no_compression() { + ClearBit(GRPC_WRITE_NO_COMPRESS); + return *this; + } + + /// Get value for the flag indicating whether compression for the next + /// message write is forcefully disabled. + /// + /// \sa GRPC_WRITE_NO_COMPRESS + inline bool get_no_compression() const { + return GetBit(GRPC_WRITE_NO_COMPRESS); + } + + /// Sets flag indicating that the write may be buffered and need not go out on + /// the wire immediately. + /// + /// \sa GRPC_WRITE_BUFFER_HINT + inline WriteOptions& set_buffer_hint() { + SetBit(GRPC_WRITE_BUFFER_HINT); + return *this; + } + + /// Clears flag indicating that the write may be buffered and need not go out + /// on the wire immediately. + /// + /// \sa GRPC_WRITE_BUFFER_HINT + inline WriteOptions& clear_buffer_hint() { + ClearBit(GRPC_WRITE_BUFFER_HINT); + return *this; + } + + /// Get value for the flag indicating that the write may be buffered and need + /// not go out on the wire immediately. + /// + /// \sa GRPC_WRITE_BUFFER_HINT + inline bool get_buffer_hint() const { return GetBit(GRPC_WRITE_BUFFER_HINT); } + + /// corked bit: aliases set_buffer_hint currently, with the intent that + /// set_buffer_hint will be removed in the future + inline WriteOptions& set_corked() { + SetBit(GRPC_WRITE_BUFFER_HINT); + return *this; + } + + inline WriteOptions& clear_corked() { + ClearBit(GRPC_WRITE_BUFFER_HINT); + return *this; + } + + inline bool is_corked() const { return GetBit(GRPC_WRITE_BUFFER_HINT); } + + /// last-message bit: indicates this is the last message in a stream + /// client-side: makes Write the equivalent of performing Write, WritesDone + /// in a single step + /// server-side: hold the Write until the service handler returns (sync api) + /// or until Finish is called (async api) + inline WriteOptions& set_last_message() { + last_message_ = true; + return *this; + } + + /// Clears flag indicating that this is the last message in a stream, + /// disabling coalescing. + inline WriteOptions& clear_last_message() { + last_message_ = false; + return *this; + } + + /// Guarantee that all bytes have been written to the socket before completing + /// this write (usually writes are completed when they pass flow control). + inline WriteOptions& set_write_through() { + SetBit(GRPC_WRITE_THROUGH); + return *this; + } + + inline bool is_write_through() const { return GetBit(GRPC_WRITE_THROUGH); } + + /// Get value for the flag indicating that this is the last message, and + /// should be coalesced with trailing metadata. + /// + /// \sa GRPC_WRITE_LAST_MESSAGE + bool is_last_message() const { return last_message_; } + + private: + void SetBit(const uint32_t mask) { flags_ |= mask; } + + void ClearBit(const uint32_t mask) { flags_ &= ~mask; } + + bool GetBit(const uint32_t mask) const { return (flags_ & mask) != 0; } + + uint32_t flags_; + bool last_message_; +}; + +namespace internal { + +/// Default argument for CallOpSet. I is unused by the class, but can be +/// used for generating multiple names for the same thing. +template +class CallNoOp { + protected: + void AddOp(grpc_op* /*ops*/, size_t* /*nops*/) {} + void FinishOp(bool* /*status*/) {} + void SetInterceptionHookPoint( + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} + void SetFinishInterceptionHookPoint( + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { + } +}; + +class CallOpSendInitialMetadata { + public: + CallOpSendInitialMetadata() : send_(false) { + maybe_compression_level_.is_set = false; + } + + void SendInitialMetadata(std::multimap* metadata, + uint32_t flags) { + maybe_compression_level_.is_set = false; + send_ = true; + flags_ = flags; + metadata_map_ = metadata; + } + + void set_compression_level(grpc_compression_level level) { + maybe_compression_level_.is_set = true; + maybe_compression_level_.level = level; + } + + protected: + void AddOp(grpc_op* ops, size_t* nops) { + if (!send_ || hijacked_) return; + grpc_op* op = &ops[(*nops)++]; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->flags = flags_; + op->reserved = NULL; + initial_metadata_ = + FillMetadataArray(*metadata_map_, &initial_metadata_count_, ""); + op->data.send_initial_metadata.count = initial_metadata_count_; + op->data.send_initial_metadata.metadata = initial_metadata_; + op->data.send_initial_metadata.maybe_compression_level.is_set = + maybe_compression_level_.is_set; + if (maybe_compression_level_.is_set) { + op->data.send_initial_metadata.maybe_compression_level.level = + maybe_compression_level_.level; + } + } + void FinishOp(bool* /*status*/) { + if (!send_ || hijacked_) return; + g_core_codegen_interface->gpr_free(initial_metadata_); + send_ = false; + } + + void SetInterceptionHookPoint( + InterceptorBatchMethodsImpl* interceptor_methods) { + if (!send_) return; + interceptor_methods->AddInterceptionHookPoint( + experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA); + interceptor_methods->SetSendInitialMetadata(metadata_map_); + } + + void SetFinishInterceptionHookPoint( + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} + + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { + hijacked_ = true; + } + + bool hijacked_ = false; + bool send_; + uint32_t flags_; + size_t initial_metadata_count_; + std::multimap* metadata_map_; + grpc_metadata* initial_metadata_; + struct { + bool is_set; + grpc_compression_level level; + } maybe_compression_level_; +}; + +class CallOpSendMessage { + public: + CallOpSendMessage() : send_buf_() {} + + /// Send \a message using \a options for the write. The \a options are cleared + /// after use. + template + Status SendMessage(const M& message, + WriteOptions options) GRPC_MUST_USE_RESULT; + + template + Status SendMessage(const M& message) GRPC_MUST_USE_RESULT; + + /// Send \a message using \a options for the write. The \a options are cleared + /// after use. This form of SendMessage allows gRPC to reference \a message + /// beyond the lifetime of SendMessage. + template + Status SendMessagePtr(const M* message, + WriteOptions options) GRPC_MUST_USE_RESULT; + + /// This form of SendMessage allows gRPC to reference \a message beyond the + /// lifetime of SendMessage. + template + Status SendMessagePtr(const M* message) GRPC_MUST_USE_RESULT; + + protected: + void AddOp(grpc_op* ops, size_t* nops) { + if (msg_ == nullptr && !send_buf_.Valid()) return; + if (hijacked_) { + serializer_ = nullptr; + return; + } + if (msg_ != nullptr) { + GPR_CODEGEN_ASSERT(serializer_(msg_).ok()); + } + serializer_ = nullptr; + grpc_op* op = &ops[(*nops)++]; + op->op = GRPC_OP_SEND_MESSAGE; + op->flags = write_options_.flags(); + op->reserved = NULL; + op->data.send_message.send_message = send_buf_.c_buffer(); + // Flags are per-message: clear them after use. + write_options_.Clear(); + } + void FinishOp(bool* status) { + if (msg_ == nullptr && !send_buf_.Valid()) return; + if (hijacked_ && failed_send_) { + // Hijacking interceptor failed this Op + *status = false; + } else if (!*status) { + // This Op was passed down to core and the Op failed + failed_send_ = true; + } + } + + void SetInterceptionHookPoint( + InterceptorBatchMethodsImpl* interceptor_methods) { + if (msg_ == nullptr && !send_buf_.Valid()) return; + interceptor_methods->AddInterceptionHookPoint( + experimental::InterceptionHookPoints::PRE_SEND_MESSAGE); + interceptor_methods->SetSendMessage(&send_buf_, &msg_, &failed_send_, + serializer_); + } + + void SetFinishInterceptionHookPoint( + InterceptorBatchMethodsImpl* interceptor_methods) { + if (msg_ != nullptr || send_buf_.Valid()) { + interceptor_methods->AddInterceptionHookPoint( + experimental::InterceptionHookPoints::POST_SEND_MESSAGE); + } + send_buf_.Clear(); + msg_ = nullptr; + // The contents of the SendMessage value that was previously set + // has had its references stolen by core's operations + interceptor_methods->SetSendMessage(nullptr, nullptr, &failed_send_, + nullptr); + } + + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { + hijacked_ = true; + } + + private: + const void* msg_ = nullptr; // The original non-serialized message + bool hijacked_ = false; + bool failed_send_ = false; + ByteBuffer send_buf_; + WriteOptions write_options_; + std::function serializer_; +}; + +template +Status CallOpSendMessage::SendMessage(const M& message, WriteOptions options) { + write_options_ = options; + serializer_ = [this](const void* message) { + bool own_buf; + send_buf_.Clear(); + // TODO(vjpai): Remove the void below when possible + // The void in the template parameter below should not be needed + // (since it should be implicit) but is needed due to an observed + // difference in behavior between clang and gcc for certain internal users + Status result = SerializationTraits::Serialize( + *static_cast(message), send_buf_.bbuf_ptr(), &own_buf); + if (!own_buf) { + send_buf_.Duplicate(); + } + return result; + }; + // Serialize immediately only if we do not have access to the message pointer + if (msg_ == nullptr) { + Status result = serializer_(&message); + serializer_ = nullptr; + return result; + } + return Status(); +} + +template +Status CallOpSendMessage::SendMessage(const M& message) { + return SendMessage(message, WriteOptions()); +} + +template +Status CallOpSendMessage::SendMessagePtr(const M* message, + WriteOptions options) { + msg_ = message; + return SendMessage(*message, options); +} + +template +Status CallOpSendMessage::SendMessagePtr(const M* message) { + msg_ = message; + return SendMessage(*message, WriteOptions()); +} + +template +class CallOpRecvMessage { + public: + CallOpRecvMessage() + : got_message(false), + message_(nullptr), + allow_not_getting_message_(false) {} + + void RecvMessage(R* message) { message_ = message; } + + // Do not change status if no message is received. + void AllowNoMessage() { allow_not_getting_message_ = true; } + + bool got_message; + + protected: + void AddOp(grpc_op* ops, size_t* nops) { + if (message_ == nullptr || hijacked_) return; + grpc_op* op = &ops[(*nops)++]; + op->op = GRPC_OP_RECV_MESSAGE; + op->flags = 0; + op->reserved = NULL; + op->data.recv_message.recv_message = recv_buf_.c_buffer_ptr(); + } + + void FinishOp(bool* status) { + if (message_ == nullptr || hijacked_) return; + if (recv_buf_.Valid()) { + if (*status) { + got_message = *status = + SerializationTraits::Deserialize(recv_buf_.bbuf_ptr(), message_) + .ok(); + recv_buf_.Release(); + } else { + got_message = false; + recv_buf_.Clear(); + } + } else { + got_message = false; + if (!allow_not_getting_message_) { + *status = false; + } + } + } + + void SetInterceptionHookPoint( + InterceptorBatchMethodsImpl* interceptor_methods) { + if (message_ == nullptr) return; + interceptor_methods->SetRecvMessage(message_, &got_message); + } + + void SetFinishInterceptionHookPoint( + InterceptorBatchMethodsImpl* interceptor_methods) { + if (message_ == nullptr) return; + interceptor_methods->AddInterceptionHookPoint( + experimental::InterceptionHookPoints::POST_RECV_MESSAGE); + if (!got_message) interceptor_methods->SetRecvMessage(nullptr, nullptr); + } + void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { + hijacked_ = true; + if (message_ == nullptr) return; + interceptor_methods->AddInterceptionHookPoint( + experimental::InterceptionHookPoints::PRE_RECV_MESSAGE); + got_message = true; + } + + private: + R* message_; + ByteBuffer recv_buf_; + bool allow_not_getting_message_; + bool hijacked_ = false; +}; + +class DeserializeFunc { + public: + virtual Status Deserialize(ByteBuffer* buf) = 0; + virtual ~DeserializeFunc() {} +}; + +template +class DeserializeFuncType final : public DeserializeFunc { + public: + DeserializeFuncType(R* message) : message_(message) {} + Status Deserialize(ByteBuffer* buf) override { + return SerializationTraits::Deserialize(buf->bbuf_ptr(), message_); + } + + ~DeserializeFuncType() override {} + + private: + R* message_; // Not a managed pointer because management is external to this +}; + +class CallOpGenericRecvMessage { + public: + CallOpGenericRecvMessage() + : got_message(false), allow_not_getting_message_(false) {} + + template + void RecvMessage(R* message) { + // Use an explicit base class pointer to avoid resolution error in the + // following unique_ptr::reset for some old implementations. + DeserializeFunc* func = new DeserializeFuncType(message); + deserialize_.reset(func); + message_ = message; + } + + // Do not change status if no message is received. + void AllowNoMessage() { allow_not_getting_message_ = true; } + + bool got_message; + + protected: + void AddOp(grpc_op* ops, size_t* nops) { + if (!deserialize_ || hijacked_) return; + grpc_op* op = &ops[(*nops)++]; + op->op = GRPC_OP_RECV_MESSAGE; + op->flags = 0; + op->reserved = NULL; + op->data.recv_message.recv_message = recv_buf_.c_buffer_ptr(); + } + + void FinishOp(bool* status) { + if (!deserialize_ || hijacked_) return; + if (recv_buf_.Valid()) { + if (*status) { + got_message = true; + *status = deserialize_->Deserialize(&recv_buf_).ok(); + recv_buf_.Release(); + } else { + got_message = false; + recv_buf_.Clear(); + } + } else { + got_message = false; + if (!allow_not_getting_message_) { + *status = false; + } + } + } + + void SetInterceptionHookPoint( + InterceptorBatchMethodsImpl* interceptor_methods) { + if (!deserialize_) return; + interceptor_methods->SetRecvMessage(message_, &got_message); + } + + void SetFinishInterceptionHookPoint( + InterceptorBatchMethodsImpl* interceptor_methods) { + if (!deserialize_) return; + interceptor_methods->AddInterceptionHookPoint( + experimental::InterceptionHookPoints::POST_RECV_MESSAGE); + if (!got_message) interceptor_methods->SetRecvMessage(nullptr, nullptr); + deserialize_.reset(); + } + void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { + hijacked_ = true; + if (!deserialize_) return; + interceptor_methods->AddInterceptionHookPoint( + experimental::InterceptionHookPoints::PRE_RECV_MESSAGE); + got_message = true; + } + + private: + void* message_; + bool hijacked_ = false; + std::unique_ptr deserialize_; + ByteBuffer recv_buf_; + bool allow_not_getting_message_; +}; + +class CallOpClientSendClose { + public: + CallOpClientSendClose() : send_(false) {} + + void ClientSendClose() { send_ = true; } + + protected: + void AddOp(grpc_op* ops, size_t* nops) { + if (!send_ || hijacked_) return; + grpc_op* op = &ops[(*nops)++]; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; + op->flags = 0; + op->reserved = NULL; + } + void FinishOp(bool* /*status*/) { send_ = false; } + + void SetInterceptionHookPoint( + InterceptorBatchMethodsImpl* interceptor_methods) { + if (!send_) return; + interceptor_methods->AddInterceptionHookPoint( + experimental::InterceptionHookPoints::PRE_SEND_CLOSE); + } + + void SetFinishInterceptionHookPoint( + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} + + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { + hijacked_ = true; + } + + private: + bool hijacked_ = false; + bool send_; +}; + +class CallOpServerSendStatus { + public: + CallOpServerSendStatus() : send_status_available_(false) {} + + void ServerSendStatus( + std::multimap* trailing_metadata, + const Status& status) { + send_error_details_ = status.error_details(); + metadata_map_ = trailing_metadata; + send_status_available_ = true; + send_status_code_ = static_cast(status.error_code()); + send_error_message_ = status.error_message(); + } + + protected: + void AddOp(grpc_op* ops, size_t* nops) { + if (!send_status_available_ || hijacked_) return; + trailing_metadata_ = FillMetadataArray( + *metadata_map_, &trailing_metadata_count_, send_error_details_); + grpc_op* op = &ops[(*nops)++]; + op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; + op->data.send_status_from_server.trailing_metadata_count = + trailing_metadata_count_; + op->data.send_status_from_server.trailing_metadata = trailing_metadata_; + op->data.send_status_from_server.status = send_status_code_; + error_message_slice_ = SliceReferencingString(send_error_message_); + op->data.send_status_from_server.status_details = + send_error_message_.empty() ? nullptr : &error_message_slice_; + op->flags = 0; + op->reserved = NULL; + } + + void FinishOp(bool* /*status*/) { + if (!send_status_available_ || hijacked_) return; + g_core_codegen_interface->gpr_free(trailing_metadata_); + send_status_available_ = false; + } + + void SetInterceptionHookPoint( + InterceptorBatchMethodsImpl* interceptor_methods) { + if (!send_status_available_) return; + interceptor_methods->AddInterceptionHookPoint( + experimental::InterceptionHookPoints::PRE_SEND_STATUS); + interceptor_methods->SetSendTrailingMetadata(metadata_map_); + interceptor_methods->SetSendStatus(&send_status_code_, &send_error_details_, + &send_error_message_); + } + + void SetFinishInterceptionHookPoint( + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} + + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { + hijacked_ = true; + } + + private: + bool hijacked_ = false; + bool send_status_available_; + grpc_status_code send_status_code_; + grpc::string send_error_details_; + grpc::string send_error_message_; + size_t trailing_metadata_count_; + std::multimap* metadata_map_; + grpc_metadata* trailing_metadata_; + grpc_slice error_message_slice_; +}; + +class CallOpRecvInitialMetadata { + public: + CallOpRecvInitialMetadata() : metadata_map_(nullptr) {} + + void RecvInitialMetadata(::grpc_impl::ClientContext* context) { + context->initial_metadata_received_ = true; + metadata_map_ = &context->recv_initial_metadata_; + } + + protected: + void AddOp(grpc_op* ops, size_t* nops) { + if (metadata_map_ == nullptr || hijacked_) return; + grpc_op* op = &ops[(*nops)++]; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata.recv_initial_metadata = metadata_map_->arr(); + op->flags = 0; + op->reserved = NULL; + } + + void FinishOp(bool* /*status*/) { + if (metadata_map_ == nullptr || hijacked_) return; + } + + void SetInterceptionHookPoint( + InterceptorBatchMethodsImpl* interceptor_methods) { + interceptor_methods->SetRecvInitialMetadata(metadata_map_); + } + + void SetFinishInterceptionHookPoint( + InterceptorBatchMethodsImpl* interceptor_methods) { + if (metadata_map_ == nullptr) return; + interceptor_methods->AddInterceptionHookPoint( + experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA); + metadata_map_ = nullptr; + } + + void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { + hijacked_ = true; + if (metadata_map_ == nullptr) return; + interceptor_methods->AddInterceptionHookPoint( + experimental::InterceptionHookPoints::PRE_RECV_INITIAL_METADATA); + } + + private: + bool hijacked_ = false; + MetadataMap* metadata_map_; +}; + +class CallOpClientRecvStatus { + public: + CallOpClientRecvStatus() + : recv_status_(nullptr), debug_error_string_(nullptr) {} + + void ClientRecvStatus(::grpc_impl::ClientContext* context, Status* status) { + client_context_ = context; + metadata_map_ = &client_context_->trailing_metadata_; + recv_status_ = status; + error_message_ = g_core_codegen_interface->grpc_empty_slice(); + } + + protected: + void AddOp(grpc_op* ops, size_t* nops) { + if (recv_status_ == nullptr || hijacked_) return; + grpc_op* op = &ops[(*nops)++]; + op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; + op->data.recv_status_on_client.trailing_metadata = metadata_map_->arr(); + op->data.recv_status_on_client.status = &status_code_; + op->data.recv_status_on_client.status_details = &error_message_; + op->data.recv_status_on_client.error_string = &debug_error_string_; + op->flags = 0; + op->reserved = NULL; + } + + void FinishOp(bool* /*status*/) { + if (recv_status_ == nullptr || hijacked_) return; + if (static_cast(status_code_) == StatusCode::OK) { + *recv_status_ = Status(); + GPR_CODEGEN_DEBUG_ASSERT(debug_error_string_ == nullptr); + } else { + *recv_status_ = + Status(static_cast(status_code_), + GRPC_SLICE_IS_EMPTY(error_message_) + ? grpc::string() + : grpc::string(GRPC_SLICE_START_PTR(error_message_), + GRPC_SLICE_END_PTR(error_message_)), + metadata_map_->GetBinaryErrorDetails()); + if (debug_error_string_ != nullptr) { + client_context_->set_debug_error_string(debug_error_string_); + g_core_codegen_interface->gpr_free((void*)debug_error_string_); + } + } + // TODO(soheil): Find callers that set debug string even for status OK, + // and fix them. + g_core_codegen_interface->grpc_slice_unref(error_message_); + } + + void SetInterceptionHookPoint( + InterceptorBatchMethodsImpl* interceptor_methods) { + interceptor_methods->SetRecvStatus(recv_status_); + interceptor_methods->SetRecvTrailingMetadata(metadata_map_); + } + + void SetFinishInterceptionHookPoint( + InterceptorBatchMethodsImpl* interceptor_methods) { + if (recv_status_ == nullptr) return; + interceptor_methods->AddInterceptionHookPoint( + experimental::InterceptionHookPoints::POST_RECV_STATUS); + recv_status_ = nullptr; + } + + void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { + hijacked_ = true; + if (recv_status_ == nullptr) return; + interceptor_methods->AddInterceptionHookPoint( + experimental::InterceptionHookPoints::PRE_RECV_STATUS); + } + + private: + bool hijacked_ = false; + ::grpc_impl::ClientContext* client_context_; + MetadataMap* metadata_map_; + Status* recv_status_; + const char* debug_error_string_; + grpc_status_code status_code_; + grpc_slice error_message_; +}; + +template , class Op2 = CallNoOp<2>, + class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>, + class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>> +class CallOpSet; + +/// Primary implementation of CallOpSetInterface. +/// Since we cannot use variadic templates, we declare slots up to +/// the maximum count of ops we'll need in a set. We leverage the +/// empty base class optimization to slim this class (especially +/// when there are many unused slots used). To avoid duplicate base classes, +/// the template parmeter for CallNoOp is varied by argument position. +template +class CallOpSet : public CallOpSetInterface, + public Op1, + public Op2, + public Op3, + public Op4, + public Op5, + public Op6 { + public: + CallOpSet() : core_cq_tag_(this), return_tag_(this) {} + // The copy constructor and assignment operator reset the value of + // core_cq_tag_, return_tag_, done_intercepting_ and interceptor_methods_ + // since those are only meaningful on a specific object, not across objects. + CallOpSet(const CallOpSet& other) + : core_cq_tag_(this), + return_tag_(this), + call_(other.call_), + done_intercepting_(false), + interceptor_methods_(InterceptorBatchMethodsImpl()) {} + + CallOpSet& operator=(const CallOpSet& other) { + core_cq_tag_ = this; + return_tag_ = this; + call_ = other.call_; + done_intercepting_ = false; + interceptor_methods_ = InterceptorBatchMethodsImpl(); + return *this; + } + + void FillOps(Call* call) override { + done_intercepting_ = false; + g_core_codegen_interface->grpc_call_ref(call->call()); + call_ = + *call; // It's fine to create a copy of call since it's just pointers + + if (RunInterceptors()) { + ContinueFillOpsAfterInterception(); + } else { + // After the interceptors are run, ContinueFillOpsAfterInterception will + // be run + } + } + + bool FinalizeResult(void** tag, bool* status) override { + if (done_intercepting_) { + // Complete the avalanching since we are done with this batch of ops + call_.cq()->CompleteAvalanching(); + // We have already finished intercepting and filling in the results. This + // round trip from the core needed to be made because interceptors were + // run + *tag = return_tag_; + *status = saved_status_; + g_core_codegen_interface->grpc_call_unref(call_.call()); + return true; + } + + this->Op1::FinishOp(status); + this->Op2::FinishOp(status); + this->Op3::FinishOp(status); + this->Op4::FinishOp(status); + this->Op5::FinishOp(status); + this->Op6::FinishOp(status); + saved_status_ = *status; + if (RunInterceptorsPostRecv()) { + *tag = return_tag_; + g_core_codegen_interface->grpc_call_unref(call_.call()); + return true; + } + // Interceptors are going to be run, so we can't return the tag just yet. + // After the interceptors are run, ContinueFinalizeResultAfterInterception + return false; + } + + void set_output_tag(void* return_tag) { return_tag_ = return_tag; } + + void* core_cq_tag() override { return core_cq_tag_; } + + /// set_core_cq_tag is used to provide a different core CQ tag than "this". + /// This is used for callback-based tags, where the core tag is the core + /// callback function. It does not change the use or behavior of any other + /// function (such as FinalizeResult) + void set_core_cq_tag(void* core_cq_tag) { core_cq_tag_ = core_cq_tag; } + + // This will be called while interceptors are run if the RPC is a hijacked + // RPC. This should set hijacking state for each of the ops. + void SetHijackingState() override { + this->Op1::SetHijackingState(&interceptor_methods_); + this->Op2::SetHijackingState(&interceptor_methods_); + this->Op3::SetHijackingState(&interceptor_methods_); + this->Op4::SetHijackingState(&interceptor_methods_); + this->Op5::SetHijackingState(&interceptor_methods_); + this->Op6::SetHijackingState(&interceptor_methods_); + } + + // Should be called after interceptors are done running + void ContinueFillOpsAfterInterception() override { + static const size_t MAX_OPS = 6; + grpc_op ops[MAX_OPS]; + size_t nops = 0; + this->Op1::AddOp(ops, &nops); + this->Op2::AddOp(ops, &nops); + this->Op3::AddOp(ops, &nops); + this->Op4::AddOp(ops, &nops); + this->Op5::AddOp(ops, &nops); + this->Op6::AddOp(ops, &nops); + + grpc_call_error err = g_core_codegen_interface->grpc_call_start_batch( + call_.call(), ops, nops, core_cq_tag(), nullptr); + + if (err != GRPC_CALL_OK) { + // A failure here indicates an API misuse; for example, doing a Write + // while another Write is already pending on the same RPC or invoking + // WritesDone multiple times + // gpr_log(GPR_ERROR, "API misuse of type %s observed", + // g_core_codegen_interface->grpc_call_error_to_string(err)); + GPR_CODEGEN_ASSERT(false); + } + } + + // Should be called after interceptors are done running on the finalize result + // path + void ContinueFinalizeResultAfterInterception() override { + done_intercepting_ = true; + // The following call_start_batch is internally-generated so no need for an + // explanatory log on failure. + GPR_CODEGEN_ASSERT(g_core_codegen_interface->grpc_call_start_batch( + call_.call(), nullptr, 0, core_cq_tag(), nullptr) == + GRPC_CALL_OK); + } + + private: + // Returns true if no interceptors need to be run + bool RunInterceptors() { + interceptor_methods_.ClearState(); + interceptor_methods_.SetCallOpSetInterface(this); + interceptor_methods_.SetCall(&call_); + this->Op1::SetInterceptionHookPoint(&interceptor_methods_); + this->Op2::SetInterceptionHookPoint(&interceptor_methods_); + this->Op3::SetInterceptionHookPoint(&interceptor_methods_); + this->Op4::SetInterceptionHookPoint(&interceptor_methods_); + this->Op5::SetInterceptionHookPoint(&interceptor_methods_); + this->Op6::SetInterceptionHookPoint(&interceptor_methods_); + if (interceptor_methods_.InterceptorsListEmpty()) { + return true; + } + // This call will go through interceptors and would need to + // schedule new batches, so delay completion queue shutdown + call_.cq()->RegisterAvalanching(); + return interceptor_methods_.RunInterceptors(); + } + // Returns true if no interceptors need to be run + bool RunInterceptorsPostRecv() { + // Call and OpSet had already been set on the set state. + // SetReverse also clears previously set hook points + interceptor_methods_.SetReverse(); + this->Op1::SetFinishInterceptionHookPoint(&interceptor_methods_); + this->Op2::SetFinishInterceptionHookPoint(&interceptor_methods_); + this->Op3::SetFinishInterceptionHookPoint(&interceptor_methods_); + this->Op4::SetFinishInterceptionHookPoint(&interceptor_methods_); + this->Op5::SetFinishInterceptionHookPoint(&interceptor_methods_); + this->Op6::SetFinishInterceptionHookPoint(&interceptor_methods_); + return interceptor_methods_.RunInterceptors(); + } + + void* core_cq_tag_; + void* return_tag_; + Call call_; + bool done_intercepting_ = false; + InterceptorBatchMethodsImpl interceptor_methods_; + bool saved_status_; +}; + +} // namespace internal +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CALL_OP_SET_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/call_op_set_interface.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/call_op_set_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..3b74566a6d35c56fc8ddb18fcca8618240cf4750 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/call_op_set_interface.h @@ -0,0 +1,59 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CALL_OP_SET_INTERFACE_H +#define GRPCPP_IMPL_CODEGEN_CALL_OP_SET_INTERFACE_H + +#include + +namespace grpc { +namespace internal { + +class Call; + +/// An abstract collection of call ops, used to generate the +/// grpc_call_op structure to pass down to the lower layers, +/// and as it is-a CompletionQueueTag, also massages the final +/// completion into the correct form for consumption in the C++ +/// API. +class CallOpSetInterface : public CompletionQueueTag { + public: + /// Fills in grpc_op, starting from ops[*nops] and moving + /// upwards. + virtual void FillOps(internal::Call* call) = 0; + + /// Get the tag to be used at the core completion queue. Generally, the + /// value of core_cq_tag will be "this". However, it can be overridden if we + /// want core to process the tag differently (e.g., as a core callback) + virtual void* core_cq_tag() = 0; + + // This will be called while interceptors are run if the RPC is a hijacked + // RPC. This should set hijacking state for each of the ops. + virtual void SetHijackingState() = 0; + + // Should be called after interceptors are done running + virtual void ContinueFillOpsAfterInterception() = 0; + + // Should be called after interceptors are done running on the finalize result + // path + virtual void ContinueFinalizeResultAfterInterception() = 0; +}; +} // namespace internal +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CALL_OP_SET_INTERFACE_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/callback_common.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/callback_common.h new file mode 100644 index 0000000000000000000000000000000000000000..aa3bd26e1c5807e6b1c4d8d0e59f98f079cad55f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/callback_common.h @@ -0,0 +1,222 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CALLBACK_COMMON_H +#define GRPCPP_IMPL_CODEGEN_CALLBACK_COMMON_H + +#include + +#include +#include +#include +#include +#include +#include + +namespace grpc { +namespace internal { + +/// An exception-safe way of invoking a user-specified callback function +// TODO(vjpai): decide whether it is better for this to take a const lvalue +// parameter or an rvalue parameter, or if it even matters +template +void CatchingCallback(Func&& func, Args&&... args) { +#if GRPC_ALLOW_EXCEPTIONS + try { + func(std::forward(args)...); + } catch (...) { + // nothing to return or change here, just don't crash the library + } +#else // GRPC_ALLOW_EXCEPTIONS + func(std::forward(args)...); +#endif // GRPC_ALLOW_EXCEPTIONS +} + +template +Reactor* CatchingReactorGetter(Func&& func, Args&&... args) { +#if GRPC_ALLOW_EXCEPTIONS + try { + return func(std::forward(args)...); + } catch (...) { + // fail the RPC, don't crash the library + return nullptr; + } +#else // GRPC_ALLOW_EXCEPTIONS + return func(std::forward(args)...); +#endif // GRPC_ALLOW_EXCEPTIONS +} + +// The contract on these tags is that they are single-shot. They must be +// constructed and then fired at exactly one point. There is no expectation +// that they can be reused without reconstruction. + +class CallbackWithStatusTag + : public grpc_experimental_completion_queue_functor { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* /*ptr*/, std::size_t size) { + GPR_CODEGEN_ASSERT(size == sizeof(CallbackWithStatusTag)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } + + CallbackWithStatusTag(grpc_call* call, std::function f, + CompletionQueueTag* ops) + : call_(call), func_(std::move(f)), ops_(ops) { + g_core_codegen_interface->grpc_call_ref(call); + functor_run = &CallbackWithStatusTag::StaticRun; + // A client-side callback should never be run inline since they will always + // have work to do from the user application. So, set the parent's + // inlineable field to false + inlineable = false; + } + ~CallbackWithStatusTag() {} + Status* status_ptr() { return &status_; } + + // force_run can not be performed on a tag if operations using this tag + // have been sent to PerformOpsOnCall. It is intended for error conditions + // that are detected before the operations are internally processed. + void force_run(Status s) { + status_ = std::move(s); + Run(true); + } + + private: + grpc_call* call_; + std::function func_; + CompletionQueueTag* ops_; + Status status_; + + static void StaticRun(grpc_experimental_completion_queue_functor* cb, + int ok) { + static_cast(cb)->Run(static_cast(ok)); + } + void Run(bool ok) { + void* ignored = ops_; + + if (!ops_->FinalizeResult(&ignored, &ok)) { + // The tag was swallowed + return; + } + GPR_CODEGEN_ASSERT(ignored == ops_); + + // Last use of func_ or status_, so ok to move them out + auto func = std::move(func_); + auto status = std::move(status_); + func_ = nullptr; // reset to clear this out for sure + status_ = Status(); // reset to clear this out for sure + CatchingCallback(std::move(func), std::move(status)); + g_core_codegen_interface->grpc_call_unref(call_); + } +}; + +/// CallbackWithSuccessTag can be reused multiple times, and will be used in +/// this fashion for streaming operations. As a result, it shouldn't clear +/// anything up until its destructor +class CallbackWithSuccessTag + : public grpc_experimental_completion_queue_functor { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* /*ptr*/, std::size_t size) { + GPR_CODEGEN_ASSERT(size == sizeof(CallbackWithSuccessTag)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } + + CallbackWithSuccessTag() : call_(nullptr) {} + + CallbackWithSuccessTag(const CallbackWithSuccessTag&) = delete; + CallbackWithSuccessTag& operator=(const CallbackWithSuccessTag&) = delete; + + ~CallbackWithSuccessTag() { Clear(); } + + // Set can only be called on a default-constructed or Clear'ed tag. + // It should never be called on a tag that was constructed with arguments + // or on a tag that has been Set before unless the tag has been cleared. + // can_inline indicates that this particular callback can be executed inline + // (without needing a thread hop) and is only used for library-provided server + // callbacks. + void Set(grpc_call* call, std::function f, + CompletionQueueTag* ops, bool can_inline) { + GPR_CODEGEN_ASSERT(call_ == nullptr); + g_core_codegen_interface->grpc_call_ref(call); + call_ = call; + func_ = std::move(f); + ops_ = ops; + functor_run = &CallbackWithSuccessTag::StaticRun; + inlineable = can_inline; + } + + void Clear() { + if (call_ != nullptr) { + grpc_call* call = call_; + call_ = nullptr; + func_ = nullptr; + g_core_codegen_interface->grpc_call_unref(call); + } + } + + CompletionQueueTag* ops() { return ops_; } + + // force_run can not be performed on a tag if operations using this tag + // have been sent to PerformOpsOnCall. It is intended for error conditions + // that are detected before the operations are internally processed. + void force_run(bool ok) { Run(ok); } + + /// check if this tag is currently set + operator bool() const { return call_ != nullptr; } + + private: + grpc_call* call_; + std::function func_; + CompletionQueueTag* ops_; + + static void StaticRun(grpc_experimental_completion_queue_functor* cb, + int ok) { + static_cast(cb)->Run(static_cast(ok)); + } + void Run(bool ok) { + void* ignored = ops_; + // Allow a "false" return value from FinalizeResult to silence the + // callback, just as it silences a CQ tag in the async cases +#ifndef NDEBUG + auto* ops = ops_; +#endif + bool do_callback = ops_->FinalizeResult(&ignored, &ok); + GPR_CODEGEN_DEBUG_ASSERT(ignored == ops); + + if (do_callback) { + CatchingCallback(func_, ok); + } + } +}; + +} // namespace internal +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CALLBACK_COMMON_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/channel_interface.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/channel_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..4fed2f674a4dbedbcb85f96760a89396d2b32229 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/channel_interface.h @@ -0,0 +1,176 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CHANNEL_INTERFACE_H +#define GRPCPP_IMPL_CODEGEN_CHANNEL_INTERFACE_H + +#include +#include +#include +#include + +namespace grpc_impl { +class ClientContext; +class CompletionQueue; +template +class ClientReader; +template +class ClientWriter; +template +class ClientReaderWriter; +namespace internal { +template +class CallbackUnaryCallImpl; +template +class ClientAsyncReaderFactory; +template +class ClientAsyncWriterFactory; +template +class ClientAsyncReaderWriterFactory; +template +class ClientAsyncResponseReaderFactory; +template +class ClientCallbackReaderWriterFactory; +template +class ClientCallbackReaderFactory; +template +class ClientCallbackWriterFactory; +class ClientCallbackUnaryFactory; +} // namespace internal +} // namespace grpc_impl + +namespace grpc { +class ChannelInterface; + +namespace experimental { +class DelegatingChannel; +} + +namespace internal { +class Call; +class CallOpSetInterface; +class RpcMethod; +class InterceptedChannel; +template +class BlockingUnaryCallImpl; +} // namespace internal + +/// Codegen interface for \a grpc::Channel. +class ChannelInterface { + public: + virtual ~ChannelInterface() {} + /// Get the current channel state. If the channel is in IDLE and + /// \a try_to_connect is set to true, try to connect. + virtual grpc_connectivity_state GetState(bool try_to_connect) = 0; + + /// Return the \a tag on \a cq when the channel state is changed or \a + /// deadline expires. \a GetState needs to called to get the current state. + template + void NotifyOnStateChange(grpc_connectivity_state last_observed, T deadline, + ::grpc_impl::CompletionQueue* cq, void* tag) { + TimePoint deadline_tp(deadline); + NotifyOnStateChangeImpl(last_observed, deadline_tp.raw_time(), cq, tag); + } + + /// Blocking wait for channel state change or \a deadline expiration. + /// \a GetState needs to called to get the current state. + template + bool WaitForStateChange(grpc_connectivity_state last_observed, T deadline) { + TimePoint deadline_tp(deadline); + return WaitForStateChangeImpl(last_observed, deadline_tp.raw_time()); + } + + /// Wait for this channel to be connected + template + bool WaitForConnected(T deadline) { + grpc_connectivity_state state; + while ((state = GetState(true)) != GRPC_CHANNEL_READY) { + if (!WaitForStateChange(state, deadline)) return false; + } + return true; + } + + private: + template + friend class ::grpc_impl::ClientReader; + template + friend class ::grpc_impl::ClientWriter; + template + friend class ::grpc_impl::ClientReaderWriter; + template + friend class ::grpc_impl::internal::ClientAsyncReaderFactory; + template + friend class ::grpc_impl::internal::ClientAsyncWriterFactory; + template + friend class ::grpc_impl::internal::ClientAsyncReaderWriterFactory; + template + friend class ::grpc_impl::internal::ClientAsyncResponseReaderFactory; + template + friend class ::grpc_impl::internal::ClientCallbackReaderWriterFactory; + template + friend class ::grpc_impl::internal::ClientCallbackReaderFactory; + template + friend class ::grpc_impl::internal::ClientCallbackWriterFactory; + friend class ::grpc_impl::internal::ClientCallbackUnaryFactory; + template + friend class ::grpc::internal::BlockingUnaryCallImpl; + template + friend class ::grpc_impl::internal::CallbackUnaryCallImpl; + friend class ::grpc::internal::RpcMethod; + friend class ::grpc::experimental::DelegatingChannel; + friend class ::grpc::internal::InterceptedChannel; + virtual internal::Call CreateCall(const internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + ::grpc_impl::CompletionQueue* cq) = 0; + virtual void PerformOpsOnCall(internal::CallOpSetInterface* ops, + internal::Call* call) = 0; + virtual void* RegisterMethod(const char* method) = 0; + virtual void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline, + ::grpc_impl::CompletionQueue* cq, + void* tag) = 0; + virtual bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline) = 0; + + // EXPERIMENTAL + // This is needed to keep codegen_test_minimal happy. InterceptedChannel needs + // to make use of this but can't directly call Channel's implementation + // because of the test. + // Returns an empty Call object (rather than being pure) since this is a new + // method and adding a new pure method to an interface would be a breaking + // change (even though this is private and non-API) + virtual internal::Call CreateCallInternal( + const internal::RpcMethod& /*method*/, + ::grpc_impl::ClientContext* /*context*/, + ::grpc_impl::CompletionQueue* /*cq*/, size_t /*interceptor_pos*/) { + return internal::Call(); + } + + // EXPERIMENTAL + // A method to get the callbackable completion queue associated with this + // channel. If the return value is nullptr, this channel doesn't support + // callback operations. + // TODO(vjpai): Consider a better default like using a global CQ + // Returns nullptr (rather than being pure) since this is a post-1.0 method + // and adding a new pure method to an interface would be a breaking change + // (even though this is private and non-API) + virtual ::grpc_impl::CompletionQueue* CallbackCQ() { return nullptr; } +}; +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CHANNEL_INTERFACE_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_callback.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_callback.h new file mode 100644 index 0000000000000000000000000000000000000000..a8b58f6b700032915036064ef0a4c0087679b44c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_callback.h @@ -0,0 +1,76 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H +#define GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H + +#include + +namespace grpc { + +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL +template +using ClientCallbackReader = ::grpc_impl::ClientCallbackReader; + +template +using ClientCallbackWriter = ::grpc_impl::ClientCallbackWriter; + +template +using ClientCallbackReaderWriter = + ::grpc_impl::ClientCallbackReaderWriter; + +template +using ClientReadReactor = ::grpc_impl::ClientReadReactor; + +template +using ClientWriteReactor = ::grpc_impl::ClientWriteReactor; + +template +using ClientBidiReactor = ::grpc_impl::ClientBidiReactor; + +typedef ::grpc_impl::ClientUnaryReactor ClientUnaryReactor; +#endif + +// TODO(vjpai): Remove namespace experimental when de-experimentalized fully. +namespace experimental { + +template +using ClientCallbackReader = ::grpc_impl::ClientCallbackReader; + +template +using ClientCallbackWriter = ::grpc_impl::ClientCallbackWriter; + +template +using ClientCallbackReaderWriter = + ::grpc_impl::ClientCallbackReaderWriter; + +template +using ClientReadReactor = ::grpc_impl::ClientReadReactor; + +template +using ClientWriteReactor = ::grpc_impl::ClientWriteReactor; + +template +using ClientBidiReactor = ::grpc_impl::ClientBidiReactor; + +typedef ::grpc_impl::ClientUnaryReactor ClientUnaryReactor; + +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_callback_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_callback_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..1a2bae1b5dbb21ddf68710040d171f20a31963f6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_callback_impl.h @@ -0,0 +1,1064 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_IMPL_H +#define GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_IMPL_H +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace grpc { +namespace internal { +class RpcMethod; +} // namespace internal +} // namespace grpc + +namespace grpc_impl { +class Channel; +class ClientContext; + +namespace internal { + +/// Perform a callback-based unary call +/// TODO(vjpai): Combine as much as possible with the blocking unary call code +template +void CallbackUnaryCall(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const InputMessage* request, OutputMessage* result, + std::function on_completion) { + CallbackUnaryCallImpl x( + channel, method, context, request, result, on_completion); +} + +template +class CallbackUnaryCallImpl { + public: + CallbackUnaryCallImpl(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const InputMessage* request, OutputMessage* result, + std::function on_completion) { + ::grpc_impl::CompletionQueue* cq = channel->CallbackCQ(); + GPR_CODEGEN_ASSERT(cq != nullptr); + grpc::internal::Call call(channel->CreateCall(method, context, cq)); + + using FullCallOpSet = grpc::internal::CallOpSet< + ::grpc::internal::CallOpSendInitialMetadata, + grpc::internal::CallOpSendMessage, + grpc::internal::CallOpRecvInitialMetadata, + grpc::internal::CallOpRecvMessage, + grpc::internal::CallOpClientSendClose, + grpc::internal::CallOpClientRecvStatus>; + + struct OpSetAndTag { + FullCallOpSet opset; + grpc::internal::CallbackWithStatusTag tag; + }; + const size_t alloc_sz = sizeof(OpSetAndTag); + auto* const alloced = static_cast( + ::grpc::g_core_codegen_interface->grpc_call_arena_alloc(call.call(), + alloc_sz)); + auto* ops = new (&alloced->opset) FullCallOpSet; + auto* tag = new (&alloced->tag) + grpc::internal::CallbackWithStatusTag(call.call(), on_completion, ops); + + // TODO(vjpai): Unify code with sync API as much as possible + ::grpc::Status s = ops->SendMessagePtr(request); + if (!s.ok()) { + tag->force_run(s); + return; + } + ops->SendInitialMetadata(&context->send_initial_metadata_, + context->initial_metadata_flags()); + ops->RecvInitialMetadata(context); + ops->RecvMessage(result); + ops->AllowNoMessage(); + ops->ClientSendClose(); + ops->ClientRecvStatus(context, tag->status_ptr()); + ops->set_core_cq_tag(tag); + call.PerformOps(ops); + } +}; +} // namespace internal + +// Forward declarations +template +class ClientBidiReactor; +template +class ClientReadReactor; +template +class ClientWriteReactor; +class ClientUnaryReactor; + +// NOTE: The streaming objects are not actually implemented in the public API. +// These interfaces are provided for mocking only. Typical applications +// will interact exclusively with the reactors that they define. +template +class ClientCallbackReaderWriter { + public: + virtual ~ClientCallbackReaderWriter() {} + virtual void StartCall() = 0; + virtual void Write(const Request* req, ::grpc::WriteOptions options) = 0; + virtual void WritesDone() = 0; + virtual void Read(Response* resp) = 0; + virtual void AddHold(int holds) = 0; + virtual void RemoveHold() = 0; + + protected: + void BindReactor(ClientBidiReactor* reactor) { + reactor->BindStream(this); + } +}; + +template +class ClientCallbackReader { + public: + virtual ~ClientCallbackReader() {} + virtual void StartCall() = 0; + virtual void Read(Response* resp) = 0; + virtual void AddHold(int holds) = 0; + virtual void RemoveHold() = 0; + + protected: + void BindReactor(ClientReadReactor* reactor) { + reactor->BindReader(this); + } +}; + +template +class ClientCallbackWriter { + public: + virtual ~ClientCallbackWriter() {} + virtual void StartCall() = 0; + void Write(const Request* req) { Write(req, ::grpc::WriteOptions()); } + virtual void Write(const Request* req, ::grpc::WriteOptions options) = 0; + void WriteLast(const Request* req, ::grpc::WriteOptions options) { + Write(req, options.set_last_message()); + } + virtual void WritesDone() = 0; + + virtual void AddHold(int holds) = 0; + virtual void RemoveHold() = 0; + + protected: + void BindReactor(ClientWriteReactor* reactor) { + reactor->BindWriter(this); + } +}; + +class ClientCallbackUnary { + public: + virtual ~ClientCallbackUnary() {} + virtual void StartCall() = 0; + + protected: + void BindReactor(ClientUnaryReactor* reactor); +}; + +// The following classes are the reactor interfaces that are to be implemented +// by the user. They are passed in to the library as an argument to a call on a +// stub (either a codegen-ed call or a generic call). The streaming RPC is +// activated by calling StartCall, possibly after initiating StartRead, +// StartWrite, or AddHold operations on the streaming object. Note that none of +// the classes are pure; all reactions have a default empty reaction so that the +// user class only needs to override those classes that it cares about. +// The reactor must be passed to the stub invocation before any of the below +// operations can be called. + +/// \a ClientBidiReactor is the interface for a bidirectional streaming RPC. +template +class ClientBidiReactor { + public: + virtual ~ClientBidiReactor() {} + + /// Activate the RPC and initiate any reads or writes that have been Start'ed + /// before this call. All streaming RPCs issued by the client MUST have + /// StartCall invoked on them (even if they are canceled) as this call is the + /// activation of their lifecycle. + void StartCall() { stream_->StartCall(); } + + /// Initiate a read operation (or post it for later initiation if StartCall + /// has not yet been invoked). + /// + /// \param[out] resp Where to eventually store the read message. Valid when + /// the library calls OnReadDone + void StartRead(Response* resp) { stream_->Read(resp); } + + /// Initiate a write operation (or post it for later initiation if StartCall + /// has not yet been invoked). + /// + /// \param[in] req The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the application + /// regains ownership of msg. + void StartWrite(const Request* req) { + StartWrite(req, ::grpc::WriteOptions()); + } + + /// Initiate/post a write operation with specified options. + /// + /// \param[in] req The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the application + /// regains ownership of msg. + /// \param[in] options The WriteOptions to use for writing this message + void StartWrite(const Request* req, ::grpc::WriteOptions options) { + stream_->Write(req, std::move(options)); + } + + /// Initiate/post a write operation with specified options and an indication + /// that this is the last write (like StartWrite and StartWritesDone, merged). + /// Note that calling this means that no more calls to StartWrite, + /// StartWriteLast, or StartWritesDone are allowed. + /// + /// \param[in] req The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the application + /// regains ownership of msg. + /// \param[in] options The WriteOptions to use for writing this message + void StartWriteLast(const Request* req, ::grpc::WriteOptions options) { + StartWrite(req, std::move(options.set_last_message())); + } + + /// Indicate that the RPC will have no more write operations. This can only be + /// issued once for a given RPC. This is not required or allowed if + /// StartWriteLast is used since that already has the same implication. + /// Note that calling this means that no more calls to StartWrite, + /// StartWriteLast, or StartWritesDone are allowed. + void StartWritesDone() { stream_->WritesDone(); } + + /// Holds are needed if (and only if) this stream has operations that take + /// place on it after StartCall but from outside one of the reactions + /// (OnReadDone, etc). This is _not_ a common use of the streaming API. + /// + /// Holds must be added before calling StartCall. If a stream still has a hold + /// in place, its resources will not be destroyed even if the status has + /// already come in from the wire and there are currently no active callbacks + /// outstanding. Similarly, the stream will not call OnDone if there are still + /// holds on it. + /// + /// For example, if a StartRead or StartWrite operation is going to be + /// initiated from elsewhere in the application, the application should call + /// AddHold or AddMultipleHolds before StartCall. If there is going to be, + /// for example, a read-flow and a write-flow taking place outside the + /// reactions, then call AddMultipleHolds(2) before StartCall. When the + /// application knows that it won't issue any more read operations (such as + /// when a read comes back as not ok), it should issue a RemoveHold(). It + /// should also call RemoveHold() again after it does StartWriteLast or + /// StartWritesDone that indicates that there will be no more write ops. + /// The number of RemoveHold calls must match the total number of AddHold + /// calls plus the number of holds added by AddMultipleHolds. + void AddHold() { AddMultipleHolds(1); } + void AddMultipleHolds(int holds) { stream_->AddHold(holds); } + void RemoveHold() { stream_->RemoveHold(); } + + /// Notifies the application that all operations associated with this RPC + /// have completed and provides the RPC status outcome. + /// + /// \param[in] s The status outcome of this RPC + virtual void OnDone(const ::grpc::Status& /*s*/) {} + + /// Notifies the application that a read of initial metadata from the + /// server is done. If the application chooses not to implement this method, + /// it can assume that the initial metadata has been read before the first + /// call of OnReadDone or OnDone. + /// + /// \param[in] ok Was the initial metadata read successfully? If false, no + /// new read/write operation will succeed. + virtual void OnReadInitialMetadataDone(bool /*ok*/) {} + + /// Notifies the application that a StartRead operation completed. + /// + /// \param[in] ok Was it successful? If false, no new read/write operation + /// will succeed. + virtual void OnReadDone(bool /*ok*/) {} + + /// Notifies the application that a StartWrite operation completed. + /// + /// \param[in] ok Was it successful? If false, no new read/write operation + /// will succeed. + virtual void OnWriteDone(bool /*ok*/) {} + + /// Notifies the application that a StartWritesDone operation completed. Note + /// that this is only used on explicit StartWritesDone operations and not for + /// those that are implicitly invoked as part of a StartWriteLast. + /// + /// \param[in] ok Was it successful? If false, the application will later see + /// the failure reflected as a bad status in OnDone. + virtual void OnWritesDoneDone(bool /*ok*/) {} + + private: + friend class ClientCallbackReaderWriter; + void BindStream(ClientCallbackReaderWriter* stream) { + stream_ = stream; + } + ClientCallbackReaderWriter* stream_; +}; + +/// \a ClientReadReactor is the interface for a server-streaming RPC. +/// All public methods behave as in ClientBidiReactor. +template +class ClientReadReactor { + public: + virtual ~ClientReadReactor() {} + + void StartCall() { reader_->StartCall(); } + void StartRead(Response* resp) { reader_->Read(resp); } + + void AddHold() { AddMultipleHolds(1); } + void AddMultipleHolds(int holds) { reader_->AddHold(holds); } + void RemoveHold() { reader_->RemoveHold(); } + + virtual void OnDone(const ::grpc::Status& /*s*/) {} + virtual void OnReadInitialMetadataDone(bool /*ok*/) {} + virtual void OnReadDone(bool /*ok*/) {} + + private: + friend class ClientCallbackReader; + void BindReader(ClientCallbackReader* reader) { reader_ = reader; } + ClientCallbackReader* reader_; +}; + +/// \a ClientWriteReactor is the interface for a client-streaming RPC. +/// All public methods behave as in ClientBidiReactor. +template +class ClientWriteReactor { + public: + virtual ~ClientWriteReactor() {} + + void StartCall() { writer_->StartCall(); } + void StartWrite(const Request* req) { + StartWrite(req, ::grpc::WriteOptions()); + } + void StartWrite(const Request* req, ::grpc::WriteOptions options) { + writer_->Write(req, std::move(options)); + } + void StartWriteLast(const Request* req, ::grpc::WriteOptions options) { + StartWrite(req, std::move(options.set_last_message())); + } + void StartWritesDone() { writer_->WritesDone(); } + + void AddHold() { AddMultipleHolds(1); } + void AddMultipleHolds(int holds) { writer_->AddHold(holds); } + void RemoveHold() { writer_->RemoveHold(); } + + virtual void OnDone(const ::grpc::Status& /*s*/) {} + virtual void OnReadInitialMetadataDone(bool /*ok*/) {} + virtual void OnWriteDone(bool /*ok*/) {} + virtual void OnWritesDoneDone(bool /*ok*/) {} + + private: + friend class ClientCallbackWriter; + void BindWriter(ClientCallbackWriter* writer) { writer_ = writer; } + ClientCallbackWriter* writer_; +}; + +/// \a ClientUnaryReactor is a reactor-style interface for a unary RPC. +/// This is _not_ a common way of invoking a unary RPC. In practice, this +/// option should be used only if the unary RPC wants to receive initial +/// metadata without waiting for the response to complete. Most deployments of +/// RPC systems do not use this option, but it is needed for generality. +/// All public methods behave as in ClientBidiReactor. +/// StartCall is included for consistency with the other reactor flavors: even +/// though there are no StartRead or StartWrite operations to queue before the +/// call (that is part of the unary call itself) and there is no reactor object +/// being created as a result of this call, we keep a consistent 2-phase +/// initiation API among all the reactor flavors. +class ClientUnaryReactor { + public: + virtual ~ClientUnaryReactor() {} + + void StartCall() { call_->StartCall(); } + virtual void OnDone(const ::grpc::Status& /*s*/) {} + virtual void OnReadInitialMetadataDone(bool /*ok*/) {} + + private: + friend class ClientCallbackUnary; + void BindCall(ClientCallbackUnary* call) { call_ = call; } + ClientCallbackUnary* call_; +}; + +// Define function out-of-line from class to avoid forward declaration issue +inline void ClientCallbackUnary::BindReactor(ClientUnaryReactor* reactor) { + reactor->BindCall(this); +} + +namespace internal { + +// Forward declare factory classes for friendship +template +class ClientCallbackReaderWriterFactory; +template +class ClientCallbackReaderFactory; +template +class ClientCallbackWriterFactory; + +template +class ClientCallbackReaderWriterImpl + : public ClientCallbackReaderWriter { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* /*ptr*/, std::size_t size) { + GPR_CODEGEN_ASSERT(size == sizeof(ClientCallbackReaderWriterImpl)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } + + void MaybeFinish() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + ::grpc::Status s = std::move(finish_status_); + auto* reactor = reactor_; + auto* call = call_.call(); + this->~ClientCallbackReaderWriterImpl(); + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + reactor->OnDone(s); + } + } + + void StartCall() override { + // This call initiates two batches, plus any backlog, each with a callback + // 1. Send initial metadata (unless corked) + recv initial metadata + // 2. Any read backlog + // 3. Any write backlog + // 4. Recv trailing metadata, on_completion callback + started_ = true; + + start_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_, /*can_inline=*/false); + if (!start_corked_) { + start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + } + start_ops_.RecvInitialMetadata(context_); + start_ops_.set_core_cq_tag(&start_tag_); + call_.PerformOps(&start_ops_); + + // Also set up the read and write tags so that they don't have to be set up + // each time + write_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWriteDone(ok); + MaybeFinish(); + }, + &write_ops_, /*can_inline=*/false); + write_ops_.set_core_cq_tag(&write_tag_); + + read_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadDone(ok); + MaybeFinish(); + }, + &read_ops_, /*can_inline=*/false); + read_ops_.set_core_cq_tag(&read_tag_); + if (read_ops_at_start_) { + call_.PerformOps(&read_ops_); + } + + if (write_ops_at_start_) { + call_.PerformOps(&write_ops_); + } + + if (writes_done_ops_at_start_) { + call_.PerformOps(&writes_done_ops_); + } + + finish_tag_.Set(call_.call(), [this](bool /*ok*/) { MaybeFinish(); }, + &finish_ops_, /*can_inline=*/false); + finish_ops_.ClientRecvStatus(context_, &finish_status_); + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void Read(Response* msg) override { + read_ops_.RecvMessage(msg); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&read_ops_); + } else { + read_ops_at_start_ = true; + } + } + + void Write(const Request* msg, ::grpc::WriteOptions options) override { + if (start_corked_) { + write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_corked_ = false; + } + + if (options.is_last_message()) { + options.set_buffer_hint(); + write_ops_.ClientSendClose(); + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&write_ops_); + } else { + write_ops_at_start_ = true; + } + } + void WritesDone() override { + if (start_corked_) { + writes_done_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_corked_ = false; + } + writes_done_ops_.ClientSendClose(); + writes_done_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWritesDoneDone(ok); + MaybeFinish(); + }, + &writes_done_ops_, /*can_inline=*/false); + writes_done_ops_.set_core_cq_tag(&writes_done_tag_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&writes_done_ops_); + } else { + writes_done_ops_at_start_ = true; + } + } + + void AddHold(int holds) override { + callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); + } + void RemoveHold() override { MaybeFinish(); } + + private: + friend class ClientCallbackReaderWriterFactory; + + ClientCallbackReaderWriterImpl(grpc::internal::Call call, + ::grpc_impl::ClientContext* context, + ClientBidiReactor* reactor) + : context_(context), + call_(call), + reactor_(reactor), + start_corked_(context_->initial_metadata_corked_) { + this->BindReactor(reactor); + } + + ::grpc_impl::ClientContext* const context_; + grpc::internal::Call call_; + ClientBidiReactor* const reactor_; + + grpc::internal::CallOpSet + start_ops_; + grpc::internal::CallbackWithSuccessTag start_tag_; + bool start_corked_; + + grpc::internal::CallOpSet finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::Status finish_status_; + + grpc::internal::CallOpSet + write_ops_; + grpc::internal::CallbackWithSuccessTag write_tag_; + bool write_ops_at_start_{false}; + + grpc::internal::CallOpSet + writes_done_ops_; + grpc::internal::CallbackWithSuccessTag writes_done_tag_; + bool writes_done_ops_at_start_{false}; + + grpc::internal::CallOpSet> + read_ops_; + grpc::internal::CallbackWithSuccessTag read_tag_; + bool read_ops_at_start_{false}; + + // Minimum of 2 callbacks to pre-register for start and finish + std::atomic callbacks_outstanding_{2}; + bool started_{false}; +}; + +template +class ClientCallbackReaderWriterFactory { + public: + static void Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + ClientBidiReactor* reactor) { + grpc::internal::Call call = + channel->CreateCall(method, context, channel->CallbackCQ()); + + ::grpc::g_core_codegen_interface->grpc_call_ref(call.call()); + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientCallbackReaderWriterImpl))) + ClientCallbackReaderWriterImpl(call, context, + reactor); + } +}; + +template +class ClientCallbackReaderImpl : public ClientCallbackReader { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* /*ptr*/, std::size_t size) { + GPR_CODEGEN_ASSERT(size == sizeof(ClientCallbackReaderImpl)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } + + void MaybeFinish() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + ::grpc::Status s = std::move(finish_status_); + auto* reactor = reactor_; + auto* call = call_.call(); + this->~ClientCallbackReaderImpl(); + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + reactor->OnDone(s); + } + } + + void StartCall() override { + // This call initiates two batches, plus any backlog, each with a callback + // 1. Send initial metadata (unless corked) + recv initial metadata + // 2. Any backlog + // 3. Recv trailing metadata, on_completion callback + started_ = true; + + start_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_, /*can_inline=*/false); + start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_ops_.RecvInitialMetadata(context_); + start_ops_.set_core_cq_tag(&start_tag_); + call_.PerformOps(&start_ops_); + + // Also set up the read tag so it doesn't have to be set up each time + read_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadDone(ok); + MaybeFinish(); + }, + &read_ops_, /*can_inline=*/false); + read_ops_.set_core_cq_tag(&read_tag_); + if (read_ops_at_start_) { + call_.PerformOps(&read_ops_); + } + + finish_tag_.Set(call_.call(), [this](bool /*ok*/) { MaybeFinish(); }, + &finish_ops_, /*can_inline=*/false); + finish_ops_.ClientRecvStatus(context_, &finish_status_); + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void Read(Response* msg) override { + read_ops_.RecvMessage(msg); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&read_ops_); + } else { + read_ops_at_start_ = true; + } + } + + void AddHold(int holds) override { + callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); + } + void RemoveHold() override { MaybeFinish(); } + + private: + friend class ClientCallbackReaderFactory; + + template + ClientCallbackReaderImpl(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, + Request* request, + ClientReadReactor* reactor) + : context_(context), call_(call), reactor_(reactor) { + this->BindReactor(reactor); + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(start_ops_.SendMessagePtr(request).ok()); + start_ops_.ClientSendClose(); + } + + ::grpc_impl::ClientContext* const context_; + grpc::internal::Call call_; + ClientReadReactor* const reactor_; + + grpc::internal::CallOpSet + start_ops_; + grpc::internal::CallbackWithSuccessTag start_tag_; + + grpc::internal::CallOpSet finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::Status finish_status_; + + grpc::internal::CallOpSet> + read_ops_; + grpc::internal::CallbackWithSuccessTag read_tag_; + bool read_ops_at_start_{false}; + + // Minimum of 2 callbacks to pre-register for start and finish + std::atomic callbacks_outstanding_{2}; + bool started_{false}; +}; + +template +class ClientCallbackReaderFactory { + public: + template + static void Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const Request* request, + ClientReadReactor* reactor) { + grpc::internal::Call call = + channel->CreateCall(method, context, channel->CallbackCQ()); + + ::grpc::g_core_codegen_interface->grpc_call_ref(call.call()); + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientCallbackReaderImpl))) + ClientCallbackReaderImpl(call, context, request, reactor); + } +}; + +template +class ClientCallbackWriterImpl : public ClientCallbackWriter { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* /*ptr*/, std::size_t size) { + GPR_CODEGEN_ASSERT(size == sizeof(ClientCallbackWriterImpl)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } + + void MaybeFinish() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + ::grpc::Status s = std::move(finish_status_); + auto* reactor = reactor_; + auto* call = call_.call(); + this->~ClientCallbackWriterImpl(); + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + reactor->OnDone(s); + } + } + + void StartCall() override { + // This call initiates two batches, plus any backlog, each with a callback + // 1. Send initial metadata (unless corked) + recv initial metadata + // 2. Any backlog + // 3. Recv trailing metadata, on_completion callback + started_ = true; + + start_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_, /*can_inline=*/false); + if (!start_corked_) { + start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + } + start_ops_.RecvInitialMetadata(context_); + start_ops_.set_core_cq_tag(&start_tag_); + call_.PerformOps(&start_ops_); + + // Also set up the read and write tags so that they don't have to be set up + // each time + write_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWriteDone(ok); + MaybeFinish(); + }, + &write_ops_, /*can_inline=*/false); + write_ops_.set_core_cq_tag(&write_tag_); + + if (write_ops_at_start_) { + call_.PerformOps(&write_ops_); + } + + if (writes_done_ops_at_start_) { + call_.PerformOps(&writes_done_ops_); + } + + finish_tag_.Set(call_.call(), [this](bool /*ok*/) { MaybeFinish(); }, + &finish_ops_, /*can_inline=*/false); + finish_ops_.ClientRecvStatus(context_, &finish_status_); + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void Write(const Request* msg, ::grpc::WriteOptions options) override { + if (start_corked_) { + write_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_corked_ = false; + } + + if (options.is_last_message()) { + options.set_buffer_hint(); + write_ops_.ClientSendClose(); + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok()); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&write_ops_); + } else { + write_ops_at_start_ = true; + } + } + void WritesDone() override { + if (start_corked_) { + writes_done_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_corked_ = false; + } + writes_done_ops_.ClientSendClose(); + writes_done_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnWritesDoneDone(ok); + MaybeFinish(); + }, + &writes_done_ops_, /*can_inline=*/false); + writes_done_ops_.set_core_cq_tag(&writes_done_tag_); + callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); + if (started_) { + call_.PerformOps(&writes_done_ops_); + } else { + writes_done_ops_at_start_ = true; + } + } + + void AddHold(int holds) override { + callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed); + } + void RemoveHold() override { MaybeFinish(); } + + private: + friend class ClientCallbackWriterFactory; + + template + ClientCallbackWriterImpl(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, + Response* response, + ClientWriteReactor* reactor) + : context_(context), + call_(call), + reactor_(reactor), + start_corked_(context_->initial_metadata_corked_) { + this->BindReactor(reactor); + finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); + } + + ::grpc_impl::ClientContext* const context_; + grpc::internal::Call call_; + ClientWriteReactor* const reactor_; + + grpc::internal::CallOpSet + start_ops_; + grpc::internal::CallbackWithSuccessTag start_tag_; + bool start_corked_; + + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::Status finish_status_; + + grpc::internal::CallOpSet + write_ops_; + grpc::internal::CallbackWithSuccessTag write_tag_; + bool write_ops_at_start_{false}; + + grpc::internal::CallOpSet + writes_done_ops_; + grpc::internal::CallbackWithSuccessTag writes_done_tag_; + bool writes_done_ops_at_start_{false}; + + // Minimum of 2 callbacks to pre-register for start and finish + std::atomic callbacks_outstanding_{2}; + bool started_{false}; +}; + +template +class ClientCallbackWriterFactory { + public: + template + static void Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, Response* response, + ClientWriteReactor* reactor) { + grpc::internal::Call call = + channel->CreateCall(method, context, channel->CallbackCQ()); + + ::grpc::g_core_codegen_interface->grpc_call_ref(call.call()); + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientCallbackWriterImpl))) + ClientCallbackWriterImpl(call, context, response, reactor); + } +}; + +class ClientCallbackUnaryImpl final : public ClientCallbackUnary { + public: + // always allocated against a call arena, no memory free required + static void operator delete(void* /*ptr*/, std::size_t size) { + GPR_CODEGEN_ASSERT(size == sizeof(ClientCallbackUnaryImpl)); + } + + // This operator should never be called as the memory should be freed as part + // of the arena destruction. It only exists to provide a matching operator + // delete to the operator new so that some compilers will not complain (see + // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this + // there are no tests catching the compiler warning. + static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } + + void StartCall() override { + // This call initiates two batches, each with a callback + // 1. Send initial metadata + write + writes done + recv initial metadata + // 2. Read message, recv trailing metadata + started_ = true; + + start_tag_.Set(call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_, /*can_inline=*/false); + start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + start_ops_.RecvInitialMetadata(context_); + start_ops_.set_core_cq_tag(&start_tag_); + call_.PerformOps(&start_ops_); + + finish_tag_.Set(call_.call(), [this](bool /*ok*/) { MaybeFinish(); }, + &finish_ops_, /*can_inline=*/false); + finish_ops_.ClientRecvStatus(context_, &finish_status_); + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void MaybeFinish() { + if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub( + 1, std::memory_order_acq_rel) == 1)) { + ::grpc::Status s = std::move(finish_status_); + auto* reactor = reactor_; + auto* call = call_.call(); + this->~ClientCallbackUnaryImpl(); + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + reactor->OnDone(s); + } + } + + private: + friend class ClientCallbackUnaryFactory; + + template + ClientCallbackUnaryImpl(::grpc::internal::Call call, + ::grpc_impl::ClientContext* context, Request* request, + Response* response, ClientUnaryReactor* reactor) + : context_(context), call_(call), reactor_(reactor) { + this->BindReactor(reactor); + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(start_ops_.SendMessagePtr(request).ok()); + start_ops_.ClientSendClose(); + finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); + } + + ::grpc_impl::ClientContext* const context_; + grpc::internal::Call call_; + ClientUnaryReactor* const reactor_; + + grpc::internal::CallOpSet + start_ops_; + grpc::internal::CallbackWithSuccessTag start_tag_; + + grpc::internal::CallOpSet + finish_ops_; + grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::Status finish_status_; + + // This call will have 2 callbacks: start and finish + std::atomic callbacks_outstanding_{2}; + bool started_{false}; +}; + +class ClientCallbackUnaryFactory { + public: + template + static void Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const Request* request, Response* response, + ClientUnaryReactor* reactor) { + grpc::internal::Call call = + channel->CreateCall(method, context, channel->CallbackCQ()); + + ::grpc::g_core_codegen_interface->grpc_call_ref(call.call()); + + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call.call(), sizeof(ClientCallbackUnaryImpl))) + ClientCallbackUnaryImpl(call, context, request, response, reactor); + } +}; + +} // namespace internal +} // namespace grpc_impl +#endif // GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_context.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_context.h new file mode 100644 index 0000000000000000000000000000000000000000..02389464ce46eea55a672cd8d14227c3f998af09 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_context.h @@ -0,0 +1,31 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_H +#define GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_H + +#include + +namespace grpc { + +typedef ::grpc_impl::ClientContext ClientContext; +typedef ::grpc_impl::PropagationOptions PropagationOptions; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_context_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_context_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..b8e90722b255e14e74548da6101b261f90049713 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_context_impl.h @@ -0,0 +1,519 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/// A ClientContext allows the person implementing a service client to: +/// +/// - Add custom metadata key-value pairs that will propagated to the server +/// side. +/// - Control call settings such as compression and authentication. +/// - Initial and trailing metadata coming from the server. +/// - Get performance metrics (ie, census). +/// +/// Context settings are only relevant to the call they are invoked with, that +/// is to say, they aren't sticky. Some of these settings, such as the +/// compression options, can be made persistent at channel construction time +/// (see \a grpc::CreateCustomChannel). +/// +/// \warning ClientContext instances should \em not be reused across rpcs. + +#ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_IMPL_H +#define GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_IMPL_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct census_context; +struct grpc_call; + +namespace grpc { + +class ChannelInterface; + +namespace internal { +class RpcMethod; +template +class BlockingUnaryCallImpl; +class CallOpClientRecvStatus; +class CallOpRecvInitialMetadata; +class ServerContextImpl; +} // namespace internal + +namespace testing { +class InteropClientContextInspector; +} // namespace testing +} // namespace grpc +namespace grpc_impl { + +namespace internal { +template +class CallbackUnaryCallImpl; +template +class ClientCallbackReaderWriterImpl; +template +class ClientCallbackReaderImpl; +template +class ClientCallbackWriterImpl; +class ClientCallbackUnaryImpl; +class ClientContextAccessor; +} // namespace internal + +class CallCredentials; +class Channel; +class CompletionQueue; +class ServerContext; +template +class ClientReader; +template +class ClientWriter; +template +class ClientReaderWriter; +template +class ClientAsyncReader; +template +class ClientAsyncWriter; +template +class ClientAsyncReaderWriter; +template +class ClientAsyncResponseReader; + +class ServerContextBase; +class CallbackServerContext; + +/// Options for \a ClientContext::FromServerContext specifying which traits from +/// the \a ServerContext to propagate (copy) from it into a new \a +/// ClientContext. +/// +/// \see ClientContext::FromServerContext +class PropagationOptions { + public: + PropagationOptions() : propagate_(GRPC_PROPAGATE_DEFAULTS) {} + + PropagationOptions& enable_deadline_propagation() { + propagate_ |= GRPC_PROPAGATE_DEADLINE; + return *this; + } + + PropagationOptions& disable_deadline_propagation() { + propagate_ &= ~GRPC_PROPAGATE_DEADLINE; + return *this; + } + + PropagationOptions& enable_census_stats_propagation() { + propagate_ |= GRPC_PROPAGATE_CENSUS_STATS_CONTEXT; + return *this; + } + + PropagationOptions& disable_census_stats_propagation() { + propagate_ &= ~GRPC_PROPAGATE_CENSUS_STATS_CONTEXT; + return *this; + } + + PropagationOptions& enable_census_tracing_propagation() { + propagate_ |= GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT; + return *this; + } + + PropagationOptions& disable_census_tracing_propagation() { + propagate_ &= ~GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT; + return *this; + } + + PropagationOptions& enable_cancellation_propagation() { + propagate_ |= GRPC_PROPAGATE_CANCELLATION; + return *this; + } + + PropagationOptions& disable_cancellation_propagation() { + propagate_ &= ~GRPC_PROPAGATE_CANCELLATION; + return *this; + } + + uint32_t c_bitmask() const { return propagate_; } + + private: + uint32_t propagate_; +}; + +/// A ClientContext allows the person implementing a service client to: +/// +/// - Add custom metadata key-value pairs that will propagated to the server +/// side. +/// - Control call settings such as compression and authentication. +/// - Initial and trailing metadata coming from the server. +/// - Get performance metrics (ie, census). +/// +/// Context settings are only relevant to the call they are invoked with, that +/// is to say, they aren't sticky. Some of these settings, such as the +/// compression options, can be made persistent at channel construction time +/// (see \a grpc::CreateCustomChannel). +/// +/// \warning ClientContext instances should \em not be reused across rpcs. +/// \warning The ClientContext instance used for creating an rpc must remain +/// alive and valid for the lifetime of the rpc. +class ClientContext { + public: + ClientContext(); + ~ClientContext(); + + /// Create a new \a ClientContext as a child of an incoming server call, + /// according to \a options (\see PropagationOptions). + /// + /// \param server_context The source server context to use as the basis for + /// constructing the client context. + /// \param options The options controlling what to copy from the \a + /// server_context. + /// + /// \return A newly constructed \a ClientContext instance based on \a + /// server_context, with traits propagated (copied) according to \a options. + static std::unique_ptr FromServerContext( + const grpc_impl::ServerContext& server_context, + PropagationOptions options = PropagationOptions()); + static std::unique_ptr FromCallbackServerContext( + const grpc_impl::CallbackServerContext& server_context, + PropagationOptions options = PropagationOptions()); + + /// Add the (\a meta_key, \a meta_value) pair to the metadata associated with + /// a client call. These are made available at the server side by the \a + /// grpc::ServerContext::client_metadata() method. + /// + /// \warning This method should only be called before invoking the rpc. + /// + /// \param meta_key The metadata key. If \a meta_value is binary data, it must + /// end in "-bin". + /// \param meta_value The metadata value. If its value is binary, the key name + /// must end in "-bin". + /// + /// Metadata must conform to the following format: + /// Custom-Metadata -> Binary-Header / ASCII-Header + /// Binary-Header -> {Header-Name "-bin" } {binary value} + /// ASCII-Header -> Header-Name ASCII-Value + /// Header-Name -> 1*( %x30-39 / %x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - . + /// ASCII-Value -> 1*( %x20-%x7E ) ; space and printable ASCII + void AddMetadata(const grpc::string& meta_key, + const grpc::string& meta_value); + + /// Return a collection of initial metadata key-value pairs. Note that keys + /// may happen more than once (ie, a \a std::multimap is returned). + /// + /// \warning This method should only be called after initial metadata has been + /// received. For streaming calls, see \a + /// ClientReaderInterface::WaitForInitialMetadata(). + /// + /// \return A multimap of initial metadata key-value pairs from the server. + const std::multimap& + GetServerInitialMetadata() const { + GPR_CODEGEN_ASSERT(initial_metadata_received_); + return *recv_initial_metadata_.map(); + } + + /// Return a collection of trailing metadata key-value pairs. Note that keys + /// may happen more than once (ie, a \a std::multimap is returned). + /// + /// \warning This method is only callable once the stream has finished. + /// + /// \return A multimap of metadata trailing key-value pairs from the server. + const std::multimap& + GetServerTrailingMetadata() const { + // TODO(yangg) check finished + return *trailing_metadata_.map(); + } + + /// Set the deadline for the client call. + /// + /// \warning This method should only be called before invoking the rpc. + /// + /// \param deadline the deadline for the client call. Units are determined by + /// the type used. The deadline is an absolute (not relative) time. + template + void set_deadline(const T& deadline) { + grpc::TimePoint deadline_tp(deadline); + deadline_ = deadline_tp.raw_time(); + } + + /// EXPERIMENTAL: Indicate that this request is idempotent. + /// By default, RPCs are assumed to not be idempotent. + /// + /// If true, the gRPC library assumes that it's safe to initiate + /// this RPC multiple times. + void set_idempotent(bool idempotent) { idempotent_ = idempotent; } + + /// EXPERIMENTAL: Set this request to be cacheable. + /// If set, grpc is free to use the HTTP GET verb for sending the request, + /// with the possibility of receiving a cached response. + void set_cacheable(bool cacheable) { cacheable_ = cacheable; } + + /// EXPERIMENTAL: Trigger wait-for-ready or not on this request. + /// See https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md. + /// If set, if an RPC is made when a channel's connectivity state is + /// TRANSIENT_FAILURE or CONNECTING, the call will not "fail fast", + /// and the channel will wait until the channel is READY before making the + /// call. + void set_wait_for_ready(bool wait_for_ready) { + wait_for_ready_ = wait_for_ready; + wait_for_ready_explicitly_set_ = true; + } + + /// DEPRECATED: Use set_wait_for_ready() instead. + void set_fail_fast(bool fail_fast) { set_wait_for_ready(!fail_fast); } + + /// Return the deadline for the client call. + std::chrono::system_clock::time_point deadline() const { + return grpc::Timespec2Timepoint(deadline_); + } + + /// Return a \a gpr_timespec representation of the client call's deadline. + gpr_timespec raw_deadline() const { return deadline_; } + + /// Set the per call authority header (see + /// https://tools.ietf.org/html/rfc7540#section-8.1.2.3). + void set_authority(const grpc::string& authority) { authority_ = authority; } + + /// Return the authentication context for the associated client call. + /// It is only valid to call this during the lifetime of the client call. + /// + /// \see grpc::AuthContext. + std::shared_ptr auth_context() const { + if (auth_context_.get() == nullptr) { + auth_context_ = grpc::CreateAuthContext(call_); + } + return auth_context_; + } + + /// Set credentials for the client call. + /// + /// A credentials object encapsulates all the state needed by a client to + /// authenticate with a server and make various assertions, e.g., about the + /// client’s identity, role, or whether it is authorized to make a particular + /// call. + /// + /// It is legal to call this only before initial metadata is sent. + /// + /// \see https://grpc.io/docs/guides/auth.html + void set_credentials( + const std::shared_ptr& creds); + + /// EXPERIMENTAL debugging API + /// + /// Returns the credentials for the client call. This should be used only in + /// tests and for diagnostic purposes, and should not be used by application + /// logic. + std::shared_ptr credentials() { return creds_; } + + /// Return the compression algorithm the client call will request be used. + /// Note that the gRPC runtime may decide to ignore this request, for example, + /// due to resource constraints. + grpc_compression_algorithm compression_algorithm() const { + return compression_algorithm_; + } + + /// Set \a algorithm to be the compression algorithm used for the client call. + /// + /// \param algorithm The compression algorithm used for the client call. + void set_compression_algorithm(grpc_compression_algorithm algorithm); + + /// Flag whether the initial metadata should be \a corked + /// + /// If \a corked is true, then the initial metadata will be coalesced with the + /// write of first message in the stream. As a result, any tag set for the + /// initial metadata operation (starting a client-streaming or bidi-streaming + /// RPC) will not actually be sent to the completion queue or delivered + /// via Next. + /// + /// \param corked The flag indicating whether the initial metadata is to be + /// corked or not. + void set_initial_metadata_corked(bool corked) { + initial_metadata_corked_ = corked; + } + + /// Return the peer uri in a string. + /// It is only valid to call this during the lifetime of the client call. + /// + /// \warning This value is never authenticated or subject to any security + /// related code. It must not be used for any authentication related + /// functionality. Instead, use auth_context. + /// + /// \return The call's peer URI. + grpc::string peer() const; + + /// Sets the census context. + /// It is only valid to call this before the client call is created. A common + /// place of setting census context is from within the DefaultConstructor + /// method of GlobalCallbacks. + void set_census_context(struct census_context* ccp) { census_context_ = ccp; } + + /// Returns the census context that has been set, or nullptr if not set. + struct census_context* census_context() const { + return census_context_; + } + + /// Send a best-effort out-of-band cancel on the call associated with + /// this client context. The call could be in any stage; e.g., if it is + /// already finished, it may still return success. + /// + /// There is no guarantee the call will be cancelled. + /// + /// Note that TryCancel() does not change any of the tags that are pending + /// on the completion queue. All pending tags will still be delivered + /// (though their ok result may reflect the effect of cancellation). + void TryCancel(); + + /// Global Callbacks + /// + /// Can be set exactly once per application to install hooks whenever + /// a client context is constructed and destructed. + class GlobalCallbacks { + public: + virtual ~GlobalCallbacks() {} + virtual void DefaultConstructor(ClientContext* context) = 0; + virtual void Destructor(ClientContext* context) = 0; + }; + static void SetGlobalCallbacks(GlobalCallbacks* callbacks); + + /// Should be used for framework-level extensions only. + /// Applications never need to call this method. + grpc_call* c_call() { return call_; } + + /// EXPERIMENTAL debugging API + /// + /// if status is not ok() for an RPC, this will return a detailed string + /// of the gRPC Core error that led to the failure. It should not be relied + /// upon for anything other than gaining more debug data in failure cases. + grpc::string debug_error_string() const { return debug_error_string_; } + + private: + // Disallow copy and assign. + ClientContext(const ClientContext&); + ClientContext& operator=(const ClientContext&); + + friend class ::grpc::testing::InteropClientContextInspector; + friend class ::grpc::internal::CallOpClientRecvStatus; + friend class ::grpc::internal::CallOpRecvInitialMetadata; + friend class ::grpc_impl::Channel; + template + friend class ::grpc_impl::ClientReader; + template + friend class ::grpc_impl::ClientWriter; + template + friend class ::grpc_impl::ClientReaderWriter; + template + friend class ::grpc_impl::ClientAsyncReader; + template + friend class ::grpc_impl::ClientAsyncWriter; + template + friend class ::grpc_impl::ClientAsyncReaderWriter; + template + friend class ::grpc_impl::ClientAsyncResponseReader; + template + friend class ::grpc::internal::BlockingUnaryCallImpl; + template + friend class ::grpc_impl::internal::CallbackUnaryCallImpl; + template + friend class ::grpc_impl::internal::ClientCallbackReaderWriterImpl; + template + friend class ::grpc_impl::internal::ClientCallbackReaderImpl; + template + friend class ::grpc_impl::internal::ClientCallbackWriterImpl; + friend class ::grpc_impl::internal::ClientCallbackUnaryImpl; + friend class ::grpc_impl::internal::ClientContextAccessor; + + // Used by friend class CallOpClientRecvStatus + void set_debug_error_string(const grpc::string& debug_error_string) { + debug_error_string_ = debug_error_string; + } + + grpc_call* call() const { return call_; } + void set_call(grpc_call* call, + const std::shared_ptr<::grpc_impl::Channel>& channel); + + grpc::experimental::ClientRpcInfo* set_client_rpc_info( + const char* method, grpc::internal::RpcMethod::RpcType type, + grpc::ChannelInterface* channel, + const std::vector>& creators, + size_t interceptor_pos) { + rpc_info_ = grpc::experimental::ClientRpcInfo(this, type, method, channel); + rpc_info_.RegisterInterceptors(creators, interceptor_pos); + return &rpc_info_; + } + + uint32_t initial_metadata_flags() const { + return (idempotent_ ? GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST : 0) | + (wait_for_ready_ ? GRPC_INITIAL_METADATA_WAIT_FOR_READY : 0) | + (cacheable_ ? GRPC_INITIAL_METADATA_CACHEABLE_REQUEST : 0) | + (wait_for_ready_explicitly_set_ + ? GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET + : 0) | + (initial_metadata_corked_ ? GRPC_INITIAL_METADATA_CORKED : 0); + } + + grpc::string authority() { return authority_; } + + void SendCancelToInterceptors(); + + static std::unique_ptr FromInternalServerContext( + const grpc_impl::ServerContextBase& server_context, + PropagationOptions options); + + bool initial_metadata_received_; + bool wait_for_ready_; + bool wait_for_ready_explicitly_set_; + bool idempotent_; + bool cacheable_; + std::shared_ptr<::grpc_impl::Channel> channel_; + grpc::internal::Mutex mu_; + grpc_call* call_; + bool call_canceled_; + gpr_timespec deadline_; + grpc::string authority_; + std::shared_ptr creds_; + mutable std::shared_ptr auth_context_; + struct census_context* census_context_; + std::multimap send_initial_metadata_; + mutable grpc::internal::MetadataMap recv_initial_metadata_; + mutable grpc::internal::MetadataMap trailing_metadata_; + + grpc_call* propagate_from_call_; + PropagationOptions propagation_options_; + + grpc_compression_algorithm compression_algorithm_; + bool initial_metadata_corked_; + + grpc::string debug_error_string_; + + grpc::experimental::ClientRpcInfo rpc_info_; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_interceptor.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_interceptor.h new file mode 100644 index 0000000000000000000000000000000000000000..03cb41fb58fdebabaa4d162a3d65bdfd2f29ecc4 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_interceptor.h @@ -0,0 +1,194 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CLIENT_INTERCEPTOR_H +#define GRPCPP_IMPL_CODEGEN_CLIENT_INTERCEPTOR_H + +#include +#include + +#include +#include +#include + +namespace grpc_impl { + +class Channel; +class ClientContext; +} // namespace grpc_impl + +namespace grpc { + +namespace internal { +class InterceptorBatchMethodsImpl; +} + +namespace experimental { +class ClientRpcInfo; + +// A factory interface for creation of client interceptors. A vector of +// factories can be provided at channel creation which will be used to create a +// new vector of client interceptors per RPC. Client interceptor authors should +// create a subclass of ClientInterceptorFactorInterface which creates objects +// of their interceptors. +class ClientInterceptorFactoryInterface { + public: + virtual ~ClientInterceptorFactoryInterface() {} + // Returns a pointer to an Interceptor object on successful creation, nullptr + // otherwise. If nullptr is returned, this server interceptor factory is + // ignored for the purposes of that RPC. + virtual Interceptor* CreateClientInterceptor(ClientRpcInfo* info) = 0; +}; +} // namespace experimental + +namespace internal { +extern experimental::ClientInterceptorFactoryInterface* + g_global_client_interceptor_factory; +} + +/// ClientRpcInfo represents the state of a particular RPC as it +/// appears to an interceptor. It is created and owned by the library and +/// passed to the CreateClientInterceptor method of the application's +/// ClientInterceptorFactoryInterface implementation +namespace experimental { +class ClientRpcInfo { + public: + // TODO(yashykt): Stop default-constructing ClientRpcInfo and remove UNKNOWN + // from the list of possible Types. + /// Type categorizes RPCs by unary or streaming type + enum class Type { + UNARY, + CLIENT_STREAMING, + SERVER_STREAMING, + BIDI_STREAMING, + UNKNOWN // UNKNOWN is not API and will be removed later + }; + + ~ClientRpcInfo() {} + + // Delete copy constructor but allow default move constructor + ClientRpcInfo(const ClientRpcInfo&) = delete; + ClientRpcInfo(ClientRpcInfo&&) = default; + + // Getter methods + + /// Return the fully-specified method name + const char* method() const { return method_; } + + /// Return a pointer to the channel on which the RPC is being sent + ChannelInterface* channel() { return channel_; } + + /// Return a pointer to the underlying ClientContext structure associated + /// with the RPC to support features that apply to it + grpc_impl::ClientContext* client_context() { return ctx_; } + + /// Return the type of the RPC (unary or a streaming flavor) + Type type() const { return type_; } + + private: + static_assert(Type::UNARY == + static_cast(internal::RpcMethod::NORMAL_RPC), + "violated expectation about Type enum"); + static_assert(Type::CLIENT_STREAMING == + static_cast(internal::RpcMethod::CLIENT_STREAMING), + "violated expectation about Type enum"); + static_assert(Type::SERVER_STREAMING == + static_cast(internal::RpcMethod::SERVER_STREAMING), + "violated expectation about Type enum"); + static_assert(Type::BIDI_STREAMING == + static_cast(internal::RpcMethod::BIDI_STREAMING), + "violated expectation about Type enum"); + + // Default constructor should only be used by ClientContext + ClientRpcInfo() = default; + + // Constructor will only be called from ClientContext + ClientRpcInfo(grpc_impl::ClientContext* ctx, + internal::RpcMethod::RpcType type, const char* method, + grpc::ChannelInterface* channel) + : ctx_(ctx), + type_(static_cast(type)), + method_(method), + channel_(channel) {} + + // Move assignment should only be used by ClientContext + // TODO(yashykt): Delete move assignment + ClientRpcInfo& operator=(ClientRpcInfo&&) = default; + + // Runs interceptor at pos \a pos. + void RunInterceptor( + experimental::InterceptorBatchMethods* interceptor_methods, size_t pos) { + GPR_CODEGEN_ASSERT(pos < interceptors_.size()); + interceptors_[pos]->Intercept(interceptor_methods); + } + + void RegisterInterceptors( + const std::vector>& creators, + size_t interceptor_pos) { + if (interceptor_pos > creators.size()) { + // No interceptors to register + return; + } + // NOTE: The following is not a range-based for loop because it will only + // iterate over a portion of the creators vector. + for (auto it = creators.begin() + interceptor_pos; it != creators.end(); + ++it) { + auto* interceptor = (*it)->CreateClientInterceptor(this); + if (interceptor != nullptr) { + interceptors_.push_back( + std::unique_ptr(interceptor)); + } + } + if (internal::g_global_client_interceptor_factory != nullptr) { + interceptors_.push_back(std::unique_ptr( + internal::g_global_client_interceptor_factory + ->CreateClientInterceptor(this))); + } + } + + grpc_impl::ClientContext* ctx_ = nullptr; + // TODO(yashykt): make type_ const once move-assignment is deleted + Type type_{Type::UNKNOWN}; + const char* method_ = nullptr; + grpc::ChannelInterface* channel_ = nullptr; + std::vector> interceptors_; + bool hijacked_ = false; + size_t hijacked_interceptor_ = 0; + + friend class internal::InterceptorBatchMethodsImpl; + friend class grpc_impl::ClientContext; +}; + +// PLEASE DO NOT USE THIS. ALWAYS PREFER PER CHANNEL INTERCEPTORS OVER A GLOBAL +// INTERCEPTOR. IF USAGE IS ABSOLUTELY NECESSARY, PLEASE READ THE SAFETY NOTES. +// Registers a global client interceptor factory object, which is used for all +// RPCs made in this process. The application is responsible for maintaining the +// life of the object while gRPC operations are in progress. The global +// interceptor factory should only be registered once at the start of the +// process before any gRPC operations have begun. +void RegisterGlobalClientInterceptorFactory( + ClientInterceptorFactoryInterface* factory); + +// For testing purposes only +void TestOnlyResetGlobalClientInterceptorFactory(); + +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CLIENT_INTERCEPTOR_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_unary_call.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_unary_call.h new file mode 100644 index 0000000000000000000000000000000000000000..7f80e571c0741c523922d94e56c02f9f214b81f4 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/client_unary_call.h @@ -0,0 +1,94 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CLIENT_UNARY_CALL_H +#define GRPCPP_IMPL_CODEGEN_CLIENT_UNARY_CALL_H + +#include +#include +#include +#include +#include + +namespace grpc_impl { + +class ClientContext; +} // namespace grpc_impl +namespace grpc { + +namespace internal { +class RpcMethod; +/// Wrapper that performs a blocking unary call +template +Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, + grpc_impl::ClientContext* context, + const InputMessage& request, OutputMessage* result) { + return BlockingUnaryCallImpl( + channel, method, context, request, result) + .status(); +} + +template +class BlockingUnaryCallImpl { + public: + BlockingUnaryCallImpl(ChannelInterface* channel, const RpcMethod& method, + grpc_impl::ClientContext* context, + const InputMessage& request, OutputMessage* result) { + ::grpc_impl::CompletionQueue cq(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, + nullptr}); // Pluckable completion queue + ::grpc::internal::Call call(channel->CreateCall(method, context, &cq)); + CallOpSet, + CallOpClientSendClose, CallOpClientRecvStatus> + ops; + status_ = ops.SendMessagePtr(&request); + if (!status_.ok()) { + return; + } + ops.SendInitialMetadata(&context->send_initial_metadata_, + context->initial_metadata_flags()); + ops.RecvInitialMetadata(context); + ops.RecvMessage(result); + ops.AllowNoMessage(); + ops.ClientSendClose(); + ops.ClientRecvStatus(context, &status_); + call.PerformOps(&ops); + cq.Pluck(&ops); + // Some of the ops might fail. If the ops fail in the core layer, status + // would reflect the error. But, if the ops fail in the C++ layer, the + // status would still be the same as the one returned by gRPC Core. This can + // happen if deserialization of the message fails. + // TODO(yashykt): If deserialization fails, but the status received is OK, + // then it might be a good idea to change the status to something better + // than StatusCode::UNIMPLEMENTED to reflect this. + if (!ops.got_message && status_.ok()) { + status_ = Status(StatusCode::UNIMPLEMENTED, + "No message returned for unary request"); + } + } + Status status() { return status_; } + + private: + Status status_; +}; + +} // namespace internal +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CLIENT_UNARY_CALL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/completion_queue.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/completion_queue.h new file mode 100644 index 0000000000000000000000000000000000000000..f67a37809797b74bc7682529c2bf6f551648730c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/completion_queue.h @@ -0,0 +1,31 @@ +/* + * + * Copyright 2015-2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H +#define GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H + +#include + +namespace grpc { + +typedef ::grpc_impl::CompletionQueue CompletionQueue; +typedef ::grpc_impl::ServerCompletionQueue ServerCompletionQueue; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/completion_queue_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/completion_queue_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..4549aa3719477be1a78cc57a49a4bb193c59fedc --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/completion_queue_impl.h @@ -0,0 +1,419 @@ +/* + * + * Copyright 2015-2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/// A completion queue implements a concurrent producer-consumer queue, with +/// two main API-exposed methods: \a Next and \a AsyncNext. These +/// methods are the essential component of the gRPC C++ asynchronous API. +/// There is also a \a Shutdown method to indicate that a given completion queue +/// will no longer have regular events. This must be called before the +/// completion queue is destroyed. +/// All completion queue APIs are thread-safe and may be used concurrently with +/// any other completion queue API invocation; it is acceptable to have +/// multiple threads calling \a Next or \a AsyncNext on the same or different +/// completion queues, or to call these methods concurrently with a \a Shutdown +/// elsewhere. +/// \remark{All other API calls on completion queue should be completed before +/// a completion queue destructor is called.} +#ifndef GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H +#define GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H + +#include +#include +#include +#include +#include +#include + +struct grpc_completion_queue; + +namespace grpc_impl { + +class Channel; +class Server; +class ServerBuilder; +template +class ClientReader; +template +class ClientWriter; +template +class ClientReaderWriter; +template +class ServerReader; +template +class ServerWriter; +class ServerContextBase; +namespace internal { +template +class ServerReaderWriterBody; + +template +class RpcMethodHandler; +template +class ClientStreamingHandler; +template +class ServerStreamingHandler; +template +class TemplatedBidiStreamingHandler; +template <::grpc::StatusCode code> +class ErrorMethodHandler; +} // namespace internal +} // namespace grpc_impl +namespace grpc { + +class ChannelInterface; +class ServerInterface; + +namespace internal { +class CompletionQueueTag; +class RpcMethod; +template +class BlockingUnaryCallImpl; +template +class CallOpSet; +} // namespace internal + +extern CoreCodegenInterface* g_core_codegen_interface; + +} // namespace grpc + +namespace grpc_impl { + +/// A thin wrapper around \ref grpc_completion_queue (see \ref +/// src/core/lib/surface/completion_queue.h). +/// See \ref doc/cpp/perf_notes.md for notes on best practices for high +/// performance servers. +class CompletionQueue : private ::grpc::GrpcLibraryCodegen { + public: + /// Default constructor. Implicitly creates a \a grpc_completion_queue + /// instance. + CompletionQueue() + : CompletionQueue(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, + nullptr}) {} + + /// Wrap \a take, taking ownership of the instance. + /// + /// \param take The completion queue instance to wrap. Ownership is taken. + explicit CompletionQueue(grpc_completion_queue* take); + + /// Destructor. Destroys the owned wrapped completion queue / instance. + ~CompletionQueue() { + ::grpc::g_core_codegen_interface->grpc_completion_queue_destroy(cq_); + } + + /// Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT. + enum NextStatus { + SHUTDOWN, ///< The completion queue has been shutdown and fully-drained + GOT_EVENT, ///< Got a new event; \a tag will be filled in with its + ///< associated value; \a ok indicating its success. + TIMEOUT ///< deadline was reached. + }; + + /// Read from the queue, blocking until an event is available or the queue is + /// shutting down. + /// + /// \param tag [out] Updated to point to the read event's tag. + /// \param ok [out] true if read a successful event, false otherwise. + /// + /// Note that each tag sent to the completion queue (through RPC operations + /// or alarms) will be delivered out of the completion queue by a call to + /// Next (or a related method), regardless of whether the operation succeeded + /// or not. Success here means that this operation completed in the normal + /// valid manner. + /// + /// Server-side RPC request: \a ok indicates that the RPC has indeed + /// been started. If it is false, the server has been Shutdown + /// before this particular call got matched to an incoming RPC. + /// + /// Client-side StartCall/RPC invocation: \a ok indicates that the RPC is + /// going to go to the wire. If it is false, it not going to the wire. This + /// would happen if the channel is either permanently broken or + /// transiently broken but with the fail-fast option. (Note that async unary + /// RPCs don't post a CQ tag at this point, nor do client-streaming + /// or bidi-streaming RPCs that have the initial metadata corked option set.) + /// + /// Client-side Write, Client-side WritesDone, Server-side Write, + /// Server-side Finish, Server-side SendInitialMetadata (which is + /// typically included in Write or Finish when not done explicitly): + /// \a ok means that the data/metadata/status/etc is going to go to the + /// wire. If it is false, it not going to the wire because the call + /// is already dead (i.e., canceled, deadline expired, other side + /// dropped the channel, etc). + /// + /// Client-side Read, Server-side Read, Client-side + /// RecvInitialMetadata (which is typically included in Read if not + /// done explicitly): \a ok indicates whether there is a valid message + /// that got read. If not, you know that there are certainly no more + /// messages that can ever be read from this stream. For the client-side + /// operations, this only happens because the call is dead. For the + /// server-sider operation, though, this could happen because the client + /// has done a WritesDone already. + /// + /// Client-side Finish: \a ok should always be true + /// + /// Server-side AsyncNotifyWhenDone: \a ok should always be true + /// + /// Alarm: \a ok is true if it expired, false if it was canceled + /// + /// \return true if got an event, false if the queue is fully drained and + /// shut down. + bool Next(void** tag, bool* ok) { + return (AsyncNextInternal(tag, ok, + ::grpc::g_core_codegen_interface->gpr_inf_future( + GPR_CLOCK_REALTIME)) != SHUTDOWN); + } + + /// Read from the queue, blocking up to \a deadline (or the queue's shutdown). + /// Both \a tag and \a ok are updated upon success (if an event is available + /// within the \a deadline). A \a tag points to an arbitrary location usually + /// employed to uniquely identify an event. + /// + /// \param tag [out] Upon success, updated to point to the event's tag. + /// \param ok [out] Upon success, true if a successful event, false otherwise + /// See documentation for CompletionQueue::Next for explanation of ok + /// \param deadline [in] How long to block in wait for an event. + /// + /// \return The type of event read. + template + NextStatus AsyncNext(void** tag, bool* ok, const T& deadline) { + ::grpc::TimePoint deadline_tp(deadline); + return AsyncNextInternal(tag, ok, deadline_tp.raw_time()); + } + + /// EXPERIMENTAL + /// First executes \a F, then reads from the queue, blocking up to + /// \a deadline (or the queue's shutdown). + /// Both \a tag and \a ok are updated upon success (if an event is available + /// within the \a deadline). A \a tag points to an arbitrary location usually + /// employed to uniquely identify an event. + /// + /// \param f [in] Function to execute before calling AsyncNext on this queue. + /// \param tag [out] Upon success, updated to point to the event's tag. + /// \param ok [out] Upon success, true if read a regular event, false + /// otherwise. + /// \param deadline [in] How long to block in wait for an event. + /// + /// \return The type of event read. + template + NextStatus DoThenAsyncNext(F&& f, void** tag, bool* ok, const T& deadline) { + CompletionQueueTLSCache cache = CompletionQueueTLSCache(this); + f(); + if (cache.Flush(tag, ok)) { + return GOT_EVENT; + } else { + return AsyncNext(tag, ok, deadline); + } + } + + /// Request the shutdown of the queue. + /// + /// \warning This method must be called at some point if this completion queue + /// is accessed with Next or AsyncNext. \a Next will not return false + /// until this method has been called and all pending tags have been drained. + /// (Likewise for \a AsyncNext returning \a NextStatus::SHUTDOWN .) + /// Only once either one of these methods does that (that is, once the queue + /// has been \em drained) can an instance of this class be destroyed. + /// Also note that applications must ensure that no work is enqueued on this + /// completion queue after this method is called. + void Shutdown(); + + /// Returns a \em raw pointer to the underlying \a grpc_completion_queue + /// instance. + /// + /// \warning Remember that the returned instance is owned. No transfer of + /// owership is performed. + grpc_completion_queue* cq() { return cq_; } + + protected: + /// Private constructor of CompletionQueue only visible to friend classes + CompletionQueue(const grpc_completion_queue_attributes& attributes) { + cq_ = ::grpc::g_core_codegen_interface->grpc_completion_queue_create( + ::grpc::g_core_codegen_interface->grpc_completion_queue_factory_lookup( + &attributes), + &attributes, NULL); + InitialAvalanching(); // reserve this for the future shutdown + } + + private: + // Friend synchronous wrappers so that they can access Pluck(), which is + // a semi-private API geared towards the synchronous implementation. + template + friend class ::grpc_impl::ClientReader; + template + friend class ::grpc_impl::ClientWriter; + template + friend class ::grpc_impl::ClientReaderWriter; + template + friend class ::grpc_impl::ServerReader; + template + friend class ::grpc_impl::ServerWriter; + template + friend class ::grpc_impl::internal::ServerReaderWriterBody; + template + friend class ::grpc_impl::internal::RpcMethodHandler; + template + friend class ::grpc_impl::internal::ClientStreamingHandler; + template + friend class ::grpc_impl::internal::ServerStreamingHandler; + template + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler; + template <::grpc::StatusCode code> + friend class ::grpc_impl::internal::ErrorMethodHandler; + friend class ::grpc_impl::Server; + friend class ::grpc_impl::ServerContextBase; + friend class ::grpc::ServerInterface; + template + friend class ::grpc::internal::BlockingUnaryCallImpl; + + // Friends that need access to constructor for callback CQ + friend class ::grpc_impl::Channel; + + // For access to Register/CompleteAvalanching + template + friend class ::grpc::internal::CallOpSet; + + /// EXPERIMENTAL + /// Creates a Thread Local cache to store the first event + /// On this completion queue queued from this thread. Once + /// initialized, it must be flushed on the same thread. + class CompletionQueueTLSCache { + public: + CompletionQueueTLSCache(CompletionQueue* cq); + ~CompletionQueueTLSCache(); + bool Flush(void** tag, bool* ok); + + private: + CompletionQueue* cq_; + bool flushed_; + }; + + NextStatus AsyncNextInternal(void** tag, bool* ok, gpr_timespec deadline); + + /// Wraps \a grpc_completion_queue_pluck. + /// \warning Must not be mixed with calls to \a Next. + bool Pluck(::grpc::internal::CompletionQueueTag* tag) { + auto deadline = + ::grpc::g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME); + while (true) { + auto ev = ::grpc::g_core_codegen_interface->grpc_completion_queue_pluck( + cq_, tag, deadline, nullptr); + bool ok = ev.success != 0; + void* ignored = tag; + if (tag->FinalizeResult(&ignored, &ok)) { + GPR_CODEGEN_ASSERT(ignored == tag); + return ok; + } + } + } + + /// Performs a single polling pluck on \a tag. + /// \warning Must not be mixed with calls to \a Next. + /// + /// TODO: sreek - This calls tag->FinalizeResult() even if the cq_ is already + /// shutdown. This is most likely a bug and if it is a bug, then change this + /// implementation to simple call the other TryPluck function with a zero + /// timeout. i.e: + /// TryPluck(tag, gpr_time_0(GPR_CLOCK_REALTIME)) + void TryPluck(::grpc::internal::CompletionQueueTag* tag) { + auto deadline = + ::grpc::g_core_codegen_interface->gpr_time_0(GPR_CLOCK_REALTIME); + auto ev = ::grpc::g_core_codegen_interface->grpc_completion_queue_pluck( + cq_, tag, deadline, nullptr); + if (ev.type == GRPC_QUEUE_TIMEOUT) return; + bool ok = ev.success != 0; + void* ignored = tag; + // the tag must be swallowed if using TryPluck + GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); + } + + /// Performs a single polling pluck on \a tag. Calls tag->FinalizeResult if + /// the pluck() was successful and returned the tag. + /// + /// This exects tag->FinalizeResult (if called) to return 'false' i.e expects + /// that the tag is internal not something that is returned to the user. + void TryPluck(::grpc::internal::CompletionQueueTag* tag, + gpr_timespec deadline) { + auto ev = ::grpc::g_core_codegen_interface->grpc_completion_queue_pluck( + cq_, tag, deadline, nullptr); + if (ev.type == GRPC_QUEUE_TIMEOUT || ev.type == GRPC_QUEUE_SHUTDOWN) { + return; + } + + bool ok = ev.success != 0; + void* ignored = tag; + GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); + } + + /// Manage state of avalanching operations : completion queue tags that + /// trigger other completion queue operations. The underlying core completion + /// queue should not really shutdown until all avalanching operations have + /// been finalized. Note that we maintain the requirement that an avalanche + /// registration must take place before CQ shutdown (which must be maintained + /// elsehwere) + void InitialAvalanching() { + gpr_atm_rel_store(&avalanches_in_flight_, static_cast(1)); + } + void RegisterAvalanching() { + gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, + static_cast(1)); + } + void CompleteAvalanching() { + if (gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, + static_cast(-1)) == 1) { + ::grpc::g_core_codegen_interface->grpc_completion_queue_shutdown(cq_); + } + } + + grpc_completion_queue* cq_; // owned + + gpr_atm avalanches_in_flight_; +}; + +/// A specific type of completion queue used by the processing of notifications +/// by servers. Instantiated by \a ServerBuilder. +class ServerCompletionQueue : public CompletionQueue { + public: + bool IsFrequentlyPolled() { return polling_type_ != GRPC_CQ_NON_LISTENING; } + + protected: + /// Default constructor + ServerCompletionQueue() : polling_type_(GRPC_CQ_DEFAULT_POLLING) {} + + private: + /// \param completion_type indicates whether this is a NEXT or CALLBACK + /// completion queue. + /// \param polling_type Informs the GRPC library about the type of polling + /// allowed on this completion queue. See grpc_cq_polling_type's description + /// in grpc_types.h for more details. + /// \param shutdown_cb is the shutdown callback used for CALLBACK api queues + ServerCompletionQueue(grpc_cq_completion_type completion_type, + grpc_cq_polling_type polling_type, + grpc_experimental_completion_queue_functor* shutdown_cb) + : CompletionQueue(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, completion_type, polling_type, + shutdown_cb}), + polling_type_(polling_type) {} + + grpc_cq_polling_type polling_type_; + friend class ::grpc_impl::ServerBuilder; + friend class ::grpc_impl::Server; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/completion_queue_tag.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/completion_queue_tag.h new file mode 100644 index 0000000000000000000000000000000000000000..304386a9eccd6a0a6fed70fa9b8c7591bdcabbd6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/completion_queue_tag.h @@ -0,0 +1,54 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_TAG_H +#define GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_TAG_H + +namespace grpc { + +namespace internal { +/// An interface allowing implementors to process and filter event tags. +class CompletionQueueTag { + public: + virtual ~CompletionQueueTag() {} + + /// FinalizeResult must be called before informing user code that the + /// operation bound to the underlying core completion queue tag has + /// completed. In practice, this means: + /// + /// 1. For the sync API - before returning from Pluck + /// 2. For the CQ-based async API - before returning from Next + /// 3. For the callback-based API - before invoking the user callback + /// + /// This is the method that translates from core-side tag/status to + /// C++ API-observable tag/status. + /// + /// The return value is the status of the operation (returning status is the + /// general behavior of this function). If this function returns false, the + /// tag is dropped and not returned from the completion queue: this concept is + /// for events that are observed at core but not requested by the user + /// application (e.g., server shutdown, for server unimplemented method + /// responses, or for cases where a server-side RPC doesn't have a completion + /// notification registered using AsyncNotifyWhenDone) + virtual bool FinalizeResult(void** tag, bool* status) = 0; +}; +} // namespace internal + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_TAG_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/config.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/config.h new file mode 100644 index 0000000000000000000000000000000000000000..37f0fd1faf86cc17f3377b9626d3339d0423edcb --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/config.h @@ -0,0 +1,41 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CONFIG_H +#define GRPCPP_IMPL_CODEGEN_CONFIG_H + +#ifndef GRPC_CUSTOM_STRING +#include +#define GRPC_CUSTOM_STRING std::string +#endif + +/// The following macros are deprecated and appear only for users +/// with PB files generated using gRPC 1.0.x plugins. They should +/// not be used in new code +#define GRPC_OVERRIDE override // deprecated +#define GRPC_FINAL final // deprecated + +namespace grpc { + +typedef GRPC_CUSTOM_STRING string; + +using std::to_string; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CONFIG_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/config_protobuf.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/config_protobuf.h new file mode 100644 index 0000000000000000000000000000000000000000..c4012fb00c94d977359c0be96e22d1bc5e3e74e8 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/config_protobuf.h @@ -0,0 +1,104 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CONFIG_PROTOBUF_H +#define GRPCPP_IMPL_CODEGEN_CONFIG_PROTOBUF_H + +#define GRPC_OPEN_SOURCE_PROTO + +#ifndef GRPC_CUSTOM_MESSAGE +#ifdef GRPC_USE_PROTO_LITE +#include +#define GRPC_CUSTOM_MESSAGE ::google::protobuf::MessageLite +#define GRPC_CUSTOM_MESSAGELITE ::google::protobuf::MessageLite +#else +#include +#define GRPC_CUSTOM_MESSAGE ::google::protobuf::Message +#define GRPC_CUSTOM_MESSAGELITE ::google::protobuf::MessageLite +#endif +#endif + +#ifndef GRPC_CUSTOM_DESCRIPTOR +#include +#include +#define GRPC_CUSTOM_DESCRIPTOR ::google::protobuf::Descriptor +#define GRPC_CUSTOM_DESCRIPTORPOOL ::google::protobuf::DescriptorPool +#define GRPC_CUSTOM_FIELDDESCRIPTOR ::google::protobuf::FieldDescriptor +#define GRPC_CUSTOM_FILEDESCRIPTOR ::google::protobuf::FileDescriptor +#define GRPC_CUSTOM_FILEDESCRIPTORPROTO ::google::protobuf::FileDescriptorProto +#define GRPC_CUSTOM_METHODDESCRIPTOR ::google::protobuf::MethodDescriptor +#define GRPC_CUSTOM_SERVICEDESCRIPTOR ::google::protobuf::ServiceDescriptor +#define GRPC_CUSTOM_SOURCELOCATION ::google::protobuf::SourceLocation +#endif + +#ifndef GRPC_CUSTOM_DESCRIPTORDATABASE +#include +#define GRPC_CUSTOM_DESCRIPTORDATABASE ::google::protobuf::DescriptorDatabase +#define GRPC_CUSTOM_SIMPLEDESCRIPTORDATABASE \ + ::google::protobuf::SimpleDescriptorDatabase +#endif + +#ifndef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM +#include +#include +#define GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM \ + ::google::protobuf::io::ZeroCopyOutputStream +#define GRPC_CUSTOM_ZEROCOPYINPUTSTREAM \ + ::google::protobuf::io::ZeroCopyInputStream +#define GRPC_CUSTOM_CODEDINPUTSTREAM ::google::protobuf::io::CodedInputStream +#endif + +#ifndef GRPC_CUSTOM_JSONUTIL +#include +#define GRPC_CUSTOM_JSONUTIL ::google::protobuf::util +#define GRPC_CUSTOM_UTIL_STATUS ::google::protobuf::util::Status +#endif + +namespace grpc { +namespace protobuf { + +typedef GRPC_CUSTOM_MESSAGE Message; +typedef GRPC_CUSTOM_MESSAGELITE MessageLite; + +typedef GRPC_CUSTOM_DESCRIPTOR Descriptor; +typedef GRPC_CUSTOM_DESCRIPTORPOOL DescriptorPool; +typedef GRPC_CUSTOM_DESCRIPTORDATABASE DescriptorDatabase; +typedef GRPC_CUSTOM_FIELDDESCRIPTOR FieldDescriptor; +typedef GRPC_CUSTOM_FILEDESCRIPTOR FileDescriptor; +typedef GRPC_CUSTOM_FILEDESCRIPTORPROTO FileDescriptorProto; +typedef GRPC_CUSTOM_METHODDESCRIPTOR MethodDescriptor; +typedef GRPC_CUSTOM_SERVICEDESCRIPTOR ServiceDescriptor; +typedef GRPC_CUSTOM_SIMPLEDESCRIPTORDATABASE SimpleDescriptorDatabase; +typedef GRPC_CUSTOM_SOURCELOCATION SourceLocation; + +namespace util { +typedef GRPC_CUSTOM_UTIL_STATUS Status; +} // namespace util + +namespace json = GRPC_CUSTOM_JSONUTIL; + +namespace io { +typedef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream; +typedef GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream; +typedef GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream; +} // namespace io + +} // namespace protobuf +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CONFIG_PROTOBUF_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/core_codegen.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/core_codegen.h new file mode 100644 index 0000000000000000000000000000000000000000..50c8da4ffe7ee89237125c02a17e2599a1fe3a88 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/core_codegen.h @@ -0,0 +1,127 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CORE_CODEGEN_H +#define GRPCPP_IMPL_CODEGEN_CORE_CODEGEN_H + +// This file should be compiled as part of grpcpp. + +#include +#include +#include +#include + +namespace grpc { + +/// Implementation of the core codegen interface. +class CoreCodegen final : public CoreCodegenInterface { + private: + virtual const grpc_completion_queue_factory* + grpc_completion_queue_factory_lookup( + const grpc_completion_queue_attributes* attributes) override; + virtual grpc_completion_queue* grpc_completion_queue_create( + const grpc_completion_queue_factory* factory, + const grpc_completion_queue_attributes* attributes, + void* reserved) override; + grpc_completion_queue* grpc_completion_queue_create_for_next( + void* reserved) override; + grpc_completion_queue* grpc_completion_queue_create_for_pluck( + void* reserved) override; + void grpc_completion_queue_shutdown(grpc_completion_queue* cq) override; + void grpc_completion_queue_destroy(grpc_completion_queue* cq) override; + grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag, + gpr_timespec deadline, + void* reserved) override; + + void* gpr_malloc(size_t size) override; + void gpr_free(void* p) override; + + void grpc_init() override; + void grpc_shutdown() override; + + void gpr_mu_init(gpr_mu* mu) override; + void gpr_mu_destroy(gpr_mu* mu) override; + void gpr_mu_lock(gpr_mu* mu) override; + void gpr_mu_unlock(gpr_mu* mu) override; + void gpr_cv_init(gpr_cv* cv) override; + void gpr_cv_destroy(gpr_cv* cv) override; + int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) override; + void gpr_cv_signal(gpr_cv* cv) override; + void gpr_cv_broadcast(gpr_cv* cv) override; + + grpc_call_error grpc_call_start_batch(grpc_call* call, const grpc_op* ops, + size_t nops, void* tag, + void* reserved) override; + grpc_call_error grpc_call_cancel_with_status(grpc_call* call, + grpc_status_code status, + const char* description, + void* reserved) override; + void grpc_call_ref(grpc_call* call) override; + void grpc_call_unref(grpc_call* call) override; + void* grpc_call_arena_alloc(grpc_call* call, size_t length) override; + const char* grpc_call_error_to_string(grpc_call_error error) override; + + grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb) override; + void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) override; + size_t grpc_byte_buffer_length(grpc_byte_buffer* bb) override; + + int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader, + grpc_byte_buffer* buffer) override; + void grpc_byte_buffer_reader_destroy( + grpc_byte_buffer_reader* reader) override; + int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader, + grpc_slice* slice) override; + int grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader* reader, + grpc_slice** slice) override; + + grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slice, + size_t nslices) override; + grpc_slice grpc_slice_new_with_user_data(void* p, size_t len, + void (*destroy)(void*), + void* user_data) override; + grpc_slice grpc_slice_new_with_len(void* p, size_t len, + void (*destroy)(void*, size_t)) override; + grpc_slice grpc_empty_slice() override; + grpc_slice grpc_slice_malloc(size_t length) override; + void grpc_slice_unref(grpc_slice slice) override; + grpc_slice grpc_slice_ref(grpc_slice slice) override; + grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) override; + grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split) override; + grpc_slice grpc_slice_sub(grpc_slice s, size_t begin, size_t end) override; + void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice slice) override; + void grpc_slice_buffer_pop(grpc_slice_buffer* sb) override; + grpc_slice grpc_slice_from_static_buffer(const void* buffer, + size_t length) override; + grpc_slice grpc_slice_from_copied_buffer(const void* buffer, + size_t length) override; + void grpc_metadata_array_init(grpc_metadata_array* array) override; + void grpc_metadata_array_destroy(grpc_metadata_array* array) override; + + gpr_timespec gpr_inf_future(gpr_clock_type type) override; + gpr_timespec gpr_time_0(gpr_clock_type type) override; + + virtual const Status& ok() override; + virtual const Status& cancelled() override; + + void assert_fail(const char* failed_assertion, const char* file, + int line) override; +}; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CORE_CODEGEN_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/core_codegen_interface.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/core_codegen_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..c08cf6c683deef5701d100d0b893a75f5090f9b8 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/core_codegen_interface.h @@ -0,0 +1,164 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H +#define GRPCPP_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H + +#include +#include +#include +#include +#include +#include + +namespace grpc { + +/// Interface between the codegen library and the minimal subset of core +/// features required by the generated code. +/// +/// All undocumented methods are simply forwarding the call to their namesakes. +/// Please refer to their corresponding documentation for details. +/// +/// \warning This interface should be considered internal and private. +class CoreCodegenInterface { + public: + virtual ~CoreCodegenInterface() = default; + + /// Upon a failed assertion, log the error. + virtual void assert_fail(const char* failed_assertion, const char* file, + int line) = 0; + + virtual const grpc_completion_queue_factory* + grpc_completion_queue_factory_lookup( + const grpc_completion_queue_attributes* attributes) = 0; + virtual grpc_completion_queue* grpc_completion_queue_create( + const grpc_completion_queue_factory* factory, + const grpc_completion_queue_attributes* attributes, void* reserved) = 0; + virtual grpc_completion_queue* grpc_completion_queue_create_for_next( + void* reserved) = 0; + virtual grpc_completion_queue* grpc_completion_queue_create_for_pluck( + void* reserved) = 0; + virtual void grpc_completion_queue_shutdown(grpc_completion_queue* cq) = 0; + virtual void grpc_completion_queue_destroy(grpc_completion_queue* cq) = 0; + virtual grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, + void* tag, + gpr_timespec deadline, + void* reserved) = 0; + + virtual void* gpr_malloc(size_t size) = 0; + virtual void gpr_free(void* p) = 0; + + // These are only to be used to fix edge cases involving grpc_init and + // grpc_shutdown. Calling grpc_init from the codegen interface before + // the real grpc_init is called will cause a crash, so if you use this + // function, ensure that it is not the first call to grpc_init. + virtual void grpc_init() = 0; + virtual void grpc_shutdown() = 0; + + virtual void gpr_mu_init(gpr_mu* mu) = 0; + virtual void gpr_mu_destroy(gpr_mu* mu) = 0; + virtual void gpr_mu_lock(gpr_mu* mu) = 0; + virtual void gpr_mu_unlock(gpr_mu* mu) = 0; + virtual void gpr_cv_init(gpr_cv* cv) = 0; + virtual void gpr_cv_destroy(gpr_cv* cv) = 0; + virtual int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, + gpr_timespec abs_deadline) = 0; + virtual void gpr_cv_signal(gpr_cv* cv) = 0; + virtual void gpr_cv_broadcast(gpr_cv* cv) = 0; + + virtual grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb) = 0; + virtual void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) = 0; + virtual size_t grpc_byte_buffer_length(grpc_byte_buffer* bb) + GRPC_MUST_USE_RESULT = 0; + + virtual int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader, + grpc_byte_buffer* buffer) + GRPC_MUST_USE_RESULT = 0; + virtual void grpc_byte_buffer_reader_destroy( + grpc_byte_buffer_reader* reader) = 0; + virtual int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader, + grpc_slice* slice) = 0; + virtual int grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader* reader, + grpc_slice** slice) = 0; + + virtual grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slice, + size_t nslices) = 0; + virtual grpc_slice grpc_slice_new_with_user_data(void* p, size_t len, + void (*destroy)(void*), + void* user_data) = 0; + virtual grpc_slice grpc_slice_new_with_len(void* p, size_t len, + void (*destroy)(void*, + size_t)) = 0; + virtual grpc_call_error grpc_call_start_batch(grpc_call* call, + const grpc_op* ops, size_t nops, + void* tag, void* reserved) = 0; + virtual grpc_call_error grpc_call_cancel_with_status(grpc_call* call, + grpc_status_code status, + const char* description, + void* reserved) = 0; + virtual void grpc_call_ref(grpc_call* call) = 0; + virtual void grpc_call_unref(grpc_call* call) = 0; + virtual void* grpc_call_arena_alloc(grpc_call* call, size_t length) = 0; + virtual const char* grpc_call_error_to_string(grpc_call_error error) = 0; + virtual grpc_slice grpc_empty_slice() = 0; + virtual grpc_slice grpc_slice_malloc(size_t length) = 0; + virtual void grpc_slice_unref(grpc_slice slice) = 0; + virtual grpc_slice grpc_slice_ref(grpc_slice slice) = 0; + virtual grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) = 0; + virtual grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split) = 0; + virtual grpc_slice grpc_slice_sub(grpc_slice s, size_t begin, size_t end) = 0; + virtual void grpc_slice_buffer_add(grpc_slice_buffer* sb, + grpc_slice slice) = 0; + virtual void grpc_slice_buffer_pop(grpc_slice_buffer* sb) = 0; + virtual grpc_slice grpc_slice_from_static_buffer(const void* buffer, + size_t length) = 0; + virtual grpc_slice grpc_slice_from_copied_buffer(const void* buffer, + size_t length) = 0; + + virtual void grpc_metadata_array_init(grpc_metadata_array* array) = 0; + virtual void grpc_metadata_array_destroy(grpc_metadata_array* array) = 0; + + virtual const Status& ok() = 0; + virtual const Status& cancelled() = 0; + + virtual gpr_timespec gpr_inf_future(gpr_clock_type type) = 0; + virtual gpr_timespec gpr_time_0(gpr_clock_type type) = 0; +}; + +extern CoreCodegenInterface* g_core_codegen_interface; + +/// Codegen specific version of \a GPR_ASSERT. +#define GPR_CODEGEN_ASSERT(x) \ + do { \ + if (GPR_UNLIKELY(!(x))) { \ + grpc::g_core_codegen_interface->assert_fail(#x, __FILE__, __LINE__); \ + } \ + } while (0) + +/// Codegen specific version of \a GPR_DEBUG_ASSERT. +#ifndef NDEBUG +#define GPR_CODEGEN_DEBUG_ASSERT(x) GPR_CODEGEN_ASSERT(x) +#else +#define GPR_CODEGEN_DEBUG_ASSERT(x) \ + do { \ + } while (0) +#endif + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/create_auth_context.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/create_auth_context.h new file mode 100644 index 0000000000000000000000000000000000000000..cb6095c3a5af085f64735037b843b21c7c54c65b --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/create_auth_context.h @@ -0,0 +1,33 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_CREATE_AUTH_CONTEXT_H +#define GRPCPP_IMPL_CODEGEN_CREATE_AUTH_CONTEXT_H + +#include + +#include +#include + +namespace grpc { + +std::shared_ptr CreateAuthContext(grpc_call* call); + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CREATE_AUTH_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/delegating_channel.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/delegating_channel.h new file mode 100644 index 0000000000000000000000000000000000000000..a18622235f916faf2dab820051f67b4edc2a861c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/delegating_channel.h @@ -0,0 +1,87 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H +#define GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H + +namespace grpc { +namespace experimental { + +class DelegatingChannel : public ::grpc::ChannelInterface { + public: + virtual ~DelegatingChannel() {} + + DelegatingChannel(std::shared_ptr<::grpc::ChannelInterface> delegate_channel) + : delegate_channel_(delegate_channel) {} + + grpc_connectivity_state GetState(bool try_to_connect) override { + return delegate_channel()->GetState(try_to_connect); + } + + std::shared_ptr<::grpc::ChannelInterface> delegate_channel() { + return delegate_channel_; + } + + private: + internal::Call CreateCall(const internal::RpcMethod& method, + ClientContext* context, + ::grpc_impl::CompletionQueue* cq) final { + return delegate_channel()->CreateCall(method, context, cq); + } + + void PerformOpsOnCall(internal::CallOpSetInterface* ops, + internal::Call* call) final { + delegate_channel()->PerformOpsOnCall(ops, call); + } + + void* RegisterMethod(const char* method) final { + return delegate_channel()->RegisterMethod(method); + } + + void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline, + ::grpc_impl::CompletionQueue* cq, + void* tag) override { + delegate_channel()->NotifyOnStateChangeImpl(last_observed, deadline, cq, + tag); + } + + bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline) override { + return delegate_channel()->WaitForStateChangeImpl(last_observed, deadline); + } + + internal::Call CreateCallInternal(const internal::RpcMethod& method, + ClientContext* context, + ::grpc_impl::CompletionQueue* cq, + size_t interceptor_pos) final { + return delegate_channel()->CreateCallInternal(method, context, cq, + interceptor_pos); + } + + ::grpc_impl::CompletionQueue* CallbackCQ() final { + return delegate_channel()->CallbackCQ(); + } + + std::shared_ptr<::grpc::ChannelInterface> delegate_channel_; +}; + +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/grpc_library.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/grpc_library.h new file mode 100644 index 0000000000000000000000000000000000000000..17c904d71a1cf9ef5a863d3492fe6f615e16a85a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/grpc_library.h @@ -0,0 +1,64 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H +#define GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H + +#include + +namespace grpc { + +class GrpcLibraryInterface { + public: + virtual ~GrpcLibraryInterface() = default; + virtual void init() = 0; + virtual void shutdown() = 0; +}; + +/// Initialized by \a grpc::GrpcLibraryInitializer from +/// +extern GrpcLibraryInterface* g_glip; + +/// Classes that require gRPC to be initialized should inherit from this class. +class GrpcLibraryCodegen { + public: + GrpcLibraryCodegen(bool call_grpc_init = true) : grpc_init_called_(false) { + if (call_grpc_init) { + GPR_CODEGEN_ASSERT(g_glip && + "gRPC library not initialized. See " + "grpc::internal::GrpcLibraryInitializer."); + g_glip->init(); + grpc_init_called_ = true; + } + } + virtual ~GrpcLibraryCodegen() { + if (grpc_init_called_) { + GPR_CODEGEN_ASSERT(g_glip && + "gRPC library not initialized. See " + "grpc::internal::GrpcLibraryInitializer."); + g_glip->shutdown(); + } + } + + private: + bool grpc_init_called_; +}; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/intercepted_channel.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/intercepted_channel.h new file mode 100644 index 0000000000000000000000000000000000000000..bcdd89db7411402783e599f9ecff71639878918f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/intercepted_channel.h @@ -0,0 +1,87 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_INTERCEPTED_CHANNEL_H +#define GRPCPP_IMPL_CODEGEN_INTERCEPTED_CHANNEL_H + +#include + +namespace grpc_impl { +class CompletionQueue; +} + +namespace grpc { + +namespace internal { + +class InterceptorBatchMethodsImpl; + +/// An InterceptedChannel is available to client Interceptors. An +/// InterceptedChannel is unique to an interceptor, and when an RPC is started +/// on this channel, only those interceptors that come after this interceptor +/// see the RPC. +class InterceptedChannel : public ChannelInterface { + public: + virtual ~InterceptedChannel() { channel_ = nullptr; } + + /// Get the current channel state. If the channel is in IDLE and + /// \a try_to_connect is set to true, try to connect. + grpc_connectivity_state GetState(bool try_to_connect) override { + return channel_->GetState(try_to_connect); + } + + private: + InterceptedChannel(ChannelInterface* channel, size_t pos) + : channel_(channel), interceptor_pos_(pos) {} + + Call CreateCall(const RpcMethod& method, ::grpc_impl::ClientContext* context, + ::grpc_impl::CompletionQueue* cq) override { + return channel_->CreateCallInternal(method, context, cq, interceptor_pos_); + } + + void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) override { + return channel_->PerformOpsOnCall(ops, call); + } + void* RegisterMethod(const char* method) override { + return channel_->RegisterMethod(method); + } + + void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline, + ::grpc_impl::CompletionQueue* cq, + void* tag) override { + return channel_->NotifyOnStateChangeImpl(last_observed, deadline, cq, tag); + } + bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline) override { + return channel_->WaitForStateChangeImpl(last_observed, deadline); + } + + ::grpc_impl::CompletionQueue* CallbackCQ() override { + return channel_->CallbackCQ(); + } + + ChannelInterface* channel_; + size_t interceptor_pos_; + + friend class InterceptorBatchMethodsImpl; +}; +} // namespace internal +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_INTERCEPTED_CHANNEL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/interceptor.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/interceptor.h new file mode 100644 index 0000000000000000000000000000000000000000..18c7cf33e2fb57644475b38ad20c3a844f18c1b4 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/interceptor.h @@ -0,0 +1,227 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_INTERCEPTOR_H +#define GRPCPP_IMPL_CODEGEN_INTERCEPTOR_H + +#include +#include +#include +#include +#include + +namespace grpc { + +class ChannelInterface; +class Status; + +namespace experimental { + +/// An enumeration of different possible points at which the \a Intercept +/// method of the \a Interceptor interface may be called. Any given call +/// to \a Intercept will include one or more of these hook points, and +/// each hook point makes certain types of information available to the +/// interceptor. +/// In these enumeration names, PRE_SEND means that an interception has taken +/// place between the time the application provided a certain type of data +/// (e.g., initial metadata, status) and the time that that data goes to the +/// other side. POST_SEND means that the data has been committed for going to +/// the other side (even if it has not yet been received at the other side). +/// PRE_RECV means an interception between the time that a certain +/// operation has been requested and it is available. POST_RECV means that a +/// result is available but has not yet been passed back to the application. +/// A batch of interception points will only contain either PRE or POST hooks +/// but not both types. For example, a batch with PRE_SEND hook points will not +/// contain POST_RECV or POST_SEND ops. Likewise, a batch with POST_* ops can +/// not contain PRE_* ops. +enum class InterceptionHookPoints { + /// The first three in this list are for clients and servers + PRE_SEND_INITIAL_METADATA, + PRE_SEND_MESSAGE, + POST_SEND_MESSAGE, + PRE_SEND_STATUS, // server only + PRE_SEND_CLOSE, // client only: WritesDone for stream; after write in unary + /// The following three are for hijacked clients only. A batch with PRE_RECV_* + /// hook points will never contain hook points of other types. + PRE_RECV_INITIAL_METADATA, + PRE_RECV_MESSAGE, + PRE_RECV_STATUS, + /// The following two are for all clients and servers + POST_RECV_INITIAL_METADATA, + POST_RECV_MESSAGE, + POST_RECV_STATUS, // client only + POST_RECV_CLOSE, // server only + /// This is a special hook point available to both clients and servers when + /// TryCancel() is performed. + /// - No other hook points will be present along with this. + /// - It is illegal for an interceptor to block/delay this operation. + /// - ALL interceptors see this hook point irrespective of whether the + /// RPC was hijacked or not. + PRE_SEND_CANCEL, + NUM_INTERCEPTION_HOOKS +}; + +/// Class that is passed as an argument to the \a Intercept method +/// of the application's \a Interceptor interface implementation. It has five +/// purposes: +/// 1. Indicate which hook points are present at a specific interception +/// 2. Allow an interceptor to inform the library that an RPC should +/// continue to the next stage of its processing (which may be another +/// interceptor or the main path of the library) +/// 3. Allow an interceptor to hijack the processing of the RPC (only for +/// client-side RPCs with PRE_SEND_INITIAL_METADATA) so that it does not +/// proceed with normal processing beyond that stage +/// 4. Access the relevant fields of an RPC at each interception point +/// 5. Set some fields of an RPC at each interception point, when possible +class InterceptorBatchMethods { + public: + virtual ~InterceptorBatchMethods() {} + /// Determine whether the current batch has an interception hook point + /// of type \a type + virtual bool QueryInterceptionHookPoint(InterceptionHookPoints type) = 0; + /// Signal that the interceptor is done intercepting the current batch of the + /// RPC. Every interceptor must either call Proceed or Hijack on each + /// interception. In most cases, only Proceed will be used. Explicit use of + /// Proceed is what enables interceptors to delay the processing of RPCs + /// while they perform other work. + /// Proceed is a no-op if the batch contains PRE_SEND_CANCEL. Simply returning + /// from the Intercept method does the job of continuing the RPC in this case. + /// This is because PRE_SEND_CANCEL is always in a separate batch and is not + /// allowed to be delayed. + virtual void Proceed() = 0; + /// Indicate that the interceptor has hijacked the RPC (only valid if the + /// batch contains send_initial_metadata on the client side). Later + /// interceptors in the interceptor list will not be called. Later batches + /// on the same RPC will go through interception, but only up to the point + /// of the hijacking interceptor. + virtual void Hijack() = 0; + + /// Send Message Methods + /// GetSerializedSendMessage and GetSendMessage/ModifySendMessage are the + /// available methods to view and modify the request payload. An interceptor + /// can access the payload in either serialized form or non-serialized form + /// but not both at the same time. + /// gRPC performs serialization in a lazy manner, which means + /// that a call to GetSerializedSendMessage will result in a serialization + /// operation if the payload stored is not in the serialized form already; the + /// non-serialized form will be lost and GetSendMessage will no longer return + /// a valid pointer, and this will remain true for later interceptors too. + /// This can change however if ModifySendMessage is used to replace the + /// current payload. Note that ModifySendMessage requires a new payload + /// message in the non-serialized form. This will overwrite the existing + /// payload irrespective of whether it had been serialized earlier. Also note + /// that gRPC Async API requires early serialization of the payload which + /// means that the payload would be available in the serialized form only + /// unless an interceptor replaces the payload with ModifySendMessage. + + /// Returns a modifable ByteBuffer holding the serialized form of the message + /// that is going to be sent. Valid for PRE_SEND_MESSAGE interceptions. + /// A return value of nullptr indicates that this ByteBuffer is not valid. + virtual ByteBuffer* GetSerializedSendMessage() = 0; + + /// Returns a non-modifiable pointer to the non-serialized form of the message + /// to be sent. Valid for PRE_SEND_MESSAGE interceptions. A return value of + /// nullptr indicates that this field is not valid. + virtual const void* GetSendMessage() = 0; + + /// Overwrites the message to be sent with \a message. \a message should be in + /// the non-serialized form expected by the method. Valid for PRE_SEND_MESSAGE + /// interceptions. Note that the interceptor is responsible for maintaining + /// the life of the message till it is serialized or it receives the + /// POST_SEND_MESSAGE interception point, whichever happens earlier. The + /// modifying interceptor may itself force early serialization by calling + /// GetSerializedSendMessage. + virtual void ModifySendMessage(const void* message) = 0; + + /// Checks whether the SEND MESSAGE op succeeded. Valid for POST_SEND_MESSAGE + /// interceptions. + virtual bool GetSendMessageStatus() = 0; + + /// Returns a modifiable multimap of the initial metadata to be sent. Valid + /// for PRE_SEND_INITIAL_METADATA interceptions. A value of nullptr indicates + /// that this field is not valid. + virtual std::multimap* + GetSendInitialMetadata() = 0; + + /// Returns the status to be sent. Valid for PRE_SEND_STATUS interceptions. + virtual Status GetSendStatus() = 0; + + /// Overwrites the status with \a status. Valid for PRE_SEND_STATUS + /// interceptions. + virtual void ModifySendStatus(const Status& status) = 0; + + /// Returns a modifiable multimap of the trailing metadata to be sent. Valid + /// for PRE_SEND_STATUS interceptions. A value of nullptr indicates + /// that this field is not valid. + virtual std::multimap* + GetSendTrailingMetadata() = 0; + + /// Returns a pointer to the modifiable received message. Note that the + /// message is already deserialized but the type is not set; the interceptor + /// should static_cast to the appropriate type before using it. This is valid + /// for PRE_RECV_MESSAGE and POST_RECV_MESSAGE interceptions; nullptr for not + /// valid + virtual void* GetRecvMessage() = 0; + + /// Returns a modifiable multimap of the received initial metadata. + /// Valid for PRE_RECV_INITIAL_METADATA and POST_RECV_INITIAL_METADATA + /// interceptions; nullptr if not valid + virtual std::multimap* + GetRecvInitialMetadata() = 0; + + /// Returns a modifiable view of the received status on PRE_RECV_STATUS and + /// POST_RECV_STATUS interceptions; nullptr if not valid. + virtual Status* GetRecvStatus() = 0; + + /// Returns a modifiable multimap of the received trailing metadata on + /// PRE_RECV_STATUS and POST_RECV_STATUS interceptions; nullptr if not valid + virtual std::multimap* + GetRecvTrailingMetadata() = 0; + + /// Gets an intercepted channel. When a call is started on this interceptor, + /// only interceptors after the current interceptor are created from the + /// factory objects registered with the channel. This allows calls to be + /// started from interceptors without infinite regress through the interceptor + /// list. + virtual std::unique_ptr GetInterceptedChannel() = 0; + + /// On a hijacked RPC, an interceptor can decide to fail a PRE_RECV_MESSAGE + /// op. This would be a signal to the reader that there will be no more + /// messages, or the stream has failed or been cancelled. + virtual void FailHijackedRecvMessage() = 0; + + /// On a hijacked RPC/ to-be hijacked RPC, this can be called to fail a SEND + /// MESSAGE op + virtual void FailHijackedSendMessage() = 0; +}; + +/// Interface for an interceptor. Interceptor authors must create a class +/// that derives from this parent class. +class Interceptor { + public: + virtual ~Interceptor() {} + + /// The one public method of an Interceptor interface. Override this to + /// trigger the desired actions at the hook points described above. + virtual void Intercept(InterceptorBatchMethods* methods) = 0; +}; + +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_INTERCEPTOR_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/interceptor_common.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/interceptor_common.h new file mode 100644 index 0000000000000000000000000000000000000000..01ffe19bc4a926b6ea021f12237a1c20d6f5b65c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/interceptor_common.h @@ -0,0 +1,556 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_INTERCEPTOR_COMMON_H +#define GRPCPP_IMPL_CODEGEN_INTERCEPTOR_COMMON_H + +#include +#include + +#include +#include +#include +#include +#include + +#include + +namespace grpc { +namespace internal { + +class InterceptorBatchMethodsImpl + : public experimental::InterceptorBatchMethods { + public: + InterceptorBatchMethodsImpl() { + for (auto i = static_cast(0); + i < experimental::InterceptionHookPoints::NUM_INTERCEPTION_HOOKS; + i = static_cast( + static_cast(i) + 1)) { + hooks_[static_cast(i)] = false; + } + } + + ~InterceptorBatchMethodsImpl() {} + + bool QueryInterceptionHookPoint( + experimental::InterceptionHookPoints type) override { + return hooks_[static_cast(type)]; + } + + void Proceed() override { + if (call_->client_rpc_info() != nullptr) { + return ProceedClient(); + } + GPR_CODEGEN_ASSERT(call_->server_rpc_info() != nullptr); + ProceedServer(); + } + + void Hijack() override { + // Only the client can hijack when sending down initial metadata + GPR_CODEGEN_ASSERT(!reverse_ && ops_ != nullptr && + call_->client_rpc_info() != nullptr); + // It is illegal to call Hijack twice + GPR_CODEGEN_ASSERT(!ran_hijacking_interceptor_); + auto* rpc_info = call_->client_rpc_info(); + rpc_info->hijacked_ = true; + rpc_info->hijacked_interceptor_ = current_interceptor_index_; + ClearHookPoints(); + ops_->SetHijackingState(); + ran_hijacking_interceptor_ = true; + rpc_info->RunInterceptor(this, current_interceptor_index_); + } + + void AddInterceptionHookPoint(experimental::InterceptionHookPoints type) { + hooks_[static_cast(type)] = true; + } + + ByteBuffer* GetSerializedSendMessage() override { + GPR_CODEGEN_ASSERT(orig_send_message_ != nullptr); + if (*orig_send_message_ != nullptr) { + GPR_CODEGEN_ASSERT(serializer_(*orig_send_message_).ok()); + *orig_send_message_ = nullptr; + } + return send_message_; + } + + const void* GetSendMessage() override { + GPR_CODEGEN_ASSERT(orig_send_message_ != nullptr); + return *orig_send_message_; + } + + void ModifySendMessage(const void* message) override { + GPR_CODEGEN_ASSERT(orig_send_message_ != nullptr); + *orig_send_message_ = message; + } + + bool GetSendMessageStatus() override { return !*fail_send_message_; } + + std::multimap* GetSendInitialMetadata() override { + return send_initial_metadata_; + } + + Status GetSendStatus() override { + return Status(static_cast(*code_), *error_message_, + *error_details_); + } + + void ModifySendStatus(const Status& status) override { + *code_ = static_cast(status.error_code()); + *error_details_ = status.error_details(); + *error_message_ = status.error_message(); + } + + std::multimap* GetSendTrailingMetadata() + override { + return send_trailing_metadata_; + } + + void* GetRecvMessage() override { return recv_message_; } + + std::multimap* GetRecvInitialMetadata() + override { + return recv_initial_metadata_->map(); + } + + Status* GetRecvStatus() override { return recv_status_; } + + void FailHijackedSendMessage() override { + GPR_CODEGEN_ASSERT(hooks_[static_cast( + experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)]); + *fail_send_message_ = true; + } + + std::multimap* GetRecvTrailingMetadata() + override { + return recv_trailing_metadata_->map(); + } + + void SetSendMessage(ByteBuffer* buf, const void** msg, + bool* fail_send_message, + std::function serializer) { + send_message_ = buf; + orig_send_message_ = msg; + fail_send_message_ = fail_send_message; + serializer_ = serializer; + } + + void SetSendInitialMetadata( + std::multimap* metadata) { + send_initial_metadata_ = metadata; + } + + void SetSendStatus(grpc_status_code* code, grpc::string* error_details, + grpc::string* error_message) { + code_ = code; + error_details_ = error_details; + error_message_ = error_message; + } + + void SetSendTrailingMetadata( + std::multimap* metadata) { + send_trailing_metadata_ = metadata; + } + + void SetRecvMessage(void* message, bool* got_message) { + recv_message_ = message; + got_message_ = got_message; + } + + void SetRecvInitialMetadata(MetadataMap* map) { + recv_initial_metadata_ = map; + } + + void SetRecvStatus(Status* status) { recv_status_ = status; } + + void SetRecvTrailingMetadata(MetadataMap* map) { + recv_trailing_metadata_ = map; + } + + std::unique_ptr GetInterceptedChannel() override { + auto* info = call_->client_rpc_info(); + if (info == nullptr) { + return std::unique_ptr(nullptr); + } + // The intercepted channel starts from the interceptor just after the + // current interceptor + return std::unique_ptr(new InterceptedChannel( + info->channel(), current_interceptor_index_ + 1)); + } + + void FailHijackedRecvMessage() override { + GPR_CODEGEN_ASSERT(hooks_[static_cast( + experimental::InterceptionHookPoints::PRE_RECV_MESSAGE)]); + *got_message_ = false; + } + + // Clears all state + void ClearState() { + reverse_ = false; + ran_hijacking_interceptor_ = false; + ClearHookPoints(); + } + + // Prepares for Post_recv operations + void SetReverse() { + reverse_ = true; + ran_hijacking_interceptor_ = false; + ClearHookPoints(); + } + + // This needs to be set before interceptors are run + void SetCall(Call* call) { call_ = call; } + + // This needs to be set before interceptors are run using RunInterceptors(). + // Alternatively, RunInterceptors(std::function f) can be used. + void SetCallOpSetInterface(CallOpSetInterface* ops) { ops_ = ops; } + + // SetCall should have been called before this. + // Returns true if the interceptors list is empty + bool InterceptorsListEmpty() { + auto* client_rpc_info = call_->client_rpc_info(); + if (client_rpc_info != nullptr) { + if (client_rpc_info->interceptors_.size() == 0) { + return true; + } else { + return false; + } + } + + auto* server_rpc_info = call_->server_rpc_info(); + if (server_rpc_info == nullptr || + server_rpc_info->interceptors_.size() == 0) { + return true; + } + return false; + } + + // This should be used only by subclasses of CallOpSetInterface. SetCall and + // SetCallOpSetInterface should have been called before this. After all the + // interceptors are done running, either ContinueFillOpsAfterInterception or + // ContinueFinalizeOpsAfterInterception will be called. Note that neither of + // them is invoked if there were no interceptors registered. + bool RunInterceptors() { + GPR_CODEGEN_ASSERT(ops_); + auto* client_rpc_info = call_->client_rpc_info(); + if (client_rpc_info != nullptr) { + if (client_rpc_info->interceptors_.size() == 0) { + return true; + } else { + RunClientInterceptors(); + return false; + } + } + + auto* server_rpc_info = call_->server_rpc_info(); + if (server_rpc_info == nullptr || + server_rpc_info->interceptors_.size() == 0) { + return true; + } + RunServerInterceptors(); + return false; + } + + // Returns true if no interceptors are run. Returns false otherwise if there + // are interceptors registered. After the interceptors are done running \a f + // will be invoked. This is to be used only by BaseAsyncRequest and + // SyncRequest. + bool RunInterceptors(std::function f) { + // This is used only by the server for initial call request + GPR_CODEGEN_ASSERT(reverse_ == true); + GPR_CODEGEN_ASSERT(call_->client_rpc_info() == nullptr); + auto* server_rpc_info = call_->server_rpc_info(); + if (server_rpc_info == nullptr || + server_rpc_info->interceptors_.size() == 0) { + return true; + } + callback_ = std::move(f); + RunServerInterceptors(); + return false; + } + + private: + void RunClientInterceptors() { + auto* rpc_info = call_->client_rpc_info(); + if (!reverse_) { + current_interceptor_index_ = 0; + } else { + if (rpc_info->hijacked_) { + current_interceptor_index_ = rpc_info->hijacked_interceptor_; + } else { + current_interceptor_index_ = rpc_info->interceptors_.size() - 1; + } + } + rpc_info->RunInterceptor(this, current_interceptor_index_); + } + + void RunServerInterceptors() { + auto* rpc_info = call_->server_rpc_info(); + if (!reverse_) { + current_interceptor_index_ = 0; + } else { + current_interceptor_index_ = rpc_info->interceptors_.size() - 1; + } + rpc_info->RunInterceptor(this, current_interceptor_index_); + } + + void ProceedClient() { + auto* rpc_info = call_->client_rpc_info(); + if (rpc_info->hijacked_ && !reverse_ && + current_interceptor_index_ == rpc_info->hijacked_interceptor_ && + !ran_hijacking_interceptor_) { + // We now need to provide hijacked recv ops to this interceptor + ClearHookPoints(); + ops_->SetHijackingState(); + ran_hijacking_interceptor_ = true; + rpc_info->RunInterceptor(this, current_interceptor_index_); + return; + } + if (!reverse_) { + current_interceptor_index_++; + // We are going down the stack of interceptors + if (current_interceptor_index_ < rpc_info->interceptors_.size()) { + if (rpc_info->hijacked_ && + current_interceptor_index_ > rpc_info->hijacked_interceptor_) { + // This is a hijacked RPC and we are done with hijacking + ops_->ContinueFillOpsAfterInterception(); + } else { + rpc_info->RunInterceptor(this, current_interceptor_index_); + } + } else { + // we are done running all the interceptors without any hijacking + ops_->ContinueFillOpsAfterInterception(); + } + } else { + // We are going up the stack of interceptors + if (current_interceptor_index_ > 0) { + // Continue running interceptors + current_interceptor_index_--; + rpc_info->RunInterceptor(this, current_interceptor_index_); + } else { + // we are done running all the interceptors without any hijacking + ops_->ContinueFinalizeResultAfterInterception(); + } + } + } + + void ProceedServer() { + auto* rpc_info = call_->server_rpc_info(); + if (!reverse_) { + current_interceptor_index_++; + if (current_interceptor_index_ < rpc_info->interceptors_.size()) { + return rpc_info->RunInterceptor(this, current_interceptor_index_); + } else if (ops_) { + return ops_->ContinueFillOpsAfterInterception(); + } + } else { + // We are going up the stack of interceptors + if (current_interceptor_index_ > 0) { + // Continue running interceptors + current_interceptor_index_--; + return rpc_info->RunInterceptor(this, current_interceptor_index_); + } else if (ops_) { + return ops_->ContinueFinalizeResultAfterInterception(); + } + } + GPR_CODEGEN_ASSERT(callback_); + callback_(); + } + + void ClearHookPoints() { + for (auto i = static_cast(0); + i < experimental::InterceptionHookPoints::NUM_INTERCEPTION_HOOKS; + i = static_cast( + static_cast(i) + 1)) { + hooks_[static_cast(i)] = false; + } + } + + std::array( + experimental::InterceptionHookPoints::NUM_INTERCEPTION_HOOKS)> + hooks_; + + size_t current_interceptor_index_ = 0; // Current iterator + bool reverse_ = false; + bool ran_hijacking_interceptor_ = false; + Call* call_ = nullptr; // The Call object is present along with CallOpSet + // object/callback + CallOpSetInterface* ops_ = nullptr; + std::function callback_; + + ByteBuffer* send_message_ = nullptr; + bool* fail_send_message_ = nullptr; + const void** orig_send_message_ = nullptr; + std::function serializer_; + + std::multimap* send_initial_metadata_; + + grpc_status_code* code_ = nullptr; + grpc::string* error_details_ = nullptr; + grpc::string* error_message_ = nullptr; + + std::multimap* send_trailing_metadata_ = nullptr; + + void* recv_message_ = nullptr; + bool* got_message_ = nullptr; + + MetadataMap* recv_initial_metadata_ = nullptr; + + Status* recv_status_ = nullptr; + + MetadataMap* recv_trailing_metadata_ = nullptr; +}; + +// A special implementation of InterceptorBatchMethods to send a Cancel +// notification down the interceptor stack +class CancelInterceptorBatchMethods + : public experimental::InterceptorBatchMethods { + public: + bool QueryInterceptionHookPoint( + experimental::InterceptionHookPoints type) override { + if (type == experimental::InterceptionHookPoints::PRE_SEND_CANCEL) { + return true; + } else { + return false; + } + } + + void Proceed() override { + // This is a no-op. For actual continuation of the RPC simply needs to + // return from the Intercept method + } + + void Hijack() override { + // Only the client can hijack when sending down initial metadata + GPR_CODEGEN_ASSERT(false && + "It is illegal to call Hijack on a method which has a " + "Cancel notification"); + } + + ByteBuffer* GetSerializedSendMessage() override { + GPR_CODEGEN_ASSERT(false && + "It is illegal to call GetSendMessage on a method which " + "has a Cancel notification"); + return nullptr; + } + + bool GetSendMessageStatus() override { + GPR_CODEGEN_ASSERT( + false && + "It is illegal to call GetSendMessageStatus on a method which " + "has a Cancel notification"); + return false; + } + + const void* GetSendMessage() override { + GPR_CODEGEN_ASSERT( + false && + "It is illegal to call GetOriginalSendMessage on a method which " + "has a Cancel notification"); + return nullptr; + } + + void ModifySendMessage(const void* /*message*/) override { + GPR_CODEGEN_ASSERT( + false && + "It is illegal to call ModifySendMessage on a method which " + "has a Cancel notification"); + } + + std::multimap* GetSendInitialMetadata() override { + GPR_CODEGEN_ASSERT(false && + "It is illegal to call GetSendInitialMetadata on a " + "method which has a Cancel notification"); + return nullptr; + } + + Status GetSendStatus() override { + GPR_CODEGEN_ASSERT(false && + "It is illegal to call GetSendStatus on a method which " + "has a Cancel notification"); + return Status(); + } + + void ModifySendStatus(const Status& /*status*/) override { + GPR_CODEGEN_ASSERT(false && + "It is illegal to call ModifySendStatus on a method " + "which has a Cancel notification"); + return; + } + + std::multimap* GetSendTrailingMetadata() + override { + GPR_CODEGEN_ASSERT(false && + "It is illegal to call GetSendTrailingMetadata on a " + "method which has a Cancel notification"); + return nullptr; + } + + void* GetRecvMessage() override { + GPR_CODEGEN_ASSERT(false && + "It is illegal to call GetRecvMessage on a method which " + "has a Cancel notification"); + return nullptr; + } + + std::multimap* GetRecvInitialMetadata() + override { + GPR_CODEGEN_ASSERT(false && + "It is illegal to call GetRecvInitialMetadata on a " + "method which has a Cancel notification"); + return nullptr; + } + + Status* GetRecvStatus() override { + GPR_CODEGEN_ASSERT(false && + "It is illegal to call GetRecvStatus on a method which " + "has a Cancel notification"); + return nullptr; + } + + std::multimap* GetRecvTrailingMetadata() + override { + GPR_CODEGEN_ASSERT(false && + "It is illegal to call GetRecvTrailingMetadata on a " + "method which has a Cancel notification"); + return nullptr; + } + + std::unique_ptr GetInterceptedChannel() override { + GPR_CODEGEN_ASSERT(false && + "It is illegal to call GetInterceptedChannel on a " + "method which has a Cancel notification"); + return std::unique_ptr(nullptr); + } + + void FailHijackedRecvMessage() override { + GPR_CODEGEN_ASSERT(false && + "It is illegal to call FailHijackedRecvMessage on a " + "method which has a Cancel notification"); + } + + void FailHijackedSendMessage() override { + GPR_CODEGEN_ASSERT(false && + "It is illegal to call FailHijackedSendMessage on a " + "method which has a Cancel notification"); + } +}; +} // namespace internal +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_INTERCEPTOR_COMMON_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/message_allocator.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/message_allocator.h new file mode 100644 index 0000000000000000000000000000000000000000..4048ea119744ba657f3a62d9e74424809f670e25 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/message_allocator.h @@ -0,0 +1,93 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H +#define GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H + +namespace grpc { +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL +namespace experimental { +#endif + +// NOTE: This is an API for advanced users who need custom allocators. +// Per rpc struct for the allocator. This is the interface to return to user. +class RpcAllocatorState { + public: + virtual ~RpcAllocatorState() = default; + // Optionally deallocate request early to reduce the size of working set. + // A custom MessageAllocator needs to be registered to make use of this. + // This is not abstract because implementing it is optional. + virtual void FreeRequest() {} +}; + +// This is the interface returned by the allocator. +// grpc library will call the methods to get request/response pointers and to +// release the object when it is done. +template +class MessageHolder : public RpcAllocatorState { + public: + // Release this object. For example, if the custom allocator's + // AllocateMessasge creates an instance of a subclass with new, the Release() + // should do a "delete this;". + virtual void Release() = 0; + RequestT* request() { return request_; } + ResponseT* response() { return response_; } + + protected: + void set_request(RequestT* request) { request_ = request; } + void set_response(ResponseT* response) { response_ = response; } + + private: + // NOTE: subclasses should set these pointers. + RequestT* request_; + ResponseT* response_; +}; + +// A custom allocator can be set via the generated code to a callback unary +// method, such as SetMessageAllocatorFor_Echo(custom_allocator). The allocator +// needs to be alive for the lifetime of the server. +// Implementations need to be thread-safe. +template +class MessageAllocator { + public: + virtual ~MessageAllocator() = default; + virtual MessageHolder* AllocateMessages() = 0; +}; + +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL +} // namespace experimental +#endif + +// TODO(vjpai): Remove namespace experimental when de-experimentalized fully. +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL +namespace experimental { + +using ::grpc::RpcAllocatorState; + +template +using MessageHolder = ::grpc::MessageHolder; + +template +using MessageAllocator = ::grpc::MessageAllocator; + +} // namespace experimental +#endif + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/metadata_map.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/metadata_map.h new file mode 100644 index 0000000000000000000000000000000000000000..9cec54d9f01c08f6156e261980515a6e51947f71 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/metadata_map.h @@ -0,0 +1,105 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_METADATA_MAP_H +#define GRPCPP_IMPL_CODEGEN_METADATA_MAP_H + +#include + +#include +#include + +namespace grpc { + +namespace internal { + +const char kBinaryErrorDetailsKey[] = "grpc-status-details-bin"; + +class MetadataMap { + public: + MetadataMap() { Setup(); } + + ~MetadataMap() { Destroy(); } + + grpc::string GetBinaryErrorDetails() { + // if filled_, extract from the multimap for O(log(n)) + if (filled_) { + auto iter = map_.find(kBinaryErrorDetailsKey); + if (iter != map_.end()) { + return grpc::string(iter->second.begin(), iter->second.length()); + } + } + // if not yet filled, take the O(n) lookup to avoid allocating the + // multimap until it is requested. + // TODO(ncteisen): plumb this through core as a first class object, just + // like code and message. + else { + for (size_t i = 0; i < arr_.count; i++) { + if (strncmp(reinterpret_cast( + GRPC_SLICE_START_PTR(arr_.metadata[i].key)), + kBinaryErrorDetailsKey, + GRPC_SLICE_LENGTH(arr_.metadata[i].key)) == 0) { + return grpc::string(reinterpret_cast( + GRPC_SLICE_START_PTR(arr_.metadata[i].value)), + GRPC_SLICE_LENGTH(arr_.metadata[i].value)); + } + } + } + return grpc::string(); + } + + std::multimap* map() { + FillMap(); + return &map_; + } + grpc_metadata_array* arr() { return &arr_; } + + void Reset() { + filled_ = false; + map_.clear(); + Destroy(); + Setup(); + } + + private: + bool filled_ = false; + grpc_metadata_array arr_; + std::multimap map_; + + void Destroy() { + g_core_codegen_interface->grpc_metadata_array_destroy(&arr_); + } + + void Setup() { memset(&arr_, 0, sizeof(arr_)); } + + void FillMap() { + if (filled_) return; + filled_ = true; + for (size_t i = 0; i < arr_.count; i++) { + // TODO(yangg) handle duplicates? + map_.insert(std::pair( + StringRefFromSlice(&arr_.metadata[i].key), + StringRefFromSlice(&arr_.metadata[i].value))); + } + } +}; +} // namespace internal + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_METADATA_MAP_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/method_handler.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/method_handler.h new file mode 100644 index 0000000000000000000000000000000000000000..4b0f594f23779a7fe41e9dcdceedec6abeb99c8d --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/method_handler.h @@ -0,0 +1,73 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H +#define GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H + +#include + +namespace grpc { + +namespace internal { + +template +using BidiStreamingHandler = + ::grpc_impl::internal::BidiStreamingHandler; + +template +using RpcMethodHandler = + ::grpc_impl::internal::RpcMethodHandler; + +template +using ClientStreamingHandler = + ::grpc_impl::internal::ClientStreamingHandler; + +template +using ServerStreamingHandler = + ::grpc_impl::internal::ServerStreamingHandler; + +template +using TemplatedBidiStreamingHandler = + ::grpc_impl::internal::TemplatedBidiStreamingHandler; + +template +using StreamedUnaryHandler = + ::grpc_impl::internal::StreamedUnaryHandler; + +template +using SplitServerStreamingHandler = + ::grpc_impl::internal::SplitServerStreamingHandler; + +template +using ErrorMethodHandler = ::grpc_impl::internal::ErrorMethodHandler; + +using UnknownMethodHandler = ::grpc_impl::internal::UnknownMethodHandler; + +using ResourceExhaustedHandler = + ::grpc_impl::internal::ResourceExhaustedHandler; + +} // namespace internal + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/method_handler_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/method_handler_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..6368b63e1ab1d809fd34157707c4b8b375a84f9b --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/method_handler_impl.h @@ -0,0 +1,388 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H +#define GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H + +#include +#include +#include +#include + +namespace grpc_impl { + +namespace internal { + +// Invoke the method handler, fill in the status, and +// return whether or not we finished safely (without an exception). +// Note that exception handling is 0-cost in most compiler/library +// implementations (except when an exception is actually thrown), +// so this process doesn't require additional overhead in the common case. +// Additionally, we don't need to return if we caught an exception or not; +// the handling is the same in either case. +template +::grpc::Status CatchingFunctionHandler(Callable&& handler) { +#if GRPC_ALLOW_EXCEPTIONS + try { + return handler(); + } catch (...) { + return ::grpc::Status(::grpc::StatusCode::UNKNOWN, + "Unexpected error in RPC handling"); + } +#else // GRPC_ALLOW_EXCEPTIONS + return handler(); +#endif // GRPC_ALLOW_EXCEPTIONS +} + +/// A wrapper class of an application provided rpc method handler. +template +class RpcMethodHandler : public ::grpc::internal::MethodHandler { + public: + RpcMethodHandler( + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + const RequestType*, ResponseType*)> + func, + ServiceType* service) + : func_(func), service_(service) {} + + void RunHandler(const HandlerParameter& param) final { + ResponseType rsp; + ::grpc::Status status = param.status; + if (status.ok()) { + status = CatchingFunctionHandler([this, ¶m, &rsp] { + return func_( + service_, + static_cast<::grpc_impl::ServerContext*>(param.server_context), + static_cast(param.request), &rsp); + }); + static_cast(param.request)->~RequestType(); + } + + GPR_CODEGEN_ASSERT(!param.server_context->sent_initial_metadata_); + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + ops; + ops.SendInitialMetadata(¶m.server_context->initial_metadata_, + param.server_context->initial_metadata_flags()); + if (param.server_context->compression_level_set()) { + ops.set_compression_level(param.server_context->compression_level()); + } + if (status.ok()) { + status = ops.SendMessagePtr(&rsp); + } + ops.ServerSendStatus(¶m.server_context->trailing_metadata_, status); + param.call->PerformOps(&ops); + param.call->cq()->Pluck(&ops); + } + + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** /*handler_data*/) final { + ::grpc::ByteBuffer buf; + buf.set_buffer(req); + auto* request = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(RequestType))) RequestType(); + *status = + ::grpc::SerializationTraits::Deserialize(&buf, request); + buf.Release(); + if (status->ok()) { + return request; + } + request->~RequestType(); + return nullptr; + } + + private: + /// Application provided rpc handler function. + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + const RequestType*, ResponseType*)> + func_; + // The class the above handler function lives in. + ServiceType* service_; +}; + +/// A wrapper class of an application provided client streaming handler. +template +class ClientStreamingHandler : public ::grpc::internal::MethodHandler { + public: + ClientStreamingHandler( + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + ::grpc_impl::ServerReader*, + ResponseType*)> + func, + ServiceType* service) + : func_(func), service_(service) {} + + void RunHandler(const HandlerParameter& param) final { + ::grpc_impl::ServerReader reader( + param.call, + static_cast<::grpc_impl::ServerContext*>(param.server_context)); + ResponseType rsp; + ::grpc::Status status = + CatchingFunctionHandler([this, ¶m, &reader, &rsp] { + return func_( + service_, + static_cast<::grpc_impl::ServerContext*>(param.server_context), + &reader, &rsp); + }); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + ops; + if (!param.server_context->sent_initial_metadata_) { + ops.SendInitialMetadata(¶m.server_context->initial_metadata_, + param.server_context->initial_metadata_flags()); + if (param.server_context->compression_level_set()) { + ops.set_compression_level(param.server_context->compression_level()); + } + } + if (status.ok()) { + status = ops.SendMessagePtr(&rsp); + } + ops.ServerSendStatus(¶m.server_context->trailing_metadata_, status); + param.call->PerformOps(&ops); + param.call->cq()->Pluck(&ops); + } + + private: + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + ::grpc_impl::ServerReader*, + ResponseType*)> + func_; + ServiceType* service_; +}; + +/// A wrapper class of an application provided server streaming handler. +template +class ServerStreamingHandler : public ::grpc::internal::MethodHandler { + public: + ServerStreamingHandler( + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + const RequestType*, + ::grpc_impl::ServerWriter*)> + func, + ServiceType* service) + : func_(func), service_(service) {} + + void RunHandler(const HandlerParameter& param) final { + ::grpc::Status status = param.status; + if (status.ok()) { + ::grpc_impl::ServerWriter writer( + param.call, + static_cast<::grpc_impl::ServerContext*>(param.server_context)); + status = CatchingFunctionHandler([this, ¶m, &writer] { + return func_( + service_, + static_cast<::grpc_impl::ServerContext*>(param.server_context), + static_cast(param.request), &writer); + }); + static_cast(param.request)->~RequestType(); + } + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + ops; + if (!param.server_context->sent_initial_metadata_) { + ops.SendInitialMetadata(¶m.server_context->initial_metadata_, + param.server_context->initial_metadata_flags()); + if (param.server_context->compression_level_set()) { + ops.set_compression_level(param.server_context->compression_level()); + } + } + ops.ServerSendStatus(¶m.server_context->trailing_metadata_, status); + param.call->PerformOps(&ops); + if (param.server_context->has_pending_ops_) { + param.call->cq()->Pluck(¶m.server_context->pending_ops_); + } + param.call->cq()->Pluck(&ops); + } + + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** /*handler_data*/) final { + ::grpc::ByteBuffer buf; + buf.set_buffer(req); + auto* request = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(RequestType))) RequestType(); + *status = + ::grpc::SerializationTraits::Deserialize(&buf, request); + buf.Release(); + if (status->ok()) { + return request; + } + request->~RequestType(); + return nullptr; + } + + private: + std::function<::grpc::Status(ServiceType*, ::grpc_impl::ServerContext*, + const RequestType*, + ::grpc_impl::ServerWriter*)> + func_; + ServiceType* service_; +}; + +/// A wrapper class of an application provided bidi-streaming handler. +/// This also applies to server-streamed implementation of a unary method +/// with the additional requirement that such methods must have done a +/// write for status to be ok +/// Since this is used by more than 1 class, the service is not passed in. +/// Instead, it is expected to be an implicitly-captured argument of func +/// (through bind or something along those lines) +template +class TemplatedBidiStreamingHandler : public ::grpc::internal::MethodHandler { + public: + TemplatedBidiStreamingHandler( + std::function<::grpc::Status(::grpc_impl::ServerContext*, Streamer*)> + func) + : func_(func), write_needed_(WriteNeeded) {} + + void RunHandler(const HandlerParameter& param) final { + Streamer stream(param.call, static_cast<::grpc_impl::ServerContext*>( + param.server_context)); + ::grpc::Status status = CatchingFunctionHandler([this, ¶m, &stream] { + return func_( + static_cast<::grpc_impl::ServerContext*>(param.server_context), + &stream); + }); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + ops; + if (!param.server_context->sent_initial_metadata_) { + ops.SendInitialMetadata(¶m.server_context->initial_metadata_, + param.server_context->initial_metadata_flags()); + if (param.server_context->compression_level_set()) { + ops.set_compression_level(param.server_context->compression_level()); + } + if (write_needed_ && status.ok()) { + // If we needed a write but never did one, we need to mark the + // status as a fail + status = ::grpc::Status(::grpc::StatusCode::INTERNAL, + "Service did not provide response message"); + } + } + ops.ServerSendStatus(¶m.server_context->trailing_metadata_, status); + param.call->PerformOps(&ops); + if (param.server_context->has_pending_ops_) { + param.call->cq()->Pluck(¶m.server_context->pending_ops_); + } + param.call->cq()->Pluck(&ops); + } + + private: + std::function<::grpc::Status(::grpc_impl::ServerContext*, Streamer*)> func_; + const bool write_needed_; +}; + +template +class BidiStreamingHandler + : public TemplatedBidiStreamingHandler< + ::grpc_impl::ServerReaderWriter, false> { + public: + BidiStreamingHandler( + std::function<::grpc::Status( + ServiceType*, ::grpc_impl::ServerContext*, + ::grpc_impl::ServerReaderWriter*)> + func, + ServiceType* service) + : TemplatedBidiStreamingHandler< + ::grpc_impl::ServerReaderWriter, false>( + std::bind(func, service, std::placeholders::_1, + std::placeholders::_2)) {} +}; + +template +class StreamedUnaryHandler + : public TemplatedBidiStreamingHandler< + ::grpc_impl::ServerUnaryStreamer, true> { + public: + explicit StreamedUnaryHandler( + std::function<::grpc::Status( + ::grpc_impl::ServerContext*, + ::grpc_impl::ServerUnaryStreamer*)> + func) + : TemplatedBidiStreamingHandler< + ::grpc_impl::ServerUnaryStreamer, true>( + func) {} +}; + +template +class SplitServerStreamingHandler + : public TemplatedBidiStreamingHandler< + ::grpc_impl::ServerSplitStreamer, false> { + public: + explicit SplitServerStreamingHandler( + std::function<::grpc::Status( + ::grpc_impl::ServerContext*, + ::grpc_impl::ServerSplitStreamer*)> + func) + : TemplatedBidiStreamingHandler< + ::grpc_impl::ServerSplitStreamer, false>( + func) {} +}; + +/// General method handler class for errors that prevent real method use +/// e.g., handle unknown method by returning UNIMPLEMENTED error. +template <::grpc::StatusCode code> +class ErrorMethodHandler : public ::grpc::internal::MethodHandler { + public: + template + static void FillOps(::grpc_impl::ServerContextBase* context, T* ops) { + ::grpc::Status status(code, ""); + if (!context->sent_initial_metadata_) { + ops->SendInitialMetadata(&context->initial_metadata_, + context->initial_metadata_flags()); + if (context->compression_level_set()) { + ops->set_compression_level(context->compression_level()); + } + context->sent_initial_metadata_ = true; + } + ops->ServerSendStatus(&context->trailing_metadata_, status); + } + + void RunHandler(const HandlerParameter& param) final { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpServerSendStatus> + ops; + FillOps(param.server_context, &ops); + param.call->PerformOps(&ops); + param.call->cq()->Pluck(&ops); + } + + void* Deserialize(grpc_call* /*call*/, grpc_byte_buffer* req, + ::grpc::Status* /*status*/, void** /*handler_data*/) final { + // We have to destroy any request payload + if (req != nullptr) { + ::grpc::g_core_codegen_interface->grpc_byte_buffer_destroy(req); + } + return nullptr; + } +}; + +typedef ErrorMethodHandler<::grpc::StatusCode::UNIMPLEMENTED> + UnknownMethodHandler; +typedef ErrorMethodHandler<::grpc::StatusCode::RESOURCE_EXHAUSTED> + ResourceExhaustedHandler; + +} // namespace internal +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/proto_buffer_reader.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/proto_buffer_reader.h new file mode 100644 index 0000000000000000000000000000000000000000..487471290d9eb56c7bd85176eab894b9b99bdb40 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/proto_buffer_reader.h @@ -0,0 +1,149 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_READER_H +#define GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_READER_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +/// This header provides an object that reads bytes directly from a +/// grpc::ByteBuffer, via the ZeroCopyInputStream interface + +namespace grpc { + +extern CoreCodegenInterface* g_core_codegen_interface; + +/// This is a specialization of the protobuf class ZeroCopyInputStream +/// The principle is to get one chunk of data at a time from the proto layer, +/// with options to backup (re-see some bytes) or skip (forward past some bytes) +/// +/// Read more about ZeroCopyInputStream interface here: +/// https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.zero_copy_stream#ZeroCopyInputStream +class ProtoBufferReader : public ::grpc::protobuf::io::ZeroCopyInputStream { + public: + /// Constructs buffer reader from \a buffer. Will set \a status() to non ok + /// if \a buffer is invalid (the internal buffer has not been initialized). + explicit ProtoBufferReader(ByteBuffer* buffer) + : byte_count_(0), backup_count_(0), status_() { + /// Implemented through a grpc_byte_buffer_reader which iterates + /// over the slices that make up a byte buffer + if (!buffer->Valid() || + !g_core_codegen_interface->grpc_byte_buffer_reader_init( + &reader_, buffer->c_buffer())) { + status_ = Status(StatusCode::INTERNAL, + "Couldn't initialize byte buffer reader"); + } + } + + ~ProtoBufferReader() { + if (status_.ok()) { + g_core_codegen_interface->grpc_byte_buffer_reader_destroy(&reader_); + } + } + + /// Give the proto library a chunk of data from the stream. The caller + /// may safely read from data[0, size - 1]. + bool Next(const void** data, int* size) override { + if (!status_.ok()) { + return false; + } + /// If we have backed up previously, we need to return the backed-up slice + if (backup_count_ > 0) { + *data = GRPC_SLICE_START_PTR(*slice_) + GRPC_SLICE_LENGTH(*slice_) - + backup_count_; + GPR_CODEGEN_ASSERT(backup_count_ <= INT_MAX); + *size = (int)backup_count_; + backup_count_ = 0; + return true; + } + /// Otherwise get the next slice from the byte buffer reader + if (!g_core_codegen_interface->grpc_byte_buffer_reader_peek(&reader_, + &slice_)) { + return false; + } + *data = GRPC_SLICE_START_PTR(*slice_); + // On win x64, int is only 32bit + GPR_CODEGEN_ASSERT(GRPC_SLICE_LENGTH(*slice_) <= INT_MAX); + byte_count_ += * size = (int)GRPC_SLICE_LENGTH(*slice_); + return true; + } + + /// Returns the status of the buffer reader. + Status status() const { return status_; } + + /// The proto library calls this to indicate that we should back up \a count + /// bytes that have already been returned by the last call of Next. + /// So do the backup and have that ready for a later Next. + void BackUp(int count) override { + GPR_CODEGEN_ASSERT(count <= static_cast(GRPC_SLICE_LENGTH(*slice_))); + backup_count_ = count; + } + + /// The proto library calls this to skip over \a count bytes. Implement this + /// using Next and BackUp combined. + bool Skip(int count) override { + const void* data; + int size; + while (Next(&data, &size)) { + if (size >= count) { + BackUp(size - count); + return true; + } + // size < count; + count -= size; + } + // error or we have too large count; + return false; + } + + /// Returns the total number of bytes read since this object was created. + int64_t ByteCount() const override { return byte_count_ - backup_count_; } + + // These protected members are needed to support internal optimizations. + // they expose internal bits of grpc core that are NOT stable. If you have + // a use case needs to use one of these functions, please send an email to + // https://groups.google.com/forum/#!forum/grpc-io. + protected: + void set_byte_count(int64_t byte_count) { byte_count_ = byte_count; } + int64_t backup_count() { return backup_count_; } + void set_backup_count(int64_t backup_count) { backup_count_ = backup_count; } + grpc_byte_buffer_reader* reader() { return &reader_; } + grpc_slice* slice() { return slice_; } + grpc_slice** mutable_slice_ptr() { return &slice_; } + + private: + int64_t byte_count_; ///< total bytes read since object creation + int64_t backup_count_; ///< how far backed up in the stream we are + grpc_byte_buffer_reader reader_; ///< internal object to read \a grpc_slice + ///< from the \a grpc_byte_buffer + grpc_slice* slice_; ///< current slice passed back to the caller + Status status_; ///< status of the entire object +}; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_READER_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/proto_buffer_writer.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/proto_buffer_writer.h new file mode 100644 index 0000000000000000000000000000000000000000..0af4616e508673bac98415ef17f3df3089ab0783 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/proto_buffer_writer.h @@ -0,0 +1,167 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_WRITER_H +#define GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_WRITER_H + +#include + +#include +#include +#include +#include +#include +#include +#include + +/// This header provides an object that writes bytes directly into a +/// grpc::ByteBuffer, via the ZeroCopyOutputStream interface + +namespace grpc { + +extern CoreCodegenInterface* g_core_codegen_interface; + +// Forward declaration for testing use only +namespace internal { +class ProtoBufferWriterPeer; +} // namespace internal + +const int kProtoBufferWriterMaxBufferLength = 1024 * 1024; + +/// This is a specialization of the protobuf class ZeroCopyOutputStream. +/// The principle is to give the proto layer one buffer of bytes at a time +/// that it can use to serialize the next portion of the message, with the +/// option to "backup" if more buffer is given than required at the last buffer. +/// +/// Read more about ZeroCopyOutputStream interface here: +/// https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.zero_copy_stream#ZeroCopyOutputStream +class ProtoBufferWriter : public ::grpc::protobuf::io::ZeroCopyOutputStream { + public: + /// Constructor for this derived class + /// + /// \param[out] byte_buffer A pointer to the grpc::ByteBuffer created + /// \param block_size How big are the chunks to allocate at a time + /// \param total_size How many total bytes are required for this proto + ProtoBufferWriter(ByteBuffer* byte_buffer, int block_size, int total_size) + : block_size_(block_size), + total_size_(total_size), + byte_count_(0), + have_backup_(false) { + GPR_CODEGEN_ASSERT(!byte_buffer->Valid()); + /// Create an empty raw byte buffer and look at its underlying slice buffer + grpc_byte_buffer* bp = + g_core_codegen_interface->grpc_raw_byte_buffer_create(NULL, 0); + byte_buffer->set_buffer(bp); + slice_buffer_ = &bp->data.raw.slice_buffer; + } + + ~ProtoBufferWriter() { + if (have_backup_) { + g_core_codegen_interface->grpc_slice_unref(backup_slice_); + } + } + + /// Give the proto library the next buffer of bytes and its size. It is + /// safe for the caller to write from data[0, size - 1]. + bool Next(void** data, int* size) override { + // Protobuf should not ask for more memory than total_size_. + GPR_CODEGEN_ASSERT(byte_count_ < total_size_); + // 1. Use the remaining backup slice if we have one + // 2. Otherwise allocate a slice, up to the remaining length needed + // or our maximum allocation size + // 3. Provide the slice start and size available + // 4. Add the slice being returned to the slice buffer + size_t remain = static_cast(total_size_ - byte_count_); + if (have_backup_) { + /// If we have a backup slice, we should use it first + slice_ = backup_slice_; + have_backup_ = false; + if (GRPC_SLICE_LENGTH(slice_) > remain) { + GRPC_SLICE_SET_LENGTH(slice_, remain); + } + } else { + // When less than a whole block is needed, only allocate that much. + // But make sure the allocated slice is not inlined. + size_t allocate_length = + remain > static_cast(block_size_) ? block_size_ : remain; + slice_ = g_core_codegen_interface->grpc_slice_malloc( + allocate_length > GRPC_SLICE_INLINED_SIZE + ? allocate_length + : GRPC_SLICE_INLINED_SIZE + 1); + } + *data = GRPC_SLICE_START_PTR(slice_); + // On win x64, int is only 32bit + GPR_CODEGEN_ASSERT(GRPC_SLICE_LENGTH(slice_) <= INT_MAX); + byte_count_ += * size = (int)GRPC_SLICE_LENGTH(slice_); + g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_); + return true; + } + + /// Backup by \a count bytes because Next returned more bytes than needed + /// (only used in the last buffer). \a count must be less than or equal too + /// the last buffer returned from next. + void BackUp(int count) override { + /// 1. Remove the partially-used last slice from the slice buffer + /// 2. Split it into the needed (if any) and unneeded part + /// 3. Add the needed part back to the slice buffer + /// 4. Mark that we still have the remaining part (for later use/unref) + GPR_CODEGEN_ASSERT(count <= static_cast(GRPC_SLICE_LENGTH(slice_))); + g_core_codegen_interface->grpc_slice_buffer_pop(slice_buffer_); + if ((size_t)count == GRPC_SLICE_LENGTH(slice_)) { + backup_slice_ = slice_; + } else { + backup_slice_ = g_core_codegen_interface->grpc_slice_split_tail( + &slice_, GRPC_SLICE_LENGTH(slice_) - count); + g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_); + } + // It's dangerous to keep an inlined grpc_slice as the backup slice, since + // on a following Next() call, a reference will be returned to this slice + // via GRPC_SLICE_START_PTR, which will not be an address held by + // slice_buffer_. + have_backup_ = backup_slice_.refcount != NULL; + byte_count_ -= count; + } + + /// Returns the total number of bytes written since this object was created. + int64_t ByteCount() const override { return byte_count_; } + + // These protected members are needed to support internal optimizations. + // they expose internal bits of grpc core that are NOT stable. If you have + // a use case needs to use one of these functions, please send an email to + // https://groups.google.com/forum/#!forum/grpc-io. + protected: + grpc_slice_buffer* slice_buffer() { return slice_buffer_; } + void set_byte_count(int64_t byte_count) { byte_count_ = byte_count; } + + private: + // friend for testing purposes only + friend class internal::ProtoBufferWriterPeer; + const int block_size_; ///< size to alloc for each new \a grpc_slice needed + const int total_size_; ///< byte size of proto being serialized + int64_t byte_count_; ///< bytes written since this object was created + grpc_slice_buffer* + slice_buffer_; ///< internal buffer of slices holding the serialized data + bool have_backup_; ///< if we are holding a backup slice or not + grpc_slice backup_slice_; ///< holds space we can still write to, if the + ///< caller has called BackUp + grpc_slice slice_; ///< current slice passed back to the caller +}; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_WRITER_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/proto_utils.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/proto_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..2cf4cdcc9b5067ea782233ecf39bad946fa52e74 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/proto_utils.h @@ -0,0 +1,119 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_PROTO_UTILS_H +#define GRPCPP_IMPL_CODEGEN_PROTO_UTILS_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/// This header provides serialization and deserialization between gRPC +/// messages serialized using protobuf and the C++ objects they represent. + +namespace grpc { + +extern CoreCodegenInterface* g_core_codegen_interface; + +// ProtoBufferWriter must be a subclass of ::protobuf::io::ZeroCopyOutputStream. +template +Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, + bool* own_buffer) { + static_assert(std::is_base_of::value, + "ProtoBufferWriter must be a subclass of " + "::protobuf::io::ZeroCopyOutputStream"); + *own_buffer = true; + int byte_size = msg.ByteSize(); + if ((size_t)byte_size <= GRPC_SLICE_INLINED_SIZE) { + Slice slice(byte_size); + // We serialize directly into the allocated slices memory + GPR_CODEGEN_ASSERT(slice.end() == msg.SerializeWithCachedSizesToArray( + const_cast(slice.begin()))); + ByteBuffer tmp(&slice, 1); + bb->Swap(&tmp); + + return g_core_codegen_interface->ok(); + } + ProtoBufferWriter writer(bb, kProtoBufferWriterMaxBufferLength, byte_size); + return msg.SerializeToZeroCopyStream(&writer) + ? g_core_codegen_interface->ok() + : Status(StatusCode::INTERNAL, "Failed to serialize message"); +} + +// BufferReader must be a subclass of ::protobuf::io::ZeroCopyInputStream. +template +Status GenericDeserialize(ByteBuffer* buffer, + grpc::protobuf::MessageLite* msg) { + static_assert(std::is_base_of::value, + "ProtoBufferReader must be a subclass of " + "::protobuf::io::ZeroCopyInputStream"); + if (buffer == nullptr) { + return Status(StatusCode::INTERNAL, "No payload"); + } + Status result = g_core_codegen_interface->ok(); + { + ProtoBufferReader reader(buffer); + if (!reader.status().ok()) { + return reader.status(); + } + if (!msg->ParseFromZeroCopyStream(&reader)) { + result = Status(StatusCode::INTERNAL, msg->InitializationErrorString()); + } + } + buffer->Clear(); + return result; +} + +// this is needed so the following class does not conflict with protobuf +// serializers that utilize internal-only tools. +#ifdef GRPC_OPEN_SOURCE_PROTO +// This class provides a protobuf serializer. It translates between protobuf +// objects and grpc_byte_buffers. More information about SerializationTraits can +// be found in include/grpcpp/impl/codegen/serialization_traits.h. +template +class SerializationTraits< + T, typename std::enable_if< + std::is_base_of::value>::type> { + public: + static Status Serialize(const grpc::protobuf::MessageLite& msg, + ByteBuffer* bb, bool* own_buffer) { + return GenericSerialize(msg, bb, own_buffer); + } + + static Status Deserialize(ByteBuffer* buffer, + grpc::protobuf::MessageLite* msg) { + return GenericDeserialize(buffer, msg); + } +}; +#endif + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_PROTO_UTILS_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/rpc_method.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/rpc_method.h new file mode 100644 index 0000000000000000000000000000000000000000..9dcde954f1dac5e1b93019bb19d2e083f53e7ffb --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/rpc_method.h @@ -0,0 +1,61 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_RPC_METHOD_H +#define GRPCPP_IMPL_CODEGEN_RPC_METHOD_H + +#include + +#include + +namespace grpc { +namespace internal { +/// Descriptor of an RPC method +class RpcMethod { + public: + enum RpcType { + NORMAL_RPC = 0, + CLIENT_STREAMING, // request streaming + SERVER_STREAMING, // response streaming + BIDI_STREAMING + }; + + RpcMethod(const char* name, RpcType type) + : name_(name), method_type_(type), channel_tag_(NULL) {} + + RpcMethod(const char* name, RpcType type, + const std::shared_ptr& channel) + : name_(name), + method_type_(type), + channel_tag_(channel->RegisterMethod(name)) {} + + const char* name() const { return name_; } + RpcType method_type() const { return method_type_; } + void SetMethodType(RpcType type) { method_type_ = type; } + void* channel_tag() const { return channel_tag_; } + + private: + const char* const name_; + RpcType method_type_; + void* const channel_tag_; +}; + +} // namespace internal +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_RPC_METHOD_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/rpc_service_method.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/rpc_service_method.h new file mode 100644 index 0000000000000000000000000000000000000000..da0e5b60b20e595bb67f45a9ed9cc8a219f68c42 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/rpc_service_method.h @@ -0,0 +1,156 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_RPC_SERVICE_METHOD_H +#define GRPCPP_IMPL_CODEGEN_RPC_SERVICE_METHOD_H + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace grpc_impl { +class ServerContextBase; +} // namespace grpc_impl + +namespace grpc { +namespace internal { +/// Base class for running an RPC handler. +class MethodHandler { + public: + virtual ~MethodHandler() {} + struct HandlerParameter { + /// Constructor for HandlerParameter + /// + /// \param c : the gRPC Call structure for this server call + /// \param context : the ServerContext structure for this server call + /// \param req : the request payload, if appropriate for this RPC + /// \param req_status : the request status after any interceptors have run + /// \param handler_data: internal data for the handler. + /// \param requester : used only by the callback API. It is a function + /// called by the RPC Controller to request another RPC (and also + /// to set up the state required to make that request possible) + HandlerParameter(Call* c, ::grpc_impl::ServerContextBase* context, + void* req, Status req_status, void* handler_data, + std::function requester) + : call(c), + server_context(context), + request(req), + status(req_status), + internal_data(handler_data), + call_requester(std::move(requester)) {} + ~HandlerParameter() {} + Call* const call; + ::grpc_impl::ServerContextBase* const server_context; + void* const request; + const Status status; + void* const internal_data; + const std::function call_requester; + }; + virtual void RunHandler(const HandlerParameter& param) = 0; + + /* Returns a pointer to the deserialized request. \a status reflects the + result of deserialization. This pointer and the status should be filled in + a HandlerParameter and passed to RunHandler. It is illegal to access the + pointer after calling RunHandler. Ownership of the deserialized request is + retained by the handler. Returns nullptr if deserialization failed. */ + virtual void* Deserialize(grpc_call* /*call*/, grpc_byte_buffer* req, + Status* /*status*/, void** /*handler_data*/) { + GPR_CODEGEN_ASSERT(req == nullptr); + return nullptr; + } +}; + +/// Server side rpc method class +class RpcServiceMethod : public RpcMethod { + public: + /// Takes ownership of the handler + RpcServiceMethod(const char* name, RpcMethod::RpcType type, + MethodHandler* handler) + : RpcMethod(name, type), + server_tag_(nullptr), + api_type_(ApiType::SYNC), + handler_(handler) {} + + enum class ApiType { + SYNC, + ASYNC, + RAW, + CALL_BACK, // not CALLBACK because that is reserved in Windows + RAW_CALL_BACK, + }; + + void set_server_tag(void* tag) { server_tag_ = tag; } + void* server_tag() const { return server_tag_; } + /// if MethodHandler is nullptr, then this is an async method + MethodHandler* handler() const { return handler_.get(); } + ApiType api_type() const { return api_type_; } + void SetHandler(MethodHandler* handler) { handler_.reset(handler); } + void SetServerApiType(RpcServiceMethod::ApiType type) { + if ((api_type_ == ApiType::SYNC) && + (type == ApiType::ASYNC || type == ApiType::RAW)) { + // this marks this method as async + handler_.reset(); + } else if (api_type_ != ApiType::SYNC) { + // this is not an error condition, as it allows users to declare a server + // like WithRawMethod_foo. However since it + // overwrites behavior, it should be logged. + gpr_log( + GPR_INFO, + "You are marking method %s as '%s', even though it was " + "previously marked '%s'. This behavior will overwrite the original " + "behavior. If you expected this then ignore this message.", + name(), TypeToString(api_type_), TypeToString(type)); + } + api_type_ = type; + } + + private: + void* server_tag_; + ApiType api_type_; + std::unique_ptr handler_; + + const char* TypeToString(RpcServiceMethod::ApiType type) { + switch (type) { + case ApiType::SYNC: + return "sync"; + case ApiType::ASYNC: + return "async"; + case ApiType::RAW: + return "raw"; + case ApiType::CALL_BACK: + return "callback"; + case ApiType::RAW_CALL_BACK: + return "raw_callback"; + default: + GPR_UNREACHABLE_CODE(return "unknown"); + } + } +}; +} // namespace internal + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_RPC_SERVICE_METHOD_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/security/auth_context.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/security/auth_context.h new file mode 100644 index 0000000000000000000000000000000000000000..6c0089ca4244743c7e93a1d1115cb14e51cb5976 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/security/auth_context.h @@ -0,0 +1,95 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H +#define GRPCPP_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H + +#include +#include + +#include +#include + +struct grpc_auth_context; +struct grpc_auth_property; +struct grpc_auth_property_iterator; + +namespace grpc { +class SecureAuthContext; + +typedef std::pair AuthProperty; + +class AuthPropertyIterator + : public std::iterator { + public: + ~AuthPropertyIterator(); + AuthPropertyIterator& operator++(); + AuthPropertyIterator operator++(int); + bool operator==(const AuthPropertyIterator& rhs) const; + bool operator!=(const AuthPropertyIterator& rhs) const; + const AuthProperty operator*(); + + protected: + AuthPropertyIterator(); + AuthPropertyIterator(const grpc_auth_property* property, + const grpc_auth_property_iterator* iter); + + private: + friend class SecureAuthContext; + const grpc_auth_property* property_; + // The following items form a grpc_auth_property_iterator. + const grpc_auth_context* ctx_; + size_t index_; + const char* name_; +}; + +/// Class encapsulating the Authentication Information. +/// +/// It includes the secure identity of the peer, the type of secure transport +/// used as well as any other properties required by the authorization layer. +class AuthContext { + public: + virtual ~AuthContext() {} + + /// Returns true if the peer is authenticated. + virtual bool IsPeerAuthenticated() const = 0; + + /// A peer identity. + /// + /// It is, in general, comprised of one or more properties (in which case they + /// have the same name). + virtual std::vector GetPeerIdentity() const = 0; + virtual grpc::string GetPeerIdentityPropertyName() const = 0; + + /// Returns all the property values with the given name. + virtual std::vector FindPropertyValues( + const grpc::string& name) const = 0; + + /// Iteration over all the properties. + virtual AuthPropertyIterator begin() const = 0; + virtual AuthPropertyIterator end() const = 0; + + /// Mutation functions: should only be used by an AuthMetadataProcessor. + virtual void AddProperty(const grpc::string& key, + const string_ref& value) = 0; + virtual bool SetPeerIdentityPropertyName(const string& name) = 0; +}; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/serialization_traits.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/serialization_traits.h new file mode 100644 index 0000000000000000000000000000000000000000..8f792232909871bbf0f10982c445be2897af7c6a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/serialization_traits.h @@ -0,0 +1,62 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SERIALIZATION_TRAITS_H +#define GRPCPP_IMPL_CODEGEN_SERIALIZATION_TRAITS_H + +namespace grpc { + +/// Defines how to serialize and deserialize some type. +/// +/// Used for hooking different message serialization API's into GRPC. +/// Each SerializationTraits implementation must provide the +/// following functions: +/// 1. static Status Serialize(const Message& msg, +/// ByteBuffer* buffer, +/// bool* own_buffer); +/// OR +/// static Status Serialize(const Message& msg, +/// grpc_byte_buffer** buffer, +/// bool* own_buffer); +/// The former is preferred; the latter is deprecated +/// +/// 2. static Status Deserialize(ByteBuffer* buffer, +/// Message* msg); +/// OR +/// static Status Deserialize(grpc_byte_buffer* buffer, +/// Message* msg); +/// The former is preferred; the latter is deprecated +/// +/// Serialize is required to convert message to a ByteBuffer, and +/// return that byte buffer through *buffer. *own_buffer should +/// be set to true if the caller owns said byte buffer, or false if +/// ownership is retained elsewhere. +/// +/// Deserialize is required to convert buffer into the message stored at +/// msg. max_receive_message_size is passed in as a bound on the maximum +/// number of message bytes Deserialize should accept. +/// +/// Both functions return a Status, allowing them to explain what went +/// wrong if required. +template +class SerializationTraits; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_SERIALIZATION_TRAITS_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_callback.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_callback.h new file mode 100644 index 0000000000000000000000000000000000000000..1d8b2f6f5bb42187f5652e48df4119bcdedb1884 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_callback.h @@ -0,0 +1,56 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_H +#define GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_H + +#include + +namespace grpc { + +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL +template +using ServerReadReactor = ::grpc_impl::ServerReadReactor; + +template +using ServerWriteReactor = ::grpc_impl::ServerWriteReactor; + +template +using ServerBidiReactor = ::grpc_impl::ServerBidiReactor; + +using ServerUnaryReactor = ::grpc_impl::ServerUnaryReactor; +#endif + +// TODO(vjpai): Remove namespace experimental when de-experimentalized fully. +namespace experimental { + +template +using ServerReadReactor = ::grpc_impl::ServerReadReactor; + +template +using ServerWriteReactor = ::grpc_impl::ServerWriteReactor; + +template +using ServerBidiReactor = ::grpc_impl::ServerBidiReactor; + +using ServerUnaryReactor = ::grpc_impl::ServerUnaryReactor; + +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_callback_handlers.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_callback_handlers.h new file mode 100644 index 0000000000000000000000000000000000000000..7752864175d502437352cef34b2208e7a270e3ae --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_callback_handlers.h @@ -0,0 +1,802 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_HANDLERS_H +#define GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_HANDLERS_H + +#include +#include +#include +#include +#include + +namespace grpc_impl { +namespace internal { + +template +class CallbackUnaryHandler : public ::grpc::internal::MethodHandler { + public: + explicit CallbackUnaryHandler( + std::function + get_reactor) + : get_reactor_(std::move(get_reactor)) {} + + void SetMessageAllocator( + ::grpc::experimental::MessageAllocator* + allocator) { + allocator_ = allocator; + } + + void RunHandler(const HandlerParameter& param) final { + // Arena allocate a controller structure (that includes request/response) + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + auto* allocator_state = static_cast< + ::grpc::experimental::MessageHolder*>( + param.internal_data); + + auto* call = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackUnaryImpl))) + ServerCallbackUnaryImpl( + static_cast<::grpc_impl::CallbackServerContext*>( + param.server_context), + param.call, allocator_state, std::move(param.call_requester)); + param.server_context->BeginCompletionOp( + param.call, [call](bool) { call->MaybeDone(); }, call); + + ServerUnaryReactor* reactor = nullptr; + if (param.status.ok()) { + reactor = ::grpc::internal::CatchingReactorGetter( + get_reactor_, + static_cast<::grpc_impl::CallbackServerContext*>( + param.server_context), + call->request(), call->response()); + } + + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(UnimplementedUnaryReactor))) + UnimplementedUnaryReactor( + ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } + + /// Invoke SetupReactor as the last part of the handler + call->SetupReactor(reactor); + } + + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** handler_data) final { + ::grpc::ByteBuffer buf; + buf.set_buffer(req); + RequestType* request = nullptr; + ::grpc::experimental::MessageHolder* + allocator_state = nullptr; + if (allocator_ != nullptr) { + allocator_state = allocator_->AllocateMessages(); + } else { + allocator_state = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(DefaultMessageHolder))) + DefaultMessageHolder(); + } + *handler_data = allocator_state; + request = allocator_state->request(); + *status = + ::grpc::SerializationTraits::Deserialize(&buf, request); + buf.Release(); + if (status->ok()) { + return request; + } + // Clean up on deserialization failure. + allocator_state->Release(); + return nullptr; + } + + private: + std::function + get_reactor_; + ::grpc::experimental::MessageAllocator* + allocator_ = nullptr; + + class ServerCallbackUnaryImpl : public ServerCallbackUnary { + public: + void Finish(::grpc::Status s) override { + finish_tag_.Set( + call_.call(), [this](bool) { MaybeDone(); }, &finish_ops_, + reactor_.load(std::memory_order_relaxed)->InternalInlineable()); + finish_ops_.set_core_cq_tag(&finish_tag_); + + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (s.ok()) { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_ops_.SendMessagePtr(response())); + } else { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + } + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + this->Ref(); + meta_tag_.Set(call_.call(), + [this](bool ok) { + reactor_.load(std::memory_order_relaxed) + ->OnSendInitialMetadataDone(ok); + MaybeDone(); + }, + &meta_ops_, false); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + private: + friend class CallbackUnaryHandler; + + ServerCallbackUnaryImpl( + ::grpc_impl::CallbackServerContext* ctx, ::grpc::internal::Call* call, + ::grpc::experimental::MessageHolder* + allocator_state, + std::function call_requester) + : ctx_(ctx), + call_(*call), + allocator_state_(allocator_state), + call_requester_(std::move(call_requester)) { + ctx_->set_message_allocator_state(allocator_state); + } + + /// SetupReactor binds the reactor (which also releases any queued + /// operations), maybe calls OnCancel if possible/needed, and maybe marks + /// the completion of the RPC. This should be the last component of the + /// handler. + void SetupReactor(ServerUnaryReactor* reactor) { + reactor_.store(reactor, std::memory_order_relaxed); + this->BindReactor(reactor); + this->MaybeCallOnCancel(reactor); + this->MaybeDone(); + } + + const RequestType* request() { return allocator_state_->request(); } + ResponseType* response() { return allocator_state_->response(); } + + void MaybeDone() override { + if (GPR_UNLIKELY(this->Unref() == 1)) { + reactor_.load(std::memory_order_relaxed)->OnDone(); + grpc_call* call = call_.call(); + auto call_requester = std::move(call_requester_); + allocator_state_->Release(); + this->~ServerCallbackUnaryImpl(); // explicitly call destructor + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + call_requester(); + } + } + + ServerReactor* reactor() override { + return reactor_.load(std::memory_order_relaxed); + } + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallbackWithSuccessTag meta_tag_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; + ::grpc::internal::CallbackWithSuccessTag finish_tag_; + + ::grpc_impl::CallbackServerContext* const ctx_; + ::grpc::internal::Call call_; + ::grpc::experimental::MessageHolder* const + allocator_state_; + std::function call_requester_; + // reactor_ can always be loaded/stored with relaxed memory ordering because + // its value is only set once, independently of other data in the object, + // and the loads that use it will always actually come provably later even + // though they are from different threads since they are triggered by + // actions initiated only by the setting up of the reactor_ variable. In + // a sense, it's a delayed "const": it gets its value from the SetupReactor + // method (not the constructor, so it's not a true const), but it doesn't + // change after that and it only gets used by actions caused, directly or + // indirectly, by that setup. This comment also applies to the reactor_ + // variables of the other streaming objects in this file. + std::atomic reactor_; + // callbacks_outstanding_ follows a refcount pattern + std::atomic callbacks_outstanding_{ + 3}; // reserve for start, Finish, and CompletionOp + }; +}; + +template +class CallbackClientStreamingHandler : public ::grpc::internal::MethodHandler { + public: + explicit CallbackClientStreamingHandler( + std::function*( + ::grpc_impl::CallbackServerContext*, ResponseType*)> + get_reactor) + : get_reactor_(std::move(get_reactor)) {} + void RunHandler(const HandlerParameter& param) final { + // Arena allocate a reader structure (that includes response) + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + + auto* reader = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackReaderImpl))) + ServerCallbackReaderImpl( + static_cast<::grpc_impl::CallbackServerContext*>( + param.server_context), + param.call, std::move(param.call_requester)); + param.server_context->BeginCompletionOp( + param.call, [reader](bool) { reader->MaybeDone(); }, reader); + + ServerReadReactor* reactor = nullptr; + if (param.status.ok()) { + reactor = ::grpc::internal::CatchingReactorGetter< + ServerReadReactor>( + get_reactor_, + static_cast<::grpc_impl::CallbackServerContext*>( + param.server_context), + reader->response()); + } + + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(UnimplementedReadReactor))) + UnimplementedReadReactor( + ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } + + reader->SetupReactor(reactor); + } + + private: + std::function*( + ::grpc_impl::CallbackServerContext*, ResponseType*)> + get_reactor_; + + class ServerCallbackReaderImpl : public ServerCallbackReader { + public: + void Finish(::grpc::Status s) override { + finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, &finish_ops_, + false); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (s.ok()) { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_ops_.SendMessagePtr(&resp_)); + } else { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + } + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + this->Ref(); + meta_tag_.Set(call_.call(), + [this](bool ok) { + reactor_.load(std::memory_order_relaxed) + ->OnSendInitialMetadataDone(ok); + MaybeDone(); + }, + &meta_ops_, false); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + void Read(RequestType* req) override { + this->Ref(); + read_ops_.RecvMessage(req); + call_.PerformOps(&read_ops_); + } + + private: + friend class CallbackClientStreamingHandler; + + ServerCallbackReaderImpl(::grpc_impl::CallbackServerContext* ctx, + ::grpc::internal::Call* call, + std::function call_requester) + : ctx_(ctx), call_(*call), call_requester_(std::move(call_requester)) {} + + void SetupReactor(ServerReadReactor* reactor) { + reactor_.store(reactor, std::memory_order_relaxed); + read_tag_.Set(call_.call(), + [this](bool ok) { + reactor_.load(std::memory_order_relaxed)->OnReadDone(ok); + MaybeDone(); + }, + &read_ops_, false); + read_ops_.set_core_cq_tag(&read_tag_); + this->BindReactor(reactor); + this->MaybeCallOnCancel(reactor); + this->MaybeDone(); + } + + ~ServerCallbackReaderImpl() {} + + ResponseType* response() { return &resp_; } + + void MaybeDone() override { + if (GPR_UNLIKELY(this->Unref() == 1)) { + reactor_.load(std::memory_order_relaxed)->OnDone(); + grpc_call* call = call_.call(); + auto call_requester = std::move(call_requester_); + this->~ServerCallbackReaderImpl(); // explicitly call destructor + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + call_requester(); + } + } + + ServerReactor* reactor() override { + return reactor_.load(std::memory_order_relaxed); + } + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallbackWithSuccessTag meta_tag_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; + ::grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::internal::CallOpSet< + ::grpc::internal::CallOpRecvMessage> + read_ops_; + ::grpc::internal::CallbackWithSuccessTag read_tag_; + + ::grpc_impl::CallbackServerContext* const ctx_; + ::grpc::internal::Call call_; + ResponseType resp_; + std::function call_requester_; + // The memory ordering of reactor_ follows ServerCallbackUnaryImpl. + std::atomic*> reactor_; + // callbacks_outstanding_ follows a refcount pattern + std::atomic callbacks_outstanding_{ + 3}; // reserve for OnStarted, Finish, and CompletionOp + }; +}; + +template +class CallbackServerStreamingHandler : public ::grpc::internal::MethodHandler { + public: + explicit CallbackServerStreamingHandler( + std::function*( + ::grpc_impl::CallbackServerContext*, const RequestType*)> + get_reactor) + : get_reactor_(std::move(get_reactor)) {} + void RunHandler(const HandlerParameter& param) final { + // Arena allocate a writer structure + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + + auto* writer = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackWriterImpl))) + ServerCallbackWriterImpl( + static_cast<::grpc_impl::CallbackServerContext*>( + param.server_context), + param.call, static_cast(param.request), + std::move(param.call_requester)); + param.server_context->BeginCompletionOp( + param.call, [writer](bool) { writer->MaybeDone(); }, writer); + + ServerWriteReactor* reactor = nullptr; + if (param.status.ok()) { + reactor = ::grpc::internal::CatchingReactorGetter< + ServerWriteReactor>( + get_reactor_, + static_cast<::grpc_impl::CallbackServerContext*>( + param.server_context), + writer->request()); + } + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(UnimplementedWriteReactor))) + UnimplementedWriteReactor( + ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } + + writer->SetupReactor(reactor); + } + + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** /*handler_data*/) final { + ::grpc::ByteBuffer buf; + buf.set_buffer(req); + auto* request = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(RequestType))) RequestType(); + *status = + ::grpc::SerializationTraits::Deserialize(&buf, request); + buf.Release(); + if (status->ok()) { + return request; + } + request->~RequestType(); + return nullptr; + } + + private: + std::function*( + ::grpc_impl::CallbackServerContext*, const RequestType*)> + get_reactor_; + + class ServerCallbackWriterImpl : public ServerCallbackWriter { + public: + void Finish(::grpc::Status s) override { + finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, &finish_ops_, + false); + finish_ops_.set_core_cq_tag(&finish_tag_); + + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + this->Ref(); + meta_tag_.Set(call_.call(), + [this](bool ok) { + reactor_.load(std::memory_order_relaxed) + ->OnSendInitialMetadataDone(ok); + MaybeDone(); + }, + &meta_ops_, false); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + void Write(const ResponseType* resp, + ::grpc::WriteOptions options) override { + this->Ref(); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + if (!ctx_->sent_initial_metadata_) { + write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + write_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WriteAndFinish(const ResponseType* resp, ::grpc::WriteOptions options, + ::grpc::Status s) override { + // This combines the write into the finish callback + // Don't send any message if the status is bad + if (s.ok()) { + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); + } + Finish(std::move(s)); + } + + private: + friend class CallbackServerStreamingHandler; + + ServerCallbackWriterImpl(::grpc_impl::CallbackServerContext* ctx, + ::grpc::internal::Call* call, + const RequestType* req, + std::function call_requester) + : ctx_(ctx), + call_(*call), + req_(req), + call_requester_(std::move(call_requester)) {} + + void SetupReactor(ServerWriteReactor* reactor) { + reactor_.store(reactor, std::memory_order_relaxed); + write_tag_.Set( + call_.call(), + [this](bool ok) { + reactor_.load(std::memory_order_relaxed)->OnWriteDone(ok); + MaybeDone(); + }, + &write_ops_, false); + write_ops_.set_core_cq_tag(&write_tag_); + this->BindReactor(reactor); + this->MaybeCallOnCancel(reactor); + this->MaybeDone(); + } + ~ServerCallbackWriterImpl() { req_->~RequestType(); } + + const RequestType* request() { return req_; } + + void MaybeDone() override { + if (GPR_UNLIKELY(this->Unref() == 1)) { + reactor_.load(std::memory_order_relaxed)->OnDone(); + grpc_call* call = call_.call(); + auto call_requester = std::move(call_requester_); + this->~ServerCallbackWriterImpl(); // explicitly call destructor + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + call_requester(); + } + } + + ServerReactor* reactor() override { + return reactor_.load(std::memory_order_relaxed); + } + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallbackWithSuccessTag meta_tag_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; + ::grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage> + write_ops_; + ::grpc::internal::CallbackWithSuccessTag write_tag_; + + ::grpc_impl::CallbackServerContext* const ctx_; + ::grpc::internal::Call call_; + const RequestType* req_; + std::function call_requester_; + // The memory ordering of reactor_ follows ServerCallbackUnaryImpl. + std::atomic*> reactor_; + // callbacks_outstanding_ follows a refcount pattern + std::atomic callbacks_outstanding_{ + 3}; // reserve for OnStarted, Finish, and CompletionOp + }; +}; + +template +class CallbackBidiHandler : public ::grpc::internal::MethodHandler { + public: + explicit CallbackBidiHandler( + std::function*( + ::grpc_impl::CallbackServerContext*)> + get_reactor) + : get_reactor_(std::move(get_reactor)) {} + void RunHandler(const HandlerParameter& param) final { + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + + auto* stream = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackReaderWriterImpl))) + ServerCallbackReaderWriterImpl( + static_cast<::grpc_impl::CallbackServerContext*>( + param.server_context), + param.call, std::move(param.call_requester)); + param.server_context->BeginCompletionOp( + param.call, [stream](bool) { stream->MaybeDone(); }, stream); + + ServerBidiReactor* reactor = nullptr; + if (param.status.ok()) { + reactor = ::grpc::internal::CatchingReactorGetter< + ServerBidiReactor>( + get_reactor_, static_cast<::grpc_impl::CallbackServerContext*>( + param.server_context)); + } + + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), + sizeof(UnimplementedBidiReactor))) + UnimplementedBidiReactor( + ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } + + stream->SetupReactor(reactor); + } + + private: + std::function*( + ::grpc_impl::CallbackServerContext*)> + get_reactor_; + + class ServerCallbackReaderWriterImpl + : public ServerCallbackReaderWriter { + public: + void Finish(::grpc::Status s) override { + finish_tag_.Set(call_.call(), [this](bool) { MaybeDone(); }, &finish_ops_, + false); + finish_ops_.set_core_cq_tag(&finish_tag_); + + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + this->Ref(); + meta_tag_.Set(call_.call(), + [this](bool ok) { + reactor_.load(std::memory_order_relaxed) + ->OnSendInitialMetadataDone(ok); + MaybeDone(); + }, + &meta_ops_, false); + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + void Write(const ResponseType* resp, + ::grpc::WriteOptions options) override { + this->Ref(); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + if (!ctx_->sent_initial_metadata_) { + write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + write_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WriteAndFinish(const ResponseType* resp, ::grpc::WriteOptions options, + ::grpc::Status s) override { + // Don't send any message if the status is bad + if (s.ok()) { + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); + } + Finish(std::move(s)); + } + + void Read(RequestType* req) override { + this->Ref(); + read_ops_.RecvMessage(req); + call_.PerformOps(&read_ops_); + } + + private: + friend class CallbackBidiHandler; + + ServerCallbackReaderWriterImpl(::grpc_impl::CallbackServerContext* ctx, + ::grpc::internal::Call* call, + std::function call_requester) + : ctx_(ctx), call_(*call), call_requester_(std::move(call_requester)) {} + + void SetupReactor(ServerBidiReactor* reactor) { + reactor_.store(reactor, std::memory_order_relaxed); + write_tag_.Set( + call_.call(), + [this](bool ok) { + reactor_.load(std::memory_order_relaxed)->OnWriteDone(ok); + MaybeDone(); + }, + &write_ops_, false); + write_ops_.set_core_cq_tag(&write_tag_); + read_tag_.Set(call_.call(), + [this](bool ok) { + reactor_.load(std::memory_order_relaxed)->OnReadDone(ok); + MaybeDone(); + }, + &read_ops_, false); + read_ops_.set_core_cq_tag(&read_tag_); + this->BindReactor(reactor); + this->MaybeCallOnCancel(reactor); + this->MaybeDone(); + } + + void MaybeDone() override { + if (GPR_UNLIKELY(this->Unref() == 1)) { + reactor_.load(std::memory_order_relaxed)->OnDone(); + grpc_call* call = call_.call(); + auto call_requester = std::move(call_requester_); + this->~ServerCallbackReaderWriterImpl(); // explicitly call destructor + ::grpc::g_core_codegen_interface->grpc_call_unref(call); + call_requester(); + } + } + + ServerReactor* reactor() override { + return reactor_.load(std::memory_order_relaxed); + } + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallbackWithSuccessTag meta_tag_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; + ::grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage> + write_ops_; + ::grpc::internal::CallbackWithSuccessTag write_tag_; + ::grpc::internal::CallOpSet< + ::grpc::internal::CallOpRecvMessage> + read_ops_; + ::grpc::internal::CallbackWithSuccessTag read_tag_; + + ::grpc_impl::CallbackServerContext* const ctx_; + ::grpc::internal::Call call_; + std::function call_requester_; + // The memory ordering of reactor_ follows ServerCallbackUnaryImpl. + std::atomic*> reactor_; + // callbacks_outstanding_ follows a refcount pattern + std::atomic callbacks_outstanding_{ + 3}; // reserve for OnStarted, Finish, and CompletionOp + }; +}; + +} // namespace internal +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_HANDLERS_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_callback_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_callback_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..781e96f974f807c3494b1fb51f4e5ed4586b4493 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_callback_impl.h @@ -0,0 +1,750 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_IMPL_H +#define GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_IMPL_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +// Declare base class of all reactors as internal +namespace internal { + +// Forward declarations +template +class CallbackUnaryHandler; +template +class CallbackClientStreamingHandler; +template +class CallbackServerStreamingHandler; +template +class CallbackBidiHandler; + +class ServerReactor { + public: + virtual ~ServerReactor() = default; + virtual void OnDone() = 0; + virtual void OnCancel() = 0; + + // The following is not API. It is for internal use only and specifies whether + // all reactions of this Reactor can be run without an extra executor + // scheduling. This should only be used for internally-defined reactors with + // trivial reactions. + virtual bool InternalInlineable() { return false; } + + private: + template + friend class CallbackUnaryHandler; + template + friend class CallbackClientStreamingHandler; + template + friend class CallbackServerStreamingHandler; + template + friend class CallbackBidiHandler; +}; + +/// The base class of ServerCallbackUnary etc. +class ServerCallbackCall { + public: + virtual ~ServerCallbackCall() {} + + // This object is responsible for tracking when it is safe to call + // OnCancel. This function should not be called until after the method handler + // is done and the RPC has completed with a cancellation. This is tracked by + // counting how many of these conditions have been met and calling OnCancel + // when none remain unmet. + + // Fast version called with known reactor passed in, used from derived + // classes, typically in non-cancel case + void MaybeCallOnCancel(ServerReactor* reactor) { + if (GPR_UNLIKELY(UnblockCancellation())) { + CallOnCancel(reactor); + } + } + + // Slower version called from object that doesn't know the reactor a priori + // (such as the ServerContext CompletionOp which is formed before the + // reactor). This is used in cancel cases only, so it's ok to be slower and + // invoke a virtual function. + void MaybeCallOnCancel() { + if (GPR_UNLIKELY(UnblockCancellation())) { + CallOnCancel(reactor()); + } + } + + protected: + /// Increases the reference count + void Ref() { callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed); } + + /// Decreases the reference count and returns the previous value + int Unref() { + return callbacks_outstanding_.fetch_sub(1, std::memory_order_acq_rel); + } + + private: + virtual ServerReactor* reactor() = 0; + virtual void MaybeDone() = 0; + + // If the OnCancel reaction is inlineable, execute it inline. Otherwise send + // it to an executor. + void CallOnCancel(ServerReactor* reactor); + + // Implement the cancellation constraint counter. Return true if OnCancel + // should be called, false otherwise. + bool UnblockCancellation() { + return on_cancel_conditions_remaining_.fetch_sub( + 1, std::memory_order_acq_rel) == 1; + } + + std::atomic_int on_cancel_conditions_remaining_{2}; + std::atomic_int callbacks_outstanding_{ + 3}; // reserve for start, Finish, and CompletionOp +}; + +template +class DefaultMessageHolder + : public ::grpc::experimental::MessageHolder { + public: + DefaultMessageHolder() { + this->set_request(&request_obj_); + this->set_response(&response_obj_); + } + void Release() override { + // the object is allocated in the call arena. + this->~DefaultMessageHolder(); + } + + private: + Request request_obj_; + Response response_obj_; +}; + +} // namespace internal + +// Forward declarations +class ServerUnaryReactor; +template +class ServerReadReactor; +template +class ServerWriteReactor; +template +class ServerBidiReactor; + +// NOTE: The actual call/stream object classes are provided as API only to +// support mocking. There are no implementations of these class interfaces in +// the API. +class ServerCallbackUnary : public internal::ServerCallbackCall { + public: + virtual ~ServerCallbackUnary() {} + virtual void Finish(::grpc::Status s) = 0; + virtual void SendInitialMetadata() = 0; + + protected: + // Use a template rather than explicitly specifying ServerUnaryReactor to + // delay binding and avoid a circular forward declaration issue + template + void BindReactor(Reactor* reactor) { + reactor->InternalBindCall(this); + } +}; + +template +class ServerCallbackReader : public internal::ServerCallbackCall { + public: + virtual ~ServerCallbackReader() {} + virtual void Finish(::grpc::Status s) = 0; + virtual void SendInitialMetadata() = 0; + virtual void Read(Request* msg) = 0; + + protected: + void BindReactor(ServerReadReactor* reactor) { + reactor->InternalBindReader(this); + } +}; + +template +class ServerCallbackWriter : public internal::ServerCallbackCall { + public: + virtual ~ServerCallbackWriter() {} + + virtual void Finish(::grpc::Status s) = 0; + virtual void SendInitialMetadata() = 0; + virtual void Write(const Response* msg, ::grpc::WriteOptions options) = 0; + virtual void WriteAndFinish(const Response* msg, ::grpc::WriteOptions options, + ::grpc::Status s) = 0; + + protected: + void BindReactor(ServerWriteReactor* reactor) { + reactor->InternalBindWriter(this); + } +}; + +template +class ServerCallbackReaderWriter : public internal::ServerCallbackCall { + public: + virtual ~ServerCallbackReaderWriter() {} + + virtual void Finish(::grpc::Status s) = 0; + virtual void SendInitialMetadata() = 0; + virtual void Read(Request* msg) = 0; + virtual void Write(const Response* msg, ::grpc::WriteOptions options) = 0; + virtual void WriteAndFinish(const Response* msg, ::grpc::WriteOptions options, + ::grpc::Status s) = 0; + + protected: + void BindReactor(ServerBidiReactor* reactor) { + reactor->InternalBindStream(this); + } +}; + +// The following classes are the reactor interfaces that are to be implemented +// by the user, returned as the output parameter of the method handler for a +// callback method. Note that none of the classes are pure; all reactions have a +// default empty reaction so that the user class only needs to override those +// classes that it cares about. + +/// \a ServerBidiReactor is the interface for a bidirectional streaming RPC. +template +class ServerBidiReactor : public internal::ServerReactor { + public: + // NOTE: Initializing stream_ as a constructor initializer rather than a + // default initializer because gcc-4.x requires a copy constructor for + // default initializing a templated member, which isn't ok for atomic. + // TODO(vjpai): Switch to default constructor and default initializer when + // gcc-4.x is no longer supported + ServerBidiReactor() : stream_(nullptr) {} + ~ServerBidiReactor() = default; + + /// Send any initial metadata stored in the RPC context. If not invoked, + /// any initial metadata will be passed along with the first Write or the + /// Finish (if there are no writes). + void StartSendInitialMetadata() { + ServerCallbackReaderWriter* stream = + stream_.load(std::memory_order_acquire); + if (stream == nullptr) { + grpc::internal::MutexLock l(&stream_mu_); + stream = stream_.load(std::memory_order_relaxed); + if (stream == nullptr) { + backlog_.send_initial_metadata_wanted = true; + return; + } + } + stream->SendInitialMetadata(); + } + + /// Initiate a read operation. + /// + /// \param[out] req Where to eventually store the read message. Valid when + /// the library calls OnReadDone + void StartRead(Request* req) { + ServerCallbackReaderWriter* stream = + stream_.load(std::memory_order_acquire); + if (stream == nullptr) { + grpc::internal::MutexLock l(&stream_mu_); + stream = stream_.load(std::memory_order_relaxed); + if (stream == nullptr) { + backlog_.read_wanted = req; + return; + } + } + stream->Read(req); + } + + /// Initiate a write operation. + /// + /// \param[in] resp The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the + /// application regains ownership of resp. + void StartWrite(const Response* resp) { + StartWrite(resp, ::grpc::WriteOptions()); + } + + /// Initiate a write operation with specified options. + /// + /// \param[in] resp The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the + /// application regains ownership of resp. + /// \param[in] options The WriteOptions to use for writing this message + void StartWrite(const Response* resp, ::grpc::WriteOptions options) { + ServerCallbackReaderWriter* stream = + stream_.load(std::memory_order_acquire); + if (stream == nullptr) { + grpc::internal::MutexLock l(&stream_mu_); + stream = stream_.load(std::memory_order_relaxed); + if (stream == nullptr) { + backlog_.write_wanted = resp; + backlog_.write_options_wanted = std::move(options); + return; + } + } + stream->Write(resp, std::move(options)); + } + + /// Initiate a write operation with specified options and final RPC Status, + /// which also causes any trailing metadata for this RPC to be sent out. + /// StartWriteAndFinish is like merging StartWriteLast and Finish into a + /// single step. A key difference, though, is that this operation doesn't have + /// an OnWriteDone reaction - it is considered complete only when OnDone is + /// available. An RPC can either have StartWriteAndFinish or Finish, but not + /// both. + /// + /// \param[in] resp The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the + /// application regains ownership of resp. + /// \param[in] options The WriteOptions to use for writing this message + /// \param[in] s The status outcome of this RPC + void StartWriteAndFinish(const Response* resp, ::grpc::WriteOptions options, + ::grpc::Status s) { + ServerCallbackReaderWriter* stream = + stream_.load(std::memory_order_acquire); + if (stream == nullptr) { + grpc::internal::MutexLock l(&stream_mu_); + stream = stream_.load(std::memory_order_relaxed); + if (stream == nullptr) { + backlog_.write_and_finish_wanted = true; + backlog_.write_wanted = resp; + backlog_.write_options_wanted = std::move(options); + backlog_.status_wanted = std::move(s); + return; + } + } + stream->WriteAndFinish(resp, std::move(options), std::move(s)); + } + + /// Inform system of a planned write operation with specified options, but + /// allow the library to schedule the actual write coalesced with the writing + /// of trailing metadata (which takes place on a Finish call). + /// + /// \param[in] resp The message to be written. The library takes temporary + /// ownership until OnWriteDone, at which point the + /// application regains ownership of resp. + /// \param[in] options The WriteOptions to use for writing this message + void StartWriteLast(const Response* resp, ::grpc::WriteOptions options) { + StartWrite(resp, std::move(options.set_last_message())); + } + + /// Indicate that the stream is to be finished and the trailing metadata and + /// RPC status are to be sent. Every RPC MUST be finished using either Finish + /// or StartWriteAndFinish (but not both), even if the RPC is already + /// cancelled. + /// + /// \param[in] s The status outcome of this RPC + void Finish(::grpc::Status s) { + ServerCallbackReaderWriter* stream = + stream_.load(std::memory_order_acquire); + if (stream == nullptr) { + grpc::internal::MutexLock l(&stream_mu_); + stream = stream_.load(std::memory_order_relaxed); + if (stream == nullptr) { + backlog_.finish_wanted = true; + backlog_.status_wanted = std::move(s); + return; + } + } + stream->Finish(std::move(s)); + } + + /// Notifies the application that an explicit StartSendInitialMetadata + /// operation completed. Not used when the sending of initial metadata + /// piggybacks onto the first write. + /// + /// \param[in] ok Was it successful? If false, no further write-side operation + /// will succeed. + virtual void OnSendInitialMetadataDone(bool /*ok*/) {} + + /// Notifies the application that a StartRead operation completed. + /// + /// \param[in] ok Was it successful? If false, no further read-side operation + /// will succeed. + virtual void OnReadDone(bool /*ok*/) {} + + /// Notifies the application that a StartWrite (or StartWriteLast) operation + /// completed. + /// + /// \param[in] ok Was it successful? If false, no further write-side operation + /// will succeed. + virtual void OnWriteDone(bool /*ok*/) {} + + /// Notifies the application that all operations associated with this RPC + /// have completed. This is an override (from the internal base class) but + /// still abstract, so derived classes MUST override it to be instantiated. + void OnDone() override = 0; + + /// Notifies the application that this RPC has been cancelled. This is an + /// override (from the internal base class) but not final, so derived classes + /// should override it if they want to take action. + void OnCancel() override {} + + private: + friend class ServerCallbackReaderWriter; + // May be overridden by internal implementation details. This is not a public + // customization point. + virtual void InternalBindStream( + ServerCallbackReaderWriter* stream) { + // TODO(vjpai): When stream_or_backlog_ becomes a variant (see below), use + // a scoped MutexLock and std::swap stream_or_backlog_ with a variant that + // has stream, then std::get out of that after the lock. + // Do likewise with the remaining InternalBind* functions as well. + grpc::internal::ReleasableMutexLock l(&stream_mu_); + PreBindBacklog ops(std::move(backlog_)); + stream_.store(stream, std::memory_order_release); + l.Unlock(); + + if (ops.send_initial_metadata_wanted) { + stream->SendInitialMetadata(); + } + if (ops.read_wanted != nullptr) { + stream->Read(ops.read_wanted); + } + if (ops.write_and_finish_wanted) { + stream->WriteAndFinish(ops.write_wanted, + std::move(ops.write_options_wanted), + std::move(ops.status_wanted)); + } else { + if (ops.write_wanted != nullptr) { + stream->Write(ops.write_wanted, std::move(ops.write_options_wanted)); + } + if (ops.finish_wanted) { + stream->Finish(std::move(ops.status_wanted)); + } + } + } + + grpc::internal::Mutex stream_mu_; + // TODO(vjpai): Make stream_or_backlog_ into a std::variant or absl::variant + // once C++17 or ABSL is supported since stream and backlog are + // mutually exclusive in this class. Do likewise with the + // remaining reactor classes and their backlogs as well. + std::atomic*> stream_{nullptr}; + struct PreBindBacklog { + bool send_initial_metadata_wanted = false; + bool write_and_finish_wanted = false; + bool finish_wanted = false; + Request* read_wanted = nullptr; + const Response* write_wanted = nullptr; + ::grpc::WriteOptions write_options_wanted; + ::grpc::Status status_wanted; + }; + PreBindBacklog backlog_ /* GUARDED_BY(stream_mu_) */; +}; + +/// \a ServerReadReactor is the interface for a client-streaming RPC. +template +class ServerReadReactor : public internal::ServerReactor { + public: + ServerReadReactor() : reader_(nullptr) {} + ~ServerReadReactor() = default; + + /// The following operation initiations are exactly like ServerBidiReactor. + void StartSendInitialMetadata() { + ServerCallbackReader* reader = + reader_.load(std::memory_order_acquire); + if (reader == nullptr) { + grpc::internal::MutexLock l(&reader_mu_); + reader = reader_.load(std::memory_order_relaxed); + if (reader == nullptr) { + backlog_.send_initial_metadata_wanted = true; + return; + } + } + reader->SendInitialMetadata(); + } + void StartRead(Request* req) { + ServerCallbackReader* reader = + reader_.load(std::memory_order_acquire); + if (reader == nullptr) { + grpc::internal::MutexLock l(&reader_mu_); + reader = reader_.load(std::memory_order_relaxed); + if (reader == nullptr) { + backlog_.read_wanted = req; + return; + } + } + reader->Read(req); + } + void Finish(::grpc::Status s) { + ServerCallbackReader* reader = + reader_.load(std::memory_order_acquire); + if (reader == nullptr) { + grpc::internal::MutexLock l(&reader_mu_); + reader = reader_.load(std::memory_order_relaxed); + if (reader == nullptr) { + backlog_.finish_wanted = true; + backlog_.status_wanted = std::move(s); + return; + } + } + reader->Finish(std::move(s)); + } + + /// The following notifications are exactly like ServerBidiReactor. + virtual void OnSendInitialMetadataDone(bool /*ok*/) {} + virtual void OnReadDone(bool /*ok*/) {} + void OnDone() override = 0; + void OnCancel() override {} + + private: + friend class ServerCallbackReader; + + // May be overridden by internal implementation details. This is not a public + // customization point. + virtual void InternalBindReader(ServerCallbackReader* reader) { + grpc::internal::ReleasableMutexLock l(&reader_mu_); + PreBindBacklog ops(std::move(backlog_)); + reader_.store(reader, std::memory_order_release); + l.Unlock(); + + if (ops.send_initial_metadata_wanted) { + reader->SendInitialMetadata(); + } + if (ops.read_wanted != nullptr) { + reader->Read(ops.read_wanted); + } + if (ops.finish_wanted) { + reader->Finish(std::move(ops.status_wanted)); + } + } + + grpc::internal::Mutex reader_mu_; + std::atomic*> reader_{nullptr}; + struct PreBindBacklog { + bool send_initial_metadata_wanted = false; + bool finish_wanted = false; + Request* read_wanted = nullptr; + ::grpc::Status status_wanted; + }; + PreBindBacklog backlog_ /* GUARDED_BY(reader_mu_) */; +}; + +/// \a ServerWriteReactor is the interface for a server-streaming RPC. +template +class ServerWriteReactor : public internal::ServerReactor { + public: + ServerWriteReactor() : writer_(nullptr) {} + ~ServerWriteReactor() = default; + + /// The following operation initiations are exactly like ServerBidiReactor. + void StartSendInitialMetadata() { + ServerCallbackWriter* writer = + writer_.load(std::memory_order_acquire); + if (writer == nullptr) { + grpc::internal::MutexLock l(&writer_mu_); + writer = writer_.load(std::memory_order_relaxed); + if (writer == nullptr) { + backlog_.send_initial_metadata_wanted = true; + return; + } + } + writer->SendInitialMetadata(); + } + void StartWrite(const Response* resp) { + StartWrite(resp, ::grpc::WriteOptions()); + } + void StartWrite(const Response* resp, ::grpc::WriteOptions options) { + ServerCallbackWriter* writer = + writer_.load(std::memory_order_acquire); + if (writer == nullptr) { + grpc::internal::MutexLock l(&writer_mu_); + writer = writer_.load(std::memory_order_relaxed); + if (writer == nullptr) { + backlog_.write_wanted = resp; + backlog_.write_options_wanted = std::move(options); + return; + } + } + writer->Write(resp, std::move(options)); + } + void StartWriteAndFinish(const Response* resp, ::grpc::WriteOptions options, + ::grpc::Status s) { + ServerCallbackWriter* writer = + writer_.load(std::memory_order_acquire); + if (writer == nullptr) { + grpc::internal::MutexLock l(&writer_mu_); + writer = writer_.load(std::memory_order_relaxed); + if (writer == nullptr) { + backlog_.write_and_finish_wanted = true; + backlog_.write_wanted = resp; + backlog_.write_options_wanted = std::move(options); + backlog_.status_wanted = std::move(s); + return; + } + } + writer->WriteAndFinish(resp, std::move(options), std::move(s)); + } + void StartWriteLast(const Response* resp, ::grpc::WriteOptions options) { + StartWrite(resp, std::move(options.set_last_message())); + } + void Finish(::grpc::Status s) { + ServerCallbackWriter* writer = + writer_.load(std::memory_order_acquire); + if (writer == nullptr) { + grpc::internal::MutexLock l(&writer_mu_); + writer = writer_.load(std::memory_order_relaxed); + if (writer == nullptr) { + backlog_.finish_wanted = true; + backlog_.status_wanted = std::move(s); + return; + } + } + writer->Finish(std::move(s)); + } + + /// The following notifications are exactly like ServerBidiReactor. + virtual void OnSendInitialMetadataDone(bool /*ok*/) {} + virtual void OnWriteDone(bool /*ok*/) {} + void OnDone() override = 0; + void OnCancel() override {} + + private: + friend class ServerCallbackWriter; + // May be overridden by internal implementation details. This is not a public + // customization point. + virtual void InternalBindWriter(ServerCallbackWriter* writer) { + grpc::internal::ReleasableMutexLock l(&writer_mu_); + PreBindBacklog ops(std::move(backlog_)); + writer_.store(writer, std::memory_order_release); + l.Unlock(); + + if (ops.send_initial_metadata_wanted) { + writer->SendInitialMetadata(); + } + if (ops.write_and_finish_wanted) { + writer->WriteAndFinish(ops.write_wanted, + std::move(ops.write_options_wanted), + std::move(ops.status_wanted)); + } else { + if (ops.write_wanted != nullptr) { + writer->Write(ops.write_wanted, std::move(ops.write_options_wanted)); + } + if (ops.finish_wanted) { + writer->Finish(std::move(ops.status_wanted)); + } + } + } + + grpc::internal::Mutex writer_mu_; + std::atomic*> writer_{nullptr}; + struct PreBindBacklog { + bool send_initial_metadata_wanted = false; + bool write_and_finish_wanted = false; + bool finish_wanted = false; + const Response* write_wanted = nullptr; + ::grpc::WriteOptions write_options_wanted; + ::grpc::Status status_wanted; + }; + PreBindBacklog backlog_ /* GUARDED_BY(writer_mu_) */; +}; + +class ServerUnaryReactor : public internal::ServerReactor { + public: + ServerUnaryReactor() : call_(nullptr) {} + ~ServerUnaryReactor() = default; + + /// The following operation initiations are exactly like ServerBidiReactor. + void StartSendInitialMetadata() { + ServerCallbackUnary* call = call_.load(std::memory_order_acquire); + if (call == nullptr) { + grpc::internal::MutexLock l(&call_mu_); + call = call_.load(std::memory_order_relaxed); + if (call == nullptr) { + backlog_.send_initial_metadata_wanted = true; + return; + } + } + call->SendInitialMetadata(); + } + void Finish(::grpc::Status s) { + ServerCallbackUnary* call = call_.load(std::memory_order_acquire); + if (call == nullptr) { + grpc::internal::MutexLock l(&call_mu_); + call = call_.load(std::memory_order_relaxed); + if (call == nullptr) { + backlog_.finish_wanted = true; + backlog_.status_wanted = std::move(s); + return; + } + } + call->Finish(std::move(s)); + } + + /// The following notifications are exactly like ServerBidiReactor. + virtual void OnSendInitialMetadataDone(bool /*ok*/) {} + void OnDone() override = 0; + void OnCancel() override {} + + private: + friend class ServerCallbackUnary; + // May be overridden by internal implementation details. This is not a public + // customization point. + virtual void InternalBindCall(ServerCallbackUnary* call) { + grpc::internal::ReleasableMutexLock l(&call_mu_); + PreBindBacklog ops(std::move(backlog_)); + call_.store(call, std::memory_order_release); + l.Unlock(); + + if (ops.send_initial_metadata_wanted) { + call->SendInitialMetadata(); + } + if (ops.finish_wanted) { + call->Finish(std::move(ops.status_wanted)); + } + } + + grpc::internal::Mutex call_mu_; + std::atomic call_{nullptr}; + struct PreBindBacklog { + bool send_initial_metadata_wanted = false; + bool finish_wanted = false; + ::grpc::Status status_wanted; + }; + PreBindBacklog backlog_ /* GUARDED_BY(call_mu_) */; +}; + +namespace internal { + +template +class FinishOnlyReactor : public Base { + public: + explicit FinishOnlyReactor(::grpc::Status s) { this->Finish(std::move(s)); } + void OnDone() override { this->~FinishOnlyReactor(); } +}; + +using UnimplementedUnaryReactor = FinishOnlyReactor; +template +using UnimplementedReadReactor = FinishOnlyReactor>; +template +using UnimplementedWriteReactor = + FinishOnlyReactor>; +template +using UnimplementedBidiReactor = + FinishOnlyReactor>; + +} // namespace internal +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_context.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_context.h new file mode 100644 index 0000000000000000000000000000000000000000..85b309e6d5213ba9197955c60d423e0f79783fab --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_context.h @@ -0,0 +1,42 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SERVER_CONTEXT_H +#define GRPCPP_IMPL_CODEGEN_SERVER_CONTEXT_H + +#include + +namespace grpc { + +typedef ::grpc_impl::ServerContext ServerContext; + +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL +typedef ::grpc_impl::ServerContextBase ServerContextBase; +typedef ::grpc_impl::CallbackServerContext CallbackServerContext; +#endif + +// TODO(vjpai): Remove namespace experimental when de-experimentalized fully. +namespace experimental { + +typedef ::grpc_impl::ServerContextBase ServerContextBase; +typedef ::grpc_impl::CallbackServerContext CallbackServerContext; + +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_SERVER_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_context_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_context_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..7458eb3aeae3d1440ed6af4762abe67ad076e7cf --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_context_impl.h @@ -0,0 +1,588 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SERVER_CONTEXT_IMPL_H +#define GRPCPP_IMPL_CODEGEN_SERVER_CONTEXT_IMPL_H + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct grpc_metadata; +struct grpc_call; +struct census_context; + +namespace grpc_impl { +class ClientContext; +class CompletionQueue; +class Server; +template +class ServerAsyncReader; +template +class ServerAsyncWriter; +template +class ServerAsyncResponseWriter; +template +class ServerAsyncReaderWriter; +template +class ServerReader; +template +class ServerWriter; + +namespace internal { +template +class BidiStreamingHandler; +template +class CallbackUnaryHandler; +template +class CallbackClientStreamingHandler; +template +class CallbackServerStreamingHandler; +template +class CallbackBidiHandler; +template +class ClientStreamingHandler; +template +class RpcMethodHandler; +template +class FinishOnlyReactor; +template +class ServerReaderWriterBody; +template +class ServerStreamingHandler; +class ServerReactor; +template +class TemplatedBidiStreamingHandler; +template <::grpc::StatusCode code> +class ErrorMethodHandler; +} // namespace internal + +} // namespace grpc_impl +namespace grpc { +class GenericServerContext; +class ServerInterface; + +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL +namespace experimental { +#endif +class GenericCallbackServerContext; +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL +} // namespace experimental +#endif +namespace internal { +class Call; +} // namespace internal + +namespace testing { +class InteropServerContextInspector; +class ServerContextTestSpouse; +class DefaultReactorTestPeer; +} // namespace testing + +} // namespace grpc + +namespace grpc_impl { + +/// Base class of ServerContext. Experimental until callback API is final. +class ServerContextBase { + public: + virtual ~ServerContextBase(); + + /// Return the deadline for the server call. + std::chrono::system_clock::time_point deadline() const { + return ::grpc::Timespec2Timepoint(deadline_); + } + + /// Return a \a gpr_timespec representation of the server call's deadline. + gpr_timespec raw_deadline() const { return deadline_; } + + /// Add the (\a key, \a value) pair to the initial metadata + /// associated with a server call. These are made available at the client side + /// by the \a grpc::ClientContext::GetServerInitialMetadata() method. + /// + /// \warning This method should only be called before sending initial metadata + /// to the client (which can happen explicitly, or implicitly when sending a + /// a response message or status to the client). + /// + /// \param key The metadata key. If \a value is binary data, it must + /// end in "-bin". + /// \param value The metadata value. If its value is binary, the key name + /// must end in "-bin". + /// + /// Metadata must conform to the following format: + /// Custom-Metadata -> Binary-Header / ASCII-Header + /// Binary-Header -> {Header-Name "-bin" } {binary value} + /// ASCII-Header -> Header-Name ASCII-Value + /// Header-Name -> 1*( %x30-39 / %x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - . + /// ASCII-Value -> 1*( %x20-%x7E ) ; space and printable ASCII + void AddInitialMetadata(const grpc::string& key, const grpc::string& value); + + /// Add the (\a key, \a value) pair to the initial metadata + /// associated with a server call. These are made available at the client + /// side by the \a grpc::ClientContext::GetServerTrailingMetadata() method. + /// + /// \warning This method should only be called before sending trailing + /// metadata to the client (which happens when the call is finished and a + /// status is sent to the client). + /// + /// \param key The metadata key. If \a value is binary data, + /// it must end in "-bin". + /// \param value The metadata value. If its value is binary, the key name + /// must end in "-bin". + /// + /// Metadata must conform to the following format: + /// Custom-Metadata -> Binary-Header / ASCII-Header + /// Binary-Header -> {Header-Name "-bin" } {binary value} + /// ASCII-Header -> Header-Name ASCII-Value + /// Header-Name -> 1*( %x30-39 / %x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - . + /// ASCII-Value -> 1*( %x20-%x7E ) ; space and printable ASCII + void AddTrailingMetadata(const grpc::string& key, const grpc::string& value); + + /// IsCancelled is always safe to call when using sync or callback API. + /// When using async API, it is only safe to call IsCancelled after + /// the AsyncNotifyWhenDone tag has been delivered. Thread-safe. + bool IsCancelled() const; + + /// Cancel the Call from the server. This is a best-effort API and + /// depending on when it is called, the RPC may still appear successful to + /// the client. + /// For example, if TryCancel() is called on a separate thread, it might race + /// with the server handler which might return success to the client before + /// TryCancel() was even started by the thread. + /// + /// It is the caller's responsibility to prevent such races and ensure that if + /// TryCancel() is called, the serverhandler must return Status::CANCELLED. + /// The only exception is that if the serverhandler is already returning an + /// error status code, it is ok to not return Status::CANCELLED even if + /// TryCancel() was called. + /// + /// Note that TryCancel() does not change any of the tags that are pending + /// on the completion queue. All pending tags will still be delivered + /// (though their ok result may reflect the effect of cancellation). + void TryCancel() const; + + /// Return a collection of initial metadata key-value pairs sent from the + /// client. Note that keys may happen more than + /// once (ie, a \a std::multimap is returned). + /// + /// It is safe to use this method after initial metadata has been received, + /// Calls always begin with the client sending initial metadata, so this is + /// safe to access as soon as the call has begun on the server side. + /// + /// \return A multimap of initial metadata key-value pairs from the server. + const std::multimap& client_metadata() + const { + return *client_metadata_.map(); + } + + /// Return the compression algorithm to be used by the server call. + grpc_compression_level compression_level() const { + return compression_level_; + } + + /// Set \a level to be the compression level used for the server call. + /// + /// \param level The compression level used for the server call. + void set_compression_level(grpc_compression_level level) { + compression_level_set_ = true; + compression_level_ = level; + } + + /// Return a bool indicating whether the compression level for this call + /// has been set (either implicitly or through a previous call to + /// \a set_compression_level. + bool compression_level_set() const { return compression_level_set_; } + + /// Return the compression algorithm the server call will request be used. + /// Note that the gRPC runtime may decide to ignore this request, for example, + /// due to resource constraints, or if the server is aware the client doesn't + /// support the requested algorithm. + grpc_compression_algorithm compression_algorithm() const { + return compression_algorithm_; + } + /// Set \a algorithm to be the compression algorithm used for the server call. + /// + /// \param algorithm The compression algorithm used for the server call. + void set_compression_algorithm(grpc_compression_algorithm algorithm); + + /// Set the serialized load reporting costs in \a cost_data for the call. + void SetLoadReportingCosts(const std::vector& cost_data); + + /// Return the authentication context for this server call. + /// + /// \see grpc::AuthContext. + std::shared_ptr auth_context() const { + if (auth_context_.get() == nullptr) { + auth_context_ = ::grpc::CreateAuthContext(call_); + } + return auth_context_; + } + + /// Return the peer uri in a string. + /// WARNING: this value is never authenticated or subject to any security + /// related code. It must not be used for any authentication related + /// functionality. Instead, use auth_context. + grpc::string peer() const; + + /// Get the census context associated with this server call. + const struct census_context* census_context() const; + + /// Should be used for framework-level extensions only. + /// Applications never need to call this method. + grpc_call* c_call() { return call_; } + + protected: + /// Async only. Has to be called before the rpc starts. + /// Returns the tag in completion queue when the rpc finishes. + /// IsCancelled() can then be called to check whether the rpc was cancelled. + /// TODO(vjpai): Fix this so that the tag is returned even if the call never + /// starts (https://github.com/grpc/grpc/issues/10136). + void AsyncNotifyWhenDone(void* tag) { + has_notify_when_done_tag_ = true; + async_notify_when_done_tag_ = tag; + } + + /// NOTE: This is an API for advanced users who need custom allocators. + /// Get and maybe mutate the allocator state associated with the current RPC. + /// Currently only applicable for callback unary RPC methods. + /// WARNING: This is experimental API and could be changed or removed. + ::grpc::experimental::RpcAllocatorState* GetRpcAllocatorState() { + return message_allocator_state_; + } + + /// Get a library-owned default unary reactor for use in minimal reaction + /// cases. This supports typical unary RPC usage of providing a response and + /// status. It supports immediate Finish (finish from within the method + /// handler) or delayed Finish (finish called after the method handler + /// invocation). It does not support reacting to cancellation or completion, + /// or early sending of initial metadata. Since this is a library-owned + /// reactor, it should not be delete'd or freed in any way. This is more + /// efficient than creating a user-owned reactor both because of avoiding an + /// allocation and because its minimal reactions are optimized using a core + /// surface flag that allows their reactions to run inline without any + /// thread-hop. + /// + /// This method should not be called more than once or called after return + /// from the method handler. + /// + /// WARNING: This is experimental API and could be changed or removed. + ::grpc_impl::ServerUnaryReactor* DefaultReactor() { + auto reactor = &default_reactor_; + default_reactor_used_.store(true, std::memory_order_relaxed); + return reactor; + } + + /// Constructors for use by derived classes + ServerContextBase(); + ServerContextBase(gpr_timespec deadline, grpc_metadata_array* arr); + + private: + friend class ::grpc::testing::InteropServerContextInspector; + friend class ::grpc::testing::ServerContextTestSpouse; + friend class ::grpc::testing::DefaultReactorTestPeer; + friend class ::grpc::ServerInterface; + friend class ::grpc_impl::Server; + template + friend class ::grpc_impl::ServerAsyncReader; + template + friend class ::grpc_impl::ServerAsyncWriter; + template + friend class ::grpc_impl::ServerAsyncResponseWriter; + template + friend class ::grpc_impl::ServerAsyncReaderWriter; + template + friend class ::grpc_impl::ServerReader; + template + friend class ::grpc_impl::ServerWriter; + template + friend class ::grpc_impl::internal::ServerReaderWriterBody; + template + friend class ::grpc_impl::internal::RpcMethodHandler; + template + friend class ::grpc_impl::internal::ClientStreamingHandler; + template + friend class ::grpc_impl::internal::ServerStreamingHandler; + template + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler; + template + friend class ::grpc_impl::internal::CallbackUnaryHandler; + template + friend class ::grpc_impl::internal::CallbackClientStreamingHandler; + template + friend class ::grpc_impl::internal::CallbackServerStreamingHandler; + template + friend class ::grpc_impl::internal::CallbackBidiHandler; + template <::grpc::StatusCode code> + friend class ::grpc_impl::internal::ErrorMethodHandler; + template + friend class ::grpc_impl::internal::FinishOnlyReactor; + friend class ::grpc_impl::ClientContext; + friend class ::grpc::GenericServerContext; +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL + friend class ::grpc::GenericCallbackServerContext; +#else + friend class ::grpc::experimental::GenericCallbackServerContext; +#endif + + /// Prevent copying. + ServerContextBase(const ServerContextBase&); + ServerContextBase& operator=(const ServerContextBase&); + + class CompletionOp; + + void BeginCompletionOp( + ::grpc::internal::Call* call, std::function callback, + ::grpc_impl::internal::ServerCallbackCall* callback_controller); + /// Return the tag queued by BeginCompletionOp() + ::grpc::internal::CompletionQueueTag* GetCompletionOpTag(); + + void set_call(grpc_call* call) { call_ = call; } + + void BindDeadlineAndMetadata(gpr_timespec deadline, grpc_metadata_array* arr); + + void Clear(); + + void Setup(gpr_timespec deadline); + + uint32_t initial_metadata_flags() const { return 0; } + + ::grpc::experimental::ServerRpcInfo* set_server_rpc_info( + const char* method, ::grpc::internal::RpcMethod::RpcType type, + const std::vector>& creators) { + if (creators.size() != 0) { + rpc_info_ = new ::grpc::experimental::ServerRpcInfo(this, method, type); + rpc_info_->RegisterInterceptors(creators); + } + return rpc_info_; + } + + void set_message_allocator_state( + ::grpc::experimental::RpcAllocatorState* allocator_state) { + message_allocator_state_ = allocator_state; + } + + CompletionOp* completion_op_; + bool has_notify_when_done_tag_; + void* async_notify_when_done_tag_; + ::grpc::internal::CallbackWithSuccessTag completion_tag_; + + gpr_timespec deadline_; + grpc_call* call_; + ::grpc_impl::CompletionQueue* cq_; + bool sent_initial_metadata_; + mutable std::shared_ptr auth_context_; + mutable ::grpc::internal::MetadataMap client_metadata_; + std::multimap initial_metadata_; + std::multimap trailing_metadata_; + + bool compression_level_set_; + grpc_compression_level compression_level_; + grpc_compression_algorithm compression_algorithm_; + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage> + pending_ops_; + bool has_pending_ops_; + + ::grpc::experimental::ServerRpcInfo* rpc_info_; + ::grpc::experimental::RpcAllocatorState* message_allocator_state_ = nullptr; + + class Reactor : public ServerUnaryReactor { + public: + void OnCancel() override {} + void OnDone() override {} + // Override InternalInlineable for this class since its reactions are + // trivial and thus do not need to be run from the executor (triggering a + // thread hop). This should only be used by internal reactors (thus the + // name) and not by user application code. + bool InternalInlineable() override { return true; } + }; + + void SetupTestDefaultReactor(std::function func) { + test_unary_.reset(new TestServerCallbackUnary(this, std::move(func))); + } + bool test_status_set() const { + return (test_unary_ != nullptr) && test_unary_->status_set(); + } + ::grpc::Status test_status() const { return test_unary_->status(); } + + class TestServerCallbackUnary : public ::grpc_impl::ServerCallbackUnary { + public: + TestServerCallbackUnary(ServerContextBase* ctx, + std::function func) + : reactor_(&ctx->default_reactor_), func_(std::move(func)) { + this->BindReactor(reactor_); + } + void Finish(::grpc::Status s) override { + status_ = s; + func_(std::move(s)); + status_set_.store(true, std::memory_order_release); + } + void SendInitialMetadata() override {} + + bool status_set() const { + return status_set_.load(std::memory_order_acquire); + } + ::grpc::Status status() const { return status_; } + + private: + void MaybeDone() override {} + ::grpc_impl::internal::ServerReactor* reactor() override { + return reactor_; + } + + ::grpc_impl::ServerUnaryReactor* const reactor_; + std::atomic_bool status_set_{false}; + ::grpc::Status status_; + const std::function func_; + }; + + Reactor default_reactor_; + std::atomic_bool default_reactor_used_{false}; + std::unique_ptr test_unary_; +}; + +/// A ServerContext or CallbackServerContext allows the code implementing a +/// service handler to: +/// +/// - Add custom initial and trailing metadata key-value pairs that will +/// propagated to the client side. +/// - Control call settings such as compression and authentication. +/// - Access metadata coming from the client. +/// - Get performance metrics (ie, census). +/// +/// Context settings are only relevant to the call handler they are supplied to, +/// that is to say, they aren't sticky across multiple calls. Some of these +/// settings, such as the compression options, can be made persistent at server +/// construction time by specifying the appropriate \a ChannelArguments +/// to a \a grpc::ServerBuilder, via \a ServerBuilder::AddChannelArgument. +/// +/// \warning ServerContext instances should \em not be reused across rpcs. +class ServerContext : public ServerContextBase { + public: + ServerContext() {} // for async calls + + using ServerContextBase::AddInitialMetadata; + using ServerContextBase::AddTrailingMetadata; + using ServerContextBase::IsCancelled; + using ServerContextBase::SetLoadReportingCosts; + using ServerContextBase::TryCancel; + using ServerContextBase::auth_context; + using ServerContextBase::c_call; + using ServerContextBase::census_context; + using ServerContextBase::client_metadata; + using ServerContextBase::compression_algorithm; + using ServerContextBase::compression_level; + using ServerContextBase::compression_level_set; + using ServerContextBase::deadline; + using ServerContextBase::peer; + using ServerContextBase::raw_deadline; + using ServerContextBase::set_compression_algorithm; + using ServerContextBase::set_compression_level; + + // Sync/CQ-based Async ServerContext only + using ServerContextBase::AsyncNotifyWhenDone; + + private: + // Constructor for internal use by server only + friend class ::grpc_impl::Server; + ServerContext(gpr_timespec deadline, grpc_metadata_array* arr) + : ServerContextBase(deadline, arr) {} + + // CallbackServerContext only + using ServerContextBase::DefaultReactor; + using ServerContextBase::GetRpcAllocatorState; + + /// Prevent copying. + ServerContext(const ServerContext&) = delete; + ServerContext& operator=(const ServerContext&) = delete; +}; + +class CallbackServerContext : public ServerContextBase { + public: + /// Public constructors are for direct use only by mocking tests. In practice, + /// these objects will be owned by the library. + CallbackServerContext() {} + + using ServerContextBase::AddInitialMetadata; + using ServerContextBase::AddTrailingMetadata; + using ServerContextBase::IsCancelled; + using ServerContextBase::SetLoadReportingCosts; + using ServerContextBase::TryCancel; + using ServerContextBase::auth_context; + using ServerContextBase::c_call; + using ServerContextBase::census_context; + using ServerContextBase::client_metadata; + using ServerContextBase::compression_algorithm; + using ServerContextBase::compression_level; + using ServerContextBase::compression_level_set; + using ServerContextBase::deadline; + using ServerContextBase::peer; + using ServerContextBase::raw_deadline; + using ServerContextBase::set_compression_algorithm; + using ServerContextBase::set_compression_level; + + // CallbackServerContext only + using ServerContextBase::DefaultReactor; + using ServerContextBase::GetRpcAllocatorState; + + private: + // Sync/CQ-based Async ServerContext only + using ServerContextBase::AsyncNotifyWhenDone; + + /// Prevent copying. + CallbackServerContext(const CallbackServerContext&) = delete; + CallbackServerContext& operator=(const CallbackServerContext&) = delete; +}; + +} // namespace grpc_impl + +static_assert(std::is_base_of<::grpc_impl::ServerContextBase, + ::grpc_impl::ServerContext>::value, + "improper base class"); +static_assert(std::is_base_of<::grpc_impl::ServerContextBase, + ::grpc_impl::CallbackServerContext>::value, + "improper base class"); +static_assert(sizeof(::grpc_impl::ServerContextBase) == + sizeof(::grpc_impl::ServerContext), + "wrong size"); +static_assert(sizeof(::grpc_impl::ServerContextBase) == + sizeof(::grpc_impl::CallbackServerContext), + "wrong size"); + +#endif // GRPCPP_IMPL_CODEGEN_SERVER_CONTEXT_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_interceptor.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_interceptor.h new file mode 100644 index 0000000000000000000000000000000000000000..cee6869f208aa0b2cd9f918ca7c99ca9dded36d9 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_interceptor.h @@ -0,0 +1,143 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SERVER_INTERCEPTOR_H +#define GRPCPP_IMPL_CODEGEN_SERVER_INTERCEPTOR_H + +#include +#include + +#include +#include +#include + +namespace grpc_impl { +class ServerContextBase; +} // namespace grpc_impl + +namespace grpc { + +namespace internal { +class InterceptorBatchMethodsImpl; +} + +namespace experimental { +class ServerRpcInfo; + +// A factory interface for creation of server interceptors. A vector of +// factories can be provided to ServerBuilder which will be used to create a new +// vector of server interceptors per RPC. Server interceptor authors should +// create a subclass of ServerInterceptorFactorInterface which creates objects +// of their interceptors. +class ServerInterceptorFactoryInterface { + public: + virtual ~ServerInterceptorFactoryInterface() {} + // Returns a pointer to an Interceptor object on successful creation, nullptr + // otherwise. If nullptr is returned, this server interceptor factory is + // ignored for the purposes of that RPC. + virtual Interceptor* CreateServerInterceptor(ServerRpcInfo* info) = 0; +}; + +/// ServerRpcInfo represents the state of a particular RPC as it +/// appears to an interceptor. It is created and owned by the library and +/// passed to the CreateServerInterceptor method of the application's +/// ServerInterceptorFactoryInterface implementation +class ServerRpcInfo { + public: + /// Type categorizes RPCs by unary or streaming type + enum class Type { UNARY, CLIENT_STREAMING, SERVER_STREAMING, BIDI_STREAMING }; + + ~ServerRpcInfo() {} + + // Delete all copy and move constructors and assignments + ServerRpcInfo(const ServerRpcInfo&) = delete; + ServerRpcInfo& operator=(const ServerRpcInfo&) = delete; + ServerRpcInfo(ServerRpcInfo&&) = delete; + ServerRpcInfo& operator=(ServerRpcInfo&&) = delete; + + // Getter methods + + /// Return the fully-specified method name + const char* method() const { return method_; } + + /// Return the type of the RPC (unary or a streaming flavor) + Type type() const { return type_; } + + /// Return a pointer to the underlying ServerContext structure associated + /// with the RPC to support features that apply to it + grpc_impl::ServerContextBase* server_context() { return ctx_; } + + private: + static_assert(Type::UNARY == + static_cast(internal::RpcMethod::NORMAL_RPC), + "violated expectation about Type enum"); + static_assert(Type::CLIENT_STREAMING == + static_cast(internal::RpcMethod::CLIENT_STREAMING), + "violated expectation about Type enum"); + static_assert(Type::SERVER_STREAMING == + static_cast(internal::RpcMethod::SERVER_STREAMING), + "violated expectation about Type enum"); + static_assert(Type::BIDI_STREAMING == + static_cast(internal::RpcMethod::BIDI_STREAMING), + "violated expectation about Type enum"); + + ServerRpcInfo(grpc_impl::ServerContextBase* ctx, const char* method, + internal::RpcMethod::RpcType type) + : ctx_(ctx), method_(method), type_(static_cast(type)) {} + + // Runs interceptor at pos \a pos. + void RunInterceptor( + experimental::InterceptorBatchMethods* interceptor_methods, size_t pos) { + GPR_CODEGEN_ASSERT(pos < interceptors_.size()); + interceptors_[pos]->Intercept(interceptor_methods); + } + + void RegisterInterceptors( + const std::vector< + std::unique_ptr>& + creators) { + for (const auto& creator : creators) { + auto* interceptor = creator->CreateServerInterceptor(this); + if (interceptor != nullptr) { + interceptors_.push_back( + std::unique_ptr(interceptor)); + } + } + } + + void Ref() { ref_.fetch_add(1, std::memory_order_relaxed); } + void Unref() { + if (GPR_UNLIKELY(ref_.fetch_sub(1, std::memory_order_acq_rel) == 1)) { + delete this; + } + } + + grpc_impl::ServerContextBase* ctx_ = nullptr; + const char* method_ = nullptr; + const Type type_; + std::atomic ref_{1}; + std::vector> interceptors_; + + friend class internal::InterceptorBatchMethodsImpl; + friend class grpc_impl::ServerContextBase; +}; + +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_SERVER_INTERCEPTOR_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_interface.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..80fba7fe57dcfe1311c4e32b7780979ad3878620 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/server_interface.h @@ -0,0 +1,403 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SERVER_INTERFACE_H +#define GRPCPP_IMPL_CODEGEN_SERVER_INTERFACE_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +class Channel; +class CompletionQueue; +class ServerCompletionQueue; +class ServerCredentials; +} // namespace grpc_impl +namespace grpc { + +class AsyncGenericService; +class GenericServerContext; +class Service; + +extern CoreCodegenInterface* g_core_codegen_interface; + +/// Models a gRPC server. +/// +/// Servers are configured and started via \a grpc::ServerBuilder. +namespace internal { +class ServerAsyncStreamingInterface; +} // namespace internal + +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL +namespace experimental { +#endif +class CallbackGenericService; +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL +} // namespace experimental +#endif + +namespace experimental { +class ServerInterceptorFactoryInterface; +} // namespace experimental + +class ServerInterface : public internal::CallHook { + public: + virtual ~ServerInterface() {} + + /// \a Shutdown does the following things: + /// + /// 1. Shutdown the server: deactivate all listening ports, mark it in + /// "shutdown mode" so that further call Request's or incoming RPC matches + /// are no longer allowed. Also return all Request'ed-but-not-yet-active + /// calls as failed (!ok). This refers to calls that have been requested + /// at the server by the server-side library or application code but that + /// have not yet been matched to incoming RPCs from the client. Note that + /// this would even include default calls added automatically by the gRPC + /// C++ API without the user's input (e.g., "Unimplemented RPC method") + /// + /// 2. Block until all rpc method handlers invoked automatically by the sync + /// API finish. + /// + /// 3. If all pending calls complete (and all their operations are + /// retrieved by Next) before \a deadline expires, this finishes + /// gracefully. Otherwise, forcefully cancel all pending calls associated + /// with the server after \a deadline expires. In the case of the sync API, + /// if the RPC function for a streaming call has already been started and + /// takes a week to complete, the RPC function won't be forcefully + /// terminated (since that would leave state corrupt and incomplete) and + /// the method handler will just keep running (which will prevent the + /// server from completing the "join" operation that it needs to do at + /// shutdown time). + /// + /// All completion queue associated with the server (for example, for async + /// serving) must be shutdown *after* this method has returned: + /// See \a ServerBuilder::AddCompletionQueue for details. + /// They must also be drained (by repeated Next) after being shutdown. + /// + /// \param deadline How long to wait until pending rpcs are forcefully + /// terminated. + template + void Shutdown(const T& deadline) { + ShutdownInternal(TimePoint(deadline).raw_time()); + } + + /// Shutdown the server without a deadline and forced cancellation. + /// + /// All completion queue associated with the server (for example, for async + /// serving) must be shutdown *after* this method has returned: + /// See \a ServerBuilder::AddCompletionQueue for details. + void Shutdown() { + ShutdownInternal( + g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_MONOTONIC)); + } + + /// Block waiting for all work to complete. + /// + /// \warning The server must be either shutting down or some other thread must + /// call \a Shutdown for this function to ever return. + virtual void Wait() = 0; + + protected: + friend class ::grpc::Service; + + /// Register a service. This call does not take ownership of the service. + /// The service must exist for the lifetime of the Server instance. + virtual bool RegisterService(const grpc::string* host, Service* service) = 0; + + /// Register a generic service. This call does not take ownership of the + /// service. The service must exist for the lifetime of the Server instance. + virtual void RegisterAsyncGenericService(AsyncGenericService* service) = 0; + +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL + /// Register a callback generic service. This call does not take ownership of + /// the service. The service must exist for the lifetime of the Server + /// instance. May not be abstract since this is a post-1.0 API addition. + + virtual void RegisterCallbackGenericService(CallbackGenericService* + /*service*/) {} +#else + /// NOTE: class experimental_registration_interface is not part of the public + /// API of this class + /// TODO(vjpai): Move these contents to public API when no longer experimental + class experimental_registration_interface { + public: + virtual ~experimental_registration_interface() {} + /// May not be abstract since this is a post-1.0 API addition + virtual void RegisterCallbackGenericService( + experimental::CallbackGenericService* /*service*/) {} + }; + + /// NOTE: The function experimental_registration() is not stable public API. + /// It is a view to the experimental components of this class. It may be + /// changed or removed at any time. May not be abstract since this is a + /// post-1.0 API addition + virtual experimental_registration_interface* experimental_registration() { + return nullptr; + } +#endif + + /// Tries to bind \a server to the given \a addr. + /// + /// It can be invoked multiple times. + /// + /// \param addr The address to try to bind to the server (eg, localhost:1234, + /// 192.168.1.1:31416, [::1]:27182, etc.). + /// \params creds The credentials associated with the server. + /// + /// \return bound port number on success, 0 on failure. + /// + /// \warning It's an error to call this method on an already started server. + virtual int AddListeningPort(const grpc::string& addr, + grpc_impl::ServerCredentials* creds) = 0; + + /// Start the server. + /// + /// \param cqs Completion queues for handling asynchronous services. The + /// caller is required to keep all completion queues live until the server is + /// destroyed. + /// \param num_cqs How many completion queues does \a cqs hold. + virtual void Start(::grpc_impl::ServerCompletionQueue** cqs, + size_t num_cqs) = 0; + + virtual void ShutdownInternal(gpr_timespec deadline) = 0; + + virtual int max_receive_message_size() const = 0; + + virtual grpc_server* server() = 0; + + virtual void PerformOpsOnCall(internal::CallOpSetInterface* ops, + internal::Call* call) = 0; + + class BaseAsyncRequest : public internal::CompletionQueueTag { + public: + BaseAsyncRequest(ServerInterface* server, + ::grpc_impl::ServerContext* context, + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag, bool delete_on_finalize); + virtual ~BaseAsyncRequest(); + + bool FinalizeResult(void** tag, bool* status) override; + + private: + void ContinueFinalizeResultAfterInterception(); + + protected: + ServerInterface* const server_; + ::grpc_impl::ServerContext* const context_; + internal::ServerAsyncStreamingInterface* const stream_; + ::grpc_impl::CompletionQueue* const call_cq_; + ::grpc_impl::ServerCompletionQueue* const notification_cq_; + void* const tag_; + const bool delete_on_finalize_; + grpc_call* call_; + internal::Call call_wrapper_; + internal::InterceptorBatchMethodsImpl interceptor_methods_; + bool done_intercepting_; + }; + + /// RegisteredAsyncRequest is not part of the C++ API + class RegisteredAsyncRequest : public BaseAsyncRequest { + public: + RegisteredAsyncRequest(ServerInterface* server, + ::grpc_impl::ServerContext* context, + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag, const char* name, + internal::RpcMethod::RpcType type); + + virtual bool FinalizeResult(void** tag, bool* status) override { + /* If we are done intercepting, then there is nothing more for us to do */ + if (done_intercepting_) { + return BaseAsyncRequest::FinalizeResult(tag, status); + } + call_wrapper_ = ::grpc::internal::Call( + call_, server_, call_cq_, server_->max_receive_message_size(), + context_->set_server_rpc_info(name_, type_, + *server_->interceptor_creators())); + return BaseAsyncRequest::FinalizeResult(tag, status); + } + + protected: + void IssueRequest(void* registered_method, grpc_byte_buffer** payload, + ::grpc_impl::ServerCompletionQueue* notification_cq); + const char* name_; + const internal::RpcMethod::RpcType type_; + }; + + class NoPayloadAsyncRequest final : public RegisteredAsyncRequest { + public: + NoPayloadAsyncRequest(internal::RpcServiceMethod* registered_method, + ServerInterface* server, + ::grpc_impl::ServerContext* context, + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag) + : RegisteredAsyncRequest( + server, context, stream, call_cq, notification_cq, tag, + registered_method->name(), registered_method->method_type()) { + IssueRequest(registered_method->server_tag(), nullptr, notification_cq); + } + + // uses RegisteredAsyncRequest::FinalizeResult + }; + + template + class PayloadAsyncRequest final : public RegisteredAsyncRequest { + public: + PayloadAsyncRequest(internal::RpcServiceMethod* registered_method, + ServerInterface* server, + ::grpc_impl::ServerContext* context, + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag, Message* request) + : RegisteredAsyncRequest( + server, context, stream, call_cq, notification_cq, tag, + registered_method->name(), registered_method->method_type()), + registered_method_(registered_method), + request_(request) { + IssueRequest(registered_method->server_tag(), payload_.bbuf_ptr(), + notification_cq); + } + + ~PayloadAsyncRequest() { + payload_.Release(); // We do not own the payload_ + } + + bool FinalizeResult(void** tag, bool* status) override { + /* If we are done intercepting, then there is nothing more for us to do */ + if (done_intercepting_) { + return RegisteredAsyncRequest::FinalizeResult(tag, status); + } + if (*status) { + if (!payload_.Valid() || !SerializationTraits::Deserialize( + payload_.bbuf_ptr(), request_) + .ok()) { + // If deserialization fails, we cancel the call and instantiate + // a new instance of ourselves to request another call. We then + // return false, which prevents the call from being returned to + // the application. + g_core_codegen_interface->grpc_call_cancel_with_status( + call_, GRPC_STATUS_INTERNAL, "Unable to parse request", nullptr); + g_core_codegen_interface->grpc_call_unref(call_); + new PayloadAsyncRequest(registered_method_, server_, context_, + stream_, call_cq_, notification_cq_, tag_, + request_); + delete this; + return false; + } + } + /* Set interception point for recv message */ + interceptor_methods_.AddInterceptionHookPoint( + experimental::InterceptionHookPoints::POST_RECV_MESSAGE); + interceptor_methods_.SetRecvMessage(request_, nullptr); + return RegisteredAsyncRequest::FinalizeResult(tag, status); + } + + private: + internal::RpcServiceMethod* const registered_method_; + Message* const request_; + ByteBuffer payload_; + }; + + class GenericAsyncRequest : public BaseAsyncRequest { + public: + GenericAsyncRequest(ServerInterface* server, GenericServerContext* context, + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag, bool delete_on_finalize); + + bool FinalizeResult(void** tag, bool* status) override; + + private: + grpc_call_details call_details_; + }; + + template + void RequestAsyncCall(internal::RpcServiceMethod* method, + ::grpc_impl::ServerContext* context, + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag, Message* message) { + GPR_CODEGEN_ASSERT(method); + new PayloadAsyncRequest(method, this, context, stream, call_cq, + notification_cq, tag, message); + } + + void RequestAsyncCall(internal::RpcServiceMethod* method, + ::grpc_impl::ServerContext* context, + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag) { + GPR_CODEGEN_ASSERT(method); + new NoPayloadAsyncRequest(method, this, context, stream, call_cq, + notification_cq, tag); + } + + void RequestAsyncGenericCall( + GenericServerContext* context, + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { + new GenericAsyncRequest(this, context, stream, call_cq, notification_cq, + tag, true); + } + + private: + // EXPERIMENTAL + // Getter method for the vector of interceptor factory objects. + // Returns a nullptr (rather than being pure) since this is a post-1.0 method + // and adding a new pure method to an interface would be a breaking change + // (even though this is private and non-API) + virtual std::vector< + std::unique_ptr>* + interceptor_creators() { + return nullptr; + } + + // EXPERIMENTAL + // A method to get the callbackable completion queue associated with this + // server. If the return value is nullptr, this server doesn't support + // callback operations. + // TODO(vjpai): Consider a better default like using a global CQ + // Returns nullptr (rather than being pure) since this is a post-1.0 method + // and adding a new pure method to an interface would be a breaking change + // (even though this is private and non-API) + virtual ::grpc_impl::CompletionQueue* CallbackCQ() { return nullptr; } +}; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_SERVER_INTERFACE_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/service_type.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/service_type.h new file mode 100644 index 0000000000000000000000000000000000000000..34f97b6a6877b74983d7db6e529986c51b980954 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/service_type.h @@ -0,0 +1,279 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SERVICE_TYPE_H +#define GRPCPP_IMPL_CODEGEN_SERVICE_TYPE_H + +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +class Server; +class CompletionQueue; +class ServerContext; +} // namespace grpc_impl +namespace grpc { + +class ServerInterface; + +namespace internal { +class Call; +class ServerAsyncStreamingInterface { + public: + virtual ~ServerAsyncStreamingInterface() {} + + /// Request notification of the sending of initial metadata to the client. + /// Completion will be notified by \a tag on the associated completion + /// queue. This call is optional, but if it is used, it cannot be used + /// concurrently with or after the \a Finish method. + /// + /// \param[in] tag Tag identifying this request. + virtual void SendInitialMetadata(void* tag) = 0; + + private: + friend class ::grpc::ServerInterface; + virtual void BindCall(Call* call) = 0; +}; +} // namespace internal + +/// Desriptor of an RPC service and its various RPC methods +class Service { + public: + Service() : server_(nullptr) {} + virtual ~Service() {} + + bool has_async_methods() const { + for (const auto& method : methods_) { + if (method && method->handler() == nullptr) { + return true; + } + } + return false; + } + + bool has_synchronous_methods() const { + for (const auto& method : methods_) { + if (method && + method->api_type() == internal::RpcServiceMethod::ApiType::SYNC) { + return true; + } + } + return false; + } + + bool has_callback_methods() const { + for (const auto& method : methods_) { + if (method && (method->api_type() == + internal::RpcServiceMethod::ApiType::CALL_BACK || + method->api_type() == + internal::RpcServiceMethod::ApiType::RAW_CALL_BACK)) { + return true; + } + } + return false; + } + + bool has_generic_methods() const { + for (const auto& method : methods_) { + if (method.get() == nullptr) { + return true; + } + } + return false; + } + + protected: + // TODO(vjpai): Promote experimental contents once callback API is accepted + class experimental_type { + public: + explicit experimental_type(Service* service) : service_(service) {} + + void MarkMethodCallback(int index, internal::MethodHandler* handler) { + service_->MarkMethodCallbackInternal(index, handler); + } + + void MarkMethodRawCallback(int index, internal::MethodHandler* handler) { + service_->MarkMethodRawCallbackInternal(index, handler); + } + + internal::MethodHandler* GetHandler(int index) { + return service_->GetHandlerInternal(index); + } + + private: + Service* service_; + }; + + experimental_type experimental() { return experimental_type(this); } + + template + void RequestAsyncUnary(int index, ::grpc_impl::ServerContext* context, + Message* request, + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, + void* tag) { + // Typecast the index to size_t for indexing into a vector + // while preserving the API that existed before a compiler + // warning was first seen (grpc/grpc#11664) + size_t idx = static_cast(index); + server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, + notification_cq, tag, request); + } + void RequestAsyncClientStreaming( + int index, ::grpc_impl::ServerContext* context, + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { + size_t idx = static_cast(index); + server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, + notification_cq, tag); + } + template + void RequestAsyncServerStreaming( + int index, ::grpc_impl::ServerContext* context, Message* request, + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { + size_t idx = static_cast(index); + server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, + notification_cq, tag, request); + } + void RequestAsyncBidiStreaming( + int index, ::grpc_impl::ServerContext* context, + internal::ServerAsyncStreamingInterface* stream, + ::grpc_impl::CompletionQueue* call_cq, + ::grpc_impl::ServerCompletionQueue* notification_cq, void* tag) { + size_t idx = static_cast(index); + server_->RequestAsyncCall(methods_[idx].get(), context, stream, call_cq, + notification_cq, tag); + } + + void AddMethod(internal::RpcServiceMethod* method) { + methods_.emplace_back(method); + } + + void MarkMethodAsync(int index) { + // This does not have to be a hard error, however no one has approached us + // with a use case yet. Please file an issue if you believe you have one. + size_t idx = static_cast(index); + GPR_CODEGEN_ASSERT( + methods_[idx].get() != nullptr && + "Cannot mark the method as 'async' because it has already been " + "marked as 'generic'."); + methods_[idx]->SetServerApiType(internal::RpcServiceMethod::ApiType::ASYNC); + } + + void MarkMethodRaw(int index) { + // This does not have to be a hard error, however no one has approached us + // with a use case yet. Please file an issue if you believe you have one. + size_t idx = static_cast(index); + GPR_CODEGEN_ASSERT(methods_[idx].get() != nullptr && + "Cannot mark the method as 'raw' because it has already " + "been marked as 'generic'."); + methods_[idx]->SetServerApiType(internal::RpcServiceMethod::ApiType::RAW); + } + + void MarkMethodGeneric(int index) { + // This does not have to be a hard error, however no one has approached us + // with a use case yet. Please file an issue if you believe you have one. + size_t idx = static_cast(index); + GPR_CODEGEN_ASSERT( + methods_[idx]->handler() != nullptr && + "Cannot mark the method as 'generic' because it has already been " + "marked as 'async' or 'raw'."); + methods_[idx].reset(); + } + + void MarkMethodStreamed(int index, internal::MethodHandler* streamed_method) { + // This does not have to be a hard error, however no one has approached us + // with a use case yet. Please file an issue if you believe you have one. + size_t idx = static_cast(index); + GPR_CODEGEN_ASSERT(methods_[idx] && methods_[idx]->handler() && + "Cannot mark an async or generic method Streamed"); + methods_[idx]->SetHandler(streamed_method); + + // From the server's point of view, streamed unary is a special + // case of BIDI_STREAMING that has 1 read and 1 write, in that order, + // and split server-side streaming is BIDI_STREAMING with 1 read and + // any number of writes, in that order. + methods_[idx]->SetMethodType(internal::RpcMethod::BIDI_STREAMING); + } + +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL + void MarkMethodCallback(int index, internal::MethodHandler* handler) { + MarkMethodCallbackInternal(index, handler); + } + + void MarkMethodRawCallback(int index, internal::MethodHandler* handler) { + MarkMethodRawCallbackInternal(index, handler); + } + + internal::MethodHandler* GetHandler(int index) { + return GetHandlerInternal(index); + } +#endif + private: + // TODO(vjpai): migrate the Internal functions to mainline functions once + // callback API is fully de-experimental + void MarkMethodCallbackInternal(int index, internal::MethodHandler* handler) { + // This does not have to be a hard error, however no one has approached us + // with a use case yet. Please file an issue if you believe you have one. + size_t idx = static_cast(index); + GPR_CODEGEN_ASSERT( + methods_[idx].get() != nullptr && + "Cannot mark the method as 'callback' because it has already been " + "marked as 'generic'."); + methods_[idx]->SetHandler(handler); + methods_[idx]->SetServerApiType( + internal::RpcServiceMethod::ApiType::CALL_BACK); + } + + void MarkMethodRawCallbackInternal(int index, + internal::MethodHandler* handler) { + // This does not have to be a hard error, however no one has approached us + // with a use case yet. Please file an issue if you believe you have one. + size_t idx = static_cast(index); + GPR_CODEGEN_ASSERT( + methods_[idx].get() != nullptr && + "Cannot mark the method as 'raw callback' because it has already " + "been marked as 'generic'."); + methods_[idx]->SetHandler(handler); + methods_[idx]->SetServerApiType( + internal::RpcServiceMethod::ApiType::RAW_CALL_BACK); + } + + internal::MethodHandler* GetHandlerInternal(int index) { + size_t idx = static_cast(index); + return methods_[idx]->handler(); + } + + friend class grpc_impl::Server; + friend class ServerInterface; + ServerInterface* server_; + std::vector> methods_; +}; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_SERVICE_TYPE_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/slice.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/slice.h new file mode 100644 index 0000000000000000000000000000000000000000..8966559dc853494bf815b23a485dffddf2d98734 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/slice.h @@ -0,0 +1,143 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SLICE_H +#define GRPCPP_IMPL_CODEGEN_SLICE_H + +#include +#include +#include + +#include + +namespace grpc { + +/// A wrapper around \a grpc_slice. +/// +/// A slice represents a contiguous reference counted array of bytes. +/// It is cheap to take references to a slice, and it is cheap to create a +/// slice pointing to a subset of another slice. +class Slice final { + public: + /// Construct an empty slice. + Slice() : slice_(g_core_codegen_interface->grpc_empty_slice()) {} + /// Destructor - drops one reference. + ~Slice() { g_core_codegen_interface->grpc_slice_unref(slice_); } + + enum AddRef { ADD_REF }; + /// Construct a slice from \a slice, adding a reference. + Slice(grpc_slice slice, AddRef) + : slice_(g_core_codegen_interface->grpc_slice_ref(slice)) {} + + enum StealRef { STEAL_REF }; + /// Construct a slice from \a slice, stealing a reference. + Slice(grpc_slice slice, StealRef) : slice_(slice) {} + + /// Allocate a slice of specified size + Slice(size_t len) + : slice_(g_core_codegen_interface->grpc_slice_malloc(len)) {} + + /// Construct a slice from a copied buffer + Slice(const void* buf, size_t len) + : slice_(g_core_codegen_interface->grpc_slice_from_copied_buffer( + reinterpret_cast(buf), len)) {} + + /// Construct a slice from a copied string + Slice(const grpc::string& str) + : slice_(g_core_codegen_interface->grpc_slice_from_copied_buffer( + str.c_str(), str.length())) {} + + enum StaticSlice { STATIC_SLICE }; + + /// Construct a slice from a static buffer + Slice(const void* buf, size_t len, StaticSlice) + : slice_(g_core_codegen_interface->grpc_slice_from_static_buffer( + reinterpret_cast(buf), len)) {} + + /// Copy constructor, adds a reference. + Slice(const Slice& other) + : slice_(g_core_codegen_interface->grpc_slice_ref(other.slice_)) {} + + /// Assignment, reference count is unchanged. + Slice& operator=(Slice other) { + std::swap(slice_, other.slice_); + return *this; + } + + /// Create a slice pointing at some data. Calls malloc to allocate a refcount + /// for the object, and arranges that destroy will be called with the + /// user data pointer passed in at destruction. Can be the same as buf or + /// different (e.g., if data is part of a larger structure that must be + /// destroyed when the data is no longer needed) + Slice(void* buf, size_t len, void (*destroy)(void*), void* user_data) + : slice_(g_core_codegen_interface->grpc_slice_new_with_user_data( + buf, len, destroy, user_data)) {} + + /// Specialization of above for common case where buf == user_data + Slice(void* buf, size_t len, void (*destroy)(void*)) + : Slice(buf, len, destroy, buf) {} + + /// Similar to the above but has a destroy that also takes slice length + Slice(void* buf, size_t len, void (*destroy)(void*, size_t)) + : slice_(g_core_codegen_interface->grpc_slice_new_with_len(buf, len, + destroy)) {} + + /// Byte size. + size_t size() const { return GRPC_SLICE_LENGTH(slice_); } + + /// Raw pointer to the beginning (first element) of the slice. + const uint8_t* begin() const { return GRPC_SLICE_START_PTR(slice_); } + + /// Raw pointer to the end (one byte \em past the last element) of the slice. + const uint8_t* end() const { return GRPC_SLICE_END_PTR(slice_); } + + /// Raw C slice. Caller needs to call grpc_slice_unref when done. + grpc_slice c_slice() const { + return g_core_codegen_interface->grpc_slice_ref(slice_); + } + + private: + friend class ByteBuffer; + + grpc_slice slice_; +}; + +inline grpc::string_ref StringRefFromSlice(const grpc_slice* slice) { + return grpc::string_ref( + reinterpret_cast(GRPC_SLICE_START_PTR(*slice)), + GRPC_SLICE_LENGTH(*slice)); +} + +inline grpc::string StringFromCopiedSlice(grpc_slice slice) { + return grpc::string(reinterpret_cast(GRPC_SLICE_START_PTR(slice)), + GRPC_SLICE_LENGTH(slice)); +} + +inline grpc_slice SliceReferencingString(const grpc::string& str) { + return g_core_codegen_interface->grpc_slice_from_static_buffer(str.data(), + str.length()); +} + +inline grpc_slice SliceFromCopiedString(const grpc::string& str) { + return g_core_codegen_interface->grpc_slice_from_copied_buffer(str.data(), + str.length()); +} + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_SLICE_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/status.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/status.h new file mode 100644 index 0000000000000000000000000000000000000000..e625a76b15da8feb1d14ce13a1ba49e017405389 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/status.h @@ -0,0 +1,133 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_STATUS_H +#define GRPCPP_IMPL_CODEGEN_STATUS_H + +#include +#include +#include + +namespace grpc { + +/// Did it work? If it didn't, why? +/// +/// See \a grpc::StatusCode for details on the available code and their meaning. +class Status { + public: + /// Construct an OK instance. + Status() : code_(StatusCode::OK) { + // Static assertions to make sure that the C++ API value correctly + // maps to the core surface API value + static_assert(StatusCode::OK == static_cast(GRPC_STATUS_OK), + "Mismatched status code"); + static_assert( + StatusCode::CANCELLED == static_cast(GRPC_STATUS_CANCELLED), + "Mismatched status code"); + static_assert( + StatusCode::UNKNOWN == static_cast(GRPC_STATUS_UNKNOWN), + "Mismatched status code"); + static_assert(StatusCode::INVALID_ARGUMENT == + static_cast(GRPC_STATUS_INVALID_ARGUMENT), + "Mismatched status code"); + static_assert(StatusCode::DEADLINE_EXCEEDED == + static_cast(GRPC_STATUS_DEADLINE_EXCEEDED), + "Mismatched status code"); + static_assert( + StatusCode::NOT_FOUND == static_cast(GRPC_STATUS_NOT_FOUND), + "Mismatched status code"); + static_assert(StatusCode::ALREADY_EXISTS == + static_cast(GRPC_STATUS_ALREADY_EXISTS), + "Mismatched status code"); + static_assert(StatusCode::PERMISSION_DENIED == + static_cast(GRPC_STATUS_PERMISSION_DENIED), + "Mismatched status code"); + static_assert(StatusCode::UNAUTHENTICATED == + static_cast(GRPC_STATUS_UNAUTHENTICATED), + "Mismatched status code"); + static_assert(StatusCode::RESOURCE_EXHAUSTED == + static_cast(GRPC_STATUS_RESOURCE_EXHAUSTED), + "Mismatched status code"); + static_assert(StatusCode::FAILED_PRECONDITION == + static_cast(GRPC_STATUS_FAILED_PRECONDITION), + "Mismatched status code"); + static_assert( + StatusCode::ABORTED == static_cast(GRPC_STATUS_ABORTED), + "Mismatched status code"); + static_assert(StatusCode::OUT_OF_RANGE == + static_cast(GRPC_STATUS_OUT_OF_RANGE), + "Mismatched status code"); + static_assert(StatusCode::UNIMPLEMENTED == + static_cast(GRPC_STATUS_UNIMPLEMENTED), + "Mismatched status code"); + static_assert( + StatusCode::INTERNAL == static_cast(GRPC_STATUS_INTERNAL), + "Mismatched status code"); + static_assert(StatusCode::UNAVAILABLE == + static_cast(GRPC_STATUS_UNAVAILABLE), + "Mismatched status code"); + static_assert( + StatusCode::DATA_LOSS == static_cast(GRPC_STATUS_DATA_LOSS), + "Mismatched status code"); + } + + /// Construct an instance with associated \a code and \a error_message. + /// It is an error to construct an OK status with non-empty \a error_message. + Status(StatusCode code, const grpc::string& error_message) + : code_(code), error_message_(error_message) {} + + /// Construct an instance with \a code, \a error_message and + /// \a error_details. It is an error to construct an OK status with non-empty + /// \a error_message and/or \a error_details. + Status(StatusCode code, const grpc::string& error_message, + const grpc::string& error_details) + : code_(code), + error_message_(error_message), + binary_error_details_(error_details) {} + + // Pre-defined special status objects. + /// An OK pre-defined instance. + static const Status& OK; + /// A CANCELLED pre-defined instance. + static const Status& CANCELLED; + + /// Return the instance's error code. + StatusCode error_code() const { return code_; } + /// Return the instance's error message. + grpc::string error_message() const { return error_message_; } + /// Return the (binary) error details. + // Usually it contains a serialized google.rpc.Status proto. + grpc::string error_details() const { return binary_error_details_; } + + /// Is the status OK? + bool ok() const { return code_ == StatusCode::OK; } + + // Ignores any errors. This method does nothing except potentially suppress + // complaints from any tools that are checking that errors are not dropped on + // the floor. + void IgnoreError() const {} + + private: + StatusCode code_; + grpc::string error_message_; + grpc::string binary_error_details_; +}; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_STATUS_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/status_code_enum.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/status_code_enum.h new file mode 100644 index 0000000000000000000000000000000000000000..bdd7ead6add1730a5d30678f22b2c384f99ed84a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/status_code_enum.h @@ -0,0 +1,143 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_STATUS_CODE_ENUM_H +#define GRPCPP_IMPL_CODEGEN_STATUS_CODE_ENUM_H + +namespace grpc { + +enum StatusCode { + /// Not an error; returned on success. + OK = 0, + + /// The operation was cancelled (typically by the caller). + CANCELLED = 1, + + /// Unknown error. An example of where this error may be returned is if a + /// Status value received from another address space belongs to an error-space + /// that is not known in this address space. Also errors raised by APIs that + /// do not return enough error information may be converted to this error. + UNKNOWN = 2, + + /// Client specified an invalid argument. Note that this differs from + /// FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments that are + /// problematic regardless of the state of the system (e.g., a malformed file + /// name). + INVALID_ARGUMENT = 3, + + /// Deadline expired before operation could complete. For operations that + /// change the state of the system, this error may be returned even if the + /// operation has completed successfully. For example, a successful response + /// from a server could have been delayed long enough for the deadline to + /// expire. + DEADLINE_EXCEEDED = 4, + + /// Some requested entity (e.g., file or directory) was not found. + NOT_FOUND = 5, + + /// Some entity that we attempted to create (e.g., file or directory) already + /// exists. + ALREADY_EXISTS = 6, + + /// The caller does not have permission to execute the specified operation. + /// PERMISSION_DENIED must not be used for rejections caused by exhausting + /// some resource (use RESOURCE_EXHAUSTED instead for those errors). + /// PERMISSION_DENIED must not be used if the caller can not be identified + /// (use UNAUTHENTICATED instead for those errors). + PERMISSION_DENIED = 7, + + /// The request does not have valid authentication credentials for the + /// operation. + UNAUTHENTICATED = 16, + + /// Some resource has been exhausted, perhaps a per-user quota, or perhaps the + /// entire file system is out of space. + RESOURCE_EXHAUSTED = 8, + + /// Operation was rejected because the system is not in a state required for + /// the operation's execution. For example, directory to be deleted may be + /// non-empty, an rmdir operation is applied to a non-directory, etc. + /// + /// A litmus test that may help a service implementor in deciding + /// between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE: + /// (a) Use UNAVAILABLE if the client can retry just the failing call. + /// (b) Use ABORTED if the client should retry at a higher-level + /// (e.g., restarting a read-modify-write sequence). + /// (c) Use FAILED_PRECONDITION if the client should not retry until + /// the system state has been explicitly fixed. E.g., if an "rmdir" + /// fails because the directory is non-empty, FAILED_PRECONDITION + /// should be returned since the client should not retry unless + /// they have first fixed up the directory by deleting files from it. + /// (d) Use FAILED_PRECONDITION if the client performs conditional + /// REST Get/Update/Delete on a resource and the resource on the + /// server does not match the condition. E.g., conflicting + /// read-modify-write on the same resource. + FAILED_PRECONDITION = 9, + + /// The operation was aborted, typically due to a concurrency issue like + /// sequencer check failures, transaction aborts, etc. + /// + /// See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, + /// and UNAVAILABLE. + ABORTED = 10, + + /// Operation was attempted past the valid range. E.g., seeking or reading + /// past end of file. + /// + /// Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed + /// if the system state changes. For example, a 32-bit file system will + /// generate INVALID_ARGUMENT if asked to read at an offset that is not in the + /// range [0,2^32-1], but it will generate OUT_OF_RANGE if asked to read from + /// an offset past the current file size. + /// + /// There is a fair bit of overlap between FAILED_PRECONDITION and + /// OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific error) + /// when it applies so that callers who are iterating through a space can + /// easily look for an OUT_OF_RANGE error to detect when they are done. + OUT_OF_RANGE = 11, + + /// Operation is not implemented or not supported/enabled in this service. + UNIMPLEMENTED = 12, + + /// Internal errors. Means some invariants expected by underlying System has + /// been broken. If you see one of these errors, Something is very broken. + INTERNAL = 13, + + /// The service is currently unavailable. This is a most likely a transient + /// condition and may be corrected by retrying with a backoff. Note that it is + /// not always safe to retry non-idempotent operations. + /// + /// \warning Although data MIGHT not have been transmitted when this + /// status occurs, there is NOT A GUARANTEE that the server has not seen + /// anything. So in general it is unsafe to retry on this status code + /// if the call is non-idempotent. + /// + /// See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, + /// and UNAVAILABLE. + UNAVAILABLE = 14, + + /// Unrecoverable data loss or corruption. + DATA_LOSS = 15, + + /// Force users to include a default branch: + DO_NOT_USE = -1 +}; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_STATUS_CODE_ENUM_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/string_ref.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/string_ref.h new file mode 100644 index 0000000000000000000000000000000000000000..5d55fc4180576eb77a0eb479d72a56d992bf65cc --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/string_ref.h @@ -0,0 +1,146 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_STRING_REF_H +#define GRPCPP_IMPL_CODEGEN_STRING_REF_H + +#include + +#include +#include +#include +#include + +#include + +namespace grpc { + +/// This class is a non owning reference to a string. +/// +/// It should be a strict subset of the upcoming std::string_ref. +/// +/// \see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3442.html +/// +/// The constexpr is dropped or replaced with const for legacy compiler +/// compatibility. +class string_ref { + public: + /// types + typedef const char* const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + /// constants + const static size_t npos; + + /// construct/copy. + string_ref() : data_(nullptr), length_(0) {} + string_ref(const string_ref& other) + : data_(other.data_), length_(other.length_) {} + string_ref& operator=(const string_ref& rhs) { + data_ = rhs.data_; + length_ = rhs.length_; + return *this; + } + + string_ref(const char* s) : data_(s), length_(strlen(s)) {} + string_ref(const char* s, size_t l) : data_(s), length_(l) {} + string_ref(const grpc::string& s) : data_(s.data()), length_(s.length()) {} + + /// iterators + const_iterator begin() const { return data_; } + const_iterator end() const { return data_ + length_; } + const_iterator cbegin() const { return data_; } + const_iterator cend() const { return data_ + length_; } + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + const_reverse_iterator crbegin() const { + return const_reverse_iterator(end()); + } + const_reverse_iterator crend() const { + return const_reverse_iterator(begin()); + } + + /// capacity + size_t size() const { return length_; } + size_t length() const { return length_; } + size_t max_size() const { return length_; } + bool empty() const { return length_ == 0; } + + /// element access + const char* data() const { return data_; } + + /// string operations + int compare(string_ref x) const { + size_t min_size = length_ < x.length_ ? length_ : x.length_; + int r = memcmp(data_, x.data_, min_size); + if (r < 0) return -1; + if (r > 0) return 1; + if (length_ < x.length_) return -1; + if (length_ > x.length_) return 1; + return 0; + } + + bool starts_with(string_ref x) const { + return length_ >= x.length_ && (memcmp(data_, x.data_, x.length_) == 0); + } + + bool ends_with(string_ref x) const { + return length_ >= x.length_ && + (memcmp(data_ + (length_ - x.length_), x.data_, x.length_) == 0); + } + + size_t find(string_ref s) const { + auto it = std::search(cbegin(), cend(), s.cbegin(), s.cend()); + return it == cend() ? npos : std::distance(cbegin(), it); + } + + size_t find(char c) const { + auto it = std::find(cbegin(), cend(), c); + return it == cend() ? npos : std::distance(cbegin(), it); + } + + string_ref substr(size_t pos, size_t n = npos) const { + if (pos > length_) pos = length_; + if (n > (length_ - pos)) n = length_ - pos; + return string_ref(data_ + pos, n); + } + + private: + const char* data_; + size_t length_; +}; + +/// Comparison operators +inline bool operator==(string_ref x, string_ref y) { return x.compare(y) == 0; } +inline bool operator!=(string_ref x, string_ref y) { return x.compare(y) != 0; } +inline bool operator<(string_ref x, string_ref y) { return x.compare(y) < 0; } +inline bool operator<=(string_ref x, string_ref y) { return x.compare(y) <= 0; } +inline bool operator>(string_ref x, string_ref y) { return x.compare(y) > 0; } +inline bool operator>=(string_ref x, string_ref y) { return x.compare(y) >= 0; } + +inline std::ostream& operator<<(std::ostream& out, const string_ref& string) { + return out << grpc::string(string.begin(), string.end()); +} + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_STRING_REF_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/stub_options.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/stub_options.h new file mode 100644 index 0000000000000000000000000000000000000000..a56695a8f82bce693c43ce2619eeecdcbf8cf756 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/stub_options.h @@ -0,0 +1,29 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_STUB_OPTIONS_H +#define GRPCPP_IMPL_CODEGEN_STUB_OPTIONS_H + +namespace grpc { + +/// Useful interface for generated stubs +class StubOptions {}; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_STUB_OPTIONS_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/sync.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/sync.h new file mode 100644 index 0000000000000000000000000000000000000000..146f182e57b9627122069b90caa23dacea816340 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/sync.h @@ -0,0 +1,151 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SYNC_H +#define GRPCPP_IMPL_CODEGEN_SYNC_H + +#include + +#ifdef GPR_HAS_PTHREAD_H +#include +#endif + +#include + +#include +#include + +#include + +// The core library is not accessible in C++ codegen headers, and vice versa. +// Thus, we need to have duplicate headers with similar functionality. +// Make sure any change to this file is also reflected in +// src/core/lib/gprpp/sync.h too. +// +// Whenever possible, prefer "src/core/lib/gprpp/sync.h" over this file, +// since in core we do not rely on g_core_codegen_interface and hence do not +// pay the costs of virtual function calls. + +namespace grpc { +namespace internal { + +class Mutex { + public: + Mutex() { g_core_codegen_interface->gpr_mu_init(&mu_); } + ~Mutex() { g_core_codegen_interface->gpr_mu_destroy(&mu_); } + + Mutex(const Mutex&) = delete; + Mutex& operator=(const Mutex&) = delete; + + gpr_mu* get() { return &mu_; } + const gpr_mu* get() const { return &mu_; } + + private: + union { + gpr_mu mu_; + std::mutex do_not_use_sth_; +#ifdef GPR_HAS_PTHREAD_H + pthread_mutex_t do_not_use_pth_; +#endif + }; +}; + +// MutexLock is a std:: +class MutexLock { + public: + explicit MutexLock(Mutex* mu) : mu_(mu->get()) { + g_core_codegen_interface->gpr_mu_lock(mu_); + } + explicit MutexLock(gpr_mu* mu) : mu_(mu) { + g_core_codegen_interface->gpr_mu_lock(mu_); + } + ~MutexLock() { g_core_codegen_interface->gpr_mu_unlock(mu_); } + + MutexLock(const MutexLock&) = delete; + MutexLock& operator=(const MutexLock&) = delete; + + private: + gpr_mu* const mu_; +}; + +class ReleasableMutexLock { + public: + explicit ReleasableMutexLock(Mutex* mu) : mu_(mu->get()) { + g_core_codegen_interface->gpr_mu_lock(mu_); + } + explicit ReleasableMutexLock(gpr_mu* mu) : mu_(mu) { + g_core_codegen_interface->gpr_mu_lock(mu_); + } + ~ReleasableMutexLock() { + if (!released_) g_core_codegen_interface->gpr_mu_unlock(mu_); + } + + ReleasableMutexLock(const ReleasableMutexLock&) = delete; + ReleasableMutexLock& operator=(const ReleasableMutexLock&) = delete; + + void Lock() { + GPR_DEBUG_ASSERT(released_); + g_core_codegen_interface->gpr_mu_lock(mu_); + released_ = false; + } + + void Unlock() { + GPR_DEBUG_ASSERT(!released_); + released_ = true; + g_core_codegen_interface->gpr_mu_unlock(mu_); + } + + private: + gpr_mu* const mu_; + bool released_ = false; +}; + +class CondVar { + public: + CondVar() { g_core_codegen_interface->gpr_cv_init(&cv_); } + ~CondVar() { g_core_codegen_interface->gpr_cv_destroy(&cv_); } + + CondVar(const CondVar&) = delete; + CondVar& operator=(const CondVar&) = delete; + + void Signal() { g_core_codegen_interface->gpr_cv_signal(&cv_); } + void Broadcast() { g_core_codegen_interface->gpr_cv_broadcast(&cv_); } + + int Wait(Mutex* mu) { + return Wait(mu, + g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME)); + } + int Wait(Mutex* mu, const gpr_timespec& deadline) { + return g_core_codegen_interface->gpr_cv_wait(&cv_, mu->get(), deadline); + } + + template + void WaitUntil(Mutex* mu, Predicate pred) { + while (!pred()) { + Wait(mu, g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME)); + } + } + + private: + gpr_cv cv_; +}; + +} // namespace internal +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_SYNC_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/sync_stream.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/sync_stream.h new file mode 100644 index 0000000000000000000000000000000000000000..852fe6676bf12cd938042a037f45cf3ba61330f0 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/sync_stream.h @@ -0,0 +1,100 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SYNC_STREAM_H +#define GRPCPP_IMPL_CODEGEN_SYNC_STREAM_H + +#include + +namespace grpc { + +namespace internal { + +typedef ::grpc_impl::internal::ClientStreamingInterface + ClientStreamingInterface; + +typedef ::grpc_impl::internal::ServerStreamingInterface + ServerStreamingInterface; + +template +using ReaderInterface = ::grpc_impl::internal::ReaderInterface; + +template +using WriterInterface = ::grpc_impl::internal::WriterInterface; + +template +using ClientReaderFactory = ::grpc_impl::internal::ClientReaderFactory; + +template +using ClientWriterFactory = ::grpc_impl::internal::ClientWriterFactory; + +template +using ClientReaderWriterFactory = + ::grpc_impl::internal::ClientReaderWriterFactory; + +} // namespace internal + +template +using ClientReaderInterface = ::grpc_impl::ClientReaderInterface; + +template +using ClientReader = ::grpc_impl::ClientReader; + +template +using ClientWriterInterface = ::grpc_impl::ClientWriterInterface; + +template +using ClientWriter = ::grpc_impl::ClientWriter; + +template +using ClientReaderWriterInterface = + ::grpc_impl::ClientReaderWriterInterface; + +template +using ClientReaderWriter = ::grpc_impl::ClientReaderWriter; + +template +using ServerReaderInterface = ::grpc_impl::ServerReaderInterface; + +template +using ServerReader = ::grpc_impl::ServerReader; + +template +using ServerWriterInterface = ::grpc_impl::ServerWriterInterface; + +template +using ServerWriter = ::grpc_impl::ServerWriter; + +template +using ServerReaderWriterInterface = + ::grpc_impl::ServerReaderWriterInterface; + +template +using ServerReaderWriter = ::grpc_impl::ServerReaderWriter; + +template +using ServerUnaryStreamer = + ::grpc_impl::ServerUnaryStreamer; + +template +using ServerSplitStreamer = + ::grpc_impl::ServerSplitStreamer; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_SYNC_STREAM_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/sync_stream_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/sync_stream_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..80b0bd73d2aa2120cbe71ffcce48db428fb8badf --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/sync_stream_impl.h @@ -0,0 +1,948 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H +#define GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace grpc_impl { + +namespace internal { +/// Common interface for all synchronous client side streaming. +class ClientStreamingInterface { + public: + virtual ~ClientStreamingInterface() {} + + /// Block waiting until the stream finishes and a final status of the call is + /// available. + /// + /// It is appropriate to call this method exactly once when both: + /// * the calling code (client-side) has no more message to send + /// (this can be declared implicitly by calling this method, or + /// explicitly through an earlier call to WritesDone method of the + /// class in use, e.g. \a ClientWriterInterface::WritesDone or + /// \a ClientReaderWriterInterface::WritesDone). + /// * there are no more messages to be received from the server (which can + /// be known implicitly, or explicitly from an earlier call to \a + /// ReaderInterface::Read that returned "false"). + /// + /// This function will return either: + /// - when all incoming messages have been read and the server has + /// returned status. + /// - when the server has returned a non-OK status. + /// - OR when the call failed for some reason and the library generated a + /// status. + /// + /// Return values: + /// - \a Status contains the status code, message and details for the call + /// - the \a ClientContext associated with this call is updated with + /// possible trailing metadata sent from the server. + virtual ::grpc::Status Finish() = 0; +}; + +/// Common interface for all synchronous server side streaming. +class ServerStreamingInterface { + public: + virtual ~ServerStreamingInterface() {} + + /// Block to send initial metadata to client. + /// This call is optional, but if it is used, it cannot be used concurrently + /// with or after the \a Finish method. + /// + /// The initial metadata that will be sent to the client will be + /// taken from the \a ServerContext associated with the call. + virtual void SendInitialMetadata() = 0; +}; + +/// An interface that yields a sequence of messages of type \a R. +template +class ReaderInterface { + public: + virtual ~ReaderInterface() {} + + /// Get an upper bound on the next message size available for reading on this + /// stream. + virtual bool NextMessageSize(uint32_t* sz) = 0; + + /// Block to read a message and parse to \a msg. Returns \a true on success. + /// This is thread-safe with respect to \a Write or \WritesDone methods on + /// the same stream. It should not be called concurrently with another \a + /// Read on the same stream as the order of delivery will not be defined. + /// + /// \param[out] msg The read message. + /// + /// \return \a false when there will be no more incoming messages, either + /// because the other side has called \a WritesDone() or the stream has failed + /// (or been cancelled). + virtual bool Read(R* msg) = 0; +}; + +/// An interface that can be fed a sequence of messages of type \a W. +template +class WriterInterface { + public: + virtual ~WriterInterface() {} + + /// Block to write \a msg to the stream with WriteOptions \a options. + /// This is thread-safe with respect to \a ReaderInterface::Read + /// + /// \param msg The message to be written to the stream. + /// \param options The WriteOptions affecting the write operation. + /// + /// \return \a true on success, \a false when the stream has been closed. + virtual bool Write(const W& msg, ::grpc::WriteOptions options) = 0; + + /// Block to write \a msg to the stream with default write options. + /// This is thread-safe with respect to \a ReaderInterface::Read + /// + /// \param msg The message to be written to the stream. + /// + /// \return \a true on success, \a false when the stream has been closed. + inline bool Write(const W& msg) { return Write(msg, ::grpc::WriteOptions()); } + + /// Write \a msg and coalesce it with the writing of trailing metadata, using + /// WriteOptions \a options. + /// + /// For client, WriteLast is equivalent of performing Write and WritesDone in + /// a single step. \a msg and trailing metadata are coalesced and sent on wire + /// by calling this function. For server, WriteLast buffers the \a msg. + /// The writing of \a msg is held until the service handler returns, + /// where \a msg and trailing metadata are coalesced and sent on wire. + /// Note that WriteLast can only buffer \a msg up to the flow control window + /// size. If \a msg size is larger than the window size, it will be sent on + /// wire without buffering. + /// + /// \param[in] msg The message to be written to the stream. + /// \param[in] options The WriteOptions to be used to write this message. + void WriteLast(const W& msg, ::grpc::WriteOptions options) { + Write(msg, options.set_last_message()); + } +}; + +} // namespace internal + +/// Client-side interface for streaming reads of message of type \a R. +template +class ClientReaderInterface : public internal::ClientStreamingInterface, + public internal::ReaderInterface { + public: + /// Block to wait for initial metadata from server. The received metadata + /// can only be accessed after this call returns. Should only be called before + /// the first read. Calling this method is optional, and if it is not called + /// the metadata will be available in ClientContext after the first read. + virtual void WaitForInitialMetadata() = 0; +}; + +namespace internal { +template +class ClientReaderFactory { + public: + template + static ClientReader* Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + const W& request) { + return new ClientReader(channel, method, context, request); + } +}; +} // namespace internal + +/// Synchronous (blocking) client-side API for doing server-streaming RPCs, +/// where the stream of messages coming from the server has messages +/// of type \a R. +template +class ClientReader final : public ClientReaderInterface { + public: + /// See the \a ClientStreamingInterface.WaitForInitialMetadata method for + /// semantics. + /// + // Side effect: + /// Once complete, the initial metadata read from + /// the server will be accessible through the \a ClientContext used to + /// construct this object. + void WaitForInitialMetadata() override { + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + ops; + ops.RecvInitialMetadata(context_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); /// status ignored + } + + bool NextMessageSize(uint32_t* sz) override { + int result = call_.max_receive_message_size(); + *sz = (result > 0) ? result : UINT32_MAX; + return true; + } + + /// See the \a ReaderInterface.Read method for semantics. + /// Side effect: + /// This also receives initial metadata from the server, if not + /// already received (if initial metadata is received, it can be then + /// accessed through the \a ClientContext associated with this call). + bool Read(R* msg) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage> + ops; + if (!context_->initial_metadata_received_) { + ops.RecvInitialMetadata(context_); + } + ops.RecvMessage(msg); + call_.PerformOps(&ops); + return cq_.Pluck(&ops) && ops.got_message; + } + + /// See the \a ClientStreamingInterface.Finish method for semantics. + /// + /// Side effect: + /// The \a ClientContext associated with this call is updated with + /// possible metadata received from the server. + ::grpc::Status Finish() override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientRecvStatus> ops; + ::grpc::Status status; + ops.ClientRecvStatus(context_, &status); + call_.PerformOps(&ops); + GPR_CODEGEN_ASSERT(cq_.Pluck(&ops)); + return status; + } + + private: + friend class internal::ClientReaderFactory; + ::grpc_impl::ClientContext* context_; + ::grpc_impl::CompletionQueue cq_; + ::grpc::internal::Call call_; + + /// Block to create a stream and write the initial metadata and \a request + /// out. Note that \a context will be used to fill in custom initial + /// metadata used to send to the server when starting the call. + template + ClientReader(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, const W& request) + : context_(context), + cq_(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, + nullptr}), // Pluckable cq + call_(channel->CreateCall(method, context, &cq_)) { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + ops; + ops.SendInitialMetadata(&context->send_initial_metadata_, + context->initial_metadata_flags()); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(ops.SendMessagePtr(&request).ok()); + ops.ClientSendClose(); + call_.PerformOps(&ops); + cq_.Pluck(&ops); + } +}; + +/// Client-side interface for streaming writes of message type \a W. +template +class ClientWriterInterface : public internal::ClientStreamingInterface, + public internal::WriterInterface { + public: + /// Half close writing from the client. (signal that the stream of messages + /// coming from the client is complete). + /// Blocks until currently-pending writes are completed. + /// Thread safe with respect to \a ReaderInterface::Read operations only + /// + /// \return Whether the writes were successful. + virtual bool WritesDone() = 0; +}; + +namespace internal { +template +class ClientWriterFactory { + public: + template + static ClientWriter* Create(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, + R* response) { + return new ClientWriter(channel, method, context, response); + } +}; +} // namespace internal + +/// Synchronous (blocking) client-side API for doing client-streaming RPCs, +/// where the outgoing message stream coming from the client has messages of +/// type \a W. +template +class ClientWriter : public ClientWriterInterface { + public: + /// See the \a ClientStreamingInterface.WaitForInitialMetadata method for + /// semantics. + /// + // Side effect: + /// Once complete, the initial metadata read from the server will be + /// accessible through the \a ClientContext used to construct this object. + void WaitForInitialMetadata() { + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + ops; + ops.RecvInitialMetadata(context_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); // status ignored + } + + /// See the WriterInterface.Write(const W& msg, WriteOptions options) method + /// for semantics. + /// + /// Side effect: + /// Also sends initial metadata if not already sent (using the + /// \a ClientContext associated with this call). + using internal::WriterInterface::Write; + bool Write(const W& msg, ::grpc::WriteOptions options) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + ops; + + if (options.is_last_message()) { + options.set_buffer_hint(); + ops.ClientSendClose(); + } + if (context_->initial_metadata_corked_) { + ops.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + context_->set_initial_metadata_corked(false); + } + if (!ops.SendMessagePtr(&msg, options).ok()) { + return false; + } + + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + bool WritesDone() override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientSendClose> ops; + ops.ClientSendClose(); + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + /// See the ClientStreamingInterface.Finish method for semantics. + /// Side effects: + /// - Also receives initial metadata if not already received. + /// - Attempts to fill in the \a response parameter passed + /// to the constructor of this instance with the response + /// message from the server. + ::grpc::Status Finish() override { + ::grpc::Status status; + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, &status); + call_.PerformOps(&finish_ops_); + GPR_CODEGEN_ASSERT(cq_.Pluck(&finish_ops_)); + return status; + } + + private: + friend class internal::ClientWriterFactory; + + /// Block to create a stream (i.e. send request headers and other initial + /// metadata to the server). Note that \a context will be used to fill + /// in custom initial metadata. \a response will be filled in with the + /// single expected response message from the server upon a successful + /// call to the \a Finish method of this instance. + template + ClientWriter(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context, R* response) + : context_(context), + cq_(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, + nullptr}), // Pluckable cq + call_(channel->CreateCall(method, context, &cq_)) { + finish_ops_.RecvMessage(response); + finish_ops_.AllowNoMessage(); + + if (!context_->initial_metadata_corked_) { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + ops; + ops.SendInitialMetadata(&context->send_initial_metadata_, + context->initial_metadata_flags()); + call_.PerformOps(&ops); + cq_.Pluck(&ops); + } + } + + ::grpc_impl::ClientContext* context_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpGenericRecvMessage, + ::grpc::internal::CallOpClientRecvStatus> + finish_ops_; + ::grpc_impl::CompletionQueue cq_; + ::grpc::internal::Call call_; +}; + +/// Client-side interface for bi-directional streaming with +/// client-to-server stream messages of type \a W and +/// server-to-client stream messages of type \a R. +template +class ClientReaderWriterInterface : public internal::ClientStreamingInterface, + public internal::WriterInterface, + public internal::ReaderInterface { + public: + /// Block to wait for initial metadata from server. The received metadata + /// can only be accessed after this call returns. Should only be called before + /// the first read. Calling this method is optional, and if it is not called + /// the metadata will be available in ClientContext after the first read. + virtual void WaitForInitialMetadata() = 0; + + /// Half close writing from the client. (signal that the stream of messages + /// coming from the clinet is complete). + /// Blocks until currently-pending writes are completed. + /// Thread-safe with respect to \a ReaderInterface::Read + /// + /// \return Whether the writes were successful. + virtual bool WritesDone() = 0; +}; + +namespace internal { +template +class ClientReaderWriterFactory { + public: + static ClientReaderWriter* Create( + ::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context) { + return new ClientReaderWriter(channel, method, context); + } +}; +} // namespace internal + +/// Synchronous (blocking) client-side API for bi-directional streaming RPCs, +/// where the outgoing message stream coming from the client has messages of +/// type \a W, and the incoming messages stream coming from the server has +/// messages of type \a R. +template +class ClientReaderWriter final : public ClientReaderWriterInterface { + public: + /// Block waiting to read initial metadata from the server. + /// This call is optional, but if it is used, it cannot be used concurrently + /// with or after the \a Finish method. + /// + /// Once complete, the initial metadata read from the server will be + /// accessible through the \a ClientContext used to construct this object. + void WaitForInitialMetadata() override { + GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata> + ops; + ops.RecvInitialMetadata(context_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); // status ignored + } + + bool NextMessageSize(uint32_t* sz) override { + int result = call_.max_receive_message_size(); + *sz = (result > 0) ? result : UINT32_MAX; + return true; + } + + /// See the \a ReaderInterface.Read method for semantics. + /// Side effect: + /// Also receives initial metadata if not already received (updates the \a + /// ClientContext associated with this call in that case). + bool Read(R* msg) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpRecvMessage> + ops; + if (!context_->initial_metadata_received_) { + ops.RecvInitialMetadata(context_); + } + ops.RecvMessage(msg); + call_.PerformOps(&ops); + return cq_.Pluck(&ops) && ops.got_message; + } + + /// See the \a WriterInterface.Write method for semantics. + /// + /// Side effect: + /// Also sends initial metadata if not already sent (using the + /// \a ClientContext associated with this call to fill in values). + using internal::WriterInterface::Write; + bool Write(const W& msg, ::grpc::WriteOptions options) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpClientSendClose> + ops; + + if (options.is_last_message()) { + options.set_buffer_hint(); + ops.ClientSendClose(); + } + if (context_->initial_metadata_corked_) { + ops.SendInitialMetadata(&context_->send_initial_metadata_, + context_->initial_metadata_flags()); + context_->set_initial_metadata_corked(false); + } + if (!ops.SendMessagePtr(&msg, options).ok()) { + return false; + } + + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + bool WritesDone() override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpClientSendClose> ops; + ops.ClientSendClose(); + call_.PerformOps(&ops); + return cq_.Pluck(&ops); + } + + /// See the ClientStreamingInterface.Finish method for semantics. + /// + /// Side effect: + /// - the \a ClientContext associated with this call is updated with + /// possible trailing metadata sent from the server. + ::grpc::Status Finish() override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata, + ::grpc::internal::CallOpClientRecvStatus> + ops; + if (!context_->initial_metadata_received_) { + ops.RecvInitialMetadata(context_); + } + ::grpc::Status status; + ops.ClientRecvStatus(context_, &status); + call_.PerformOps(&ops); + GPR_CODEGEN_ASSERT(cq_.Pluck(&ops)); + return status; + } + + private: + friend class internal::ClientReaderWriterFactory; + + ::grpc_impl::ClientContext* context_; + ::grpc_impl::CompletionQueue cq_; + ::grpc::internal::Call call_; + + /// Block to create a stream and write the initial metadata and \a request + /// out. Note that \a context will be used to fill in custom initial metadata + /// used to send to the server when starting the call. + ClientReaderWriter(::grpc::ChannelInterface* channel, + const ::grpc::internal::RpcMethod& method, + ::grpc_impl::ClientContext* context) + : context_(context), + cq_(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, + nullptr}), // Pluckable cq + call_(channel->CreateCall(method, context, &cq_)) { + if (!context_->initial_metadata_corked_) { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + ops; + ops.SendInitialMetadata(&context->send_initial_metadata_, + context->initial_metadata_flags()); + call_.PerformOps(&ops); + cq_.Pluck(&ops); + } + } +}; + +/// Server-side interface for streaming reads of message of type \a R. +template +class ServerReaderInterface : public internal::ServerStreamingInterface, + public internal::ReaderInterface {}; + +/// Synchronous (blocking) server-side API for doing client-streaming RPCs, +/// where the incoming message stream coming from the client has messages of +/// type \a R. +template +class ServerReader final : public ServerReaderInterface { + public: + /// See the \a ServerStreamingInterface.SendInitialMetadata method + /// for semantics. Note that initial metadata will be affected by the + /// \a ServerContext associated with this call. + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + ops; + ops.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_->PerformOps(&ops); + call_->cq()->Pluck(&ops); + } + + bool NextMessageSize(uint32_t* sz) override { + int result = call_->max_receive_message_size(); + *sz = (result > 0) ? result : UINT32_MAX; + return true; + } + + bool Read(R* msg) override { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> ops; + ops.RecvMessage(msg); + call_->PerformOps(&ops); + return call_->cq()->Pluck(&ops) && ops.got_message; + } + + private: + ::grpc::internal::Call* const call_; + ServerContext* const ctx_; + + template + friend class ::grpc_impl::internal::ClientStreamingHandler; + + ServerReader(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) + : call_(call), ctx_(ctx) {} +}; + +/// Server-side interface for streaming writes of message of type \a W. +template +class ServerWriterInterface : public internal::ServerStreamingInterface, + public internal::WriterInterface {}; + +/// Synchronous (blocking) server-side API for doing for doing a +/// server-streaming RPCs, where the outgoing message stream coming from the +/// server has messages of type \a W. +template +class ServerWriter final : public ServerWriterInterface { + public: + /// See the \a ServerStreamingInterface.SendInitialMetadata method + /// for semantics. + /// Note that initial metadata will be affected by the + /// \a ServerContext associated with this call. + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + ops; + ops.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_->PerformOps(&ops); + call_->cq()->Pluck(&ops); + } + + /// See the \a WriterInterface.Write method for semantics. + /// + /// Side effect: + /// Also sends initial metadata if not already sent (using the + /// \a ClientContext associated with this call to fill in values). + using internal::WriterInterface::Write; + bool Write(const W& msg, ::grpc::WriteOptions options) override { + if (options.is_last_message()) { + options.set_buffer_hint(); + } + + if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) { + return false; + } + if (!ctx_->sent_initial_metadata_) { + ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ctx_->pending_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + call_->PerformOps(&ctx_->pending_ops_); + // if this is the last message we defer the pluck until AFTER we start + // the trailing md op. This prevents hangs. See + // https://github.com/grpc/grpc/issues/11546 + if (options.is_last_message()) { + ctx_->has_pending_ops_ = true; + return true; + } + ctx_->has_pending_ops_ = false; + return call_->cq()->Pluck(&ctx_->pending_ops_); + } + + private: + ::grpc::internal::Call* const call_; + ::grpc_impl::ServerContext* const ctx_; + + template + friend class ::grpc_impl::internal::ServerStreamingHandler; + + ServerWriter(::grpc::internal::Call* call, ::grpc_impl::ServerContext* ctx) + : call_(call), ctx_(ctx) {} +}; + +/// Server-side interface for bi-directional streaming. +template +class ServerReaderWriterInterface : public internal::ServerStreamingInterface, + public internal::WriterInterface, + public internal::ReaderInterface {}; + +/// Actual implementation of bi-directional streaming +namespace internal { +template +class ServerReaderWriterBody final { + public: + ServerReaderWriterBody(grpc::internal::Call* call, + ::grpc_impl::ServerContext* ctx) + : call_(call), ctx_(ctx) {} + + void SendInitialMetadata() { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + + grpc::internal::CallOpSet ops; + ops.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ops.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + call_->PerformOps(&ops); + call_->cq()->Pluck(&ops); + } + + bool NextMessageSize(uint32_t* sz) { + int result = call_->max_receive_message_size(); + *sz = (result > 0) ? result : UINT32_MAX; + return true; + } + + bool Read(R* msg) { + ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage> ops; + ops.RecvMessage(msg); + call_->PerformOps(&ops); + return call_->cq()->Pluck(&ops) && ops.got_message; + } + + bool Write(const W& msg, ::grpc::WriteOptions options) { + if (options.is_last_message()) { + options.set_buffer_hint(); + } + if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) { + return false; + } + if (!ctx_->sent_initial_metadata_) { + ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + ctx_->pending_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + call_->PerformOps(&ctx_->pending_ops_); + // if this is the last message we defer the pluck until AFTER we start + // the trailing md op. This prevents hangs. See + // https://github.com/grpc/grpc/issues/11546 + if (options.is_last_message()) { + ctx_->has_pending_ops_ = true; + return true; + } + ctx_->has_pending_ops_ = false; + return call_->cq()->Pluck(&ctx_->pending_ops_); + } + + private: + grpc::internal::Call* const call_; + ::grpc_impl::ServerContext* const ctx_; +}; + +} // namespace internal + +/// Synchronous (blocking) server-side API for a bidirectional +/// streaming call, where the incoming message stream coming from the client has +/// messages of type \a R, and the outgoing message streaming coming from +/// the server has messages of type \a W. +template +class ServerReaderWriter final : public ServerReaderWriterInterface { + public: + /// See the \a ServerStreamingInterface.SendInitialMetadata method + /// for semantics. Note that initial metadata will be affected by the + /// \a ServerContext associated with this call. + void SendInitialMetadata() override { body_.SendInitialMetadata(); } + + bool NextMessageSize(uint32_t* sz) override { + return body_.NextMessageSize(sz); + } + + bool Read(R* msg) override { return body_.Read(msg); } + + /// See the \a WriterInterface.Write(const W& msg, WriteOptions options) + /// method for semantics. + /// Side effect: + /// Also sends initial metadata if not already sent (using the \a + /// ServerContext associated with this call). + using internal::WriterInterface::Write; + bool Write(const W& msg, ::grpc::WriteOptions options) override { + return body_.Write(msg, options); + } + + private: + internal::ServerReaderWriterBody body_; + + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< + ServerReaderWriter, false>; + ServerReaderWriter(::grpc::internal::Call* call, + ::grpc_impl::ServerContext* ctx) + : body_(call, ctx) {} +}; + +/// A class to represent a flow-controlled unary call. This is something +/// of a hybrid between conventional unary and streaming. This is invoked +/// through a unary call on the client side, but the server responds to it +/// as though it were a single-ping-pong streaming call. The server can use +/// the \a NextMessageSize method to determine an upper-bound on the size of +/// the message. A key difference relative to streaming: ServerUnaryStreamer +/// must have exactly 1 Read and exactly 1 Write, in that order, to function +/// correctly. Otherwise, the RPC is in error. +template +class ServerUnaryStreamer final + : public ServerReaderWriterInterface { + public: + /// Block to send initial metadata to client. + /// Implicit input parameter: + /// - the \a ServerContext associated with this call will be used for + /// sending initial metadata. + void SendInitialMetadata() override { body_.SendInitialMetadata(); } + + /// Get an upper bound on the request message size from the client. + bool NextMessageSize(uint32_t* sz) override { + return body_.NextMessageSize(sz); + } + + /// Read a message of type \a R into \a msg. Completion will be notified by \a + /// tag on the associated completion queue. + /// This is thread-safe with respect to \a Write or \a WritesDone methods. It + /// should not be called concurrently with other streaming APIs + /// on the same stream. It is not meaningful to call it concurrently + /// with another \a ReaderInterface::Read on the same stream since reads on + /// the same stream are delivered in order. + /// + /// \param[out] msg Where to eventually store the read message. + /// \param[in] tag The tag identifying the operation. + bool Read(RequestType* request) override { + if (read_done_) { + return false; + } + read_done_ = true; + return body_.Read(request); + } + + /// Block to write \a msg to the stream with WriteOptions \a options. + /// This is thread-safe with respect to \a ReaderInterface::Read + /// + /// \param msg The message to be written to the stream. + /// \param options The WriteOptions affecting the write operation. + /// + /// \return \a true on success, \a false when the stream has been closed. + using internal::WriterInterface::Write; + bool Write(const ResponseType& response, + ::grpc::WriteOptions options) override { + if (write_done_ || !read_done_) { + return false; + } + write_done_ = true; + return body_.Write(response, options); + } + + private: + internal::ServerReaderWriterBody body_; + bool read_done_; + bool write_done_; + + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< + ServerUnaryStreamer, true>; + ServerUnaryStreamer(::grpc::internal::Call* call, + ::grpc_impl::ServerContext* ctx) + : body_(call, ctx), read_done_(false), write_done_(false) {} +}; + +/// A class to represent a flow-controlled server-side streaming call. +/// This is something of a hybrid between server-side and bidi streaming. +/// This is invoked through a server-side streaming call on the client side, +/// but the server responds to it as though it were a bidi streaming call that +/// must first have exactly 1 Read and then any number of Writes. +template +class ServerSplitStreamer final + : public ServerReaderWriterInterface { + public: + /// Block to send initial metadata to client. + /// Implicit input parameter: + /// - the \a ServerContext associated with this call will be used for + /// sending initial metadata. + void SendInitialMetadata() override { body_.SendInitialMetadata(); } + + /// Get an upper bound on the request message size from the client. + bool NextMessageSize(uint32_t* sz) override { + return body_.NextMessageSize(sz); + } + + /// Read a message of type \a R into \a msg. Completion will be notified by \a + /// tag on the associated completion queue. + /// This is thread-safe with respect to \a Write or \a WritesDone methods. It + /// should not be called concurrently with other streaming APIs + /// on the same stream. It is not meaningful to call it concurrently + /// with another \a ReaderInterface::Read on the same stream since reads on + /// the same stream are delivered in order. + /// + /// \param[out] msg Where to eventually store the read message. + /// \param[in] tag The tag identifying the operation. + bool Read(RequestType* request) override { + if (read_done_) { + return false; + } + read_done_ = true; + return body_.Read(request); + } + + /// Block to write \a msg to the stream with WriteOptions \a options. + /// This is thread-safe with respect to \a ReaderInterface::Read + /// + /// \param msg The message to be written to the stream. + /// \param options The WriteOptions affecting the write operation. + /// + /// \return \a true on success, \a false when the stream has been closed. + using internal::WriterInterface::Write; + bool Write(const ResponseType& response, + ::grpc::WriteOptions options) override { + return read_done_ && body_.Write(response, options); + } + + private: + internal::ServerReaderWriterBody body_; + bool read_done_; + + friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< + ServerSplitStreamer, false>; + ServerSplitStreamer(::grpc::internal::Call* call, + ::grpc_impl::ServerContext* ctx) + : body_(call, ctx), read_done_(false) {} +}; + +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/time.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/time.h new file mode 100644 index 0000000000000000000000000000000000000000..b3521722e9e4b9e511beeff36538446e09ecfb37 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/codegen/time.h @@ -0,0 +1,89 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_TIME_H +#define GRPCPP_IMPL_CODEGEN_TIME_H + +#include + +#include +#include + +namespace grpc { + +/** If you are trying to use CompletionQueue::AsyncNext with a time class that + isn't either gpr_timespec or std::chrono::system_clock::time_point, you + will most likely be looking at this comment as your compiler will have + fired an error below. In order to fix this issue, you have two potential + solutions: + + 1. Use gpr_timespec or std::chrono::system_clock::time_point instead + 2. Specialize the TimePoint class with whichever time class that you + want to use here. See below for two examples of how to do this. + */ +template +class TimePoint { + public: + TimePoint(const T& /*time*/) { you_need_a_specialization_of_TimePoint(); } + gpr_timespec raw_time() { + gpr_timespec t; + return t; + } + + private: + void you_need_a_specialization_of_TimePoint(); +}; + +template <> +class TimePoint { + public: + TimePoint(const gpr_timespec& time) : time_(time) {} + gpr_timespec raw_time() { return time_; } + + private: + gpr_timespec time_; +}; + +} // namespace grpc + +namespace grpc { + +// from and to should be absolute time. +void Timepoint2Timespec(const std::chrono::system_clock::time_point& from, + gpr_timespec* to); +void TimepointHR2Timespec( + const std::chrono::high_resolution_clock::time_point& from, + gpr_timespec* to); + +std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t); + +template <> +class TimePoint { + public: + TimePoint(const std::chrono::system_clock::time_point& time) { + Timepoint2Timespec(time, &time_); + } + gpr_timespec raw_time() const { return time_; } + + private: + gpr_timespec time_; +}; + +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_TIME_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/grpc_library.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/grpc_library.h new file mode 100644 index 0000000000000000000000000000000000000000..3711c098790f1c924bbde29e33b189828faa0af4 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/grpc_library.h @@ -0,0 +1,60 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_GRPC_LIBRARY_H +#define GRPCPP_IMPL_GRPC_LIBRARY_H + +#include + +#include +#include +#include +#include + +namespace grpc { + +namespace internal { +class GrpcLibrary final : public GrpcLibraryInterface { + public: + void init() override { grpc_init(); } + void shutdown() override { grpc_shutdown(); } +}; + +/// Instantiating this class ensures the proper initialization of gRPC. +class GrpcLibraryInitializer final { + public: + GrpcLibraryInitializer() { + if (grpc::g_glip == nullptr) { + static auto* const g_gli = new GrpcLibrary(); + grpc::g_glip = g_gli; + } + if (grpc::g_core_codegen_interface == nullptr) { + static auto* const g_core_codegen = new CoreCodegen(); + grpc::g_core_codegen_interface = g_core_codegen; + } + } + + /// A no-op method to force the linker to reference this class, which will + /// take care of initializing and shutting down the gRPC runtime. + int summon() { return 0; } +}; + +} // namespace internal +} // namespace grpc + +#endif // GRPCPP_IMPL_GRPC_LIBRARY_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/method_handler_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/method_handler_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..7f3be6428b30f47203bfab3390959e0fe3418989 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/method_handler_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_METHOD_HANDLER_IMPL_H +#define GRPCPP_IMPL_METHOD_HANDLER_IMPL_H + +#include + +#endif // GRPCPP_IMPL_METHOD_HANDLER_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/rpc_method.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/rpc_method.h new file mode 100644 index 0000000000000000000000000000000000000000..5da704167185b26cd797933a46b3f7e013af11e8 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/rpc_method.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_RPC_METHOD_H +#define GRPCPP_IMPL_RPC_METHOD_H + +#include + +#endif // GRPCPP_IMPL_RPC_METHOD_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/rpc_service_method.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/rpc_service_method.h new file mode 100644 index 0000000000000000000000000000000000000000..ef70a3a10080833bc372a3421110c9f45009b0ab --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/rpc_service_method.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_RPC_SERVICE_METHOD_H +#define GRPCPP_IMPL_RPC_SERVICE_METHOD_H + +#include + +#endif // GRPCPP_IMPL_RPC_SERVICE_METHOD_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/serialization_traits.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/serialization_traits.h new file mode 100644 index 0000000000000000000000000000000000000000..95194fbd89480495c979b9a46bedab22bc5e34d2 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/serialization_traits.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_SERIALIZATION_TRAITS_H +#define GRPCPP_IMPL_SERIALIZATION_TRAITS_H + +#include + +#endif // GRPCPP_IMPL_SERIALIZATION_TRAITS_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/server_builder_option.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/server_builder_option.h new file mode 100644 index 0000000000000000000000000000000000000000..4b3d6b541187d6fc0268c5a22244245388369432 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/server_builder_option.h @@ -0,0 +1,30 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_SERVER_BUILDER_OPTION_H +#define GRPCPP_IMPL_SERVER_BUILDER_OPTION_H + +#include + +namespace grpc { + +typedef ::grpc_impl::ServerBuilderOption ServerBuilderOption; + +} // namespace grpc + +#endif // GRPCPP_IMPL_SERVER_BUILDER_OPTION_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/server_builder_option_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/server_builder_option_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..8271d0f56b2be1b16fc2519e05ff0619d914d547 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/server_builder_option_impl.h @@ -0,0 +1,43 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_SERVER_BUILDER_OPTION_IMPL_H +#define GRPCPP_IMPL_SERVER_BUILDER_OPTION_IMPL_H + +#include +#include + +#include +#include + +namespace grpc_impl { + +/// Interface to pass an option to a \a ServerBuilder. +class ServerBuilderOption { + public: + virtual ~ServerBuilderOption() {} + /// Alter the \a ChannelArguments used to create the gRPC server. + virtual void UpdateArguments(grpc::ChannelArguments* args) = 0; + /// Alter the ServerBuilderPlugin map that will be added into ServerBuilder. + virtual void UpdatePlugins( + std::vector>* plugins) = 0; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_SERVER_BUILDER_OPTION_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/server_builder_plugin.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/server_builder_plugin.h new file mode 100644 index 0000000000000000000000000000000000000000..203e5465bc3f0c52c834da0d478c2fe7f667a6da --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/server_builder_plugin.h @@ -0,0 +1,68 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_SERVER_BUILDER_PLUGIN_H +#define GRPCPP_IMPL_SERVER_BUILDER_PLUGIN_H + +#include + +#include +#include + +namespace grpc_impl { + +class ServerBuilder; +class ServerInitializer; +} // namespace grpc_impl +namespace grpc { + +/// This interface is meant for internal usage only. Implementations of this +/// interface should add themselves to a \a ServerBuilder instance through the +/// \a InternalAddPluginFactory method. +class ServerBuilderPlugin { + public: + virtual ~ServerBuilderPlugin() {} + virtual grpc::string name() = 0; + + /// UpdateServerBuilder will be called at an early stage in + /// ServerBuilder::BuildAndStart(), right after the ServerBuilderOptions have + /// done their updates. + virtual void UpdateServerBuilder(grpc_impl::ServerBuilder* /*builder*/) {} + + /// InitServer will be called in ServerBuilder::BuildAndStart(), after the + /// Server instance is created. + virtual void InitServer(grpc_impl::ServerInitializer* si) = 0; + + /// Finish will be called at the end of ServerBuilder::BuildAndStart(). + virtual void Finish(grpc_impl::ServerInitializer* si) = 0; + + /// ChangeArguments is an interface that can be used in + /// ServerBuilderOption::UpdatePlugins + virtual void ChangeArguments(const grpc::string& name, void* value) = 0; + + /// UpdateChannelArguments will be called in ServerBuilder::BuildAndStart(), + /// before the Server instance is created. + virtual void UpdateChannelArguments(ChannelArguments* /*args*/) {} + + virtual bool has_sync_methods() const { return false; } + virtual bool has_async_methods() const { return false; } +}; + +} // namespace grpc + +#endif // GRPCPP_IMPL_SERVER_BUILDER_PLUGIN_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/server_initializer.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/server_initializer.h new file mode 100644 index 0000000000000000000000000000000000000000..d40bb98feb63c92dfcdd0a305787e61a3e9b8858 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/server_initializer.h @@ -0,0 +1,30 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_SERVER_INITIALIZER_H +#define GRPCPP_IMPL_SERVER_INITIALIZER_H + +#include + +namespace grpc { + +typedef ::grpc_impl::ServerInitializer ServerInitializer; + +} // namespace grpc + +#endif // GRPCPP_IMPL_SERVER_INITIALIZER_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/server_initializer_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/server_initializer_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..0e2c65f4af4e946764746c74f2328e7f8fc7f5fb --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/server_initializer_impl.h @@ -0,0 +1,57 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_SERVER_INITIALIZER_IMPL_H +#define GRPCPP_IMPL_SERVER_INITIALIZER_IMPL_H + +#include +#include + +#include + +namespace grpc { + +class Service; +} // namespace grpc +namespace grpc_impl { +class Server; + +class ServerInitializer { + public: + ServerInitializer(grpc::Server* server) : server_(server) {} + + bool RegisterService(std::shared_ptr service) { + if (!server_->RegisterService(nullptr, service.get())) { + return false; + } + default_services_.push_back(service); + return true; + } + + const std::vector* GetServiceList() { + return &server_->services_; + } + + private: + grpc::Server* server_; + std::vector > default_services_; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_IMPL_SERVER_INITIALIZER_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/service_type.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/service_type.h new file mode 100644 index 0000000000000000000000000000000000000000..250bc8cd56d1eb042496385001e9d878b05180d6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/service_type.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_SERVICE_TYPE_H +#define GRPCPP_IMPL_SERVICE_TYPE_H + +#include + +#endif // GRPCPP_IMPL_SERVICE_TYPE_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/sync_cxx11.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/sync_cxx11.h new file mode 100644 index 0000000000000000000000000000000000000000..76dcfe391c90eec6444473f5fff1c1840c00cf19 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/sync_cxx11.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_SYNC_CXX11_H +#define GRPCPP_IMPL_SYNC_CXX11_H + +#include + +#endif // GRPCPP_IMPL_SYNC_CXX11_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/impl/sync_no_cxx11.h b/deps/exla/cache/xla_extension/include/grpcpp/impl/sync_no_cxx11.h new file mode 100644 index 0000000000000000000000000000000000000000..cc2d4f104cf86ecbaa898d312eaf87116460b141 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/impl/sync_no_cxx11.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_SYNC_NO_CXX11_H +#define GRPCPP_IMPL_SYNC_NO_CXX11_H + +#include + +#endif // GRPCPP_IMPL_SYNC_NO_CXX11_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/resource_quota.h b/deps/exla/cache/xla_extension/include/grpcpp/resource_quota.h new file mode 100644 index 0000000000000000000000000000000000000000..333767b95c50367bf5f9d47367b0e26ffcbf2711 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/resource_quota.h @@ -0,0 +1,29 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_RESOURCE_QUOTA_H +#define GRPCPP_RESOURCE_QUOTA_H + +#include + +namespace grpc { + +typedef ::grpc_impl::ResourceQuota ResourceQuota; +} // namespace grpc + +#endif // GRPCPP_RESOURCE_QUOTA_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/resource_quota_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/resource_quota_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..16c0e35385b23a5c1b5b14f0343658e28fbbfe52 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/resource_quota_impl.h @@ -0,0 +1,68 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_RESOURCE_QUOTA_IMPL_H +#define GRPCPP_RESOURCE_QUOTA_IMPL_H + +struct grpc_resource_quota; + +#include +#include + +namespace grpc_impl { + +/// ResourceQuota represents a bound on memory and thread usage by the gRPC +/// library. A ResourceQuota can be attached to a server (via \a ServerBuilder), +/// or a client channel (via \a ChannelArguments). +/// gRPC will attempt to keep memory and threads used by all attached entities +/// below the ResourceQuota bound. +class ResourceQuota final : private ::grpc::GrpcLibraryCodegen { + public: + /// \param name - a unique name for this ResourceQuota. + explicit ResourceQuota(const grpc::string& name); + ResourceQuota(); + ~ResourceQuota(); + + /// Resize this \a ResourceQuota to a new size. If \a new_size is smaller + /// than the current size of the pool, memory usage will be monotonically + /// decreased until it falls under \a new_size. + /// No time bound is given for this to occur however. + ResourceQuota& Resize(size_t new_size); + + /// Set the max number of threads that can be allocated from this + /// ResourceQuota object. + /// + /// If the new_max_threads value is smaller than the current value, no new + /// threads are allocated until the number of active threads fall below + /// new_max_threads. There is no time bound on when this may happen i.e none + /// of the current threads are forcefully destroyed and all threads run their + /// normal course. + ResourceQuota& SetMaxThreads(int new_max_threads); + + grpc_resource_quota* c_resource_quota() const { return impl_; } + + private: + ResourceQuota(const ResourceQuota& rhs); + ResourceQuota& operator=(const ResourceQuota& rhs); + + grpc_resource_quota* const impl_; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_RESOURCE_QUOTA_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/security/auth_context.h b/deps/exla/cache/xla_extension/include/grpcpp/security/auth_context.h new file mode 100644 index 0000000000000000000000000000000000000000..7a6f2cb718bc56c8023012cd795fe95026f51c70 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/security/auth_context.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SECURITY_AUTH_CONTEXT_H +#define GRPCPP_SECURITY_AUTH_CONTEXT_H + +#include + +#endif // GRPCPP_SECURITY_AUTH_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/security/auth_metadata_processor.h b/deps/exla/cache/xla_extension/include/grpcpp/security/auth_metadata_processor.h new file mode 100644 index 0000000000000000000000000000000000000000..1b66b72b9672594247d6988616931c17ac0bb91c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/security/auth_metadata_processor.h @@ -0,0 +1,30 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_H +#define GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_H + +#include + +namespace grpc { + +typedef ::grpc_impl::AuthMetadataProcessor AuthMetadataProcessor; + +} // namespace grpc + +#endif // GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/security/auth_metadata_processor_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/security/auth_metadata_processor_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..ae4542006227b1a1ce0065ff8c7d4a6ec2b4d753 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/security/auth_metadata_processor_impl.h @@ -0,0 +1,61 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_IMPL_H +#define GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_IMPL_H + +#include + +#include +#include +#include + +namespace grpc_impl { + +/// Interface allowing custom server-side authorization based on credentials +/// encoded in metadata. Objects of this type can be passed to +/// \a ServerCredentials::SetAuthMetadataProcessor(). +class AuthMetadataProcessor { + public: + typedef std::multimap InputMetadata; + typedef std::multimap OutputMetadata; + + virtual ~AuthMetadataProcessor() {} + + /// If this method returns true, the \a Process function will be scheduled in + /// a different thread from the one processing the call. + virtual bool IsBlocking() const { return true; } + + /// context is read/write: it contains the properties of the channel peer and + /// it is the job of the Process method to augment it with properties derived + /// from the passed-in auth_metadata. + /// consumed_auth_metadata needs to be filled with metadata that has been + /// consumed by the processor and will be removed from the call. + /// response_metadata is the metadata that will be sent as part of the + /// response. + /// If the return value is not Status::OK, the rpc call will be aborted with + /// the error code and error message sent back to the client. + virtual grpc::Status Process(const InputMetadata& auth_metadata, + grpc::AuthContext* context, + OutputMetadata* consumed_auth_metadata, + OutputMetadata* response_metadata) = 0; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/security/credentials.h b/deps/exla/cache/xla_extension/include/grpcpp/security/credentials.h new file mode 100644 index 0000000000000000000000000000000000000000..0449017e77b19a12c2f8e32af58ff128c53cf627 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/security/credentials.h @@ -0,0 +1,143 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SECURITY_CREDENTIALS_H +#define GRPCPP_SECURITY_CREDENTIALS_H + +#include + +namespace grpc { + +typedef ::grpc_impl::ChannelCredentials ChannelCredentials; +typedef ::grpc_impl::CallCredentials CallCredentials; +typedef ::grpc_impl::SslCredentialsOptions SslCredentialsOptions; +typedef ::grpc_impl::SecureCallCredentials SecureCallCredentials; +typedef ::grpc_impl::SecureChannelCredentials SecureChannelCredentials; +typedef ::grpc_impl::MetadataCredentialsPlugin MetadataCredentialsPlugin; + +static inline std::shared_ptr +GoogleDefaultCredentials() { + return ::grpc_impl::GoogleDefaultCredentials(); +} + +static inline std::shared_ptr SslCredentials( + const SslCredentialsOptions& options) { + return ::grpc_impl::SslCredentials(options); +} + +static inline std::shared_ptr +GoogleComputeEngineCredentials() { + return ::grpc_impl::GoogleComputeEngineCredentials(); +} + +/// Constant for maximum auth token lifetime. +constexpr long kMaxAuthTokenLifetimeSecs = + ::grpc_impl::kMaxAuthTokenLifetimeSecs; + +static inline std::shared_ptr +ServiceAccountJWTAccessCredentials( + const grpc::string& json_key, + long token_lifetime_seconds = grpc::kMaxAuthTokenLifetimeSecs) { + return ::grpc_impl::ServiceAccountJWTAccessCredentials( + json_key, token_lifetime_seconds); +} + +static inline std::shared_ptr +GoogleRefreshTokenCredentials(const grpc::string& json_refresh_token) { + return ::grpc_impl::GoogleRefreshTokenCredentials(json_refresh_token); +} + +static inline std::shared_ptr +AccessTokenCredentials(const grpc::string& access_token) { + return ::grpc_impl::AccessTokenCredentials(access_token); +} + +static inline std::shared_ptr GoogleIAMCredentials( + const grpc::string& authorization_token, + const grpc::string& authority_selector) { + return ::grpc_impl::GoogleIAMCredentials(authorization_token, + authority_selector); +} + +static inline std::shared_ptr CompositeChannelCredentials( + const std::shared_ptr& channel_creds, + const std::shared_ptr& call_creds) { + return ::grpc_impl::CompositeChannelCredentials(channel_creds, call_creds); +} + +static inline std::shared_ptr +CompositeCallCredentials(const std::shared_ptr& creds1, + const std::shared_ptr& creds2) { + return ::grpc_impl::CompositeCallCredentials(creds1, creds2); +} + +static inline std::shared_ptr +InsecureChannelCredentials() { + return ::grpc_impl::InsecureChannelCredentials(); +} + +typedef ::grpc_impl::MetadataCredentialsPlugin MetadataCredentialsPlugin; + +static inline std::shared_ptr +MetadataCredentialsFromPlugin( + std::unique_ptr plugin) { + return ::grpc_impl::MetadataCredentialsFromPlugin(std::move(plugin)); +} + +namespace experimental { + +typedef ::grpc_impl::experimental::StsCredentialsOptions StsCredentialsOptions; + +static inline grpc::Status StsCredentialsOptionsFromJson( + const grpc::string& json_string, StsCredentialsOptions* options) { + return ::grpc_impl::experimental::StsCredentialsOptionsFromJson(json_string, + options); +} + +static inline grpc::Status StsCredentialsOptionsFromEnv( + StsCredentialsOptions* options) { + return grpc_impl::experimental::StsCredentialsOptionsFromEnv(options); +} + +static inline std::shared_ptr StsCredentials( + const StsCredentialsOptions& options) { + return grpc_impl::experimental::StsCredentials(options); +} + +typedef ::grpc_impl::experimental::AltsCredentialsOptions + AltsCredentialsOptions; + +static inline std::shared_ptr AltsCredentials( + const AltsCredentialsOptions& options) { + return ::grpc_impl::experimental::AltsCredentials(options); +} + +static inline std::shared_ptr LocalCredentials( + grpc_local_connect_type type) { + return ::grpc_impl::experimental::LocalCredentials(type); +} + +static inline std::shared_ptr TlsCredentials( + const ::grpc_impl::experimental::TlsCredentialsOptions& options) { + return ::grpc_impl::experimental::TlsCredentials(options); +} + +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_SECURITY_CREDENTIALS_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/security/credentials_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/security/credentials_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..08415171d21a0177a006377a1c38b017af750e7b --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/security/credentials_impl.h @@ -0,0 +1,351 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SECURITY_CREDENTIALS_IMPL_H +#define GRPCPP_SECURITY_CREDENTIALS_IMPL_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct grpc_call; + +namespace grpc_impl { + +class ChannelCredentials; +class CallCredentials; +class SecureCallCredentials; +class SecureChannelCredentials; + +std::shared_ptr CreateCustomChannelImpl( + const grpc::string& target, + const std::shared_ptr& creds, + const ChannelArguments& args); + +namespace experimental { +std::shared_ptr CreateCustomChannelWithInterceptors( + const grpc::string& target, + const std::shared_ptr& creds, + const ChannelArguments& args, + std::vector< + std::unique_ptr> + interceptor_creators); +} + +/// A channel credentials object encapsulates all the state needed by a client +/// to authenticate with a server for a given channel. +/// It can make various assertions, e.g., about the client’s identity, role +/// for all the calls on that channel. +/// +/// \see https://grpc.io/docs/guides/auth.html +class ChannelCredentials : private grpc::GrpcLibraryCodegen { + public: + ChannelCredentials(); + ~ChannelCredentials(); + + protected: + friend std::shared_ptr CompositeChannelCredentials( + const std::shared_ptr& channel_creds, + const std::shared_ptr& call_creds); + + virtual SecureChannelCredentials* AsSecureCredentials() = 0; + + private: + friend std::shared_ptr CreateCustomChannelImpl( + const grpc::string& target, + const std::shared_ptr& creds, + const ChannelArguments& args); + + friend std::shared_ptr + grpc_impl::experimental::CreateCustomChannelWithInterceptors( + const grpc::string& target, + const std::shared_ptr& creds, + const ChannelArguments& args, + std::vector> + interceptor_creators); + + virtual std::shared_ptr CreateChannelImpl( + const grpc::string& target, const ChannelArguments& args) = 0; + + // This function should have been a pure virtual function, but it is + // implemented as a virtual function so that it does not break API. + virtual std::shared_ptr CreateChannelWithInterceptors( + const grpc::string& /*target*/, const ChannelArguments& /*args*/, + std::vector> + /*interceptor_creators*/) { + return nullptr; + } +}; + +/// A call credentials object encapsulates the state needed by a client to +/// authenticate with a server for a given call on a channel. +/// +/// \see https://grpc.io/docs/guides/auth.html +class CallCredentials : private grpc::GrpcLibraryCodegen { + public: + CallCredentials(); + ~CallCredentials(); + + /// Apply this instance's credentials to \a call. + virtual bool ApplyToCall(grpc_call* call) = 0; + + protected: + friend std::shared_ptr CompositeChannelCredentials( + const std::shared_ptr& channel_creds, + const std::shared_ptr& call_creds); + + friend std::shared_ptr CompositeCallCredentials( + const std::shared_ptr& creds1, + const std::shared_ptr& creds2); + + virtual SecureCallCredentials* AsSecureCredentials() = 0; +}; + +/// Options used to build SslCredentials. +struct SslCredentialsOptions { + /// The buffer containing the PEM encoding of the server root certificates. If + /// this parameter is empty, the default roots will be used. The default + /// roots can be overridden using the \a GRPC_DEFAULT_SSL_ROOTS_FILE_PATH + /// environment variable pointing to a file on the file system containing the + /// roots. + grpc::string pem_root_certs; + + /// The buffer containing the PEM encoding of the client's private key. This + /// parameter can be empty if the client does not have a private key. + grpc::string pem_private_key; + + /// The buffer containing the PEM encoding of the client's certificate chain. + /// This parameter can be empty if the client does not have a certificate + /// chain. + grpc::string pem_cert_chain; +}; + +// Factories for building different types of Credentials The functions may +// return empty shared_ptr when credentials cannot be created. If a +// Credentials pointer is returned, it can still be invalid when used to create +// a channel. A lame channel will be created then and all rpcs will fail on it. + +/// Builds credentials with reasonable defaults. +/// +/// \warning Only use these credentials when connecting to a Google endpoint. +/// Using these credentials to connect to any other service may result in this +/// service being able to impersonate your client for requests to Google +/// services. +std::shared_ptr GoogleDefaultCredentials(); + +/// Builds SSL Credentials given SSL specific options +std::shared_ptr SslCredentials( + const SslCredentialsOptions& options); + +/// Builds credentials for use when running in GCE +/// +/// \warning Only use these credentials when connecting to a Google endpoint. +/// Using these credentials to connect to any other service may result in this +/// service being able to impersonate your client for requests to Google +/// services. +std::shared_ptr GoogleComputeEngineCredentials(); + +constexpr long kMaxAuthTokenLifetimeSecs = 3600; + +/// Builds Service Account JWT Access credentials. +/// json_key is the JSON key string containing the client's private key. +/// token_lifetime_seconds is the lifetime in seconds of each Json Web Token +/// (JWT) created with this credentials. It should not exceed +/// \a kMaxAuthTokenLifetimeSecs or will be cropped to this value. +std::shared_ptr ServiceAccountJWTAccessCredentials( + const grpc::string& json_key, + long token_lifetime_seconds = grpc_impl::kMaxAuthTokenLifetimeSecs); + +/// Builds refresh token credentials. +/// json_refresh_token is the JSON string containing the refresh token along +/// with a client_id and client_secret. +/// +/// \warning Only use these credentials when connecting to a Google endpoint. +/// Using these credentials to connect to any other service may result in this +/// service being able to impersonate your client for requests to Google +/// services. +std::shared_ptr GoogleRefreshTokenCredentials( + const grpc::string& json_refresh_token); + +/// Builds access token credentials. +/// access_token is an oauth2 access token that was fetched using an out of band +/// mechanism. +/// +/// \warning Only use these credentials when connecting to a Google endpoint. +/// Using these credentials to connect to any other service may result in this +/// service being able to impersonate your client for requests to Google +/// services. +std::shared_ptr AccessTokenCredentials( + const grpc::string& access_token); + +/// Builds IAM credentials. +/// +/// \warning Only use these credentials when connecting to a Google endpoint. +/// Using these credentials to connect to any other service may result in this +/// service being able to impersonate your client for requests to Google +/// services. +std::shared_ptr GoogleIAMCredentials( + const grpc::string& authorization_token, + const grpc::string& authority_selector); + +/// Combines a channel credentials and a call credentials into a composite +/// channel credentials. +std::shared_ptr CompositeChannelCredentials( + const std::shared_ptr& channel_creds, + const std::shared_ptr& call_creds); + +/// Combines two call credentials objects into a composite call credentials. +std::shared_ptr CompositeCallCredentials( + const std::shared_ptr& creds1, + const std::shared_ptr& creds2); + +/// Credentials for an unencrypted, unauthenticated channel +std::shared_ptr InsecureChannelCredentials(); + +/// User defined metadata credentials. +class MetadataCredentialsPlugin { + public: + virtual ~MetadataCredentialsPlugin() {} + + /// If this method returns true, the Process function will be scheduled in + /// a different thread from the one processing the call. + virtual bool IsBlocking() const { return true; } + + /// Type of credentials this plugin is implementing. + virtual const char* GetType() const { return ""; } + + /// Gets the auth metatada produced by this plugin. + /// The fully qualified method name is: + /// service_url + "/" + method_name. + /// The channel_auth_context contains (among other things), the identity of + /// the server. + virtual grpc::Status GetMetadata( + grpc::string_ref service_url, grpc::string_ref method_name, + const grpc::AuthContext& channel_auth_context, + std::multimap* metadata) = 0; +}; + +std::shared_ptr MetadataCredentialsFromPlugin( + std::unique_ptr plugin); + +namespace experimental { + +/// Options for creating STS Oauth Token Exchange credentials following the IETF +/// draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. +/// Optional fields may be set to empty string. It is the responsibility of the +/// caller to ensure that the subject and actor tokens are refreshed on disk at +/// the specified paths. +struct StsCredentialsOptions { + grpc::string token_exchange_service_uri; // Required. + grpc::string resource; // Optional. + grpc::string audience; // Optional. + grpc::string scope; // Optional. + grpc::string requested_token_type; // Optional. + grpc::string subject_token_path; // Required. + grpc::string subject_token_type; // Required. + grpc::string actor_token_path; // Optional. + grpc::string actor_token_type; // Optional. +}; + +/// Creates STS Options from a JSON string. The JSON schema is as follows: +/// { +/// "title": "STS Credentials Config", +/// "type": "object", +/// "required": ["token_exchange_service_uri", "subject_token_path", +/// "subject_token_type"], +/// "properties": { +/// "token_exchange_service_uri": { +/// "type": "string" +/// }, +/// "resource": { +/// "type": "string" +/// }, +/// "audience": { +/// "type": "string" +/// }, +/// "scope": { +/// "type": "string" +/// }, +/// "requested_token_type": { +/// "type": "string" +/// }, +/// "subject_token_path": { +/// "type": "string" +/// }, +/// "subject_token_type": { +/// "type": "string" +/// }, +/// "actor_token_path" : { +/// "type": "string" +/// }, +/// "actor_token_type": { +/// "type": "string" +/// } +/// } +/// } +grpc::Status StsCredentialsOptionsFromJson(const grpc::string& json_string, + StsCredentialsOptions* options); + +/// Creates STS credentials options from the $STS_CREDENTIALS environment +/// variable. This environment variable points to the path of a JSON file +/// comforming to the schema described above. +grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options); + +std::shared_ptr StsCredentials( + const StsCredentialsOptions& options); + +std::shared_ptr MetadataCredentialsFromPlugin( + std::unique_ptr plugin, + grpc_security_level min_security_level); + +/// Options used to build AltsCredentials. +struct AltsCredentialsOptions { + /// service accounts of target endpoint that will be acceptable + /// by the client. If service accounts are provided and none of them matches + /// that of the server, authentication will fail. + std::vector target_service_accounts; +}; + +/// Builds ALTS Credentials given ALTS specific options +std::shared_ptr AltsCredentials( + const AltsCredentialsOptions& options); + +/// Builds Local Credentials. +std::shared_ptr LocalCredentials( + grpc_local_connect_type type); + +/// Builds TLS Credentials given TLS options. +std::shared_ptr TlsCredentials( + const TlsCredentialsOptions& options); + +} // namespace experimental +} // namespace grpc_impl + +#endif // GRPCPP_SECURITY_CREDENTIALS_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/security/server_credentials.h b/deps/exla/cache/xla_extension/include/grpcpp/security/server_credentials.h new file mode 100644 index 0000000000000000000000000000000000000000..f41c05d59f2e3d571d159dbafecd9c13c95ac9ec --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/security/server_credentials.h @@ -0,0 +1,91 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SECURITY_SERVER_CREDENTIALS_H +#define GRPCPP_SECURITY_SERVER_CREDENTIALS_H + +#include + +namespace grpc_impl { + +class Server; +} // namespace grpc_impl +namespace grpc { + +typedef ::grpc_impl::ServerCredentials ServerCredentials; + +/// Options to create ServerCredentials with SSL +struct SslServerCredentialsOptions { + /// \warning Deprecated + SslServerCredentialsOptions() + : force_client_auth(false), + client_certificate_request(GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE) {} + SslServerCredentialsOptions( + grpc_ssl_client_certificate_request_type request_type) + : force_client_auth(false), client_certificate_request(request_type) {} + + struct PemKeyCertPair { + grpc::string private_key; + grpc::string cert_chain; + }; + grpc::string pem_root_certs; + std::vector pem_key_cert_pairs; + /// \warning Deprecated + bool force_client_auth; + + /// If both \a force_client_auth and \a client_certificate_request + /// fields are set, \a force_client_auth takes effect, i.e. + /// \a REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY + /// will be enforced. + grpc_ssl_client_certificate_request_type client_certificate_request; +}; + +static inline std::shared_ptr SslServerCredentials( + const SslServerCredentialsOptions& options) { + return ::grpc_impl::SslServerCredentials(options); +} + +static inline std::shared_ptr InsecureServerCredentials() { + return ::grpc_impl::InsecureServerCredentials(); +} + +namespace experimental { + +typedef ::grpc_impl::experimental::AltsServerCredentialsOptions + AltsServerCredentialsOptions; + +static inline std::shared_ptr AltsServerCredentials( + const AltsServerCredentialsOptions& options) { + return ::grpc_impl::experimental::AltsServerCredentials(options); +} + +static inline std::shared_ptr LocalServerCredentials( + grpc_local_connect_type type) { + return ::grpc_impl::experimental::LocalServerCredentials(type); +} + +/// Builds TLS ServerCredentials given TLS options. +static inline std::shared_ptr TlsServerCredentials( + const ::grpc_impl::experimental::TlsCredentialsOptions& options) { + return ::grpc_impl::experimental::TlsServerCredentials(options); +} + +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_SECURITY_SERVER_CREDENTIALS_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/security/server_credentials_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/security/server_credentials_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..efd7cf667597c08ca2e75ac33ef9db68aca04183 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/security/server_credentials_impl.h @@ -0,0 +1,90 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SECURITY_SERVER_CREDENTIALS_IMPL_H +#define GRPCPP_SECURITY_SERVER_CREDENTIALS_IMPL_H + +#include +#include + +#include +#include +#include +#include + +struct grpc_server; + +namespace grpc { + +struct SslServerCredentialsOptions; +} // namespace grpc +namespace grpc_impl { +class Server; + +/// Wrapper around \a grpc_server_credentials, a way to authenticate a server. +class ServerCredentials { + public: + virtual ~ServerCredentials(); + + /// This method is not thread-safe and has to be called before the server is + /// started. The last call to this function wins. + virtual void SetAuthMetadataProcessor( + const std::shared_ptr& processor) = 0; + + private: + friend class ::grpc_impl::Server; + + /// Tries to bind \a server to the given \a addr (eg, localhost:1234, + /// 192.168.1.1:31416, [::1]:27182, etc.) + /// + /// \return bound port number on success, 0 on failure. + // TODO(dgq): the "port" part seems to be a misnomer. + virtual int AddPortToServer(const grpc::string& addr, + grpc_server* server) = 0; +}; + +/// Builds SSL ServerCredentials given SSL specific options +std::shared_ptr SslServerCredentials( + const grpc::SslServerCredentialsOptions& options); + +/// Builds insecure server credentials. +std::shared_ptr InsecureServerCredentials(); + +namespace experimental { + +/// Options to create ServerCredentials with ALTS +struct AltsServerCredentialsOptions { + /// Add fields if needed. +}; + +/// Builds ALTS ServerCredentials given ALTS specific options +std::shared_ptr AltsServerCredentials( + const AltsServerCredentialsOptions& options); + +/// Builds Local ServerCredentials. +std::shared_ptr LocalServerCredentials( + grpc_local_connect_type type); + +/// Builds TLS ServerCredentials given TLS options. +std::shared_ptr TlsServerCredentials( + const TlsCredentialsOptions& options); + +} // namespace experimental +} // namespace grpc_impl + +#endif // GRPCPP_SECURITY_SERVER_CREDENTIALS_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/security/tls_credentials_options.h b/deps/exla/cache/xla_extension/include/grpcpp/security/tls_credentials_options.h new file mode 100644 index 0000000000000000000000000000000000000000..b5bb7c78b7f39b4ee9a04a934ecebb93461e6191 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/security/tls_credentials_options.h @@ -0,0 +1,339 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SECURITY_TLS_CREDENTIALS_OPTIONS_H +#define GRPCPP_SECURITY_TLS_CREDENTIALS_OPTIONS_H + +#include +#include + +#include +#include +#include +#include + +typedef struct grpc_tls_credential_reload_arg grpc_tls_credential_reload_arg; +typedef struct grpc_tls_credential_reload_config + grpc_tls_credential_reload_config; +typedef struct grpc_tls_server_authorization_check_arg + grpc_tls_server_authorization_check_arg; +typedef struct grpc_tls_server_authorization_check_config + grpc_tls_server_authorization_check_config; +typedef struct grpc_tls_credentials_options grpc_tls_credentials_options; + +namespace grpc_impl { +namespace experimental { + +/** TLS key materials config, wrapper for grpc_tls_key_materials_config. It is + * used for experimental purposes for now and subject to change. **/ +class TlsKeyMaterialsConfig { + public: + struct PemKeyCertPair { + grpc::string private_key; + grpc::string cert_chain; + }; + + /** Getters for member fields. **/ + const grpc::string pem_root_certs() const { return pem_root_certs_; } + const std::vector& pem_key_cert_pair_list() const { + return pem_key_cert_pair_list_; + } + int version() const { return version_; } + + /** Setter for key materials that will be called by the user. The setter + * transfers ownership of the arguments to the config. **/ + void set_pem_root_certs(grpc::string pem_root_certs); + void add_pem_key_cert_pair(const PemKeyCertPair& pem_key_cert_pair); + void set_key_materials(grpc::string pem_root_certs, + std::vector pem_key_cert_pair_list); + void set_version(int version) { version_ = version; }; + + private: + int version_ = 0; + std::vector pem_key_cert_pair_list_; + grpc::string pem_root_certs_; +}; + +/** TLS credential reload arguments, wraps grpc_tls_credential_reload_arg. It is + * used for experimental purposes for now and it is subject to change. + * + * The credential reload arg contains all the info necessary to schedule/cancel + * a credential reload request. The callback function must be called after + * finishing the schedule operation. See the description of the + * grpc_tls_credential_reload_arg struct in grpc_security.h for more details. + * **/ +class TlsCredentialReloadArg { + public: + /** TlsCredentialReloadArg does not take ownership of the C arg that is passed + * to the constructor. One must remember to free any memory allocated to the C + * arg after using the setter functions below. **/ + TlsCredentialReloadArg(grpc_tls_credential_reload_arg* arg); + ~TlsCredentialReloadArg(); + + /** Getters for member fields. The callback function is not exposed. + * They return the corresponding fields of the underlying C arg. In the case + * of the key materials config, it creates a new instance of the C++ key + * materials config from the underlying C grpc_tls_key_materials_config. **/ + void* cb_user_data() const; + bool is_pem_key_cert_pair_list_empty() const; + grpc_ssl_certificate_config_reload_status status() const; + grpc::string error_details() const; + + /** Setters for member fields. They modify the fields of the underlying C arg. + * The setters for the key_materials_config and the error_details allocate + * memory when modifying c_arg_, so one must remember to free c_arg_'s + * original key_materials_config or error_details after using the appropriate + * setter function. + * **/ + void set_cb_user_data(void* cb_user_data); + void set_pem_root_certs(const grpc::string& pem_root_certs); + void add_pem_key_cert_pair( + TlsKeyMaterialsConfig::PemKeyCertPair pem_key_cert_pair); + void set_key_materials_config( + const std::shared_ptr& key_materials_config); + void set_status(grpc_ssl_certificate_config_reload_status status); + void set_error_details(const grpc::string& error_details); + + /** Calls the C arg's callback function. **/ + void OnCredentialReloadDoneCallback(); + + private: + grpc_tls_credential_reload_arg* c_arg_; +}; + +/** An interface that the application derives and uses to instantiate a + * TlsCredentialReloadConfig instance. Refer to the definition of the + * grpc_tls_credential_reload_config in grpc_tls_credentials_options.h for more + * details on the expectations of the member functions of the interface. **/ +struct TlsCredentialReloadInterface { + virtual ~TlsCredentialReloadInterface() = default; + /** A callback that invokes the credential reload. **/ + virtual int Schedule(TlsCredentialReloadArg* arg) = 0; + /** A callback that cancels a credential reload request. **/ + virtual void Cancel(TlsCredentialReloadArg* /* arg */) {} +}; + +/** TLS credential reloag config, wraps grpc_tls_credential_reload_config. It is + * used for experimental purposes for now and it is subject to change. **/ +class TlsCredentialReloadConfig { + public: + TlsCredentialReloadConfig(std::shared_ptr + credential_reload_interface); + ~TlsCredentialReloadConfig(); + + int Schedule(TlsCredentialReloadArg* arg) const { + if (credential_reload_interface_ == nullptr) { + gpr_log(GPR_ERROR, "credential reload interface is nullptr"); + if (arg != nullptr) { + arg->set_status(GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL); + arg->set_error_details( + "the interface of the credential reload config is nullptr"); + } + return 1; + } + return credential_reload_interface_->Schedule(arg); + } + + void Cancel(TlsCredentialReloadArg* arg) const { + if (credential_reload_interface_ == nullptr) { + gpr_log(GPR_ERROR, "credential reload interface is nullptr"); + if (arg != nullptr) { + arg->set_status(GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL); + arg->set_error_details( + "the interface of the credential reload config is nullptr"); + } + return; + } + credential_reload_interface_->Cancel(arg); + } + + /** Returns a C struct for the credential reload config. **/ + grpc_tls_credential_reload_config* c_config() const { return c_config_; } + + private: + grpc_tls_credential_reload_config* c_config_; + std::shared_ptr credential_reload_interface_; +}; + +/** TLS server authorization check arguments, wraps + * grpc_tls_server_authorization_check_arg. It is used for experimental + * purposes for now and it is subject to change. + * + * The server authorization check arg contains all the info necessary to + * schedule/cancel a server authorization check request. The callback function + * must be called after finishing the schedule operation. See the description + * of the grpc_tls_server_authorization_check_arg struct in grpc_security.h for + * more details. **/ +class TlsServerAuthorizationCheckArg { + public: + /** TlsServerAuthorizationCheckArg does not take ownership of the C arg passed + * to the constructor. One must remember to free any memory allocated to the + * C arg after using the setter functions below. **/ + TlsServerAuthorizationCheckArg(grpc_tls_server_authorization_check_arg* arg); + ~TlsServerAuthorizationCheckArg(); + + /** Getters for member fields. They return the corresponding fields of the + * underlying C arg.**/ + void* cb_user_data() const; + int success() const; + grpc::string target_name() const; + grpc::string peer_cert() const; + grpc::string peer_cert_full_chain() const; + grpc_status_code status() const; + grpc::string error_details() const; + + /** Setters for member fields. They modify the fields of the underlying C arg. + * The setters for target_name, peer_cert, and error_details allocate memory + * when modifying c_arg_, so one must remember to free c_arg_'s original + * target_name, peer_cert, or error_details after using the appropriate setter + * function. + * **/ + void set_cb_user_data(void* cb_user_data); + void set_success(int success); + void set_target_name(const grpc::string& target_name); + void set_peer_cert(const grpc::string& peer_cert); + void set_peer_cert_full_chain(const grpc::string& peer_cert_full_chain); + void set_status(grpc_status_code status); + void set_error_details(const grpc::string& error_details); + + /** Calls the C arg's callback function. **/ + void OnServerAuthorizationCheckDoneCallback(); + + private: + grpc_tls_server_authorization_check_arg* c_arg_; +}; + +/** An interface that the application derives and uses to instantiate a + * TlsServerAuthorizationCheckConfig instance. Refer to the definition of the + * grpc_tls_server_authorization_check_config in grpc_tls_credentials_options.h + * for more details on the expectations of the member functions of the + * interface. + * **/ +struct TlsServerAuthorizationCheckInterface { + virtual ~TlsServerAuthorizationCheckInterface() = default; + /** A callback that invokes the server authorization check. **/ + virtual int Schedule(TlsServerAuthorizationCheckArg* arg) = 0; + /** A callback that cancels a server authorization check request. **/ + virtual void Cancel(TlsServerAuthorizationCheckArg* /* arg */) {} +}; + +/** TLS server authorization check config, wraps + * grps_tls_server_authorization_check_config. It is used for experimental + * purposes for now and it is subject to change. **/ +class TlsServerAuthorizationCheckConfig { + public: + TlsServerAuthorizationCheckConfig( + std::shared_ptr + server_authorization_check_interface); + ~TlsServerAuthorizationCheckConfig(); + + int Schedule(TlsServerAuthorizationCheckArg* arg) const { + if (server_authorization_check_interface_ == nullptr) { + gpr_log(GPR_ERROR, "server authorization check interface is nullptr"); + if (arg != nullptr) { + arg->set_status(GRPC_STATUS_NOT_FOUND); + arg->set_error_details( + "the interface of the server authorization check config is " + "nullptr"); + } + return 1; + } + return server_authorization_check_interface_->Schedule(arg); + } + + void Cancel(TlsServerAuthorizationCheckArg* arg) const { + if (server_authorization_check_interface_ == nullptr) { + gpr_log(GPR_ERROR, "server authorization check interface is nullptr"); + if (arg != nullptr) { + arg->set_status(GRPC_STATUS_NOT_FOUND); + arg->set_error_details( + "the interface of the server authorization check config is " + "nullptr"); + } + return; + } + server_authorization_check_interface_->Cancel(arg); + } + + /** Returns C struct for the server authorization check config. **/ + grpc_tls_server_authorization_check_config* c_config() const { + return c_config_; + } + + private: + grpc_tls_server_authorization_check_config* c_config_; + std::shared_ptr + server_authorization_check_interface_; +}; + +/** TLS credentials options, wrapper for grpc_tls_credentials_options. It is + * used for experimental purposes for now and it is subject to change. See the + * description of the grpc_tls_credentials_options struct in grpc_security.h for + * more details. **/ +class TlsCredentialsOptions { + public: + TlsCredentialsOptions( + grpc_ssl_client_certificate_request_type cert_request_type, + grpc_tls_server_verification_option server_verification_option, + std::shared_ptr key_materials_config, + std::shared_ptr credential_reload_config, + std::shared_ptr + server_authorization_check_config); + ~TlsCredentialsOptions(); + + /** Getters for member fields. **/ + grpc_ssl_client_certificate_request_type cert_request_type() const { + return cert_request_type_; + } + grpc_tls_server_verification_option server_verification_option() const { + return server_verification_option_; + } + std::shared_ptr key_materials_config() const { + return key_materials_config_; + } + std::shared_ptr credential_reload_config() const { + return credential_reload_config_; + } + std::shared_ptr + server_authorization_check_config() const { + return server_authorization_check_config_; + } + grpc_tls_credentials_options* c_credentials_options() const { + return c_credentials_options_; + } + + private: + /** The cert_request_type_ flag is only relevant when the + * TlsCredentialsOptions are used to instantiate server credentials; the flag + * goes unused when creating channel credentials, and the user can set it to + * GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE. **/ + grpc_ssl_client_certificate_request_type cert_request_type_; + /** The server_verification_option_ flag is only relevant when the + * TlsCredentialsOptions are used to instantiate client credentials; **/ + grpc_tls_server_verification_option server_verification_option_; + std::shared_ptr key_materials_config_; + std::shared_ptr credential_reload_config_; + std::shared_ptr + server_authorization_check_config_; + grpc_tls_credentials_options* c_credentials_options_; +}; + +} // namespace experimental +} // namespace grpc_impl + +#endif // GRPCPP_SECURITY_TLS_CREDENTIALS_OPTIONS_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/server.h b/deps/exla/cache/xla_extension/include/grpcpp/server.h new file mode 100644 index 0000000000000000000000000000000000000000..3de2aba0b5921245b8a964bbd487d7255e71ba17 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/server.h @@ -0,0 +1,30 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SERVER_H +#define GRPCPP_SERVER_H + +#include + +namespace grpc { + +typedef ::grpc_impl::Server Server; + +} // namespace grpc + +#endif // GRPCPP_SERVER_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/server_builder.h b/deps/exla/cache/xla_extension/include/grpcpp/server_builder.h new file mode 100644 index 0000000000000000000000000000000000000000..d9ec7c42f3dda26cfe8e8a542dfd78d308ab7680 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/server_builder.h @@ -0,0 +1,30 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SERVER_BUILDER_H +#define GRPCPP_SERVER_BUILDER_H + +#include + +namespace grpc { + +typedef ::grpc_impl::ServerBuilder ServerBuilder; + +} // namespace grpc + +#endif // GRPCPP_SERVER_BUILDER_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/server_builder_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/server_builder_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..294a798bb9c457c051ddce1b0c8151bf9ab6c14f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/server_builder_impl.h @@ -0,0 +1,416 @@ +/* + * + * Copyright 2015-2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SERVER_BUILDER_IMPL_H +#define GRPCPP_SERVER_BUILDER_IMPL_H + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct grpc_resource_quota; + +namespace grpc_impl { + +class CompletionQueue; +class ResourceQuota; +class Server; +class ServerCompletionQueue; +class ServerCredentials; +} // namespace grpc_impl + +namespace grpc { + +class AsyncGenericService; +class Service; +namespace testing { +class ServerBuilderPluginTest; +} // namespace testing + +namespace internal { +class ExternalConnectionAcceptorImpl; +} // namespace internal + +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL +namespace experimental { +#endif +class CallbackGenericService; +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL +} // namespace experimental +#endif + +namespace experimental { +// EXPERIMENTAL API: +// Interface for a grpc server to build transports with connections created out +// of band. +// See ServerBuilder's AddExternalConnectionAcceptor API. +class ExternalConnectionAcceptor { + public: + struct NewConnectionParameters { + int listener_fd = -1; + int fd = -1; + ByteBuffer read_buffer; // data intended for the grpc server + }; + virtual ~ExternalConnectionAcceptor() {} + // If called before grpc::Server is started or after it is shut down, the new + // connection will be closed. + virtual void HandleNewConnection(NewConnectionParameters* p) = 0; +}; + +} // namespace experimental +} // namespace grpc + +namespace grpc_impl { + +/// A builder class for the creation and startup of \a grpc::Server instances. +class ServerBuilder { + public: + ServerBuilder(); + virtual ~ServerBuilder(); + + ////////////////////////////////////////////////////////////////////////////// + // Primary API's + + /// Return a running server which is ready for processing calls. + /// Before calling, one typically needs to ensure that: + /// 1. a service is registered - so that the server knows what to serve + /// (via RegisterService, or RegisterAsyncGenericService) + /// 2. a listening port has been added - so the server knows where to receive + /// traffic (via AddListeningPort) + /// 3. [for async api only] completion queues have been added via + /// AddCompletionQueue + virtual std::unique_ptr BuildAndStart(); + + /// Register a service. This call does not take ownership of the service. + /// The service must exist for the lifetime of the \a Server instance returned + /// by \a BuildAndStart(). + /// Matches requests with any :authority + ServerBuilder& RegisterService(grpc::Service* service); + + /// Enlists an endpoint \a addr (port with an optional IP address) to + /// bind the \a grpc::Server object to be created to. + /// + /// It can be invoked multiple times. + /// + /// \param addr_uri The address to try to bind to the server in URI form. If + /// the scheme name is omitted, "dns:///" is assumed. To bind to any address, + /// please use IPv6 any, i.e., [::]:, which also accepts IPv4 + /// connections. Valid values include dns:///localhost:1234, / + /// 192.168.1.1:31416, dns:///[::1]:27182, etc.). + /// \param creds The credentials associated with the server. + /// \param selected_port[out] If not `nullptr`, gets populated with the port + /// number bound to the \a grpc::Server for the corresponding endpoint after + /// it is successfully bound by BuildAndStart(), 0 otherwise. AddListeningPort + /// does not modify this pointer. + ServerBuilder& AddListeningPort( + const grpc::string& addr_uri, + std::shared_ptr creds, + int* selected_port = nullptr); + + /// Add a completion queue for handling asynchronous services. + /// + /// Best performance is typically obtained by using one thread per polling + /// completion queue. + /// + /// Caller is required to shutdown the server prior to shutting down the + /// returned completion queue. Caller is also required to drain the + /// completion queue after shutting it down. A typical usage scenario: + /// + /// // While building the server: + /// ServerBuilder builder; + /// ... + /// cq_ = builder.AddCompletionQueue(); + /// server_ = builder.BuildAndStart(); + /// + /// // While shutting down the server; + /// server_->Shutdown(); + /// cq_->Shutdown(); // Always *after* the associated server's Shutdown()! + /// // Drain the cq_ that was created + /// void* ignored_tag; + /// bool ignored_ok; + /// while (cq_->Next(&ignored_tag, &ignored_ok)) { } + /// + /// \param is_frequently_polled This is an optional parameter to inform gRPC + /// library about whether this completion queue would be frequently polled + /// (i.e. by calling \a Next() or \a AsyncNext()). The default value is + /// 'true' and is the recommended setting. Setting this to 'false' (i.e. + /// not polling the completion queue frequently) will have a significantly + /// negative performance impact and hence should not be used in production + /// use cases. + std::unique_ptr AddCompletionQueue( + bool is_frequently_polled = true); + + ////////////////////////////////////////////////////////////////////////////// + // Less commonly used RegisterService variants + + /// Register a service. This call does not take ownership of the service. + /// The service must exist for the lifetime of the \a Server instance + /// returned by \a BuildAndStart(). Only matches requests with :authority \a + /// host + ServerBuilder& RegisterService(const grpc::string& host, + grpc::Service* service); + + /// Register a generic service. + /// Matches requests with any :authority + /// This is mostly useful for writing generic gRPC Proxies where the exact + /// serialization format is unknown + ServerBuilder& RegisterAsyncGenericService( + grpc::AsyncGenericService* service); + + ////////////////////////////////////////////////////////////////////////////// + // Fine control knobs + + /// Set max receive message size in bytes. + /// The default is GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH. + ServerBuilder& SetMaxReceiveMessageSize(int max_receive_message_size) { + max_receive_message_size_ = max_receive_message_size; + return *this; + } + + /// Set max send message size in bytes. + /// The default is GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH. + ServerBuilder& SetMaxSendMessageSize(int max_send_message_size) { + max_send_message_size_ = max_send_message_size; + return *this; + } + + /// \deprecated For backward compatibility. + ServerBuilder& SetMaxMessageSize(int max_message_size) { + return SetMaxReceiveMessageSize(max_message_size); + } + + /// Set the support status for compression algorithms. All algorithms are + /// enabled by default. + /// + /// Incoming calls compressed with an unsupported algorithm will fail with + /// \a GRPC_STATUS_UNIMPLEMENTED. + ServerBuilder& SetCompressionAlgorithmSupportStatus( + grpc_compression_algorithm algorithm, bool enabled); + + /// The default compression level to use for all channel calls in the + /// absence of a call-specific level. + ServerBuilder& SetDefaultCompressionLevel(grpc_compression_level level); + + /// The default compression algorithm to use for all channel calls in the + /// absence of a call-specific level. Note that it overrides any compression + /// level set by \a SetDefaultCompressionLevel. + ServerBuilder& SetDefaultCompressionAlgorithm( + grpc_compression_algorithm algorithm); + + /// Set the attached buffer pool for this server + ServerBuilder& SetResourceQuota( + const grpc_impl::ResourceQuota& resource_quota); + + ServerBuilder& SetOption(std::unique_ptr option); + + /// Options for synchronous servers. + enum SyncServerOption { + NUM_CQS, ///< Number of completion queues. + MIN_POLLERS, ///< Minimum number of polling threads. + MAX_POLLERS, ///< Maximum number of polling threads. + CQ_TIMEOUT_MSEC ///< Completion queue timeout in milliseconds. + }; + + /// Only useful if this is a Synchronous server. + ServerBuilder& SetSyncServerOption(SyncServerOption option, int value); + + /// Add a channel argument (an escape hatch to tuning core library parameters + /// directly) + template + ServerBuilder& AddChannelArgument(const grpc::string& arg, const T& value) { + return SetOption(grpc::MakeChannelArgumentOption(arg, value)); + } + + /// For internal use only: Register a ServerBuilderPlugin factory function. + static void InternalAddPluginFactory( + std::unique_ptr (*CreatePlugin)()); + + /// Enable a server workaround. Do not use unless you know what the workaround + /// does. For explanation and detailed descriptions of workarounds, see + /// doc/workarounds.md. + ServerBuilder& EnableWorkaround(grpc_workaround_list id); + + /// NOTE: class experimental_type is not part of the public API of this class. + /// TODO(yashykt): Integrate into public API when this is no longer + /// experimental. + class experimental_type { + public: + explicit experimental_type(grpc_impl::ServerBuilder* builder) + : builder_(builder) {} + + void SetInterceptorCreators( + std::vector> + interceptor_creators) { + builder_->interceptor_creators_ = std::move(interceptor_creators); + } + +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL + /// Register a generic service that uses the callback API. + /// Matches requests with any :authority + /// This is mostly useful for writing generic gRPC Proxies where the exact + /// serialization format is unknown + ServerBuilder& RegisterCallbackGenericService( + grpc::experimental::CallbackGenericService* service); +#endif + + enum class ExternalConnectionType { + FROM_FD = 0 // in the form of a file descriptor + }; + + /// Register an acceptor to handle the externally accepted connection in + /// grpc server. The returned acceptor can be used to pass the connection + /// to grpc server, where a channel will be created with the provided + /// server credentials. + std::unique_ptr + AddExternalConnectionAcceptor(ExternalConnectionType type, + std::shared_ptr creds); + + private: + ServerBuilder* builder_; + }; + +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL + /// Register a generic service that uses the callback API. + /// Matches requests with any :authority + /// This is mostly useful for writing generic gRPC Proxies where the exact + /// serialization format is unknown + ServerBuilder& RegisterCallbackGenericService( + grpc::CallbackGenericService* service); +#endif + + /// NOTE: The function experimental() is not stable public API. It is a view + /// to the experimental components of this class. It may be changed or removed + /// at any time. + experimental_type experimental() { return experimental_type(this); } + + protected: + /// Experimental, to be deprecated + struct Port { + grpc::string addr; + std::shared_ptr creds; + int* selected_port; + }; + + /// Experimental, to be deprecated + typedef std::unique_ptr HostString; + struct NamedService { + explicit NamedService(grpc::Service* s) : service(s) {} + NamedService(const grpc::string& h, grpc::Service* s) + : host(new grpc::string(h)), service(s) {} + HostString host; + grpc::Service* service; + }; + + /// Experimental, to be deprecated + std::vector ports() { return ports_; } + + /// Experimental, to be deprecated + std::vector services() { + std::vector service_refs; + for (auto& ptr : services_) { + service_refs.push_back(ptr.get()); + } + return service_refs; + } + + /// Experimental, to be deprecated + std::vector options() { + std::vector option_refs; + for (auto& ptr : options_) { + option_refs.push_back(ptr.get()); + } + return option_refs; + } + + private: + friend class ::grpc::testing::ServerBuilderPluginTest; + + struct SyncServerSettings { + SyncServerSettings() + : num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {} + + /// Number of server completion queues to create to listen to incoming RPCs. + int num_cqs; + + /// Minimum number of threads per completion queue that should be listening + /// to incoming RPCs. + int min_pollers; + + /// Maximum number of threads per completion queue that can be listening to + /// incoming RPCs. + int max_pollers; + + /// The timeout for server completion queue's AsyncNext call. + int cq_timeout_msec; + }; + + int max_receive_message_size_; + int max_send_message_size_; + std::vector> options_; + std::vector> services_; + std::vector ports_; + + SyncServerSettings sync_server_settings_; + + /// List of completion queues added via \a AddCompletionQueue method. + std::vector cqs_; + + std::shared_ptr creds_; + std::vector> plugins_; + grpc_resource_quota* resource_quota_; + grpc::AsyncGenericService* generic_service_{nullptr}; +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL + grpc::CallbackGenericService* callback_generic_service_{nullptr}; +#else + grpc::experimental::CallbackGenericService* callback_generic_service_{ + nullptr}; +#endif + + struct { + bool is_set; + grpc_compression_level level; + } maybe_default_compression_level_; + struct { + bool is_set; + grpc_compression_algorithm algorithm; + } maybe_default_compression_algorithm_; + uint32_t enabled_compression_algorithms_bitset_; + std::vector< + std::unique_ptr> + interceptor_creators_; + std::vector> + acceptors_; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_SERVER_BUILDER_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/server_context.h b/deps/exla/cache/xla_extension/include/grpcpp/server_context.h new file mode 100644 index 0000000000000000000000000000000000000000..45f2614994173d27a9917cd09b9ef656350c7328 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/server_context.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SERVER_CONTEXT_H +#define GRPCPP_SERVER_CONTEXT_H + +#include + +#endif // GRPCPP_SERVER_CONTEXT_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/server_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/server_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..9506c419018e9a07759006d38f5bdd08710ac393 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/server_impl.h @@ -0,0 +1,392 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SERVER_IMPL_H +#define GRPCPP_SERVER_IMPL_H + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct grpc_server; + +namespace grpc { +class AsyncGenericService; + +namespace internal { +class ExternalConnectionAcceptorImpl; +} // namespace internal + +} // namespace grpc + +namespace grpc_impl { +class HealthCheckServiceInterface; +class ServerContext; +class ServerInitializer; + +/// Represents a gRPC server. +/// +/// Use a \a grpc::ServerBuilder to create, configure, and start +/// \a Server instances. +class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { + public: + ~Server(); + + /// Block until the server shuts down. + /// + /// \warning The server must be either shutting down or some other thread must + /// call \a Shutdown for this function to ever return. + void Wait() override; + + /// Global callbacks are a set of hooks that are called when server + /// events occur. \a SetGlobalCallbacks method is used to register + /// the hooks with gRPC. Note that + /// the \a GlobalCallbacks instance will be shared among all + /// \a Server instances in an application and can be set exactly + /// once per application. + class GlobalCallbacks { + public: + virtual ~GlobalCallbacks() {} + /// Called before server is created. + virtual void UpdateArguments(ChannelArguments* /*args*/) {} + /// Called before application callback for each synchronous server request + virtual void PreSynchronousRequest(grpc_impl::ServerContext* context) = 0; + /// Called after application callback for each synchronous server request + virtual void PostSynchronousRequest(grpc_impl::ServerContext* context) = 0; + /// Called before server is started. + virtual void PreServerStart(Server* /*server*/) {} + /// Called after a server port is added. + virtual void AddPort(Server* /*server*/, const grpc::string& /*addr*/, + grpc::ServerCredentials* /*creds*/, int /*port*/) {} + }; + /// Set the global callback object. Can only be called once per application. + /// Does not take ownership of callbacks, and expects the pointed to object + /// to be alive until all server objects in the process have been destroyed. + /// The same \a GlobalCallbacks object will be used throughout the + /// application and is shared among all \a Server objects. + static void SetGlobalCallbacks(GlobalCallbacks* callbacks); + + /// Returns a \em raw pointer to the underlying \a grpc_server instance. + /// EXPERIMENTAL: for internal/test use only + grpc_server* c_server(); + + /// Returns the health check service. + grpc::HealthCheckServiceInterface* GetHealthCheckService() const { + return health_check_service_.get(); + } + + /// Establish a channel for in-process communication + std::shared_ptr InProcessChannel(const ChannelArguments& args); + + /// NOTE: class experimental_type is not part of the public API of this class. + /// TODO(yashykt): Integrate into public API when this is no longer + /// experimental. + class experimental_type { + public: + explicit experimental_type(Server* server) : server_(server) {} + + /// Establish a channel for in-process communication with client + /// interceptors + std::shared_ptr InProcessChannelWithInterceptors( + const ChannelArguments& args, + std::vector> + interceptor_creators); + + private: + Server* server_; + }; + + /// NOTE: The function experimental() is not stable public API. It is a view + /// to the experimental components of this class. It may be changed or removed + /// at any time. + experimental_type experimental() { return experimental_type(this); } + + protected: + /// Register a service. This call does not take ownership of the service. + /// The service must exist for the lifetime of the Server instance. + bool RegisterService(const grpc::string* host, + grpc::Service* service) override; + + /// Try binding the server to the given \a addr endpoint + /// (port, and optionally including IP address to bind to). + /// + /// It can be invoked multiple times. Should be used before + /// starting the server. + /// + /// \param addr The address to try to bind to the server (eg, localhost:1234, + /// 192.168.1.1:31416, [::1]:27182, etc.). + /// \param creds The credentials associated with the server. + /// + /// \return bound port number on success, 0 on failure. + /// + /// \warning It is an error to call this method on an already started server. + int AddListeningPort(const grpc::string& addr, + grpc::ServerCredentials* creds) override; + + /// NOTE: This is *NOT* a public API. The server constructors are supposed to + /// be used by \a ServerBuilder class only. The constructor will be made + /// 'private' very soon. + /// + /// Server constructors. To be used by \a ServerBuilder only. + /// + /// \param args The channel args + /// + /// \param sync_server_cqs The completion queues to use if the server is a + /// synchronous server (or a hybrid server). The server polls for new RPCs on + /// these queues + /// + /// \param min_pollers The minimum number of polling threads per server + /// completion queue (in param sync_server_cqs) to use for listening to + /// incoming requests (used only in case of sync server) + /// + /// \param max_pollers The maximum number of polling threads per server + /// completion queue (in param sync_server_cqs) to use for listening to + /// incoming requests (used only in case of sync server) + /// + /// \param sync_cq_timeout_msec The timeout to use when calling AsyncNext() on + /// server completion queues passed via sync_server_cqs param. + Server(ChannelArguments* args, + std::shared_ptr>> + sync_server_cqs, + int min_pollers, int max_pollers, int sync_cq_timeout_msec, + std::vector< + std::shared_ptr> + acceptors, + grpc_resource_quota* server_rq = nullptr, + std::vector> + interceptor_creators = std::vector>()); + + /// Start the server. + /// + /// \param cqs Completion queues for handling asynchronous services. The + /// caller is required to keep all completion queues live until the server is + /// destroyed. + /// \param num_cqs How many completion queues does \a cqs hold. + void Start(ServerCompletionQueue** cqs, size_t num_cqs) override; + + grpc_server* server() override { return server_; } + + protected: + /// NOTE: This method is not part of the public API for this class. + void set_health_check_service( + std::unique_ptr service) { + health_check_service_ = std::move(service); + } + + /// NOTE: This method is not part of the public API for this class. + bool health_check_service_disabled() const { + return health_check_service_disabled_; + } + + private: + std::vector< + std::unique_ptr>* + interceptor_creators() override { + return &interceptor_creators_; + } + + friend class grpc::AsyncGenericService; + friend class grpc_impl::ServerBuilder; + friend class grpc_impl::ServerInitializer; + + class SyncRequest; + class CallbackRequestBase; + template + class CallbackRequest; + class UnimplementedAsyncRequest; + class UnimplementedAsyncResponse; + + /// SyncRequestThreadManager is an implementation of ThreadManager. This class + /// is responsible for polling for incoming RPCs and calling the RPC handlers. + /// This is only used in case of a Sync server (i.e a server exposing a sync + /// interface) + class SyncRequestThreadManager; + + /// Register a generic service. This call does not take ownership of the + /// service. The service must exist for the lifetime of the Server instance. + void RegisterAsyncGenericService(grpc::AsyncGenericService* service) override; + +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL + /// Register a callback-based generic service. This call does not take + /// ownership of theservice. The service must exist for the lifetime of the + /// Server instance. + void RegisterCallbackGenericService( + grpc::CallbackGenericService* service) override; +#else + /// NOTE: class experimental_registration_type is not part of the public API + /// of this class + /// TODO(vjpai): Move these contents to the public API of Server when + /// they are no longer experimental + class experimental_registration_type final + : public experimental_registration_interface { + public: + explicit experimental_registration_type(Server* server) : server_(server) {} + void RegisterCallbackGenericService( + grpc::experimental::CallbackGenericService* service) override { + server_->RegisterCallbackGenericService(service); + } + + private: + Server* server_; + }; + + /// TODO(vjpai): Mark this override when experimental type above is deleted + void RegisterCallbackGenericService( + grpc::experimental::CallbackGenericService* service); + + /// NOTE: The function experimental_registration() is not stable public API. + /// It is a view to the experimental components of this class. It may be + /// changed or removed at any time. + experimental_registration_interface* experimental_registration() override { + return &experimental_registration_; + } +#endif + + void PerformOpsOnCall(grpc::internal::CallOpSetInterface* ops, + grpc::internal::Call* call) override; + + void ShutdownInternal(gpr_timespec deadline) override; + + int max_receive_message_size() const override { + return max_receive_message_size_; + } + + CompletionQueue* CallbackCQ() override; + + grpc_impl::ServerInitializer* initializer(); + + std::vector> + acceptors_; + + // A vector of interceptor factory objects. + // This should be destroyed after health_check_service_ and this requirement + // is satisfied by declaring interceptor_creators_ before + // health_check_service_. (C++ mandates that member objects be destroyed in + // the reverse order of initialization.) + std::vector< + std::unique_ptr> + interceptor_creators_; + + int max_receive_message_size_; + + /// The following completion queues are ONLY used in case of Sync API + /// i.e. if the server has any services with sync methods. The server uses + /// these completion queues to poll for new RPCs + std::shared_ptr>> + sync_server_cqs_; + + /// List of \a ThreadManager instances (one for each cq in + /// the \a sync_server_cqs) + std::vector> sync_req_mgrs_; + + // Outstanding unmatched callback requests, indexed by method. + // NOTE: Using a gpr_atm rather than atomic_int because atomic_int isn't + // copyable or movable and thus will cause compilation errors. We + // actually only want to extend the vector before the threaded use + // starts, but this is still a limitation. + std::vector callback_unmatched_reqs_count_; + + // List of callback requests to start when server actually starts. + std::list callback_reqs_to_start_; + +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL + // For registering experimental callback generic service; remove when that + // method longer experimental + experimental_registration_type experimental_registration_{this}; +#endif + + // Server status + grpc::internal::Mutex mu_; + bool started_; + bool shutdown_; + bool shutdown_notified_; // Was notify called on the shutdown_cv_ + + grpc::internal::CondVar shutdown_cv_; + + // It is ok (but not required) to nest callback_reqs_mu_ under mu_ . + // Incrementing callback_reqs_outstanding_ is ok without a lock but it must be + // decremented under the lock in case it is the last request and enables the + // server shutdown. The increment is performance-critical since it happens + // during periods of increasing load; the decrement happens only when memory + // is maxed out, during server shutdown, or (possibly in a future version) + // during decreasing load, so it is less performance-critical. + grpc::internal::Mutex callback_reqs_mu_; + grpc::internal::CondVar callback_reqs_done_cv_; + std::atomic callback_reqs_outstanding_{0}; + + std::shared_ptr global_callbacks_; + + std::vector services_; + bool has_async_generic_service_{false}; + bool has_callback_generic_service_{false}; + + // Pointer to the wrapped grpc_server. + grpc_server* server_; + + std::unique_ptr server_initializer_; + + std::unique_ptr health_check_service_; + bool health_check_service_disabled_; + + // When appropriate, use a default callback generic service to handle + // unimplemented methods +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL + std::unique_ptr unimplemented_service_; +#else + std::unique_ptr + unimplemented_service_; +#endif + + // A special handler for resource exhausted in sync case + std::unique_ptr resource_exhausted_handler_; + + // Handler for callback generic service, if any + std::unique_ptr generic_handler_; + + // callback_cq_ references the callbackable completion queue associated + // with this server (if any). It is set on the first call to CallbackCQ(). + // It is _not owned_ by the server; ownership belongs with its internal + // shutdown callback tag (invoked when the CQ is fully shutdown). + // It is protected by mu_ + CompletionQueue* callback_cq_ = nullptr; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_SERVER_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/server_posix.h b/deps/exla/cache/xla_extension/include/grpcpp/server_posix.h new file mode 100644 index 0000000000000000000000000000000000000000..3d209cbc14f068faeba5e849a4a3ee247066659c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/server_posix.h @@ -0,0 +1,36 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SERVER_POSIX_H +#define GRPCPP_SERVER_POSIX_H + +#include + +namespace grpc { + +#ifdef GPR_SUPPORT_CHANNELS_FROM_FD + +static inline void AddInsecureChannelFromFd(Server* server, int fd) { + ::grpc_impl::AddInsecureChannelFromFd(server, fd); +} + +#endif // GPR_SUPPORT_CHANNELS_FROM_FD + +} // namespace grpc + +#endif // GRPCPP_SERVER_POSIX_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/server_posix_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/server_posix_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..c29af271fe99525e75daf9a0bcbf57910506a693 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/server_posix_impl.h @@ -0,0 +1,42 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SERVER_POSIX_IMPL_H +#define GRPCPP_SERVER_POSIX_IMPL_H + +#include + +#include +#include + +namespace grpc_impl { + +#ifdef GPR_SUPPORT_CHANNELS_FROM_FD + +/// Add a new client to a \a Server communicating over the given +/// file descriptor. +/// +/// \param server The server to add the client to. +/// \param fd The file descriptor representing a socket. +void AddInsecureChannelFromFd(grpc::Server* server, int fd); + +#endif // GPR_SUPPORT_CHANNELS_FROM_FD + +} // namespace grpc + +#endif // GRPCPP_SERVER_POSIX_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/async_stream.h b/deps/exla/cache/xla_extension/include/grpcpp/support/async_stream.h new file mode 100644 index 0000000000000000000000000000000000000000..ff9e455679388f789e84d385f529d25123355978 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/async_stream.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_ASYNC_STREAM_H +#define GRPCPP_SUPPORT_ASYNC_STREAM_H + +#include + +#endif // GRPCPP_SUPPORT_ASYNC_STREAM_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/async_stream_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/support/async_stream_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..cff700d3fa9546898c5b02e7c518a28fb3bda865 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/async_stream_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_ASYNC_STREAM_IMPL_H +#define GRPCPP_SUPPORT_ASYNC_STREAM_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_ASYNC_STREAM_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/async_unary_call.h b/deps/exla/cache/xla_extension/include/grpcpp/support/async_unary_call.h new file mode 100644 index 0000000000000000000000000000000000000000..2e5181c5570397774da9096a8180570a822595a6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/async_unary_call.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_ASYNC_UNARY_CALL_H +#define GRPCPP_SUPPORT_ASYNC_UNARY_CALL_H + +#include + +#endif // GRPCPP_SUPPORT_ASYNC_UNARY_CALL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/async_unary_call_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/support/async_unary_call_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..488fe87515a10a1684291f4f0337a6923b25455f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/async_unary_call_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_ASYNC_UNARY_CALL_IMPL_H +#define GRPCPP_SUPPORT_ASYNC_UNARY_CALL_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_ASYNC_UNARY_CALL_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/byte_buffer.h b/deps/exla/cache/xla_extension/include/grpcpp/support/byte_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..53aeff19f77c9c715ff6ef1f92e4c1041c2ccc5f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/byte_buffer.h @@ -0,0 +1,31 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_BYTE_BUFFER_H +#define GRPCPP_SUPPORT_BYTE_BUFFER_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // GRPCPP_SUPPORT_BYTE_BUFFER_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/channel_arguments.h b/deps/exla/cache/xla_extension/include/grpcpp/support/channel_arguments.h new file mode 100644 index 0000000000000000000000000000000000000000..593aaec76a7e76b5e184eee886c17b6426155757 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/channel_arguments.h @@ -0,0 +1,36 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_CHANNEL_ARGUMENTS_H +#define GRPCPP_SUPPORT_CHANNEL_ARGUMENTS_H + +#include + +namespace grpc_impl { + +class SecureChannelCredentials; +class ResourceQuota; +} // namespace grpc_impl + +namespace grpc { + +typedef ::grpc_impl::ChannelArguments ChannelArguments; + +} // namespace grpc + +#endif // GRPCPP_SUPPORT_CHANNEL_ARGUMENTS_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/channel_arguments_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/support/channel_arguments_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..ca3188a9e7556ab9b8cab4b1a52801c4e728eda7 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/channel_arguments_impl.h @@ -0,0 +1,152 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_CHANNEL_ARGUMENTS_IMPL_H +#define GRPCPP_SUPPORT_CHANNEL_ARGUMENTS_IMPL_H + +#include +#include + +#include +#include +#include +#include + +namespace grpc { +namespace testing { +class ChannelArgumentsTest; +} // namespace testing +} // namespace grpc + +namespace grpc_impl { + +class SecureChannelCredentials; + +/// Options for channel creation. The user can use generic setters to pass +/// key value pairs down to C channel creation code. For gRPC related options, +/// concrete setters are provided. +class ChannelArguments { + public: + ChannelArguments(); + ~ChannelArguments(); + + ChannelArguments(const ChannelArguments& other); + ChannelArguments& operator=(ChannelArguments other) { + Swap(other); + return *this; + } + + void Swap(ChannelArguments& other); + + /// Dump arguments in this instance to \a channel_args. Does not take + /// ownership of \a channel_args. + /// + /// Note that the underlying arguments are shared. Changes made to either \a + /// channel_args or this instance would be reflected on both. + void SetChannelArgs(grpc_channel_args* channel_args) const; + + // gRPC specific channel argument setters + /// Set target name override for SSL host name checking. This option should + /// be used with caution in production. + void SetSslTargetNameOverride(const grpc::string& name); + // TODO(yangg) add flow control options + /// Set the compression algorithm for the channel. + void SetCompressionAlgorithm(grpc_compression_algorithm algorithm); + + /// Set the grpclb fallback timeout (in ms) for the channel. If this amount + /// of time has passed but we have not gotten any non-empty \a serverlist from + /// the balancer, we will fall back to use the backend address(es) returned by + /// the resolver. + void SetGrpclbFallbackTimeout(int fallback_timeout); + + /// For client channel's, the socket mutator operates on + /// "channel" sockets. For server's, the socket mutator operates + /// only on "listen" sockets. + /// TODO(apolcyn): allow socket mutators to also operate + /// on server "channel" sockets, and adjust the socket mutator + /// object to be more speficic about which type of socket + /// it should operate on. + void SetSocketMutator(grpc_socket_mutator* mutator); + + /// Set the string to prepend to the user agent. + void SetUserAgentPrefix(const grpc::string& user_agent_prefix); + + /// Set the buffer pool to be attached to the constructed channel. + void SetResourceQuota(const grpc::ResourceQuota& resource_quota); + + /// Set the max receive and send message sizes. + void SetMaxReceiveMessageSize(int size); + void SetMaxSendMessageSize(int size); + + /// Set LB policy name. + /// Note that if the name resolver returns only balancer addresses, the + /// grpclb LB policy will be used, regardless of what is specified here. + void SetLoadBalancingPolicyName(const grpc::string& lb_policy_name); + + /// Set service config in JSON form. + /// Primarily meant for use in unit tests. + void SetServiceConfigJSON(const grpc::string& service_config_json); + + // Generic channel argument setters. Only for advanced use cases. + /// Set an integer argument \a value under \a key. + void SetInt(const grpc::string& key, int value); + + // Generic channel argument setter. Only for advanced use cases. + /// Set a pointer argument \a value under \a key. Owership is not transferred. + void SetPointer(const grpc::string& key, void* value); + + void SetPointerWithVtable(const grpc::string& key, void* value, + const grpc_arg_pointer_vtable* vtable); + + /// Set a textual argument \a value under \a key. + void SetString(const grpc::string& key, const grpc::string& value); + + /// Return (by value) a C \a grpc_channel_args structure which points to + /// arguments owned by this \a ChannelArguments instance + grpc_channel_args c_channel_args() const { + grpc_channel_args out; + out.num_args = args_.size(); + out.args = args_.empty() ? NULL : const_cast(&args_[0]); + return out; + } + + private: + friend class grpc_impl::SecureChannelCredentials; + friend class grpc::testing::ChannelArgumentsTest; + + /// Default pointer argument operations. + struct PointerVtableMembers { + static void* Copy(void* in) { return in; } + static void Destroy(void* /*in*/) {} + static int Compare(void* a, void* b) { + if (a < b) return -1; + if (a > b) return 1; + return 0; + } + }; + + // Returns empty string when it is not set. + grpc::string GetSslTargetNameOverride() const; + + std::vector args_; + std::list strings_; +}; + +} // namespace grpc_impl + +#endif // GRPCPP_SUPPORT_CHANNEL_ARGUMENTS_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/client_callback.h b/deps/exla/cache/xla_extension/include/grpcpp/support/client_callback.h new file mode 100644 index 0000000000000000000000000000000000000000..063fdc4f8594fac2a751315315a8d117bc2b7986 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/client_callback.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_CLIENT_CALLBACK_H +#define GRPCPP_SUPPORT_CLIENT_CALLBACK_H + +#include + +#endif // GRPCPP_SUPPORT_CLIENT_CALLBACK_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/client_callback_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/support/client_callback_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..ed8df412496da341f985ef4491297d618ddd71f6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/client_callback_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_CLIENT_CALLBACK_IMPL_H +#define GRPCPP_SUPPORT_CLIENT_CALLBACK_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_CLIENT_CALLBACK_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/client_interceptor.h b/deps/exla/cache/xla_extension/include/grpcpp/support/client_interceptor.h new file mode 100644 index 0000000000000000000000000000000000000000..50810e3fe3c7b92017a6aea037b02ed502fbb7b7 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/client_interceptor.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_CLIENT_INTERCEPTOR_H +#define GRPCPP_SUPPORT_CLIENT_INTERCEPTOR_H + +#include + +#endif // GRPCPP_SUPPORT_CLIENT_INTERCEPTOR_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/config.h b/deps/exla/cache/xla_extension/include/grpcpp/support/config.h new file mode 100644 index 0000000000000000000000000000000000000000..16bdab6427576ef76f4b67e2efe1aa4236a5a542 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/config.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_CONFIG_H +#define GRPCPP_SUPPORT_CONFIG_H + +#include + +#endif // GRPCPP_SUPPORT_CONFIG_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/interceptor.h b/deps/exla/cache/xla_extension/include/grpcpp/support/interceptor.h new file mode 100644 index 0000000000000000000000000000000000000000..7ff79516bae6ab89164e33b258b8cdb0ad27e961 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/interceptor.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_INTERCEPTOR_H +#define GRPCPP_SUPPORT_INTERCEPTOR_H + +#include + +#endif // GRPCPP_SUPPORT_INTERCEPTOR_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/message_allocator.h b/deps/exla/cache/xla_extension/include/grpcpp/support/message_allocator.h new file mode 100644 index 0000000000000000000000000000000000000000..20ce072b901b144a5e1188439db77cd9ecf43b2b --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/message_allocator.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H +#define GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H + +#include + +#endif // GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/method_handler.h b/deps/exla/cache/xla_extension/include/grpcpp/support/method_handler.h new file mode 100644 index 0000000000000000000000000000000000000000..038e76c8af8abf1b4c092be4e6593bf11d086b60 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/method_handler.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_METHOD_HANDLER_H +#define GRPCPP_SUPPORT_METHOD_HANDLER_H + +#include + +#endif // GRPCPP_SUPPORT_METHOD_HANDLER_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/proto_buffer_reader.h b/deps/exla/cache/xla_extension/include/grpcpp/support/proto_buffer_reader.h new file mode 100644 index 0000000000000000000000000000000000000000..4cdb65d531b141c3ac0f14d0118325788fa65361 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/proto_buffer_reader.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_PROTO_BUFFER_READER_H +#define GRPCPP_SUPPORT_PROTO_BUFFER_READER_H + +#include + +#endif // GRPCPP_SUPPORT_PROTO_BUFFER_READER_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/proto_buffer_writer.h b/deps/exla/cache/xla_extension/include/grpcpp/support/proto_buffer_writer.h new file mode 100644 index 0000000000000000000000000000000000000000..01cf29c457eb71ac6da64eecf5f47c7e6f755247 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/proto_buffer_writer.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_PROTO_BUFFER_WRITER_H +#define GRPCPP_SUPPORT_PROTO_BUFFER_WRITER_H + +#include + +#endif // GRPCPP_SUPPORT_PROTO_BUFFER_WRITER_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/server_callback.h b/deps/exla/cache/xla_extension/include/grpcpp/support/server_callback.h new file mode 100644 index 0000000000000000000000000000000000000000..b0aeeb53c5d40d8411403f185ad1579ba0c36f89 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/server_callback.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_SERVER_CALLBACK_H +#define GRPCPP_SUPPORT_SERVER_CALLBACK_H + +#include + +#endif // GRPCPP_SUPPORT_SERVER_CALLBACK_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/server_callback_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/support/server_callback_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..a91c8141dd897a514dd38f17befdfade3c9f12db --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/server_callback_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_SERVER_CALLBACK_IMPL_H +#define GRPCPP_SUPPORT_SERVER_CALLBACK_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_SERVER_CALLBACK_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/server_interceptor.h b/deps/exla/cache/xla_extension/include/grpcpp/support/server_interceptor.h new file mode 100644 index 0000000000000000000000000000000000000000..b0a6229b667cbccd258bd00bb303cb21706dfd74 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/server_interceptor.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_SERVER_INTERCEPTOR_H +#define GRPCPP_SUPPORT_SERVER_INTERCEPTOR_H + +#include + +#endif // GRPCPP_SUPPORT_SERVER_INTERCEPTOR_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/slice.h b/deps/exla/cache/xla_extension/include/grpcpp/support/slice.h new file mode 100644 index 0000000000000000000000000000000000000000..eaeb29a40b29b1b26d337167aedae6e02766adad --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/slice.h @@ -0,0 +1,26 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_SLICE_H +#define GRPCPP_SUPPORT_SLICE_H + +#include +#include +#include + +#endif // GRPCPP_SUPPORT_SLICE_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/status.h b/deps/exla/cache/xla_extension/include/grpcpp/support/status.h new file mode 100644 index 0000000000000000000000000000000000000000..91b629f167603969250ff1361ee232f0e803b199 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/status.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_STATUS_H +#define GRPCPP_SUPPORT_STATUS_H + +#include + +#endif // GRPCPP_SUPPORT_STATUS_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/status_code_enum.h b/deps/exla/cache/xla_extension/include/grpcpp/support/status_code_enum.h new file mode 100644 index 0000000000000000000000000000000000000000..bfb47f39c0a55caaf4da522b1562e3ec80e13090 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/status_code_enum.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_STATUS_CODE_ENUM_H +#define GRPCPP_SUPPORT_STATUS_CODE_ENUM_H + +#include + +#endif // GRPCPP_SUPPORT_STATUS_CODE_ENUM_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/string_ref.h b/deps/exla/cache/xla_extension/include/grpcpp/support/string_ref.h new file mode 100644 index 0000000000000000000000000000000000000000..0e0d3d4389e17165f81f26f5dc79c26fdef12ce6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/string_ref.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_STRING_REF_H +#define GRPCPP_SUPPORT_STRING_REF_H + +#include + +#endif // GRPCPP_SUPPORT_STRING_REF_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/stub_options.h b/deps/exla/cache/xla_extension/include/grpcpp/support/stub_options.h new file mode 100644 index 0000000000000000000000000000000000000000..e9700ea4928127f024c0491ed62ff026b16cf639 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/stub_options.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_STUB_OPTIONS_H +#define GRPCPP_SUPPORT_STUB_OPTIONS_H + +#include + +#endif // GRPCPP_SUPPORT_STUB_OPTIONS_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/sync_stream.h b/deps/exla/cache/xla_extension/include/grpcpp/support/sync_stream.h new file mode 100644 index 0000000000000000000000000000000000000000..ea60b6da6b9e7bbd4cf2509dd63db743b2fb7663 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/sync_stream.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_SYNC_STREAM_H +#define GRPCPP_SUPPORT_SYNC_STREAM_H + +#include + +#endif // GRPCPP_SUPPORT_SYNC_STREAM_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/sync_stream_impl.h b/deps/exla/cache/xla_extension/include/grpcpp/support/sync_stream_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..a00e425acfc85f793d48e24f4a5e9e65f7040496 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/sync_stream_impl.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_SYNC_STREAM_IMPL_H +#define GRPCPP_SUPPORT_SYNC_STREAM_IMPL_H + +#include + +#endif // GRPCPP_SUPPORT_SYNC_STREAM_IMPL_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/time.h b/deps/exla/cache/xla_extension/include/grpcpp/support/time.h new file mode 100644 index 0000000000000000000000000000000000000000..c7408ff27d199de1954d0e11ea88fd3aac2a91f3 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/time.h @@ -0,0 +1,24 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_TIME_H +#define GRPCPP_SUPPORT_TIME_H + +#include + +#endif // GRPCPP_SUPPORT_TIME_H diff --git a/deps/exla/cache/xla_extension/include/grpcpp/support/validate_service_config.h b/deps/exla/cache/xla_extension/include/grpcpp/support/validate_service_config.h new file mode 100644 index 0000000000000000000000000000000000000000..41f2c636bd961cea640d9994e7275349ebddb586 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/grpcpp/support/validate_service_config.h @@ -0,0 +1,36 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H +#define GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H + +#include + +namespace grpc { + +namespace experimental { +/// Validates \a service_config_json. If valid, returns an empty string. +/// Otherwise, returns the validation error. +/// TODO(yashykt): Promote it to out of experimental once it is proved useful +/// and gRFC is accepted. +grpc::string ValidateServiceConfigJSON(const grpc::string& service_config_json); +} // namespace experimental + +} // namespace grpc + +#endif // GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H diff --git a/deps/exla/cache/xla_extension/include/mlir/Transforms/LocationSnapshot.h b/deps/exla/cache/xla_extension/include/mlir/Transforms/LocationSnapshot.h new file mode 100644 index 0000000000000000000000000000000000000000..cefe005d2c4c9357eff4b7c9799ab6bd9d5f772f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/mlir/Transforms/LocationSnapshot.h @@ -0,0 +1,56 @@ +//===- LocationSnapshot.h - Location Snapshot Utilities ---------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file several utility methods for snapshotting the current IR to +// produce new debug locations. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_TRANSFORMS_LOCATIONSNAPSHOT_H +#define MLIR_TRANSFORMS_LOCATIONSNAPSHOT_H + +#include "mlir/Support/LLVM.h" +#include "llvm/ADT/StringRef.h" + +#include + +namespace mlir { +class Location; +class Operation; +class OpPrintingFlags; +class Pass; + +#define GEN_PASS_DECL_LOCATIONSNAPSHOT +#include "mlir/Transforms/Passes.h.inc" + +/// This function generates new locations from the given IR by snapshotting the +/// IR to the given stream, and using the printed locations within that stream. +/// The generated locations replace the current operation locations. +void generateLocationsFromIR(raw_ostream &os, StringRef fileName, Operation *op, + OpPrintingFlags flags); +/// This function generates new locations from the given IR by snapshotting the +/// IR to the given file, and using the printed locations within that file. If +/// `filename` is empty, a temporary file is generated instead. +LogicalResult generateLocationsFromIR(StringRef fileName, Operation *op, + OpPrintingFlags flags); + +/// This function generates new locations from the given IR by snapshotting the +/// IR to the given stream, and using the printed locations within that stream. +/// The generated locations are represented as a NameLoc with the given tag as +/// the name, and then fused with the existing locations. +void generateLocationsFromIR(raw_ostream &os, StringRef fileName, StringRef tag, + Operation *op, OpPrintingFlags flags); +/// This function generates new locations from the given IR by snapshotting the +/// IR to the given file, and using the printed locations within that file. If +/// `filename` is empty, a temporary file is generated instead. +LogicalResult generateLocationsFromIR(StringRef fileName, StringRef tag, + Operation *op, OpPrintingFlags flags); + +} // namespace mlir + +#endif // MLIR_TRANSFORMS_LOCATIONSNAPSHOT_H diff --git a/deps/exla/cache/xla_extension/include/mlir/Transforms/Transforms.capi.cpp.inc b/deps/exla/cache/xla_extension/include/mlir/Transforms/Transforms.capi.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..1041567a6699f9a81c82b7ff363b254de1f15251 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/mlir/Transforms/Transforms.capi.cpp.inc @@ -0,0 +1,168 @@ +/* Autogenerated by mlir-tblgen; don't manually edit. */ +//===----------------------------------------------------------------------===// +// Transforms Group Registration +//===----------------------------------------------------------------------===// + +void mlirRegisterTransformsPasses(void) { + registerTransformsPasses(); +} + +MlirPass mlirCreateTransformsCSE(void) { + return wrap(mlir::createCSEPass().release()); +} +void mlirRegisterTransformsCSE(void) { + registerCSE(); +} + + +MlirPass mlirCreateTransformsCanonicalizer(void) { + return wrap(mlir::createCanonicalizerPass().release()); +} +void mlirRegisterTransformsCanonicalizer(void) { + registerCanonicalizer(); +} + + +MlirPass mlirCreateTransformsCompositeFixedPointPass(void) { + return wrap(createCompositeFixedPointPass().release()); +} +void mlirRegisterTransformsCompositeFixedPointPass(void) { + registerCompositeFixedPointPass(); +} + + +MlirPass mlirCreateTransformsControlFlowSink(void) { + return wrap(::mlir::createControlFlowSinkPass().release()); +} +void mlirRegisterTransformsControlFlowSink(void) { + registerControlFlowSink(); +} + + +MlirPass mlirCreateTransformsGenerateRuntimeVerification(void) { + return wrap(mlir::createGenerateRuntimeVerificationPass().release()); +} +void mlirRegisterTransformsGenerateRuntimeVerification(void) { + registerGenerateRuntimeVerification(); +} + + +MlirPass mlirCreateTransformsInliner(void) { + return wrap(mlir::createInlinerPass().release()); +} +void mlirRegisterTransformsInliner(void) { + registerInliner(); +} + + +MlirPass mlirCreateTransformsLocationSnapshot(void) { + return wrap(createLocationSnapshot().release()); +} +void mlirRegisterTransformsLocationSnapshot(void) { + registerLocationSnapshot(); +} + + +MlirPass mlirCreateTransformsLoopInvariantCodeMotion(void) { + return wrap(mlir::createLoopInvariantCodeMotionPass().release()); +} +void mlirRegisterTransformsLoopInvariantCodeMotion(void) { + registerLoopInvariantCodeMotion(); +} + + +MlirPass mlirCreateTransformsLoopInvariantSubsetHoisting(void) { + return wrap(mlir::createLoopInvariantSubsetHoistingPass().release()); +} +void mlirRegisterTransformsLoopInvariantSubsetHoisting(void) { + registerLoopInvariantSubsetHoisting(); +} + + +MlirPass mlirCreateTransformsMem2Reg(void) { + return wrap(createMem2Reg().release()); +} +void mlirRegisterTransformsMem2Reg(void) { + registerMem2Reg(); +} + + +MlirPass mlirCreateTransformsPrintIRPass(void) { + return wrap(mlir::createPrintIRPass().release()); +} +void mlirRegisterTransformsPrintIRPass(void) { + registerPrintIRPass(); +} + + +MlirPass mlirCreateTransformsPrintOpStats(void) { + return wrap(mlir::createPrintOpStatsPass().release()); +} +void mlirRegisterTransformsPrintOpStats(void) { + registerPrintOpStats(); +} + + +MlirPass mlirCreateTransformsRemoveDeadValues(void) { + return wrap(mlir::createRemoveDeadValuesPass().release()); +} +void mlirRegisterTransformsRemoveDeadValues(void) { + registerRemoveDeadValues(); +} + + +MlirPass mlirCreateTransformsSCCP(void) { + return wrap(mlir::createSCCPPass().release()); +} +void mlirRegisterTransformsSCCP(void) { + registerSCCP(); +} + + +MlirPass mlirCreateTransformsSROA(void) { + return wrap(createSROA().release()); +} +void mlirRegisterTransformsSROA(void) { + registerSROA(); +} + + +MlirPass mlirCreateTransformsStripDebugInfo(void) { + return wrap(mlir::createStripDebugInfoPass().release()); +} +void mlirRegisterTransformsStripDebugInfo(void) { + registerStripDebugInfo(); +} + + +MlirPass mlirCreateTransformsSymbolDCE(void) { + return wrap(mlir::createSymbolDCEPass().release()); +} +void mlirRegisterTransformsSymbolDCE(void) { + registerSymbolDCE(); +} + + +MlirPass mlirCreateTransformsSymbolPrivatize(void) { + return wrap(mlir::createSymbolPrivatizePass().release()); +} +void mlirRegisterTransformsSymbolPrivatize(void) { + registerSymbolPrivatize(); +} + + +MlirPass mlirCreateTransformsTopologicalSort(void) { + return wrap(mlir::createTopologicalSortPass().release()); +} +void mlirRegisterTransformsTopologicalSort(void) { + registerTopologicalSort(); +} + + +MlirPass mlirCreateTransformsViewOpGraph(void) { + return wrap(mlir::createPrintOpGraphPass().release()); +} +void mlirRegisterTransformsViewOpGraph(void) { + registerViewOpGraph(); +} + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/api/PortableApi.h b/deps/exla/cache/xla_extension/include/stablehlo/api/PortableApi.h new file mode 100644 index 0000000000000000000000000000000000000000..7fca3cfd787c3fee1cca526b25971ecec4697db1 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/api/PortableApi.h @@ -0,0 +1,82 @@ +/* Copyright 2023 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_API_PORTABLEAPI_H +#define STABLEHLO_API_PORTABLEAPI_H + +#include + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/raw_ostream.h" +#include "mlir/Support/LogicalResult.h" + +namespace mlir { +namespace stablehlo { + +/// Return the current version for portable API. +/// Increments on all meaningful changes to this file. +inline int64_t getApiVersion() { return 9; } + +// Get the smaller version between version1 and version2. +FailureOr getSmallerVersion(llvm::StringRef version1, + llvm::StringRef version2); + +// Get the current StableHLO version. +// +// This value can be used as the `targetVersion` argument to +// `serializePortableArtifact`. +std::string getCurrentVersion(); + +// Get the minimum supported StableHLO version. +// +// This value can be used as the `targetVersion` argument to +// `serializePortableArtifact`. +// +// Each StableHLO version `producer_version` has a compatibility window, +// i.e. range of versions [`consumer_version_min`, `consumer_version_max`], +// where StableHLO portable artifacts serialized by `producer_version` +// can be deserialized by `consumer_version` within the window. +// See https://github.com/openxla/stablehlo/blob/main/docs/compatibility.md +// for the exact extent of these compatibility guarantees. +// +// This function returns `consumer_version_min` for the current StableHLO +// version. It can be used maximize forward compatibility, i.e. to maximize how +// far into the past we can go and still have the payloads produced by +// `serializePortableArtifact` compatible with potential consumers from the past +std::string getMinimumVersion(); + +// Write a StableHLO program expressed as a string (either prettyprinted MLIR +// module or MLIR bytecode) to a portable artifact. +// Can fail if `moduleStr` cannot be parsed, or if it cannot be expressed in the +// `targetVersion` version of StableHLO, e.g. if it's using new or removed +// features, or if it involves unsupported dialects. +LogicalResult serializePortableArtifact(llvm::StringRef moduleStr, + llvm::StringRef targetVersion, + llvm::raw_ostream& os); + +// Read a StableHLO program from a portable artifact, returning the module as +// MLIR bytecode. Note, this bytecode returned is not a portable artifact, +// and has the stability of returning textual assembly format. Bytecode is +// returned here since it is more compact and faster to read and write. +// Can fail if `artifactStr` cannot be expressed in the current version of +// StableHLO, e.g. if it's using incompatible features. Returns failure if +// `artifactStr` is invalid or fails to deserialize. +LogicalResult deserializePortableArtifact(llvm::StringRef artifactStr, + llvm::raw_ostream& os); + +} // namespace stablehlo +} // namespace mlir + +#endif // STABLEHLO_API_PORTABLEAPI_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/AssemblyFormat.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/AssemblyFormat.h new file mode 100644 index 0000000000000000000000000000000000000000..02ec3821c5b4f1ce15e636b8bbf2986da3ef1125 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/AssemblyFormat.h @@ -0,0 +1,443 @@ +/* Copyright 2022 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_ASSEMBLYFORMAT_H +#define STABLEHLO_DIALECT_ASSEMBLYFORMAT_H + +#include +#include + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallVector.h" +#include "mlir/IR/Attributes.h" +#include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinAttributes.h" +#include "mlir/IR/BuiltinTypeInterfaces.h" +#include "mlir/IR/Dialect.h" +#include "mlir/IR/DialectImplementation.h" +#include "mlir/IR/OpImplementation.h" +#include "mlir/IR/Operation.h" +#include "mlir/IR/OperationSupport.h" +#include "mlir/IR/Region.h" +#include "mlir/IR/TypeRange.h" +#include "mlir/IR/Types.h" +#include "mlir/IR/ValueRange.h" +#include "mlir/Support/LLVM.h" +#include "mlir/Support/LogicalResult.h" +#include "stablehlo/dialect/Base.h" + +namespace mlir { +namespace hlo { + +//===----------------------------------------------------------------------===// +// Generic Type Printers and Parsers +//===----------------------------------------------------------------------===// + +// Declarative `custom(...)` implementation: +// Pretty print for ops with many operands, but one result type, simplifies +// print if all operand types match the result type. +// +// Example: +// custom(type($result), type($operand1), +// type($operand2)) +// +// Generic: +// %0 = "stablehlo.op"(%0, %1) : (tensor, tensor) -> tensor +// Custom: +// %0 = stablehlo.op(%0, %1) : tensor +// +// Falls back to `printFunctionalType` if all operands do not match result +// type. +// +// Note that `type($result)` is the first argument, this is done because the +// behavior of trailing parameter packs is easily understandable. +namespace detail { +void printSameOperandsAndResultTypeImpl(OpAsmPrinter& p, Operation* op, + TypeRange operands, Type result); + +ParseResult parseSameOperandsAndResultTypeImpl(OpAsmParser& parser, + ArrayRef operands, + Type& result); +} // namespace detail + +template +void printSameOperandsAndResultType(OpAsmPrinter& p, Operation* op, + OpTypes... types) { + static_assert(sizeof...(types) > 0); // Must be non empty, must have result + SmallVector typesVec{types...}; + ArrayRef typesRef = ArrayRef(typesVec); + return detail::printSameOperandsAndResultTypeImpl( + p, op, typesRef.drop_back(1), typesRef.back()); +} + +template +ParseResult parseSameOperandsAndResultType(OpAsmParser& parser, + OpTypes&... types) { + static_assert(sizeof...(types) > 0); // Must be non empty, must have result + SmallVector typesVec{&types...}; + ArrayRef typesRef = ArrayRef(typesVec); + return detail::parseSameOperandsAndResultTypeImpl( + parser, typesRef.drop_back(1), *typesRef.back()); +} + +void printVariadicSameOperandsAndResultType(OpAsmPrinter& p, Operation* op, + OperandRange operands, + TypeRange opTypes, Type result); + +ParseResult parseVariadicSameOperandsAndResultType( + OpAsmParser& parser, + SmallVectorImpl& operands, + SmallVectorImpl& opTypes, Type& result); + +// Print a `constant` op. +// +// op ::= attr-dict $value +// +// When the `value` and `output` have different type, it just uses the default +// operator assembly format as a fallback. +void printConstantOp(OpAsmPrinter& p, Operation* op, ElementsAttr value); + +ParseResult parseConstantOp(OpAsmParser& parser, OperationState& result); + +// TuplesOp - only print result type. Operand type is trivially inferrable. +// +// Inferring operand types from tuple type: +// %3 = stablehlo.tuple %1, %2 : tuple, tensor> +// %1 : tensor +// %2 : tensor +// %3 : tuple, tensor> +void printTupleOpType(OpAsmPrinter& p, Operation*, TypeRange operands, + Type result); + +ParseResult parseTupleOpType(OpAsmParser& parser, + SmallVectorImpl& operands, Type& result); + +// PairwiseOps - only print result type. Operand types are trivially +// inferrable. +// +// Inferring operand types for pairwise ops: +// %3, %4 = stablehlo.operation %1, %2 : tensor, tensor +// %1 : tensor +// %2 : tensor +// %3 : tensor +// %4 : tensor +void printPairwiseOpType(OpAsmPrinter& p, Operation*, TypeRange operands, + TypeRange results); + +ParseResult parsePairwiseOpType(OpAsmParser& parser, + SmallVectorImpl& operands, + SmallVectorImpl& results); + +// Variadic operands with attributes - Need to provide custom parser since +// the built-in operand list parser parses the attribute expecting an SSA value +// and errors. +// +// %0 = stablehlo.operation %arg0, ..., %argN, attr = value +void printVariadicOperandWithAttribute(OpAsmPrinter& p, Operation*, + OperandRange operands); + +ParseResult parseVariadicOperandWithAttribute( + OpAsmParser& parser, + SmallVectorImpl& operands); + +//===----------------------------------------------------------------------===// +// Operation Printers and Parsers +//===----------------------------------------------------------------------===// + +// ComplexOpType - only print result type if the inferred complex type +// matches all operand types. +// +// Inferring operand types for complex ops: +// %0 = stablehlo.complex %1, %2 : tensor<4xcomplex> +// %0 : tensor<4xcomplex> +// %1 : tensor<4xf32> +// %2 : tensor<4xf32> +void printComplexOpType(OpAsmPrinter& p, Operation* op, ShapedType lhs, + ShapedType rhs, ShapedType result); + +ParseResult parseComplexOpType(OpAsmParser& parser, Type& lhs, Type& rhs, + Type& result); + +// Print reduce with or without compact printing +// If the reduce-op is eligible for compact printing, we emit a one-line print. +// See IsEligibleForCompactPrint code comments for criteria. +// +// Compact: +// stablehlo.reduce(...) applies across dimensions = [...] : +// Not compact: +// stablehlo.reduce(...) across dimensions = [...] : +// reducer(...) { ...} +void printReduceOp(OpAsmPrinter& p, Operation* op, ValueRange inputs, + ArrayRef dimensions, Region& body); + +// Parse reduce with or without compact parsing +ParseResult parseReduceOp( + OpAsmParser& parser, OperationState& result, + std::function)> createDimensions); + +// SelectOpType - only print the condition and result type when branch types +// match the result type. +// +// Inferring operand types for select ops: +// %3 = stablehlo.select %0, %1, %2 : tensor<2xi1>, tensor<2xi32> +// %0 : tensor<2xi1> +// %1 : tensor<2xi32> +// %2 : tensor<2xi32> +// %3 : tensor<2xi32> +void printSelectOpType(OpAsmPrinter& p, Operation* op, ShapedType pred, + ShapedType onTrue, ShapedType onFalse, + ShapedType result); + +ParseResult parseSelectOpType(OpAsmParser& parser, Type& pred, Type& onTrue, + Type& onFalse, Type& result); + +// Print a `while` op. +// +// op ::= `stablehlo.while` `(` assignment-list `)` `:` types attribute-dict +// `cond` region +// `do` region +// assignment-list ::= assignment | assignment `,` assignment-list +// assignment ::= ssa-value `=` ssa-value +void printWhileOp(OpAsmPrinter& p, Operation* op, Region& cond, Region& body); + +// Parse while with or without compact parsing +ParseResult parseWhileOp(OpAsmParser& parser, OperationState& result); + +//===----------------------------------------------------------------------===// +// Attribute Printers and Parsers +//===----------------------------------------------------------------------===// + +// SliceRanges - Used to print multi-dimensional ranges for slice. +void printSliceRanges(OpAsmPrinter& p, Operation* op, + ArrayRef startIndices, + ArrayRef limitIndices, + ArrayRef strides); + +ParseResult parseSliceRanges(OpAsmParser& parser, + DenseI64ArrayAttr& startIndices, + DenseI64ArrayAttr& limitIndices, + DenseI64ArrayAttr& strides); + +// GenericI64DenseArray - Used to print an attr that can be either +// +// Dense elements: +// { dense<[1, 2]> : tensor<2xi64> } +// Array: +// { array } +void printDenseI64Array(OpAsmPrinter& p, Operation* op, Attribute attr); + +ParseResult parseDenseI64Array(OpAsmParser& parser, Attribute& attr); + +// DimSizes - Print an array of ints. Dynamic dimensions printed as `?`. +// +// Generic: +// [1, -1] +// Custom: +// [1, ?] +std::string dimSizeToString(int64_t dimSize); +std::string dimSizesToString(ArrayRef dimSize); + +void printDimSizes(AsmPrinter& p, ArrayRef dimSizes); + +FailureOr> parseDimSizes(AsmParser& parser); +ParseResult parseDimSizes(AsmParser& parser, SmallVector& dimSizes); + +// ExponentMantissa - Abbreviated printing of exponent and mantissa as e#m#. +// +// Generic: +// {exponent = 5 : i32, mantissa = 10 : i32} +// Custom: +// e5m10 +void printExponentMantissa(AsmPrinter& p, Operation*, IntegerAttr exponent, + IntegerAttr mantissa); + +ParseResult parseExponentMantissa(AsmParser& parser, IntegerAttr& exponent, + IntegerAttr& mantissa); + +// CustomCallTarget - Print custom call target using upstream SymbolRef +// printing. +// +// Generic: +// {custom_call_target = "foo"} +// {custom_call_target = "not-valid-id"} +// +// Custom: +// @foo +// @"not-valid-id" +void printCustomCallTarget(AsmPrinter& p, Operation*, StringAttr target); + +ParseResult parseCustomCallTarget(AsmParser& parser, StringAttr& target); + +// TypeExtensions - Print a shorthand form of TypeExtensionsAttr. +// If TypeExtensionsAttr evolves in the future, the shorthand form may evolve +// as well, or we can also fall back to the autogenerated longer form. +// +// Generic: +// #stablehlo.type_extensions +// +// Custom: +// #stablehlo.bounds<4, ?> +void printTypeExtensions(BoundedAttrInterface attr, DialectAsmPrinter& os); + +Attribute parseTypeExtensions(HloDialectInterface* dialect, + DialectAsmParser& parser); + +// DotDimensionNumbers - Abbreviated printing using a ConvDimensionNumbers- +// inspired notation. batching_dims are skipped if empty. +// +// Generic: +// dot_dimension_numbers = #stablehlo.dot< +// lhs_batching_dimensions = [], +// lhs_contracting_dimensions = [1], +// rhs_batching_dimensions = [], +// rhs_contracting_dimensions = [0] +// > +// dot_dimension_numbers = #stablehlo.dot< +// lhs_batching_dimensions = [0], +// lhs_contracting_dimensions = [2], +// rhs_batching_dimensions = [0], +// rhs_contracting_dimensions = [1] +// > +// +// Custom: +// contracting_dims = [1] x [0] +// batching_dims = [0] x [0], contracting_dims = [2] x [1] +template +void printDotDimensionNumbers(AsmPrinter& p, Operation* op, AttrTy target) { + // Print two ArrayRef as `[...] x [...]` + auto printLhsRhsDims = [&](ArrayRef lhsDims, + ArrayRef rhsDims) { + DenseI64ArrayAttr::get(op->getContext(), lhsDims).print(p); + p << " x "; + DenseI64ArrayAttr::get(op->getContext(), rhsDims).print(p); + }; + + // Print the optional `batching_dims = [...] x [...]`. + if (!target.getLhsBatchingDimensions().empty() || + !target.getRhsBatchingDimensions().empty()) { + p << "batching_dims = "; + printLhsRhsDims(target.getLhsBatchingDimensions(), + target.getRhsBatchingDimensions()); + p << ", "; + } + + // Print the required `contracting_dims = [...] x [...]`. + p << "contracting_dims = "; + printLhsRhsDims(target.getLhsContractingDimensions(), + target.getRhsContractingDimensions()); +} + +template +ParseResult parseDotDimensionNumbers(AsmParser& parser, AttrTy& target) { + // Parse `[...] x [...]` into two DenseI64ArrayAttr attributes. + auto parseLhsRhsDims = [&](DenseI64ArrayAttr& lhsDims, + DenseI64ArrayAttr& rhsDims) -> ParseResult { + lhsDims = dyn_cast_or_null( + DenseI64ArrayAttr::parse(parser, Type{})); + if (!lhsDims) return failure(); + if (failed(parser.parseKeyword("x"))) return failure(); + rhsDims = dyn_cast_or_null( + DenseI64ArrayAttr::parse(parser, Type{})); + if (!rhsDims) return failure(); + return success(); + }; + + // Parse the optional `batching_dims = [...] x [...]`. + DenseI64ArrayAttr lhsBatchingDims, rhsBatchingDims; + if (succeeded(parser.parseOptionalKeyword("batching_dims"))) { + if (failed(parser.parseEqual()) || + failed(parseLhsRhsDims(lhsBatchingDims, rhsBatchingDims)) || + failed(parser.parseComma())) + return failure(); + } + + // Parse the required `contracting_dims = [...] x [...]`. + DenseI64ArrayAttr lhsContractingDims, rhsContractingDims; + if (failed(parser.parseKeyword("contracting_dims")) || + failed(parser.parseEqual()) || + failed(parseLhsRhsDims(lhsContractingDims, rhsContractingDims))) + return failure(); + + target = AttrTy::get( + parser.getBuilder().getContext(), + lhsBatchingDims ? lhsBatchingDims.asArrayRef() : ArrayRef{}, + rhsBatchingDims ? rhsBatchingDims.asArrayRef() : ArrayRef{}, + lhsContractingDims.asArrayRef(), rhsContractingDims.asArrayRef()); + return success(); +} + +// ResultAccuracyAttr - Custom printing and parsing for ResultAccuracyAttr. +// +// ResultAccuractAttr ::= `<` OptAtolAccuracy OptRtolAccuracy +// OptUlpAccuracy ModeAccuracy `>` +// OptAtolAccuracy ::= `atol` `=` APFloat `, ` | eps +// OptRtolAccuracy ::= `rtol` `=` APFloat `, ` | eps +// OptUlpAccuracy ::= `ulps` `=` int64_t `, ` | eps +// ModeAccuracy ::= `mode` `=` ResultAccuracyModeAttr +void printResultAccuracyAttr(AsmPrinter& odsPrinter, APFloat atol, APFloat rtol, + int64_t ulps, Attribute mode); + +template +Attribute parseResultAccuracyAttr(AsmParser& parser, Type type) { + APFloat resultAtol = APFloat::getZero(APFloat::IEEEdouble()); + APFloat resultRtol = APFloat::getZero(APFloat::IEEEdouble()); + int64_t resultUlps = 0; + + // Parse literal '<' + if (parser.parseLess()) return {}; + + // OptAtolAccuracy + if (succeeded(parser.parseOptionalKeyword("atol"))) { + double value; + if (parser.parseEqual() || parser.parseFloat(value) || parser.parseComma()) + return {}; + resultAtol = APFloat(value); + } + + // OptRtolAccuracy + if (succeeded(parser.parseOptionalKeyword("rtol"))) { + double value; + if (parser.parseEqual() || parser.parseFloat(value) || parser.parseComma()) + return {}; + resultRtol = APFloat(value); + } + + // OptUlpAccuracy + if (succeeded(parser.parseOptionalKeyword("ulps"))) { + int64_t value; + if (parser.parseEqual() || parser.parseInteger(value) || + parser.parseComma()) + return {}; + resultUlps = value; + } + + // ModeAccuracy + ModeTy modeAttr; + if (parser.parseKeyword("mode") || parser.parseEqual() || + parser.parseAttribute(modeAttr)) { + return {}; + } + + // Parse literal '>' + if (parser.parseGreater()) return {}; + return parser.getChecked(parser.getCurrentLocation(), + parser.getContext(), resultAtol, resultRtol, + resultUlps, modeAttr); +} + +} // namespace hlo +} // namespace mlir + +#endif // STABLEHLO_DIALECT_ASSEMBLYFORMAT_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/Base.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/Base.h new file mode 100644 index 0000000000000000000000000000000000000000..236d270d53ebbe964290e4de2583f4f7b1b21262 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/Base.h @@ -0,0 +1,571 @@ +/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. + Copyright 2022 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_BASE_H +#define STABLEHLO_DIALECT_BASE_H + +#include +#include + +#include "llvm/ADT/APSInt.h" +#include "llvm/ADT/Sequence.h" +#include "llvm/ADT/SmallVector.h" +#include "mlir/Bytecode/BytecodeImplementation.h" +#include "mlir/IR/Attributes.h" +#include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinAttributes.h" +#include "mlir/IR/BuiltinTypeInterfaces.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/Diagnostics.h" +#include "mlir/IR/DialectInterface.h" +#include "mlir/IR/MLIRContext.h" +#include "mlir/IR/Matchers.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/Operation.h" +#include "mlir/IR/TypeUtilities.h" +#include "mlir/IR/Types.h" +#include "mlir/IR/Value.h" +#include "mlir/Interfaces/InferTypeOpInterface.h" +#include "mlir/Interfaces/SideEffectInterfaces.h" +#include "mlir/Support/LogicalResult.h" + +// Include order matters +#include "stablehlo/dialect/BaseAttrInterfaces.h.inc" + +namespace mlir { +namespace hlo { + +// TODO(zhouxin) change to a better name as it's used by both of size and bound +// Check if the dimension size is dynamic. +inline static bool isDynamicDimSize(int64_t val) { + return ShapedType::isDynamic(val); +} + +inline static bool isStaticDimSize(int64_t val) { + return !isDynamicDimSize(val); +} + +// Checks whether every position in the given array contains the given value. +bool isSplatArray(ArrayRef arr, int64_t val); + +// Verifies that the two types have compatible shape with bounds but allows +// different element types. +LogicalResult verifyCompatibleShapeWithBounds(Type type1, Type type2); + +// Returns true if the given element types are compatible for the purposes of +// HLO type inference, accounting for special properties of quantization and +// sparsity. +bool isCompatibleElementTypeForHloTypeInference(Type tp1, Type tp2); + +// Returns true if the given types are compatible for the purposes of HLO type +// inference, accounting for special properties of dynamism, quantization and +// sparsity. +bool isCompatibleForHloTypeInference(Type tp1, Type tp2); + +// Returns true if the given type ranges are compatible for the purposes of HLO +// type inference, accounting for special properties of dynamism, quantization +// and sparsity. +bool isCompatibleForHloTypeInference(TypeRange tp1, TypeRange tp2); + +// Returns true if the given shape, expressed as a runtime value, is compatible +// with the given type for the purposes of HLO type inference. +// If we know that this runtime value is a constant, then we perform the check. +// If we don't, then we return true - because shape mismatches at runtime are +// undefined behavior. +bool isCompatibleForHloTypeInference(Value shape1, Type tp2); + +// Returns true if the given shape, expressed as a slice of integers, is +// compatible with the given type for the purposes of HLO type inference. +bool isCompatibleForHloTypeInference(ArrayRef shape1, Type tp2); + +// Returns true if the given element-type is a mlir::quant::QuantizedType +// and follow the constraints corresponding to quantization parameters as +// mentioned in the StableHLO specification. +bool isValidStablehloQuantizedElementType(Type elementType); + +// Returns true if the given type is a ranked per-axis tensor type +// and follow the constraints corresponding to quantized dimension as +// mentioned in the StableHLO specification. +bool isValidQuantizedDimension(Type type); + +// Returns true if the given type has a single bounded dimension. +bool hasSingleBoundedDimension(Type type); + +// TODO(zhouxin) Move type inference related methods to TypeInference.cpp + +std::pair inferConcatenatedDimAndBound(int64_t leftSize, + int64_t rightSize, + int64_t leftBound, + int64_t rightBound); + +FailureOr> inferMostSpecificDimAndBound( + std::optional location, int64_t dim, int64_t leftSize, + int64_t rightSize, int64_t leftBound, int64_t rightBound); + +FailureOr> inferLeastSpecificDimAndBound( + std::optional location, int64_t dim, int64_t leftSize, + int64_t rightSize, int64_t leftBound, int64_t rightBound); + +// Infer single least specific return type from inputTypes with support for +// bounds. (Size, bound) of each dimension of the return type will be merged +// from corresponding dimensions of every inputType by extracting the least +// specific one. Return unranked tensor if any input is unranked. +FailureOr inferLeastSpecificType(std::optional location, + TypeRange inputTypes); + +// Infer single most specific return type from inputTypes with support for +// bounds. (Size, bound) of each dimension of the return type will be merged +// from corresponding dimensions of every inputType by extracting the most +// specific one. Return unranked tensor if all inputs are unranked. +FailureOr inferMostSpecificType(std::optional location, + TypeRange inputTypes); + +LogicalResult inferMostSpecificTypeComponents( + std::optional location, TypeRange inputTypes, + SmallVectorImpl &inferredReturnShapes); + +// Matches a constant with integer value into int64_t. +LogicalResult matchInt(Value value, int64_t &result); + +// Matches a constant tensor with integer values into a 1-dimensional vector. +// Doesn't preserve the bitness or the signedness of the underlying values, +// extracting them into int64_t. +LogicalResult matchInts(Value value, SmallVector &result); + +// Matches a constant tensor with integer values into a 1-dimensional vector. +// Preserves the bitness and the signedness of the underlying values. +LogicalResult matchInts(Value value, SmallVector &result); + +// Matches a constant tensor with integer values. +// Unlike the functions above, it doesn't return these values - it just checks +// that the given argument is indeed a constant tensor with integer values. +LogicalResult matchInts(Value value); + +// Shape derivation function that computes the shape of the result based on an +// operand. For a 2-dimensional input tensor, this produces IR of the form +// +// %0 = dim %arg0, 0 : memref +// %1 = index_cast %0 : index to i64 +// %2 = dim %arg0, 1 : memref +// %3 = index_cast %2 : index to i64 +// %4 = "shape.shape_of"(%1, %3) +// : (i64, i64) -> tensor<2xi64> +// +// and returns %4 as the shape value. +LogicalResult deriveShapeFromOperand( + OpBuilder *builder, Operation *op, Value operand, + SmallVectorImpl *reifiedReturnShapes); + +// Type derivation function that returns a tensor type with a new element type. +ShapedType getSameShapeTensorType(ShapedType shapedType, Type elementType); + +// Takes a tensor type that may have complex elements and returns a type that +// maintains the shape, but with real numeric data types. +// Ex: tensor<4xcomplex> --> tensor<4xf32> +ShapedType createRealType(ShapedType type); + +// Verify bounds expressed by HLO_BoundedAttrInterface against the provided +// type. See documentation for HLO_BoundedAttrInterface for the list of checks. +LogicalResult verifyBounds(ArrayRef bounds, RankedTensorType type, + function_ref emitError); + +// If an encoding attribute conforms to HLO_BoundedAttrInterface, return the +// bounds that it carries. Otherwise, return an empty ArrayRef. +ArrayRef encodingToBounds(Attribute encoding); + +// Create an HLO_BoundedAttrInterface encoding attribute that carries the given +// bounds. Requires a prototype - an existing encoding attribute - to obtain +// the underlying dialect that knows how to create these attributes. +Attribute boundsToEncoding(Attribute prototype, ArrayRef bounds); + +// Get refinements for return types from an indices_of_shape_operands attribute, +// with tuples types flattened (see `flattenTupleTypes` below). +// If the attribute doesn't exist, returns failure. +// If the attribute exists but is not invalid with respect to the operation, +// reports an optional error and returns failure. +// If the attribute is valid but not all shape operands are constants, +// returns failure. +LogicalResult getShapeRefinements( + std::optional location, Operation *operation, + SmallVector &refinements); + +// For each type in `types`, recursively flatten tuple types into `result`. +// Result is populated via in-order traversal of tuple types in `types`, i.e.: +// * Flattenings of individual types from `types` follow one another in the +// same order as `types`. +// * Same for flattenings of element types of tuple types. +void flattenTupleTypes(TypeRange types, SmallVector &result); + +// Does the inverse of `flattenTupleTypes` - takes `types` and recursively +// unflattens it, creating tuple types as needed to exactly match the structure +// of `prototype`. +// Fails if the number of elements in flattened prototype is different from +// the number of elements in types. +LogicalResult unflattenTupleTypes(TypeRange prototype, TypeRange types, + SmallVector &result); + +ShapedType createShapedType(ShapedTypeComponents components); + +// This interface is implemented by both StableHLO and MHLO dialects +// and is used as the foundation for sharing verification, type inference and +// prettyprinting logic between them. +class HloDialectInterface : public DialectInterface::Base { + public: + HloDialectInterface(Dialect *dialect) : Base(dialect) {} + + // Creates a TokenType type, specific to this dialect. + // See docs for the particular type in the corresponding dialect. + virtual Type createTokenType() const = 0; + + // Check whether the type is of TokenType in the corresponding dialect. + virtual bool isTokenType(Type type) const = 0; + + // Creates a TypeExtensions attribute, specific to this dialect. + // See docs for the particular attribute in the corresponding dialect. + virtual Attribute createTypeExtensions(ArrayRef bounds) const = 0; +}; + +namespace detail { + +// An enum which tracks known supported dot algorithm pairs. +// Note this implementation is a detail for now and the APIs are likely to +// change once HLO broadens support for LHS/RHS components and num primitive +// operations. +// +// It is best to not rely on these values until the API solidifies. +// Instead use `isKnownDotAlgorithm`. +enum class KnownDotAlgorithm { + ANY_F8_ANY_F8_F32 = 1, + ANY_F8_ANY_F8_F32_FAST_ACCUM = 2, + F16_F16_F16 = 3, + F16_F16_F32 = 4, + BF16_BF16_BF16 = 5, + BF16_BF16_F32 = 6, + BF16_BF16_F32_X3 = 7, + BF16_BF16_F32_X6 = 8, + TF32_TF32_F32 = 9, + TF32_TF32_F32_X3 = 10, + F32_F32_F32 = 11, + F64_F64_F64 = 12, + BF16_BF16_F32_X9 = 13, +}; + +FailureOr getKnownDotAlgorithm( + Type lhsPrecisionType, Type rhsPrecisionType, Type accumulationType, + int64_t lhsComponentCount, int64_t rhsComponentCount, + int64_t numPrimitiveOperations, bool allowImpreciseAccumulation); +} // namespace detail + +// Check if the combination of a dot algorithm struct is known. +bool isKnownDotAlgorithm(Type lhsPrecisionType, Type rhsPrecisionType, + Type accumulationType, int64_t lhsComponentCount, + int64_t rhsComponentCount, + int64_t numPrimitiveOperations, + bool allowImpreciseAccumulation); + +namespace bytecode { +// Helper methods for bytecode +// Enum reader and writer. Many attrs have a single enum type to serialize. +// Use the attributes underlying type to get the numeric value. +// Note this may cause issues if enums use an int64_t and have a large value. +// All enums in StableHLO and CHLO currently use uint32_t. +template +EnumTypeAttr readEnumAttribute(DialectBytecodeReader &reader, + MLIRContext *context, SymbolizeFn symbolizeFn) { + uint64_t code; + if (failed(reader.readVarInt(code))) return EnumTypeAttr(); + + auto enumOpt = symbolizeFn(static_cast(code)); + if (!enumOpt.has_value()) return EnumTypeAttr(); + + return EnumTypeAttr::get(context, enumOpt.value()); +} + +template +void writeEnumAttribute(EnumTypeAttr val, DialectBytecodeWriter &writer) { + static_assert( + std::is_same::type, + uint32_t>::value, + "writeEnumAttribute is only implemented for uint32_t enum values"); + + uint32_t enumVal = static_cast::type>( + val.getValue()); + writer.writeVarInt(enumVal); +} +} // namespace bytecode + +// Determines the speculatability for a shaped operation `op` with `shapeCount` +// shape operands. The last `count` operands are assumed to be shape operands. +// To be speculatable, such an op must have only static inputs and constant +// shape operands. +mlir::Speculation::Speculatability getShapedSpeculatability(Operation *op, + int64_t shapeCount); + +namespace OpTrait { + +template +class BroadcastingElementwise + : public mlir::OpTrait::TraitBase {}; + +template +class IsCommutative + : public mlir::OpTrait::TraitBase {}; + +template +class PairwiseSameOperandAndResultType + : public mlir::OpTrait::TraitBase { + public: + static LogicalResult verifyTrait(Operation *op) { + const int numOperands = op->getNumOperands(); + const int numResults = op->getNumResults(); + if (numOperands != numResults) { + return op->emitOpError() + << "requires the same number of operands and results"; + } + + for (int idx : llvm::seq(0, numOperands)) { + if (op->getOperand(idx).getType() != op->getResult(idx).getType()) { + return op->emitOpError() + << "requires the same type for operand and result at index " + << idx; + } + } + return success(); + } +}; + +template +class PairwiseSameOperandAndResultElementType + : public mlir::OpTrait::TraitBase { + public: + static LogicalResult verifyTrait(Operation *op) { + const int numOperands = op->getNumOperands(); + const int numResults = op->getNumResults(); + if (numOperands != numResults) { + return op->emitOpError() + << "requires the same number of operands and results"; + } + + for (int idx : llvm::seq(0, numOperands)) { + if (getElementTypeOrSelf(op->getOperand(idx)) != + getElementTypeOrSelf(op->getResult(idx))) { + return op->emitOpError() << "requires the same element type for " + "operand and result at index " + << idx; + } + } + return success(); + } +}; + +template +class CompatibleOperandsAndResultElementType + : public mlir::OpTrait::TraitBase { + public: + static LogicalResult verifyTrait(Operation *op) { + Type expected; + if (op->getNumResults() != 0) expected = op->getResult(0).getType(); + if (op->getNumOperands() != 0) expected = op->getOperand(0).getType(); + if (!expected) return failure(); + + auto typeMatch = [&](Type actual) { + return isCompatibleElementTypeForHloTypeInference(actual, expected); + }; + auto allMatch = llvm::all_of(op->getOperandTypes(), typeMatch) && + llvm::all_of(op->getResultTypes(), typeMatch); + if (!allMatch) { + return op->emitOpError( + "requires compatible element types for all operands and results"); + } + + return success(allMatch); + } +}; + +template +class CompatibleOperandsElementType + : public mlir::OpTrait::TraitBase { + public: + static LogicalResult verifyTrait(Operation *op) { + if (failed(mlir::OpTrait::impl::verifyAtLeastNOperands(op, 1))) + return failure(); + + Type expected = op->getOperand(0).getType(); + auto typeMatch = [&](Type actual) { + return isCompatibleElementTypeForHloTypeInference(actual, expected); + }; + auto allMatch = llvm::all_of(op->getOperandTypes(), typeMatch); + if (!allMatch) { + return op->emitOpError( + "requires compatible element types for all operands"); + } + + return success(); + } +}; + +template +class CompatibleOperandsAndResultType + : public mlir::OpTrait::TraitBase { + public: + static LogicalResult verifyTrait(Operation *op) { + Type expected; + if (op->getNumResults() != 0) expected = op->getResult(0).getType(); + if (op->getNumOperands() != 0) expected = op->getOperand(0).getType(); + if (!expected) return failure(); + + auto typeMatch = [&](Type actual) { + return isCompatibleForHloTypeInference(actual, expected); + }; + auto allMatch = llvm::all_of(op->getOperandTypes(), typeMatch) && + llvm::all_of(op->getResultTypes(), typeMatch); + if (!allMatch) { + return op->emitOpError( + "requires compatible types for all operands and results"); + } + + return success(allMatch); + } + + static LogicalResult inferReturnTypes( + MLIRContext * /*context*/, std::optional location, + ValueRange operands, DictionaryAttr /*attributes*/, + OpaqueProperties /*properties*/, RegionRange /*regions*/, + SmallVectorImpl &inferredReturnTypes) { + // TODO(b/231358795): Review the use of InferTypeOpInterface for ops that + // support quantization or sparsity. + if (operands.empty()) + return emitOptionalError( + location, + "Expected non-empty operands for [CompatibleOperandsAndResultType]"); + + auto inferredTypeOrErr = + inferMostSpecificType(location, operands.getTypes()); + if (failed(inferredTypeOrErr)) return failure(); + inferredReturnTypes.emplace_back(*inferredTypeOrErr); + return success(); + } + + // This function is not going to be called automatically. + // It needs to be paired with INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS + // (see examples in StablehloOps.cpp). + static LogicalResult inferReturnTypeComponentsFromOperands( + MLIRContext *context, std::optional location, + ValueShapeRange operands, DictionaryAttr attributes, + OpaqueProperties properties, RegionRange regions, + SmallVectorImpl &inferredReturnShapes) { + SmallVector inferredReturnTypes; + if (failed(inferReturnTypes(context, location, operands.getValues(), + attributes, properties, regions, + inferredReturnTypes))) + return failure(); + if (inferredReturnTypes.size() != 1) return failure(); + auto inferredReturnType = dyn_cast(inferredReturnTypes[0]); + if (!inferredReturnType) return failure(); + inferredReturnShapes.push_back(inferredReturnType); + return success(); + } +}; + +template +struct SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait + : public mlir::OpTrait::TraitBase< + ConcreteType, + SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait> { + // A unary elementwise op is not speculatable if a dimension of the result + // type is static while the corresponding dimension in the input type is + // dynamic. Indeed, the input dimension could differ at runtime. + // If the output dimension is dynamic, there is no expectation, so there + // cannot be a mismatch. + // If the input dimension is static, the output dimension can be inferred from + // it, so there cannot be a mismatch. + mlir::Speculation::Speculatability getSpeculatability() { + auto op = this->getOperation(); + auto inputType = cast(op->getOperand(0).getType()); + auto resultType = cast(op->getResult(0).getType()); + for (size_t i : llvm::seq(resultType.getRank())) { + if (!resultType.isDynamicDim(i) && inputType.isDynamicDim(i)) + return mlir::Speculation::NotSpeculatable; + } + return mlir::Speculation::Speculatable; + } +}; + +template +struct RecursivelySpeculatableIfStaticDimInOutputIsStaticInInputImplTrait + : public mlir::OpTrait::TraitBase< + ConcreteType, + RecursivelySpeculatableIfStaticDimInOutputIsStaticInInputImplTrait> { + mlir::Speculation::Speculatability getSpeculatability() { + auto op = this->getOperation(); + auto inputType = cast(op->getOperand(0).getType()); + auto resultType = cast(op->getResult(0).getType()); + for (size_t i : llvm::seq(resultType.getRank())) { + if (!resultType.isDynamicDim(i) && inputType.isDynamicDim(i)) + return mlir::Speculation::NotSpeculatable; + } + return mlir::Speculation::RecursivelySpeculatable; + } +}; + +template +struct SpeculatableIfAllInputsStaticImplTrait + : public mlir::OpTrait::TraitBase { + mlir::Speculation::Speculatability getSpeculatability() { + return llvm::all_of(this->getOperation()->getOperandTypes(), + [](Type t) { + return cast(t).hasStaticShape(); + }) + ? mlir::Speculation::Speculatable + : mlir::Speculation::NotSpeculatable; + } +}; + +template +struct RecursivelySpeculatableIfAllInputsStaticImplTrait + : public mlir::OpTrait::TraitBase< + ConcreteType, RecursivelySpeculatableIfAllInputsStaticImplTrait> { + mlir::Speculation::Speculatability getSpeculatability() { + return llvm::all_of(this->getOperation()->getOperandTypes(), + [](Type t) { + return cast(t).hasStaticShape(); + }) + ? mlir::Speculation::RecursivelySpeculatable + : mlir::Speculation::NotSpeculatable; + } +}; + +template +struct SpeculatableIfAllInputsStaticAndShapeConstantImplTrait + : public mlir::OpTrait::TraitBase< + ConcreteType, + SpeculatableIfAllInputsStaticAndShapeConstantImplTrait> { + mlir::Speculation::Speculatability getSpeculatability() { + return getShapedSpeculatability(this->getOperation(), 1); + } +}; + +} // namespace OpTrait +} // namespace hlo +} // namespace mlir + +#endif // STABLEHLO_DIALECT_BASE_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/BaseAttrInterfaces.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/BaseAttrInterfaces.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..ef24a5b08b8c0f0d145fb5303c87254dbfcf07b2 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/BaseAttrInterfaces.cpp.inc @@ -0,0 +1,13 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + + +/// Get the attribute's bounds +::llvm::ArrayRef mlir::hlo::BoundedAttrInterface::getBounds() const { + return getImpl()->getBounds(getImpl(), *this); + } diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/BaseAttrInterfaces.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/BaseAttrInterfaces.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..d70c7a8b8b929d5e082093b4ad590e35e64f400f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/BaseAttrInterfaces.h.inc @@ -0,0 +1,79 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace hlo { +/// This interface is used for attributes that carry bounds for dimension sizes +/// of an accompanying shaped type, e.g. when the attribute represents a +/// RankedTensorType::getEncoding. +/// The number of bounds is expected to be the same as the number of dimensions +/// in the accompanying shaped type. +/// For a static dimension, the corresponding bound is ShapedType::kDynamic. +/// For a dynamic dimension, the corresponding bound is either known and is +/// a non-negative number or unknown and is ShapedType::kDynamic. +class BoundedAttrInterface; +namespace detail { +struct BoundedAttrInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + ::llvm::ArrayRef (*getBounds)(const Concept *impl, ::mlir::Attribute ); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::hlo::BoundedAttrInterface; + Model() : Concept{getBounds} {} + + static inline ::llvm::ArrayRef getBounds(const Concept *impl, ::mlir::Attribute tablegen_opaque_val); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::hlo::BoundedAttrInterface; + FallbackModel() : Concept{getBounds} {} + + static inline ::llvm::ArrayRef getBounds(const Concept *impl, ::mlir::Attribute tablegen_opaque_val); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteAttr; + }; +}; +template +struct BoundedAttrInterfaceTrait; + +} // namespace detail +class BoundedAttrInterface : public ::mlir::AttributeInterface { +public: + using ::mlir::AttributeInterface::AttributeInterface; + template + struct Trait : public detail::BoundedAttrInterfaceTrait {}; + + /// Get the attribute's bounds + ::llvm::ArrayRef getBounds() const; +}; +namespace detail { + template + struct BoundedAttrInterfaceTrait : public ::mlir::AttributeInterface::Trait { + }; +}// namespace detail +} // namespace hlo +} // namespace mlir +namespace mlir { +namespace hlo { +template +::llvm::ArrayRef detail::BoundedAttrInterfaceInterfaceTraits::Model::getBounds(const Concept *impl, ::mlir::Attribute tablegen_opaque_val) { + return (::llvm::cast(tablegen_opaque_val)).getBounds(); +} +template +::llvm::ArrayRef detail::BoundedAttrInterfaceInterfaceTraits::FallbackModel::getBounds(const Concept *impl, ::mlir::Attribute tablegen_opaque_val) { + return static_cast(impl)->getBounds(tablegen_opaque_val); +} +} // namespace hlo +} // namespace mlir diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/BroadcastUtils.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/BroadcastUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..5b0a49cdb23a32e62859858e533ec02eaa6cc544 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/BroadcastUtils.h @@ -0,0 +1,54 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + Copyright 2022 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_BROADCAST_UTILS_H +#define STABLEHLO_DIALECT_BROADCAST_UTILS_H + +// Utilities relating to implementing HLO broadcasting. +// Note: This file should not depend on any non-MLIR TensorFlow libraries. + +#include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinAttributes.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/Location.h" +#include "mlir/IR/Value.h" + +namespace mlir { +namespace hlo { + +// Checks whether the given operand types and broadcast_dims attr represent a +// legal combination for "numpy" style broadcasting (where 1-dims are prepended +// to the smaller ranked operand until it is of the same rank as the larger). +// See: https://docs.scipy.org/doc/numpy/reference/ufuncs.html +bool isLegalNumpyRankedBroadcast(Value lhs, Value rhs, + llvm::ArrayRef broadcastDims); + +// Emits shape dialect ops to compute the result shape for a broadcasting +// binary/n-ary elementwise op which broadcasts according to "numpy" semantics +// (see above), returning an extent tensor of the resulting shape. The function +// should only be used in contexts that ensure both operands to be +// broadcastable. +Value computeBinaryElementwiseBroadcastingResultExtents(Location loc, Value lhs, + Value rhs, + OpBuilder& builder); +Value computeNaryElementwiseBroadcastingResultExtents(Location loc, + ValueRange operands, + OpBuilder& builder); + +} // namespace hlo +} // namespace mlir + +#endif // STABLEHLO_DIALECT_BROADCAST_UTILS_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloAttrs.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloAttrs.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..303021bcf060b842c00ae54cfd464bba69d428a8 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloAttrs.cpp.inc @@ -0,0 +1,356 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_ATTRDEF_LIST +#undef GET_ATTRDEF_LIST + +::mlir::chlo::ComparisonDirectionAttr, +::mlir::chlo::ComparisonTypeAttr, +::mlir::chlo::PrecisionAttr, +::mlir::chlo::RaggedDotDimensionNumbersAttr + +#endif // GET_ATTRDEF_LIST + +#ifdef GET_ATTRDEF_CLASSES +#undef GET_ATTRDEF_CLASSES + +static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) { + return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser) + .Case(::mlir::chlo::ComparisonDirectionAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::chlo::ComparisonDirectionAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::chlo::ComparisonTypeAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::chlo::ComparisonTypeAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::chlo::PrecisionAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::chlo::PrecisionAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::chlo::RaggedDotDimensionNumbersAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::chlo::RaggedDotDimensionNumbersAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Default([&](llvm::StringRef keyword, llvm::SMLoc) { + *mnemonic = keyword; + return std::nullopt; + }); +} + +static ::llvm::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) { + return ::llvm::TypeSwitch<::mlir::Attribute, ::llvm::LogicalResult>(def) .Case<::mlir::chlo::ComparisonDirectionAttr>([&](auto t) { + printer << ::mlir::chlo::ComparisonDirectionAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::chlo::ComparisonTypeAttr>([&](auto t) { + printer << ::mlir::chlo::ComparisonTypeAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::chlo::PrecisionAttr>([&](auto t) { + printer << ::mlir::chlo::PrecisionAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::chlo::RaggedDotDimensionNumbersAttr>([&](auto t) { + printer << ::mlir::chlo::RaggedDotDimensionNumbersAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Default([](auto) { return ::mlir::failure(); }); +} + +namespace mlir { +namespace chlo { +namespace detail { +struct ComparisonDirectionAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::chlo::ComparisonDirection>; + ComparisonDirectionAttrStorage(::mlir::chlo::ComparisonDirection value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static ComparisonDirectionAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) ComparisonDirectionAttrStorage(std::move(value)); + } + + ::mlir::chlo::ComparisonDirection value; +}; +} // namespace detail +ComparisonDirectionAttr ComparisonDirectionAttr::get(::mlir::MLIRContext *context, ::mlir::chlo::ComparisonDirection value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute ComparisonDirectionAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::chlo::ComparisonDirection> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::chlo::ComparisonDirection> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::chlo::symbolizeComparisonDirection(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::chlo::ComparisonDirection" << " to be one of: " << "EQ" << ", " << "NE" << ", " << "GE" << ", " << "GT" << ", " << "LE" << ", " << "LT")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse CHLO_ComparisonDirectionAttr parameter 'value' which is to be a `::mlir::chlo::ComparisonDirection`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return ComparisonDirectionAttr::get(odsParser.getContext(), + ::mlir::chlo::ComparisonDirection((*_result_value))); +} + +void ComparisonDirectionAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyComparisonDirection(getValue()); +} + +::mlir::chlo::ComparisonDirection ComparisonDirectionAttr::getValue() const { + return getImpl()->value; +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::ComparisonDirectionAttr) +namespace mlir { +namespace chlo { +namespace detail { +struct ComparisonTypeAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::chlo::ComparisonType>; + ComparisonTypeAttrStorage(::mlir::chlo::ComparisonType value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static ComparisonTypeAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) ComparisonTypeAttrStorage(std::move(value)); + } + + ::mlir::chlo::ComparisonType value; +}; +} // namespace detail +ComparisonTypeAttr ComparisonTypeAttr::get(::mlir::MLIRContext *context, ::mlir::chlo::ComparisonType value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute ComparisonTypeAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::chlo::ComparisonType> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::chlo::ComparisonType> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::chlo::symbolizeComparisonType(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::chlo::ComparisonType" << " to be one of: " << "NOTYPE" << ", " << "FLOAT" << ", " << "TOTALORDER" << ", " << "SIGNED" << ", " << "UNSIGNED")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse CHLO_ComparisonTypeAttr parameter 'value' which is to be a `::mlir::chlo::ComparisonType`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return ComparisonTypeAttr::get(odsParser.getContext(), + ::mlir::chlo::ComparisonType((*_result_value))); +} + +void ComparisonTypeAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyComparisonType(getValue()); +} + +::mlir::chlo::ComparisonType ComparisonTypeAttr::getValue() const { + return getImpl()->value; +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::ComparisonTypeAttr) +namespace mlir { +namespace chlo { +namespace detail { +struct PrecisionAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::chlo::Precision>; + PrecisionAttrStorage(::mlir::chlo::Precision value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static PrecisionAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) PrecisionAttrStorage(std::move(value)); + } + + ::mlir::chlo::Precision value; +}; +} // namespace detail +PrecisionAttr PrecisionAttr::get(::mlir::MLIRContext *context, ::mlir::chlo::Precision value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute PrecisionAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::chlo::Precision> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::chlo::Precision> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::chlo::symbolizePrecision(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::chlo::Precision" << " to be one of: " << "DEFAULT" << ", " << "HIGH" << ", " << "HIGHEST")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse CHLO_PrecisionAttr parameter 'value' which is to be a `::mlir::chlo::Precision`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return PrecisionAttr::get(odsParser.getContext(), + ::mlir::chlo::Precision((*_result_value))); +} + +void PrecisionAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyPrecision(getValue()); +} + +::mlir::chlo::Precision PrecisionAttr::getValue() const { + return getImpl()->value; +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::PrecisionAttr) +namespace mlir { +namespace chlo { +namespace detail { +struct RaggedDotDimensionNumbersAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef, ::llvm::ArrayRef, ::llvm::ArrayRef, ::llvm::ArrayRef, ::llvm::ArrayRef, ::llvm::ArrayRef>; + RaggedDotDimensionNumbersAttrStorage(::llvm::ArrayRef lhsBatchingDimensions, ::llvm::ArrayRef rhsBatchingDimensions, ::llvm::ArrayRef lhsContractingDimensions, ::llvm::ArrayRef rhsContractingDimensions, ::llvm::ArrayRef lhsRaggedDimensions, ::llvm::ArrayRef rhsGroupDimensions) : lhsBatchingDimensions(std::move(lhsBatchingDimensions)), rhsBatchingDimensions(std::move(rhsBatchingDimensions)), lhsContractingDimensions(std::move(lhsContractingDimensions)), rhsContractingDimensions(std::move(rhsContractingDimensions)), lhsRaggedDimensions(std::move(lhsRaggedDimensions)), rhsGroupDimensions(std::move(rhsGroupDimensions)) {} + + KeyTy getAsKey() const { + return KeyTy(lhsBatchingDimensions, rhsBatchingDimensions, lhsContractingDimensions, rhsContractingDimensions, lhsRaggedDimensions, rhsGroupDimensions); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (lhsBatchingDimensions == std::get<0>(tblgenKey)) && (rhsBatchingDimensions == std::get<1>(tblgenKey)) && (lhsContractingDimensions == std::get<2>(tblgenKey)) && (rhsContractingDimensions == std::get<3>(tblgenKey)) && (lhsRaggedDimensions == std::get<4>(tblgenKey)) && (rhsGroupDimensions == std::get<5>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey), std::get<4>(tblgenKey), std::get<5>(tblgenKey)); + } + + static RaggedDotDimensionNumbersAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto lhsBatchingDimensions = std::move(std::get<0>(tblgenKey)); + auto rhsBatchingDimensions = std::move(std::get<1>(tblgenKey)); + auto lhsContractingDimensions = std::move(std::get<2>(tblgenKey)); + auto rhsContractingDimensions = std::move(std::get<3>(tblgenKey)); + auto lhsRaggedDimensions = std::move(std::get<4>(tblgenKey)); + auto rhsGroupDimensions = std::move(std::get<5>(tblgenKey)); + lhsBatchingDimensions = allocator.copyInto(lhsBatchingDimensions); + rhsBatchingDimensions = allocator.copyInto(rhsBatchingDimensions); + lhsContractingDimensions = allocator.copyInto(lhsContractingDimensions); + rhsContractingDimensions = allocator.copyInto(rhsContractingDimensions); + lhsRaggedDimensions = allocator.copyInto(lhsRaggedDimensions); + rhsGroupDimensions = allocator.copyInto(rhsGroupDimensions); + return new (allocator.allocate()) RaggedDotDimensionNumbersAttrStorage(std::move(lhsBatchingDimensions), std::move(rhsBatchingDimensions), std::move(lhsContractingDimensions), std::move(rhsContractingDimensions), std::move(lhsRaggedDimensions), std::move(rhsGroupDimensions)); + } + + ::llvm::ArrayRef lhsBatchingDimensions; + ::llvm::ArrayRef rhsBatchingDimensions; + ::llvm::ArrayRef lhsContractingDimensions; + ::llvm::ArrayRef rhsContractingDimensions; + ::llvm::ArrayRef lhsRaggedDimensions; + ::llvm::ArrayRef rhsGroupDimensions; +}; +} // namespace detail +RaggedDotDimensionNumbersAttr RaggedDotDimensionNumbersAttr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef lhsBatchingDimensions, ::llvm::ArrayRef rhsBatchingDimensions, ::llvm::ArrayRef lhsContractingDimensions, ::llvm::ArrayRef rhsContractingDimensions, ::llvm::ArrayRef lhsRaggedDimensions, ::llvm::ArrayRef rhsGroupDimensions) { + return Base::get(context, std::move(lhsBatchingDimensions), std::move(rhsBatchingDimensions), std::move(lhsContractingDimensions), std::move(rhsContractingDimensions), std::move(lhsRaggedDimensions), std::move(rhsGroupDimensions)); +} + +::llvm::ArrayRef RaggedDotDimensionNumbersAttr::getLhsBatchingDimensions() const { + return getImpl()->lhsBatchingDimensions; +} + +::llvm::ArrayRef RaggedDotDimensionNumbersAttr::getRhsBatchingDimensions() const { + return getImpl()->rhsBatchingDimensions; +} + +::llvm::ArrayRef RaggedDotDimensionNumbersAttr::getLhsContractingDimensions() const { + return getImpl()->lhsContractingDimensions; +} + +::llvm::ArrayRef RaggedDotDimensionNumbersAttr::getRhsContractingDimensions() const { + return getImpl()->rhsContractingDimensions; +} + +::llvm::ArrayRef RaggedDotDimensionNumbersAttr::getLhsRaggedDimensions() const { + return getImpl()->lhsRaggedDimensions; +} + +::llvm::ArrayRef RaggedDotDimensionNumbersAttr::getRhsGroupDimensions() const { + return getImpl()->rhsGroupDimensions; +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::RaggedDotDimensionNumbersAttr) + +#endif // GET_ATTRDEF_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloAttrs.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloAttrs.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..5fe02228faf14628528429f47f4720208f8d1f88 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloAttrs.h.inc @@ -0,0 +1,108 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_ATTRDEF_CLASSES +#undef GET_ATTRDEF_CLASSES + + +namespace mlir { +class AsmParser; +class AsmPrinter; +} // namespace mlir +namespace mlir { +namespace chlo { +/// Which comparison operation to perform. +class ComparisonDirectionAttr; +/// Which comparison type to use. +class ComparisonTypeAttr; +/// XLA precision for an operand. Has backend specific meaning. +class PrecisionAttr; +/// Attribute that models the dimension information for ragged dot. +class RaggedDotDimensionNumbersAttr; +namespace detail { +struct ComparisonDirectionAttrStorage; +} // namespace detail +class ComparisonDirectionAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "chlo.comparison_direction"; + static constexpr ::llvm::StringLiteral dialectName = "chlo"; + static ComparisonDirectionAttr get(::mlir::MLIRContext *context, ::mlir::chlo::ComparisonDirection value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"comparison_direction"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::chlo::ComparisonDirection getValue() const; +}; +namespace detail { +struct ComparisonTypeAttrStorage; +} // namespace detail +class ComparisonTypeAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "chlo.comparison_type"; + static constexpr ::llvm::StringLiteral dialectName = "chlo"; + static ComparisonTypeAttr get(::mlir::MLIRContext *context, ::mlir::chlo::ComparisonType value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"comparison_type"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::chlo::ComparisonType getValue() const; +}; +namespace detail { +struct PrecisionAttrStorage; +} // namespace detail +class PrecisionAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "chlo.precision"; + static constexpr ::llvm::StringLiteral dialectName = "chlo"; + static PrecisionAttr get(::mlir::MLIRContext *context, ::mlir::chlo::Precision value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"precision"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::chlo::Precision getValue() const; +}; +namespace detail { +struct RaggedDotDimensionNumbersAttrStorage; +} // namespace detail +class RaggedDotDimensionNumbersAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "chlo.ragged_dot"; + static constexpr ::llvm::StringLiteral dialectName = "chlo"; + static RaggedDotDimensionNumbersAttr get(::mlir::MLIRContext *context, ::llvm::ArrayRef lhsBatchingDimensions, ::llvm::ArrayRef rhsBatchingDimensions, ::llvm::ArrayRef lhsContractingDimensions, ::llvm::ArrayRef rhsContractingDimensions, ::llvm::ArrayRef lhsRaggedDimensions, ::llvm::ArrayRef rhsGroupDimensions); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"ragged_dot"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef getLhsBatchingDimensions() const; + ::llvm::ArrayRef getRhsBatchingDimensions() const; + ::llvm::ArrayRef getLhsContractingDimensions() const; + ::llvm::ArrayRef getRhsContractingDimensions() const; + ::llvm::ArrayRef getLhsRaggedDimensions() const; + ::llvm::ArrayRef getRhsGroupDimensions() const; +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::ComparisonDirectionAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::ComparisonTypeAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::PrecisionAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::RaggedDotDimensionNumbersAttr) + +#endif // GET_ATTRDEF_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloBytecode.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloBytecode.h new file mode 100644 index 0000000000000000000000000000000000000000..3267b6bee752cb4c6a5cf558387ed4517ca1379b --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloBytecode.h @@ -0,0 +1,28 @@ +/* Copyright 2022 The StableHLO Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_CHLO_BYTECODE_H +#define STABLEHLO_DIALECT_CHLO_BYTECODE_H + +namespace mlir { +namespace chlo { +class ChloDialect; + +// Add the interface necessary for encoding and decoding the CHLO dialect +// components in bytecode. +void addBytecodeInterface(ChloDialect *dialect); +} // namespace chlo +} // namespace mlir + +#endif // CHLO_DIALECT_CHLO_BYTECODE_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloEnums.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloEnums.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..9058789ed262e2daca5715dbc53d5fcc004b2e8c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloEnums.cpp.inc @@ -0,0 +1,114 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: ChloOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace chlo { +::llvm::StringRef stringifyComparisonDirection(ComparisonDirection val) { + switch (val) { + case ComparisonDirection::EQ: return "EQ"; + case ComparisonDirection::NE: return "NE"; + case ComparisonDirection::GE: return "GE"; + case ComparisonDirection::GT: return "GT"; + case ComparisonDirection::LE: return "LE"; + case ComparisonDirection::LT: return "LT"; + } + return ""; +} + +::std::optional symbolizeComparisonDirection(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("EQ", ComparisonDirection::EQ) + .Case("NE", ComparisonDirection::NE) + .Case("GE", ComparisonDirection::GE) + .Case("GT", ComparisonDirection::GT) + .Case("LE", ComparisonDirection::LE) + .Case("LT", ComparisonDirection::LT) + .Default(::std::nullopt); +} +::std::optional symbolizeComparisonDirection(uint32_t value) { + switch (value) { + case 0: return ComparisonDirection::EQ; + case 1: return ComparisonDirection::NE; + case 2: return ComparisonDirection::GE; + case 3: return ComparisonDirection::GT; + case 4: return ComparisonDirection::LE; + case 5: return ComparisonDirection::LT; + default: return ::std::nullopt; + } +} + +} // namespace chlo +} // namespace mlir + +namespace mlir { +namespace chlo { +::llvm::StringRef stringifyComparisonType(ComparisonType val) { + switch (val) { + case ComparisonType::NOTYPE: return "NOTYPE"; + case ComparisonType::FLOAT: return "FLOAT"; + case ComparisonType::TOTALORDER: return "TOTALORDER"; + case ComparisonType::SIGNED: return "SIGNED"; + case ComparisonType::UNSIGNED: return "UNSIGNED"; + } + return ""; +} + +::std::optional symbolizeComparisonType(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("NOTYPE", ComparisonType::NOTYPE) + .Case("FLOAT", ComparisonType::FLOAT) + .Case("TOTALORDER", ComparisonType::TOTALORDER) + .Case("SIGNED", ComparisonType::SIGNED) + .Case("UNSIGNED", ComparisonType::UNSIGNED) + .Default(::std::nullopt); +} +::std::optional symbolizeComparisonType(uint32_t value) { + switch (value) { + case 0: return ComparisonType::NOTYPE; + case 1: return ComparisonType::FLOAT; + case 2: return ComparisonType::TOTALORDER; + case 3: return ComparisonType::SIGNED; + case 4: return ComparisonType::UNSIGNED; + default: return ::std::nullopt; + } +} + +} // namespace chlo +} // namespace mlir + +namespace mlir { +namespace chlo { +::llvm::StringRef stringifyPrecision(Precision val) { + switch (val) { + case Precision::DEFAULT: return "DEFAULT"; + case Precision::HIGH: return "HIGH"; + case Precision::HIGHEST: return "HIGHEST"; + } + return ""; +} + +::std::optional symbolizePrecision(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("DEFAULT", Precision::DEFAULT) + .Case("HIGH", Precision::HIGH) + .Case("HIGHEST", Precision::HIGHEST) + .Default(::std::nullopt); +} +::std::optional symbolizePrecision(uint32_t value) { + switch (value) { + case 0: return Precision::DEFAULT; + case 1: return Precision::HIGH; + case 2: return Precision::HIGHEST; + default: return ::std::nullopt; + } +} + +} // namespace chlo +} // namespace mlir + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloEnums.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloEnums.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..4df8fcff81a1b362dd21aa3280d48eda71db204f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloEnums.h.inc @@ -0,0 +1,323 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: ChloOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace chlo { +// Which comparison operation to perform. +enum class ComparisonDirection : uint32_t { + EQ = 0, + NE = 1, + GE = 2, + GT = 3, + LE = 4, + LT = 5, +}; + +::std::optional symbolizeComparisonDirection(uint32_t); +::llvm::StringRef stringifyComparisonDirection(ComparisonDirection); +::std::optional symbolizeComparisonDirection(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForComparisonDirection() { + return 5; +} + + +inline ::llvm::StringRef stringifyEnum(ComparisonDirection enumValue) { + return stringifyComparisonDirection(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeComparisonDirection(str); +} +} // namespace chlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::chlo::ComparisonDirection, ::mlir::chlo::ComparisonDirection> { + template + static FailureOr<::mlir::chlo::ComparisonDirection> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for Which comparison operation to perform."); + + // Symbolize the keyword. + if (::std::optional<::mlir::chlo::ComparisonDirection> attr = ::mlir::chlo::symbolizeEnum<::mlir::chlo::ComparisonDirection>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [EQ, NE, GE, GT, LE, LT] for Which comparison operation to perform., got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::chlo::ComparisonDirection>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::chlo::ComparisonDirection>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::chlo::ComparisonDirection> attr = ::mlir::chlo::symbolizeEnum<::mlir::chlo::ComparisonDirection>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [EQ, NE, GE, GT, LE, LT] for Which comparison operation to perform., got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::chlo::ComparisonDirection value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::chlo::ComparisonDirection> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::chlo::ComparisonDirection getEmptyKey() { + return static_cast<::mlir::chlo::ComparisonDirection>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::chlo::ComparisonDirection getTombstoneKey() { + return static_cast<::mlir::chlo::ComparisonDirection>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::chlo::ComparisonDirection &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::chlo::ComparisonDirection &lhs, const ::mlir::chlo::ComparisonDirection &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace chlo { +// Which comparison type to use. +enum class ComparisonType : uint32_t { + NOTYPE = 0, + FLOAT = 1, + TOTALORDER = 2, + SIGNED = 3, + UNSIGNED = 4, +}; + +::std::optional symbolizeComparisonType(uint32_t); +::llvm::StringRef stringifyComparisonType(ComparisonType); +::std::optional symbolizeComparisonType(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForComparisonType() { + return 4; +} + + +inline ::llvm::StringRef stringifyEnum(ComparisonType enumValue) { + return stringifyComparisonType(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeComparisonType(str); +} +} // namespace chlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::chlo::ComparisonType, ::mlir::chlo::ComparisonType> { + template + static FailureOr<::mlir::chlo::ComparisonType> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for Which comparison type to use."); + + // Symbolize the keyword. + if (::std::optional<::mlir::chlo::ComparisonType> attr = ::mlir::chlo::symbolizeEnum<::mlir::chlo::ComparisonType>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [NOTYPE, FLOAT, TOTALORDER, SIGNED, UNSIGNED] for Which comparison type to use., got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::chlo::ComparisonType>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::chlo::ComparisonType>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::chlo::ComparisonType> attr = ::mlir::chlo::symbolizeEnum<::mlir::chlo::ComparisonType>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [NOTYPE, FLOAT, TOTALORDER, SIGNED, UNSIGNED] for Which comparison type to use., got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::chlo::ComparisonType value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::chlo::ComparisonType> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::chlo::ComparisonType getEmptyKey() { + return static_cast<::mlir::chlo::ComparisonType>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::chlo::ComparisonType getTombstoneKey() { + return static_cast<::mlir::chlo::ComparisonType>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::chlo::ComparisonType &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::chlo::ComparisonType &lhs, const ::mlir::chlo::ComparisonType &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace chlo { +// XLA precision for an operand. Has backend specific meaning. +enum class Precision : uint32_t { + DEFAULT = 0, + HIGH = 1, + HIGHEST = 2, +}; + +::std::optional symbolizePrecision(uint32_t); +::llvm::StringRef stringifyPrecision(Precision); +::std::optional symbolizePrecision(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForPrecision() { + return 2; +} + + +inline ::llvm::StringRef stringifyEnum(Precision enumValue) { + return stringifyPrecision(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizePrecision(str); +} +} // namespace chlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::chlo::Precision, ::mlir::chlo::Precision> { + template + static FailureOr<::mlir::chlo::Precision> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for XLA precision for an operand. Has backend specific meaning."); + + // Symbolize the keyword. + if (::std::optional<::mlir::chlo::Precision> attr = ::mlir::chlo::symbolizeEnum<::mlir::chlo::Precision>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [DEFAULT, HIGH, HIGHEST] for XLA precision for an operand. Has backend specific meaning., got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::chlo::Precision>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::chlo::Precision>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::chlo::Precision> attr = ::mlir::chlo::symbolizeEnum<::mlir::chlo::Precision>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [DEFAULT, HIGH, HIGHEST] for XLA precision for an operand. Has backend specific meaning., got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::chlo::Precision value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::chlo::Precision> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::chlo::Precision getEmptyKey() { + return static_cast<::mlir::chlo::Precision>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::chlo::Precision getTombstoneKey() { + return static_cast<::mlir::chlo::Precision>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::chlo::Precision &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::chlo::Precision &lhs, const ::mlir::chlo::Precision &rhs) { + return lhs == rhs; + } +}; +} + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloOps.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloOps.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..410e9543b62f4e2570bdf598f0237b64ccf12d15 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloOps.cpp.inc @@ -0,0 +1,15661 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: ChloOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_OP_LIST +#undef GET_OP_LIST + +::mlir::chlo::AcosOp, +::mlir::chlo::AcoshOp, +::mlir::chlo::AsinAcosKernelOp, +::mlir::chlo::AsinOp, +::mlir::chlo::AsinhOp, +::mlir::chlo::AtanOp, +::mlir::chlo::AtanhOp, +::mlir::chlo::BesselI1eOp, +::mlir::chlo::BroadcastAddOp, +::mlir::chlo::BroadcastAndOp, +::mlir::chlo::BroadcastAtan2Op, +::mlir::chlo::BroadcastCompareOp, +::mlir::chlo::BroadcastComplexOp, +::mlir::chlo::BroadcastDivOp, +::mlir::chlo::BroadcastMaxOp, +::mlir::chlo::BroadcastMinOp, +::mlir::chlo::BroadcastMulOp, +::mlir::chlo::BroadcastNextAfterOp, +::mlir::chlo::BroadcastOrOp, +::mlir::chlo::BroadcastPolygammaOp, +::mlir::chlo::BroadcastPowOp, +::mlir::chlo::BroadcastRemOp, +::mlir::chlo::BroadcastSelectOp, +::mlir::chlo::BroadcastShiftLeftOp, +::mlir::chlo::BroadcastShiftRightArithmeticOp, +::mlir::chlo::BroadcastShiftRightLogicalOp, +::mlir::chlo::BroadcastSubOp, +::mlir::chlo::BroadcastXorOp, +::mlir::chlo::BroadcastZetaOp, +::mlir::chlo::ConjOp, +::mlir::chlo::ConstantLikeOp, +::mlir::chlo::ConstantOp, +::mlir::chlo::CoshOp, +::mlir::chlo::DigammaOp, +::mlir::chlo::ErfInvOp, +::mlir::chlo::ErfOp, +::mlir::chlo::ErfcOp, +::mlir::chlo::IsInfOp, +::mlir::chlo::IsNegInfOp, +::mlir::chlo::IsPosInfOp, +::mlir::chlo::LgammaOp, +::mlir::chlo::NextAfterOp, +::mlir::chlo::PolygammaOp, +::mlir::chlo::RaggedDotOp, +::mlir::chlo::SinhOp, +::mlir::chlo::SquareOp, +::mlir::chlo::TanOp, +::mlir::chlo::TopKOp, +::mlir::chlo::ZetaOp +#endif // GET_OP_LIST + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace chlo { + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ChloOps1( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::TensorType>(type))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ChloOps2( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::TensorType>(type))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64()))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be tensor of complex type with 32/64-bit float elements values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ChloOps3( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::TensorType>(type))) && ((mlir::hlo::isValidQuantizedDimension(type)))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ChloOps4( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::TensorType>(type))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be tensor of bool or 2/4/8/16/32/64-bit integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ChloOps5( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::TensorType>(type))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be tensor of bool values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ChloOps6( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::TensorType>(type))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be tensor of 4/6/8/16/32/64-bit float values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ChloOps7( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of bool values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ChloOps8( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape()))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be statically shaped tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ChloOps9( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64)))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 2/4/8/16/32/64-bit integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps1( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: i64 dense array attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps1( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ChloOps1(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps2( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::chlo::ComparisonDirectionAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Which comparison operation to perform."; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps2( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ChloOps2(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps3( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::chlo::ComparisonTypeAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Which comparison type to use."; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps3( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ChloOps3(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps4( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::TypedAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: TypedAttr instance"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps4( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ChloOps4(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps5( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::ElementsAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: constant vector/tensor attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps5( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ChloOps5(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps6( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::chlo::RaggedDotDimensionNumbersAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Attribute that models the dimension information for ragged dot."; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps6( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ChloOps6(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps7( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::chlo::PrecisionAttr>(attr))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Precision Config attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps7( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ChloOps7(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps8( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64))))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 64-bit signless integer attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ChloOps8( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ChloOps8(attr, attrName, [op]() { + return op->emitOpError(); + }); +} +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AcosOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AcosOpGenericAdaptorBase::AcosOpGenericAdaptorBase(AcosOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +AcosOpAdaptor::AcosOpAdaptor(AcosOp op) : AcosOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AcosOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult AcosOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AcosOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AcosOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AcosOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AcosOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AcosOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AcosOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AcosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void AcosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AcosOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AcosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AcosOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AcosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AcosOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void AcosOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AcosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AcosOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult AcosOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AcosOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult AcosOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AcosOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void AcosOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::AcosOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AcoshOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AcoshOpGenericAdaptorBase::AcoshOpGenericAdaptorBase(AcoshOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +AcoshOpAdaptor::AcoshOpAdaptor(AcoshOp op) : AcoshOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AcoshOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult AcoshOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AcoshOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AcoshOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AcoshOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AcoshOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AcoshOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AcoshOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AcoshOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void AcoshOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AcoshOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AcoshOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AcoshOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AcoshOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AcoshOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void AcoshOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AcoshOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AcoshOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult AcoshOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AcoshOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult AcoshOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AcoshOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void AcoshOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::AcoshOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AsinAcosKernelOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AsinAcosKernelOpGenericAdaptorBase::AsinAcosKernelOpGenericAdaptorBase(AsinAcosKernelOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +AsinAcosKernelOpAdaptor::AsinAcosKernelOpAdaptor(AsinAcosKernelOp op) : AsinAcosKernelOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AsinAcosKernelOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult AsinAcosKernelOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AsinAcosKernelOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AsinAcosKernelOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AsinAcosKernelOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AsinAcosKernelOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AsinAcosKernelOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AsinAcosKernelOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AsinAcosKernelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void AsinAcosKernelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AsinAcosKernelOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AsinAcosKernelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AsinAcosKernelOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AsinAcosKernelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AsinAcosKernelOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void AsinAcosKernelOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AsinAcosKernelOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AsinAcosKernelOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult AsinAcosKernelOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AsinAcosKernelOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult AsinAcosKernelOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AsinAcosKernelOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void AsinAcosKernelOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::AsinAcosKernelOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AsinOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AsinOpGenericAdaptorBase::AsinOpGenericAdaptorBase(AsinOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +AsinOpAdaptor::AsinOpAdaptor(AsinOp op) : AsinOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AsinOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult AsinOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AsinOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AsinOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AsinOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AsinOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AsinOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AsinOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AsinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void AsinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AsinOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AsinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AsinOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AsinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AsinOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void AsinOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AsinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AsinOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult AsinOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AsinOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult AsinOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AsinOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void AsinOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::AsinOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AsinhOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AsinhOpGenericAdaptorBase::AsinhOpGenericAdaptorBase(AsinhOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +AsinhOpAdaptor::AsinhOpAdaptor(AsinhOp op) : AsinhOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AsinhOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult AsinhOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AsinhOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AsinhOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AsinhOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AsinhOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AsinhOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AsinhOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AsinhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void AsinhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AsinhOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AsinhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AsinhOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AsinhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AsinhOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void AsinhOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AsinhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AsinhOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult AsinhOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AsinhOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult AsinhOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AsinhOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void AsinhOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::AsinhOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AtanOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AtanOpGenericAdaptorBase::AtanOpGenericAdaptorBase(AtanOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +AtanOpAdaptor::AtanOpAdaptor(AtanOp op) : AtanOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AtanOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult AtanOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AtanOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AtanOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AtanOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AtanOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AtanOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AtanOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AtanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void AtanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AtanOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AtanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AtanOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AtanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AtanOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void AtanOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AtanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AtanOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult AtanOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AtanOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult AtanOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AtanOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void AtanOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::AtanOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AtanhOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AtanhOpGenericAdaptorBase::AtanhOpGenericAdaptorBase(AtanhOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +AtanhOpAdaptor::AtanhOpAdaptor(AtanhOp op) : AtanhOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AtanhOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult AtanhOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AtanhOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AtanhOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AtanhOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AtanhOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AtanhOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AtanhOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AtanhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void AtanhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AtanhOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AtanhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AtanhOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AtanhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AtanhOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void AtanhOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AtanhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AtanhOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult AtanhOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AtanhOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult AtanhOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AtanhOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void AtanhOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::AtanhOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BesselI1eOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BesselI1eOpGenericAdaptorBase::BesselI1eOpGenericAdaptorBase(BesselI1eOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +BesselI1eOpAdaptor::BesselI1eOpAdaptor(BesselI1eOp op) : BesselI1eOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BesselI1eOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult BesselI1eOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute BesselI1eOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BesselI1eOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional BesselI1eOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void BesselI1eOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void BesselI1eOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult BesselI1eOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void BesselI1eOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void BesselI1eOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BesselI1eOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BesselI1eOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BesselI1eOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BesselI1eOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BesselI1eOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BesselI1eOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BesselI1eOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BesselI1eOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BesselI1eOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BesselI1eOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BesselI1eOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BesselI1eOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void BesselI1eOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BesselI1eOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastAddOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastAddOpGenericAdaptorBase::BroadcastAddOpGenericAdaptorBase(BroadcastAddOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastAddOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastAddOpAdaptor::BroadcastAddOpAdaptor(BroadcastAddOp op) : BroadcastAddOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastAddOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_add' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastAddOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastAddOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastAddOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastAddOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastAddOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastAddOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastAddOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastAddOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastAddOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastAddOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastAddOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastAddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastAddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastAddOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastAddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastAddOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastAddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastAddOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastAddOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastAddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastAddOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastAddOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastAddOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastAddOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastAddOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastAddOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastAddOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastAddOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastAddOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastAndOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastAndOpGenericAdaptorBase::BroadcastAndOpGenericAdaptorBase(BroadcastAndOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastAndOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastAndOpAdaptor::BroadcastAndOpAdaptor(BroadcastAndOp op) : BroadcastAndOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastAndOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_and' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastAndOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastAndOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastAndOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastAndOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastAndOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastAndOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastAndOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastAndOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastAndOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastAndOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastAndOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastAndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastAndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastAndOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastAndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastAndOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastAndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastAndOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastAndOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastAndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastAndOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastAndOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastAndOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastAndOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastAndOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastAndOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastAndOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastAndOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastAndOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastAtan2Op definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastAtan2OpGenericAdaptorBase::BroadcastAtan2OpGenericAdaptorBase(BroadcastAtan2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastAtan2OpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastAtan2OpAdaptor::BroadcastAtan2OpAdaptor(BroadcastAtan2Op op) : BroadcastAtan2OpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastAtan2OpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_atan2' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastAtan2Op::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastAtan2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastAtan2Op::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastAtan2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastAtan2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastAtan2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastAtan2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastAtan2Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastAtan2Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastAtan2Op::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastAtan2Op::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastAtan2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastAtan2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastAtan2Op::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastAtan2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastAtan2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastAtan2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastAtan2Op::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastAtan2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastAtan2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastAtan2Op::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastAtan2Op::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastAtan2Op::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastAtan2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastAtan2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastAtan2Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastAtan2Op::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastAtan2Op::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastAtan2Op) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastCompareOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastCompareOpGenericAdaptorBase::BroadcastCompareOpGenericAdaptorBase(BroadcastCompareOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastCompareOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::mlir::chlo::ComparisonDirection BroadcastCompareOpGenericAdaptorBase::getComparisonDirection() { + auto attr = getComparisonDirectionAttr(); + return attr.getValue(); +} + +::std::optional<::mlir::chlo::ComparisonType> BroadcastCompareOpGenericAdaptorBase::getCompareType() { + auto attr = getCompareTypeAttr(); + return attr ? ::std::optional<::mlir::chlo::ComparisonType>(attr.getValue()) : (::std::nullopt); +} + +} // namespace detail +BroadcastCompareOpAdaptor::BroadcastCompareOpAdaptor(BroadcastCompareOp op) : BroadcastCompareOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastCompareOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + auto tblgen_compare_type = getProperties().compare_type; (void)tblgen_compare_type; + auto tblgen_comparison_direction = getProperties().comparison_direction; (void)tblgen_comparison_direction; + if (!tblgen_comparison_direction) return emitError(loc, "'chlo.broadcast_compare' op ""requires attribute 'comparison_direction'"); + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_compare' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_comparison_direction && !((::llvm::isa<::mlir::chlo::ComparisonDirectionAttr>(tblgen_comparison_direction)))) + return emitError(loc, "'chlo.broadcast_compare' op ""attribute 'comparison_direction' failed to satisfy constraint: Which comparison operation to perform."); + + if (tblgen_compare_type && !((::llvm::isa<::mlir::chlo::ComparisonTypeAttr>(tblgen_compare_type)))) + return emitError(loc, "'chlo.broadcast_compare' op ""attribute 'compare_type' failed to satisfy constraint: Which comparison type to use."); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastCompareOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.compare_type; + auto attr = dict.get("compare_type"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `compare_type` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.comparison_direction; + auto attr = dict.get("comparison_direction"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `comparison_direction` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastCompareOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.compare_type; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("compare_type", + propStorage)); + } + + { + const auto &propStorage = prop.comparison_direction; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("comparison_direction", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastCompareOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.compare_type.getAsOpaquePointer()), + llvm::hash_value(prop.comparison_direction.getAsOpaquePointer())); +} + +std::optional BroadcastCompareOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + + if (name == "compare_type") + return prop.compare_type; + + if (name == "comparison_direction") + return prop.comparison_direction; + return std::nullopt; +} + +void BroadcastCompareOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "compare_type") { + prop.compare_type = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "comparison_direction") { + prop.comparison_direction = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastCompareOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); + + if (prop.compare_type) attrs.append("compare_type", prop.compare_type); + + if (prop.comparison_direction) attrs.append("comparison_direction", prop.comparison_direction); +} + +::llvm::LogicalResult BroadcastCompareOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getCompareTypeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps3(attr, "compare_type", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getComparisonDirectionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps2(attr, "comparison_direction", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastCompareOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.compare_type))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.comparison_direction))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastCompareOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); + + writer.writeOptionalAttribute(prop.compare_type); + writer.writeAttribute(prop.comparison_direction); +} + +::std::optional<::llvm::ArrayRef> BroadcastCompareOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::mlir::chlo::ComparisonDirection BroadcastCompareOp::getComparisonDirection() { + auto attr = getComparisonDirectionAttr(); + return attr.getValue(); +} + +::std::optional<::mlir::chlo::ComparisonType> BroadcastCompareOp::getCompareType() { + auto attr = getCompareTypeAttr(); + return attr ? ::std::optional<::mlir::chlo::ComparisonType>(attr.getValue()) : (::std::nullopt); +} + +void BroadcastCompareOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastCompareOp::setComparisonDirection(::mlir::chlo::ComparisonDirection attrValue) { + getProperties().comparison_direction = ::mlir::chlo::ComparisonDirectionAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); +} + +void BroadcastCompareOp::setCompareType(::std::optional<::mlir::chlo::ComparisonType> attrValue) { + auto &odsProp = getProperties().compare_type; + if (attrValue) + odsProp = ::mlir::chlo::ComparisonTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); + else + odsProp = nullptr; +} + +void BroadcastCompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions, ::mlir::chlo::ComparisonDirectionAttr comparison_direction, /*optional*/::mlir::chlo::ComparisonTypeAttr compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.getOrAddProperties().comparison_direction = comparison_direction; + if (compare_type) { + odsState.getOrAddProperties().compare_type = compare_type; + } + odsState.addTypes(resultType0); +} + +void BroadcastCompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions, ::mlir::chlo::ComparisonDirectionAttr comparison_direction, /*optional*/::mlir::chlo::ComparisonTypeAttr compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.getOrAddProperties().comparison_direction = comparison_direction; + if (compare_type) { + odsState.getOrAddProperties().compare_type = compare_type; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastCompareOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastCompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions, ::mlir::chlo::ComparisonDirectionAttr comparison_direction, /*optional*/::mlir::chlo::ComparisonTypeAttr compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.getOrAddProperties().comparison_direction = comparison_direction; + if (compare_type) { + odsState.getOrAddProperties().compare_type = compare_type; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastCompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions, ::mlir::chlo::ComparisonDirection comparison_direction, /*optional*/::mlir::chlo::ComparisonTypeAttr compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.getOrAddProperties().comparison_direction = ::mlir::chlo::ComparisonDirectionAttr::get(odsBuilder.getContext(), comparison_direction); + if (compare_type) { + odsState.getOrAddProperties().compare_type = compare_type; + } + odsState.addTypes(resultType0); +} + +void BroadcastCompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions, ::mlir::chlo::ComparisonDirection comparison_direction, /*optional*/::mlir::chlo::ComparisonTypeAttr compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.getOrAddProperties().comparison_direction = ::mlir::chlo::ComparisonDirectionAttr::get(odsBuilder.getContext(), comparison_direction); + if (compare_type) { + odsState.getOrAddProperties().compare_type = compare_type; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastCompareOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastCompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions, ::mlir::chlo::ComparisonDirection comparison_direction, /*optional*/::mlir::chlo::ComparisonTypeAttr compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.getOrAddProperties().comparison_direction = ::mlir::chlo::ComparisonDirectionAttr::get(odsBuilder.getContext(), comparison_direction); + if (compare_type) { + odsState.getOrAddProperties().compare_type = compare_type; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastCompareOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastCompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastCompareOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastCompareOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastCompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastCompareOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastCompareOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + auto tblgen_compare_type = getProperties().compare_type; (void)tblgen_compare_type; + auto tblgen_comparison_direction = getProperties().comparison_direction; (void)tblgen_comparison_direction; + if (!tblgen_comparison_direction) return emitOpError("requires attribute 'comparison_direction'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps2(*this, tblgen_comparison_direction, "comparison_direction"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps3(*this, tblgen_compare_type, "compare_type"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastCompareOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastCompareOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastCompareOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastCompareOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastCompareOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastCompareOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastCompareOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastComplexOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastComplexOpGenericAdaptorBase::BroadcastComplexOpGenericAdaptorBase(BroadcastComplexOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastComplexOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastComplexOpAdaptor::BroadcastComplexOpAdaptor(BroadcastComplexOp op) : BroadcastComplexOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastComplexOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_complex' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastComplexOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastComplexOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastComplexOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastComplexOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastComplexOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastComplexOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastComplexOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastComplexOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastComplexOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastComplexOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastComplexOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastComplexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastComplexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastComplexOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastComplexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastComplexOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastComplexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastComplexOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastComplexOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastComplexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastComplexOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastComplexOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastComplexOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastComplexOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastComplexOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastComplexOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastComplexOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastComplexOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastComplexOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastDivOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastDivOpGenericAdaptorBase::BroadcastDivOpGenericAdaptorBase(BroadcastDivOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastDivOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastDivOpAdaptor::BroadcastDivOpAdaptor(BroadcastDivOp op) : BroadcastDivOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastDivOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_divide' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastDivOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastDivOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastDivOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastDivOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastDivOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastDivOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastDivOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastDivOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastDivOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastDivOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastDivOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastDivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastDivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastDivOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastDivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastDivOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastDivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastDivOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastDivOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastDivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastDivOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastDivOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastDivOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastDivOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastDivOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastDivOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastDivOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastDivOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastDivOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastMaxOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastMaxOpGenericAdaptorBase::BroadcastMaxOpGenericAdaptorBase(BroadcastMaxOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastMaxOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastMaxOpAdaptor::BroadcastMaxOpAdaptor(BroadcastMaxOp op) : BroadcastMaxOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastMaxOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_maximum' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastMaxOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastMaxOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastMaxOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastMaxOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastMaxOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastMaxOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastMaxOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastMaxOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastMaxOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastMaxOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastMaxOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastMaxOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastMaxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastMaxOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastMaxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastMaxOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastMaxOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastMaxOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastMaxOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastMaxOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastMaxOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastMaxOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastMaxOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastMaxOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastMinOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastMinOpGenericAdaptorBase::BroadcastMinOpGenericAdaptorBase(BroadcastMinOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastMinOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastMinOpAdaptor::BroadcastMinOpAdaptor(BroadcastMinOp op) : BroadcastMinOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastMinOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_minimum' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastMinOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastMinOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastMinOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastMinOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastMinOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastMinOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastMinOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastMinOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastMinOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastMinOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastMinOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastMinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastMinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastMinOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastMinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastMinOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastMinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastMinOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastMinOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastMinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastMinOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastMinOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastMinOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastMinOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastMinOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastMinOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastMinOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastMinOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastMinOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastMulOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastMulOpGenericAdaptorBase::BroadcastMulOpGenericAdaptorBase(BroadcastMulOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastMulOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastMulOpAdaptor::BroadcastMulOpAdaptor(BroadcastMulOp op) : BroadcastMulOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastMulOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_multiply' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastMulOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastMulOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastMulOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastMulOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastMulOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastMulOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastMulOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastMulOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastMulOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastMulOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastMulOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastMulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastMulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastMulOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastMulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastMulOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastMulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastMulOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastMulOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastMulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastMulOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastMulOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastMulOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastMulOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastMulOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastMulOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastMulOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastMulOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastMulOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastNextAfterOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastNextAfterOpGenericAdaptorBase::BroadcastNextAfterOpGenericAdaptorBase(BroadcastNextAfterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastNextAfterOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastNextAfterOpAdaptor::BroadcastNextAfterOpAdaptor(BroadcastNextAfterOp op) : BroadcastNextAfterOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastNextAfterOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_next_after' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastNextAfterOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastNextAfterOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastNextAfterOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastNextAfterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastNextAfterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastNextAfterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastNextAfterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastNextAfterOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastNextAfterOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastNextAfterOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastNextAfterOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastNextAfterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastNextAfterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastNextAfterOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastNextAfterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastNextAfterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastNextAfterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastNextAfterOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastNextAfterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastNextAfterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastNextAfterOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastNextAfterOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastNextAfterOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastNextAfterOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastNextAfterOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastNextAfterOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastNextAfterOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastNextAfterOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastNextAfterOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastOrOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastOrOpGenericAdaptorBase::BroadcastOrOpGenericAdaptorBase(BroadcastOrOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastOrOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastOrOpAdaptor::BroadcastOrOpAdaptor(BroadcastOrOp op) : BroadcastOrOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastOrOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_or' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastOrOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastOrOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastOrOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastOrOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastOrOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastOrOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastOrOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastOrOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastOrOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastOrOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastOrOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastOrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastOrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastOrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastOrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastOrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastOrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastOrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastOrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastOrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastOrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastOrOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastOrOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastOrOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastOrOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastOrOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastOrOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastOrOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastOrOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastPolygammaOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastPolygammaOpGenericAdaptorBase::BroadcastPolygammaOpGenericAdaptorBase(BroadcastPolygammaOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastPolygammaOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastPolygammaOpAdaptor::BroadcastPolygammaOpAdaptor(BroadcastPolygammaOp op) : BroadcastPolygammaOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastPolygammaOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_polygamma' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastPolygammaOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastPolygammaOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastPolygammaOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastPolygammaOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastPolygammaOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastPolygammaOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastPolygammaOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastPolygammaOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastPolygammaOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastPolygammaOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastPolygammaOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastPolygammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastPolygammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastPolygammaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastPolygammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastPolygammaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastPolygammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastPolygammaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastPolygammaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastPolygammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastPolygammaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastPolygammaOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastPolygammaOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastPolygammaOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastPolygammaOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastPolygammaOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastPolygammaOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastPolygammaOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastPolygammaOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastPowOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastPowOpGenericAdaptorBase::BroadcastPowOpGenericAdaptorBase(BroadcastPowOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastPowOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastPowOpAdaptor::BroadcastPowOpAdaptor(BroadcastPowOp op) : BroadcastPowOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastPowOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_power' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastPowOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastPowOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastPowOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastPowOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastPowOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastPowOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastPowOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastPowOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastPowOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastPowOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastPowOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastPowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastPowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastPowOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastPowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastPowOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastPowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastPowOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastPowOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastPowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastPowOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastPowOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastPowOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastPowOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastPowOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastPowOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastPowOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastPowOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastPowOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastRemOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastRemOpGenericAdaptorBase::BroadcastRemOpGenericAdaptorBase(BroadcastRemOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastRemOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastRemOpAdaptor::BroadcastRemOpAdaptor(BroadcastRemOp op) : BroadcastRemOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastRemOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_remainder' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastRemOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastRemOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastRemOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastRemOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastRemOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastRemOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastRemOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastRemOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastRemOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastRemOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastRemOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastRemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastRemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastRemOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastRemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastRemOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastRemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastRemOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastRemOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastRemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastRemOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastRemOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastRemOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastRemOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastRemOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastRemOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastRemOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastRemOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastRemOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastSelectOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastSelectOpGenericAdaptorBase::BroadcastSelectOpGenericAdaptorBase(BroadcastSelectOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +BroadcastSelectOpAdaptor::BroadcastSelectOpAdaptor(BroadcastSelectOp op) : BroadcastSelectOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastSelectOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastSelectOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastSelectOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastSelectOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional BroadcastSelectOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void BroadcastSelectOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void BroadcastSelectOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult BroadcastSelectOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void BroadcastSelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false) { + odsState.addOperands(pred); + odsState.addOperands(on_true); + odsState.addOperands(on_false); + odsState.addTypes(resultType0); +} + +void BroadcastSelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false) { + odsState.addOperands(pred); + odsState.addOperands(on_true); + odsState.addOperands(on_false); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastSelectOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastSelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false) { + odsState.addOperands(pred); + odsState.addOperands(on_true); + odsState.addOperands(on_false); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastSelectOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastSelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastSelectOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastSelectOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastSelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastSelectOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastSelectOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastSelectOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastSelectOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand predRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> predOperands(&predRawOperand, 1); ::llvm::SMLoc predOperandsLoc; + (void)predOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand on_trueRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> on_trueOperands(&on_trueRawOperand, 1); ::llvm::SMLoc on_trueOperandsLoc; + (void)on_trueOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand on_falseRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> on_falseOperands(&on_falseRawOperand, 1); ::llvm::SMLoc on_falseOperandsLoc; + (void)on_falseOperandsLoc; + ::mlir::Type predRawType{}; + ::llvm::ArrayRef<::mlir::Type> predTypes(&predRawType, 1); + ::mlir::Type on_trueRawType{}; + ::llvm::ArrayRef<::mlir::Type> on_trueTypes(&on_trueRawType, 1); + ::mlir::Type on_falseRawType{}; + ::llvm::ArrayRef<::mlir::Type> on_falseTypes(&on_falseRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + predOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(predRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + on_trueOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(on_trueRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + on_falseOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(on_falseRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + predRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + on_trueRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + on_falseRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(predOperands, predTypes, predOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(on_trueOperands, on_trueTypes, on_trueOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(on_falseOperands, on_falseTypes, on_falseOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastSelectOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getPred(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getOnTrue(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getOnFalse(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getPred().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getOnTrue().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getOnFalse().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastSelectOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastSelectOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastSelectOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastSelectOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastShiftLeftOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastShiftLeftOpGenericAdaptorBase::BroadcastShiftLeftOpGenericAdaptorBase(BroadcastShiftLeftOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastShiftLeftOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastShiftLeftOpAdaptor::BroadcastShiftLeftOpAdaptor(BroadcastShiftLeftOp op) : BroadcastShiftLeftOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastShiftLeftOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_shift_left' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastShiftLeftOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastShiftLeftOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastShiftLeftOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastShiftLeftOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastShiftLeftOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastShiftLeftOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastShiftLeftOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastShiftLeftOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastShiftLeftOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastShiftLeftOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastShiftLeftOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastShiftLeftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastShiftLeftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastShiftLeftOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastShiftLeftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastShiftLeftOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastShiftLeftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastShiftLeftOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastShiftLeftOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastShiftLeftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastShiftLeftOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastShiftLeftOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastShiftLeftOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastShiftLeftOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastShiftLeftOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastShiftLeftOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastShiftLeftOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastShiftLeftOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastShiftLeftOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastShiftRightArithmeticOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastShiftRightArithmeticOpGenericAdaptorBase::BroadcastShiftRightArithmeticOpGenericAdaptorBase(BroadcastShiftRightArithmeticOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastShiftRightArithmeticOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastShiftRightArithmeticOpAdaptor::BroadcastShiftRightArithmeticOpAdaptor(BroadcastShiftRightArithmeticOp op) : BroadcastShiftRightArithmeticOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastShiftRightArithmeticOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_shift_right_arithmetic' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastShiftRightArithmeticOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastShiftRightArithmeticOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastShiftRightArithmeticOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastShiftRightArithmeticOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastShiftRightArithmeticOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastShiftRightArithmeticOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastShiftRightArithmeticOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastShiftRightArithmeticOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastShiftRightArithmeticOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastShiftRightArithmeticOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastShiftRightArithmeticOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastShiftRightArithmeticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastShiftRightArithmeticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastShiftRightArithmeticOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastShiftRightArithmeticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastShiftRightArithmeticOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastShiftRightArithmeticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastShiftRightArithmeticOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastShiftRightArithmeticOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastShiftRightArithmeticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastShiftRightArithmeticOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastShiftRightArithmeticOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastShiftRightArithmeticOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastShiftRightArithmeticOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastShiftRightArithmeticOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastShiftRightArithmeticOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastShiftRightArithmeticOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastShiftRightArithmeticOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastShiftRightArithmeticOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastShiftRightLogicalOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastShiftRightLogicalOpGenericAdaptorBase::BroadcastShiftRightLogicalOpGenericAdaptorBase(BroadcastShiftRightLogicalOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastShiftRightLogicalOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastShiftRightLogicalOpAdaptor::BroadcastShiftRightLogicalOpAdaptor(BroadcastShiftRightLogicalOp op) : BroadcastShiftRightLogicalOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastShiftRightLogicalOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_shift_right_logical' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastShiftRightLogicalOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastShiftRightLogicalOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastShiftRightLogicalOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastShiftRightLogicalOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastShiftRightLogicalOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastShiftRightLogicalOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastShiftRightLogicalOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastShiftRightLogicalOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastShiftRightLogicalOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastShiftRightLogicalOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastShiftRightLogicalOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastShiftRightLogicalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastShiftRightLogicalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastShiftRightLogicalOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastShiftRightLogicalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastShiftRightLogicalOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastShiftRightLogicalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastShiftRightLogicalOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastShiftRightLogicalOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastShiftRightLogicalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastShiftRightLogicalOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastShiftRightLogicalOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastShiftRightLogicalOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastShiftRightLogicalOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastShiftRightLogicalOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastShiftRightLogicalOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastShiftRightLogicalOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastShiftRightLogicalOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastShiftRightLogicalOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastSubOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastSubOpGenericAdaptorBase::BroadcastSubOpGenericAdaptorBase(BroadcastSubOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastSubOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastSubOpAdaptor::BroadcastSubOpAdaptor(BroadcastSubOp op) : BroadcastSubOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastSubOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_subtract' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastSubOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastSubOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastSubOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastSubOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastSubOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastSubOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastSubOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastSubOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastSubOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastSubOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastSubOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastSubOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastSubOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastSubOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastSubOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastSubOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastSubOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastSubOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastSubOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastSubOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastSubOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastSubOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastSubOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastSubOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastSubOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastSubOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastSubOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastSubOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastSubOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastXorOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastXorOpGenericAdaptorBase::BroadcastXorOpGenericAdaptorBase(BroadcastXorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastXorOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastXorOpAdaptor::BroadcastXorOpAdaptor(BroadcastXorOp op) : BroadcastXorOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastXorOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_xor' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastXorOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastXorOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastXorOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastXorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastXorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastXorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastXorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastXorOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastXorOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastXorOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastXorOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastXorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastXorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastXorOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastXorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastXorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastXorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastXorOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastXorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastXorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastXorOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastXorOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastXorOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastXorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastXorOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastXorOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastXorOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastXorOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastXorOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastZetaOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastZetaOpGenericAdaptorBase::BroadcastZetaOpGenericAdaptorBase(BroadcastZetaOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> BroadcastZetaOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +BroadcastZetaOpAdaptor::BroadcastZetaOpAdaptor(BroadcastZetaOp op) : BroadcastZetaOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastZetaOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'chlo.broadcast_zeta' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastZetaOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastZetaOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastZetaOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastZetaOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastZetaOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastZetaOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastZetaOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastZetaOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastZetaOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.broadcast_dimensions); +} + +::std::optional<::llvm::ArrayRef> BroadcastZetaOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void BroadcastZetaOp::setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().broadcast_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void BroadcastZetaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + odsState.addTypes(resultType0); +} + +void BroadcastZetaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastZetaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastZetaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (broadcast_dimensions) { + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastZetaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastZetaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastZetaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastZetaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastZetaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastZetaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastZetaOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastZetaOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastZetaOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastZetaOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void BroadcastZetaOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastZetaOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastZetaOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastZetaOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ConjOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConjOpGenericAdaptorBase::ConjOpGenericAdaptorBase(ConjOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ConjOpAdaptor::ConjOpAdaptor(ConjOp op) : ConjOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ConjOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ConjOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ConjOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConjOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ConjOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ConjOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ConjOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ConjOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ConjOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void ConjOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConjOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ConjOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConjOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ConjOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConjOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ConjOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ConjOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConjOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ConjOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConjOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ConjOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConjOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ConjOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::ConjOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ConstantLikeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConstantLikeOpGenericAdaptorBase::ConstantLikeOpGenericAdaptorBase(ConstantLikeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::TypedAttr ConstantLikeOpGenericAdaptorBase::getValue() { + auto attr = getValueAttr(); + return attr; +} + +} // namespace detail +ConstantLikeOpAdaptor::ConstantLikeOpAdaptor(ConstantLikeOp op) : ConstantLikeOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ConstantLikeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_value = getProperties().value; (void)tblgen_value; + if (!tblgen_value) return emitError(loc, "'chlo.constant_like' op ""requires attribute 'value'"); + + if (tblgen_value && !((::llvm::isa<::mlir::TypedAttr>(tblgen_value)))) + return emitError(loc, "'chlo.constant_like' op ""attribute 'value' failed to satisfy constraint: TypedAttr instance"); + return ::mlir::success(); +} + +::llvm::LogicalResult ConstantLikeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.value; + auto attr = dict.get("value"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `value` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ConstantLikeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.value; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("value", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConstantLikeOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.value.getAsOpaquePointer())); +} + +std::optional ConstantLikeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "value") + return prop.value; + return std::nullopt; +} + +void ConstantLikeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "value") { + prop.value = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ConstantLikeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.value) attrs.append("value", prop.value); +} + +::llvm::LogicalResult ConstantLikeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getValueAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps4(attr, "value", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConstantLikeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.value))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConstantLikeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.value); +} + +::mlir::TypedAttr ConstantLikeOp::getValue() { + auto attr = getValueAttr(); + return attr; +} + +void ConstantLikeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::TypedAttr value, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.getOrAddProperties().value = value; + odsState.addTypes(resultType0); +} + +void ConstantLikeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypedAttr value, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.getOrAddProperties().value = value; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstantLikeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ConstantLikeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::TypedAttr value, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.getOrAddProperties().value = value; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConstantLikeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ConstantLikeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstantLikeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ConstantLikeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ConstantLikeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstantLikeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ConstantLikeOp::verifyInvariantsImpl() { + auto tblgen_value = getProperties().value; (void)tblgen_value; + if (!tblgen_value) return emitOpError("requires attribute 'value'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps4(*this, tblgen_value, "value"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConstantLikeOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +void ConstantLikeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +ConstantLikeOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(ConstantLikeOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::ConstantLikeOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ConstantOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConstantOpGenericAdaptorBase::ConstantOpGenericAdaptorBase(ConstantOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::ElementsAttr ConstantOpGenericAdaptorBase::getValue() { + auto attr = getValueAttr(); + return attr; +} + +} // namespace detail +ConstantOpAdaptor::ConstantOpAdaptor(ConstantOp op) : ConstantOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ConstantOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_value = getProperties().value; (void)tblgen_value; + if (!tblgen_value) return emitError(loc, "'chlo.constant' op ""requires attribute 'value'"); + + if (tblgen_value && !((::llvm::isa<::mlir::ElementsAttr>(tblgen_value)))) + return emitError(loc, "'chlo.constant' op ""attribute 'value' failed to satisfy constraint: constant vector/tensor attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult ConstantOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.value; + auto attr = dict.get("value"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `value` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ConstantOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.value; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("value", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConstantOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.value.getAsOpaquePointer())); +} + +std::optional ConstantOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "value") + return prop.value; + return std::nullopt; +} + +void ConstantOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "value") { + prop.value = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ConstantOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.value) attrs.append("value", prop.value); +} + +::llvm::LogicalResult ConstantOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getValueAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps5(attr, "value", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConstantOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.value))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConstantOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.value); +} + +::mlir::ElementsAttr ConstantOp::getValue() { + auto attr = getValueAttr(); + return attr; +} + +void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::ElementsAttr value) { + odsState.getOrAddProperties().value = value; + odsState.addTypes(output); +} + +void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ElementsAttr value) { + odsState.getOrAddProperties().value = value; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstantOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ElementsAttr value) { + odsState.getOrAddProperties().value = value; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConstantOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstantOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ConstantOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstantOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ConstantOp::verifyInvariantsImpl() { + auto tblgen_value = getProperties().value; (void)tblgen_value; + if (!tblgen_value) return emitOpError("requires attribute 'value'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps5(*this, tblgen_value, "value"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConstantOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ConstantOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::ElementsAttr valueAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + + if (parser.parseCustomAttributeWithFallback(valueAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (valueAttr) result.getOrAddProperties().value = valueAttr; + + ::llvm::SmallVector<::mlir::Type> inferredReturnTypes; + if (::mlir::failed(ConstantOp::inferReturnTypes(parser.getContext(), + result.location, result.operands, + result.attributes.getDictionary(parser.getContext()), + result.getRawProperties(), + result.regions, inferredReturnTypes))) + return ::mlir::failure(); + result.addTypes(inferredReturnTypes); + return ::mlir::success(); +} + +void ConstantOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("value"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getValueAttr()); +} + +void ConstantOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::ConstantOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::CoshOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CoshOpGenericAdaptorBase::CoshOpGenericAdaptorBase(CoshOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +CoshOpAdaptor::CoshOpAdaptor(CoshOp op) : CoshOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CoshOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult CoshOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute CoshOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CoshOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional CoshOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void CoshOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void CoshOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult CoshOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void CoshOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void CoshOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CoshOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void CoshOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CoshOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CoshOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CoshOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void CoshOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CoshOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CoshOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult CoshOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CoshOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult CoshOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CoshOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void CoshOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::CoshOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::DigammaOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DigammaOpGenericAdaptorBase::DigammaOpGenericAdaptorBase(DigammaOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +DigammaOpAdaptor::DigammaOpAdaptor(DigammaOp op) : DigammaOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DigammaOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult DigammaOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute DigammaOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DigammaOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional DigammaOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void DigammaOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void DigammaOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult DigammaOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void DigammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void DigammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DigammaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void DigammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DigammaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DigammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DigammaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void DigammaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DigammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DigammaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult DigammaOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DigammaOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult DigammaOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DigammaOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void DigammaOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::DigammaOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ErfInvOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ErfInvOpGenericAdaptorBase::ErfInvOpGenericAdaptorBase(ErfInvOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ErfInvOpAdaptor::ErfInvOpAdaptor(ErfInvOp op) : ErfInvOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ErfInvOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ErfInvOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ErfInvOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ErfInvOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ErfInvOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ErfInvOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ErfInvOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ErfInvOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ErfInvOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void ErfInvOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ErfInvOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ErfInvOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ErfInvOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ErfInvOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ErfInvOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ErfInvOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ErfInvOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ErfInvOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ErfInvOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ErfInvOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ErfInvOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ErfInvOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ErfInvOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::ErfInvOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ErfOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ErfOpGenericAdaptorBase::ErfOpGenericAdaptorBase(ErfOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ErfOpAdaptor::ErfOpAdaptor(ErfOp op) : ErfOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ErfOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ErfOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ErfOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ErfOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ErfOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ErfOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ErfOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ErfOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ErfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void ErfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ErfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ErfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ErfOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ErfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ErfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ErfOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ErfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ErfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ErfOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ErfOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ErfOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ErfOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ErfOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::ErfOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ErfcOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ErfcOpGenericAdaptorBase::ErfcOpGenericAdaptorBase(ErfcOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ErfcOpAdaptor::ErfcOpAdaptor(ErfcOp op) : ErfcOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ErfcOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ErfcOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ErfcOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ErfcOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ErfcOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ErfcOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ErfcOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ErfcOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ErfcOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void ErfcOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ErfcOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ErfcOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ErfcOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ErfcOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ErfcOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ErfcOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ErfcOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ErfcOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ErfcOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ErfcOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ErfcOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ErfcOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ErfcOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::ErfcOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::IsInfOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IsInfOpGenericAdaptorBase::IsInfOpGenericAdaptorBase(IsInfOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +IsInfOpAdaptor::IsInfOpAdaptor(IsInfOp op) : IsInfOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult IsInfOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult IsInfOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute IsInfOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code IsInfOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional IsInfOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void IsInfOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void IsInfOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult IsInfOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void IsInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void IsInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IsInfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void IsInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void IsInfOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void IsInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IsInfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void IsInfOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void IsInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IsInfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult IsInfOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult IsInfOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult IsInfOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void IsInfOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void IsInfOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::IsInfOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::IsNegInfOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IsNegInfOpGenericAdaptorBase::IsNegInfOpGenericAdaptorBase(IsNegInfOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +IsNegInfOpAdaptor::IsNegInfOpAdaptor(IsNegInfOp op) : IsNegInfOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult IsNegInfOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult IsNegInfOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute IsNegInfOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code IsNegInfOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional IsNegInfOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void IsNegInfOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void IsNegInfOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult IsNegInfOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void IsNegInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void IsNegInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IsNegInfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void IsNegInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void IsNegInfOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void IsNegInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IsNegInfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void IsNegInfOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void IsNegInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IsNegInfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult IsNegInfOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult IsNegInfOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult IsNegInfOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void IsNegInfOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void IsNegInfOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::IsNegInfOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::IsPosInfOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IsPosInfOpGenericAdaptorBase::IsPosInfOpGenericAdaptorBase(IsPosInfOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +IsPosInfOpAdaptor::IsPosInfOpAdaptor(IsPosInfOp op) : IsPosInfOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult IsPosInfOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult IsPosInfOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute IsPosInfOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code IsPosInfOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional IsPosInfOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void IsPosInfOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void IsPosInfOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult IsPosInfOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void IsPosInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void IsPosInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IsPosInfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void IsPosInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void IsPosInfOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void IsPosInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IsPosInfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void IsPosInfOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void IsPosInfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IsPosInfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult IsPosInfOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult IsPosInfOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult IsPosInfOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void IsPosInfOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void IsPosInfOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::IsPosInfOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::LgammaOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +LgammaOpGenericAdaptorBase::LgammaOpGenericAdaptorBase(LgammaOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +LgammaOpAdaptor::LgammaOpAdaptor(LgammaOp op) : LgammaOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult LgammaOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult LgammaOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute LgammaOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code LgammaOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional LgammaOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void LgammaOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void LgammaOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult LgammaOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void LgammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void LgammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(LgammaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void LgammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void LgammaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void LgammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(LgammaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void LgammaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void LgammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(LgammaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult LgammaOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult LgammaOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult LgammaOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void LgammaOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void LgammaOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::LgammaOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::NextAfterOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +NextAfterOpGenericAdaptorBase::NextAfterOpGenericAdaptorBase(NextAfterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +NextAfterOpAdaptor::NextAfterOpAdaptor(NextAfterOp op) : NextAfterOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult NextAfterOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult NextAfterOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute NextAfterOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code NextAfterOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional NextAfterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void NextAfterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void NextAfterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult NextAfterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void NextAfterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value x, ::mlir::Value y) { + odsState.addOperands(x); + odsState.addOperands(y); + odsState.addTypes(result); +} + +void NextAfterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, ::mlir::Value y) { + odsState.addOperands(x); + odsState.addOperands(y); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(NextAfterOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void NextAfterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value y) { + odsState.addOperands(x); + odsState.addOperands(y); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void NextAfterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void NextAfterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(NextAfterOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void NextAfterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void NextAfterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(NextAfterOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult NextAfterOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult NextAfterOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult NextAfterOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand xRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> xOperands(&xRawOperand, 1); ::llvm::SMLoc xOperandsLoc; + (void)xOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand yRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> yOperands(&yRawOperand, 1); ::llvm::SMLoc yOperandsLoc; + (void)yOperandsLoc; + ::mlir::Type xRawType{}; + ::llvm::ArrayRef<::mlir::Type> xTypes(&xRawType, 1); + ::mlir::Type yRawType{}; + ::llvm::ArrayRef<::mlir::Type> yTypes(&yRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + xOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(xRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + yOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(yRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + xRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + yRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(xOperands, xTypes, xOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(yOperands, yTypes, yOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void NextAfterOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getX(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getY(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getX().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getY().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void NextAfterOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::NextAfterOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::PolygammaOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PolygammaOpGenericAdaptorBase::PolygammaOpGenericAdaptorBase(PolygammaOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +PolygammaOpAdaptor::PolygammaOpAdaptor(PolygammaOp op) : PolygammaOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult PolygammaOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult PolygammaOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute PolygammaOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PolygammaOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional PolygammaOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void PolygammaOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void PolygammaOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult PolygammaOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void PolygammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value n, ::mlir::Value x) { + odsState.addOperands(n); + odsState.addOperands(x); + odsState.addTypes(result); +} + +void PolygammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value n, ::mlir::Value x) { + odsState.addOperands(n); + odsState.addOperands(x); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PolygammaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void PolygammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value n, ::mlir::Value x) { + odsState.addOperands(n); + odsState.addOperands(x); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PolygammaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PolygammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PolygammaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void PolygammaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PolygammaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PolygammaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult PolygammaOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult PolygammaOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult PolygammaOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand nRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> nOperands(&nRawOperand, 1); ::llvm::SMLoc nOperandsLoc; + (void)nOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand xRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> xOperands(&xRawOperand, 1); ::llvm::SMLoc xOperandsLoc; + (void)xOperandsLoc; + ::mlir::Type nRawType{}; + ::llvm::ArrayRef<::mlir::Type> nTypes(&nRawType, 1); + ::mlir::Type xRawType{}; + ::llvm::ArrayRef<::mlir::Type> xTypes(&xRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + nOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(nRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + xOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(xRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + nRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + xRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(nOperands, nTypes, nOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(xOperands, xTypes, xOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PolygammaOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getN(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getX(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getN().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getX().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void PolygammaOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::PolygammaOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::RaggedDotOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RaggedDotOpGenericAdaptorBase::RaggedDotOpGenericAdaptorBase(RaggedDotOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::chlo::RaggedDotDimensionNumbersAttr RaggedDotOpGenericAdaptorBase::getRaggedDotDimensionNumbers() { + auto attr = getRaggedDotDimensionNumbersAttr(); + return ::llvm::cast<::mlir::chlo::RaggedDotDimensionNumbersAttr>(attr); +} + +::std::optional< ::mlir::ArrayAttr > RaggedDotOpGenericAdaptorBase::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +} // namespace detail +RaggedDotOpAdaptor::RaggedDotOpAdaptor(RaggedDotOp op) : RaggedDotOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RaggedDotOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + auto tblgen_ragged_dot_dimension_numbers = getProperties().ragged_dot_dimension_numbers; (void)tblgen_ragged_dot_dimension_numbers; + if (!tblgen_ragged_dot_dimension_numbers) return emitError(loc, "'chlo.ragged_dot' op ""requires attribute 'ragged_dot_dimension_numbers'"); + + if (tblgen_ragged_dot_dimension_numbers && !((::llvm::isa<::mlir::chlo::RaggedDotDimensionNumbersAttr>(tblgen_ragged_dot_dimension_numbers)))) + return emitError(loc, "'chlo.ragged_dot' op ""attribute 'ragged_dot_dimension_numbers' failed to satisfy constraint: Attribute that models the dimension information for ragged dot."); + + if (tblgen_precision_config && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_precision_config))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_precision_config), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::chlo::PrecisionAttr>(attr))); })))) + return emitError(loc, "'chlo.ragged_dot' op ""attribute 'precision_config' failed to satisfy constraint: Precision Config attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult RaggedDotOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.precision_config; + auto attr = dict.get("precision_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `precision_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.ragged_dot_dimension_numbers; + auto attr = dict.get("ragged_dot_dimension_numbers"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `ragged_dot_dimension_numbers` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute RaggedDotOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.precision_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("precision_config", + propStorage)); + } + + { + const auto &propStorage = prop.ragged_dot_dimension_numbers; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("ragged_dot_dimension_numbers", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RaggedDotOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.precision_config.getAsOpaquePointer()), + llvm::hash_value(prop.ragged_dot_dimension_numbers.getAsOpaquePointer())); +} + +std::optional RaggedDotOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "precision_config") + return prop.precision_config; + + if (name == "ragged_dot_dimension_numbers") + return prop.ragged_dot_dimension_numbers; + return std::nullopt; +} + +void RaggedDotOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "precision_config") { + prop.precision_config = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "ragged_dot_dimension_numbers") { + prop.ragged_dot_dimension_numbers = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void RaggedDotOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.precision_config) attrs.append("precision_config", prop.precision_config); + + if (prop.ragged_dot_dimension_numbers) attrs.append("ragged_dot_dimension_numbers", prop.ragged_dot_dimension_numbers); +} + +::llvm::LogicalResult RaggedDotOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getPrecisionConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps7(attr, "precision_config", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRaggedDotDimensionNumbersAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps6(attr, "ragged_dot_dimension_numbers", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult RaggedDotOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.precision_config))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.ragged_dot_dimension_numbers))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RaggedDotOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.precision_config); + writer.writeAttribute(prop.ragged_dot_dimension_numbers); +} + +::mlir::chlo::RaggedDotDimensionNumbersAttr RaggedDotOp::getRaggedDotDimensionNumbers() { + auto attr = getRaggedDotDimensionNumbersAttr(); + return ::llvm::cast<::mlir::chlo::RaggedDotDimensionNumbersAttr>(attr); +} + +::std::optional< ::mlir::ArrayAttr > RaggedDotOp::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +void RaggedDotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value group_sizes, ::mlir::chlo::RaggedDotDimensionNumbersAttr ragged_dot_dimension_numbers, /*optional*/::mlir::ArrayAttr precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(group_sizes); + odsState.getOrAddProperties().ragged_dot_dimension_numbers = ragged_dot_dimension_numbers; + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + odsState.addTypes(result); +} + +void RaggedDotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value group_sizes, ::mlir::chlo::RaggedDotDimensionNumbersAttr ragged_dot_dimension_numbers, /*optional*/::mlir::ArrayAttr precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(group_sizes); + odsState.getOrAddProperties().ragged_dot_dimension_numbers = ragged_dot_dimension_numbers; + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RaggedDotOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void RaggedDotOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RaggedDotOp::verifyInvariantsImpl() { + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + auto tblgen_ragged_dot_dimension_numbers = getProperties().ragged_dot_dimension_numbers; (void)tblgen_ragged_dot_dimension_numbers; + if (!tblgen_ragged_dot_dimension_numbers) return emitOpError("requires attribute 'ragged_dot_dimension_numbers'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps6(*this, tblgen_ragged_dot_dimension_numbers, "ragged_dot_dimension_numbers"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps7(*this, tblgen_precision_config, "precision_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RaggedDotOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +void RaggedDotOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::RaggedDotOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::SinhOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SinhOpGenericAdaptorBase::SinhOpGenericAdaptorBase(SinhOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +SinhOpAdaptor::SinhOpAdaptor(SinhOp op) : SinhOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SinhOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult SinhOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute SinhOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SinhOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional SinhOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void SinhOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void SinhOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult SinhOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void SinhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void SinhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SinhOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SinhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SinhOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SinhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SinhOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void SinhOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SinhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SinhOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult SinhOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SinhOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult SinhOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SinhOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void SinhOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::SinhOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::SquareOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SquareOpGenericAdaptorBase::SquareOpGenericAdaptorBase(SquareOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +SquareOpAdaptor::SquareOpAdaptor(SquareOp op) : SquareOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SquareOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult SquareOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute SquareOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SquareOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional SquareOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void SquareOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void SquareOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult SquareOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void SquareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void SquareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SquareOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SquareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SquareOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SquareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SquareOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void SquareOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SquareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SquareOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult SquareOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SquareOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult SquareOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SquareOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void SquareOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::SquareOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::TanOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TanOpGenericAdaptorBase::TanOpGenericAdaptorBase(TanOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +TanOpAdaptor::TanOpAdaptor(TanOp op) : TanOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TanOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult TanOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute TanOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TanOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional TanOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void TanOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void TanOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult TanOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void TanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void TanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TanOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void TanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TanOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void TanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TanOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void TanOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void TanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TanOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult TanOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TanOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult TanOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawType = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TanOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void TanOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::TanOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::TopKOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TopKOpGenericAdaptorBase::TopKOpGenericAdaptorBase(TopKOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +uint64_t TopKOpGenericAdaptorBase::getK() { + auto attr = getKAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +TopKOpAdaptor::TopKOpAdaptor(TopKOp op) : TopKOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TopKOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_k = getProperties().k; (void)tblgen_k; + if (!tblgen_k) return emitError(loc, "'chlo.top_k' op ""requires attribute 'k'"); + + if (tblgen_k && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_k))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_k).getType().isSignlessInteger(64))))) + return emitError(loc, "'chlo.top_k' op ""attribute 'k' failed to satisfy constraint: 64-bit signless integer attribute"); + return ::mlir::success(); +} + +void TopKOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { + auto resultGroup0 = getODSResults(0); + if (!resultGroup0.empty()) + setNameFn(*resultGroup0.begin(), "values"); + auto resultGroup1 = getODSResults(1); + if (!resultGroup1.empty()) + setNameFn(*resultGroup1.begin(), "indices"); +} + +::llvm::LogicalResult TopKOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.k; + auto attr = dict.get("k"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `k` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute TopKOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.k; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("k", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TopKOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.k.getAsOpaquePointer())); +} + +std::optional TopKOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "k") + return prop.k; + return std::nullopt; +} + +void TopKOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "k") { + prop.k = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void TopKOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.k) attrs.append("k", prop.k); +} + +::llvm::LogicalResult TopKOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getKAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps8(attr, "k", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult TopKOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.k))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TopKOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.k); +} + +uint64_t TopKOp::getK() { + auto attr = getKAttr(); + return attr.getValue().getZExtValue(); +} + +void TopKOp::setK(uint64_t attrValue) { + getProperties().k = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void TopKOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type values, ::mlir::Type indices, ::mlir::Value operand, ::mlir::IntegerAttr k) { + odsState.addOperands(operand); + odsState.getOrAddProperties().k = k; + odsState.addTypes(values); + odsState.addTypes(indices); +} + +void TopKOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::IntegerAttr k) { + odsState.addOperands(operand); + odsState.getOrAddProperties().k = k; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TopKOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void TopKOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::IntegerAttr k) { + odsState.addOperands(operand); + odsState.getOrAddProperties().k = k; + assert(resultTypes.size() == 2u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TopKOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type values, ::mlir::Type indices, ::mlir::Value operand, uint64_t k) { + odsState.addOperands(operand); + odsState.getOrAddProperties().k = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), k); + odsState.addTypes(values); + odsState.addTypes(indices); +} + +void TopKOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, uint64_t k) { + odsState.addOperands(operand); + odsState.getOrAddProperties().k = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), k); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TopKOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void TopKOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, uint64_t k) { + odsState.addOperands(operand); + odsState.getOrAddProperties().k = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), k); + assert(resultTypes.size() == 2u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TopKOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void TopKOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TopKOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void TopKOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void TopKOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TopKOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult TopKOp::verifyInvariantsImpl() { + auto tblgen_k = getProperties().k; (void)tblgen_k; + if (!tblgen_k) return emitOpError("requires attribute 'k'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ChloOps8(*this, tblgen_k, "k"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSResults(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TopKOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult TopKOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::IntegerAttr kAttr; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type valuesRawType{}; + ::llvm::ArrayRef<::mlir::Type> valuesTypes(&valuesRawType, 1); + ::mlir::Type indicesRawType{}; + ::llvm::ArrayRef<::mlir::Type> indicesTypes(&indicesRawType, 1); + if (parser.parseLParen()) + return ::mlir::failure(); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("k")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(kAttr, parser.getBuilder().getIntegerType(64))) { + return ::mlir::failure(); + } + if (kAttr) result.getOrAddProperties().k = kAttr; + if (parser.parseRParen()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + valuesRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + indicesRawType = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + result.addTypes(valuesTypes); + result.addTypes(indicesTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TopKOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << "("; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' ' << "k"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getKAttr()); + _odsPrinter << ")"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("k"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' ' << "("; + { + auto type = getValues().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getIndices().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; +} + +void TopKOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +TopKOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(TopKOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::TopKOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ZetaOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ZetaOpGenericAdaptorBase::ZetaOpGenericAdaptorBase(ZetaOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ZetaOpAdaptor::ZetaOpAdaptor(ZetaOp op) : ZetaOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ZetaOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ZetaOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ZetaOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ZetaOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ZetaOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ZetaOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ZetaOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ZetaOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ZetaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value x, ::mlir::Value q) { + odsState.addOperands(x); + odsState.addOperands(q); + odsState.addTypes(result); +} + +void ZetaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, ::mlir::Value q) { + odsState.addOperands(x); + odsState.addOperands(q); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ZetaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ZetaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value q) { + odsState.addOperands(x); + odsState.addOperands(q); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ZetaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ZetaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ZetaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ZetaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ZetaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ZetaOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ZetaOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ChloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ZetaOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ZetaOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand xRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> xOperands(&xRawOperand, 1); ::llvm::SMLoc xOperandsLoc; + (void)xOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand qRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> qOperands(&qRawOperand, 1); ::llvm::SMLoc qOperandsLoc; + (void)qOperandsLoc; + ::mlir::Type xRawType{}; + ::llvm::ArrayRef<::mlir::Type> xTypes(&xRawType, 1); + ::mlir::Type qRawType{}; + ::llvm::ArrayRef<::mlir::Type> qTypes(&qRawType, 1); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + xOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(xRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + qOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(qRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + xRawType = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + qRawType = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(xOperands, xTypes, xOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(qOperands, qTypes, qOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ZetaOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getX(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getQ(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getX().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getQ().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void ZetaOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace chlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::chlo::ZetaOp) + + +#endif // GET_OP_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloOps.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloOps.h new file mode 100644 index 0000000000000000000000000000000000000000..33c3de5336a8129ce46b0d19e00993b274d1490e --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloOps.h @@ -0,0 +1,80 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + Copyright 2022 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_CHLO_OPS_H +#define STABLEHLO_DIALECT_CHLO_OPS_H + +#include "llvm/ADT/APFloat.h" +#include "llvm/ADT/StringRef.h" +#include "mlir/Bytecode/BytecodeOpInterface.h" +#include "mlir/Dialect/Quant/IR/QuantTypes.h" +#include "mlir/IR/Attributes.h" +#include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/Dialect.h" +#include "mlir/IR/DialectImplementation.h" +#include "mlir/IR/Location.h" +#include "mlir/IR/MLIRContext.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/Operation.h" +#include "mlir/IR/TypeUtilities.h" +#include "mlir/IR/Types.h" +#include "mlir/IR/Value.h" +#include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/InferTypeOpInterface.h" +#include "mlir/Interfaces/SideEffectInterfaces.h" +#include "stablehlo/dialect/Base.h" + +// Include order matters +#include "stablehlo/dialect/ChloEnums.h.inc" +#define GET_ATTRDEF_CLASSES +#include "stablehlo/dialect/ChloAttrs.h.inc" + +namespace mlir { +namespace chlo { + +class ChloDialect : public Dialect { + public: + explicit ChloDialect(MLIRContext* context); + static StringRef getDialectNamespace() { return "chlo"; } + + Operation* materializeConstant(OpBuilder& builder, Attribute value, Type type, + Location loc) override; + + Attribute parseAttribute(DialectAsmParser& parser, Type type) const override; + + void printAttribute(Attribute attr, DialectAsmPrinter& os) const override; +}; + +} // namespace chlo +} // namespace mlir + +namespace mlir { +namespace chlo { +namespace OpTrait { + +template +class Broadcasting + : public mlir::OpTrait::TraitBase {}; + +} // namespace OpTrait +} // namespace chlo +} // namespace mlir + +#define GET_OP_CLASSES +#include "stablehlo/dialect/ChloOps.h.inc" + +#endif // STABLEHLO_DIALECT_CHLO_OPS_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloOps.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloOps.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..e5462c798baa148f3d1a35c5c312fb32bbec12c4 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/ChloOps.h.inc @@ -0,0 +1,10538 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: ChloOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace chlo { +/// Acos operator +/// Returns `Acos(operand)` element-wise. +/// +/// $$ +/// \acos(x) = 2 * \atan(\sqrt(1 - x^2) / (1 + x)) if x != -1 +/// = pi if x == -1 +/// $$ +class AcosOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Acosh operation +/// Returns `Acosh(operand)` element-wise. +/// +/// $$ +/// \acosh(x) = log(x + sqrt(x^2 - 1)) if x >= -1 +/// \acosh(x) = nan if x < -1 +/// $$ +class AcoshOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// AsinAcosKernel operator +/// Returns `AsinAcosKernel(operand)` element-wise. +/// +/// ``` +/// If +/// w = _asin_acos_kernel(z) +/// w' = _asin_acos_kernel(I * z) +/// Then +/// asin(z) = complex(atan2(z.real, w.real), sign(z.imag) * w.imag) +/// acos(z) = complex(atan2(w.real, z.real), -sign(z.imag) * w.imag) +/// asinh(z) = complex(sign(z.real) * w'.imag, atan2(z.imag, w'.real)) +/// acosh(z) = complex(w.imag, sign(z.imag) * atan2(w.real, z.real)) +/// ``` +/// +/// This op is used as an intermediate value in decompositions and +/// should never be constructed directly by frameworks or consumed by +/// backends. +class AsinAcosKernelOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Asin operator +/// Returns `Asin(operand)` element-wise. +/// +/// $$ +/// \asin(x) = 2 * atan(x / (1 + sqrt(1 - x^2))) +/// $$ +class AsinOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Asinh operation +/// Returns `Asinh(operand)` element-wise. +/// +/// $$ +/// \asinh(x) = log(x + sqrt(x^2 + 1)) +/// $$ +class AsinhOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Atan operator +/// Returns `Atan(operand)` element-wise. +/// +/// $$ +/// \atan(x) = \atan2(x, 1) +/// $$ +class AtanOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Atanh operator +/// Returns `Atanh(operand)` element-wise. +/// +/// $$ +/// \atanh(x) = 0.5 * log((1 + x) / (1 - x)) if abs(x) <= 1 +/// = nan otherwise +/// $$ +class AtanhOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Bessel function of order 1 +/// Returns `bessel_i1e(operand)` element-wise. +class BesselI1eOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Addition operator (with optional broadcasting) +/// Returns `lhs + rhs` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastAddOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Logical and operator (with optional broadcasting) +/// Returns `logical_and(lhs, rhs)` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastAndOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Atan2 operator (with optional broadcasting) +/// Returns `atan2(lhs/rhs)` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastAtan2Op; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Compare operator (with optional broadcasting) +/// Compares `lhs` and `rhs` elementwise according to `comparison_direction` +/// and `compare_type`. If unspecified, `compare_type` is FLOAT for float element +/// types, SIGNED for signed element types and UNSIGNED for unsigned element +/// types. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_comparison_operations. +class BroadcastCompareOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Complex operator (with optional broadcasting) +/// Performs element-wise conversion of a pair of real and imaginary values to +/// a complex value. +class BroadcastComplexOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Division operator (with optional broadcasting) +/// Returns `lhs / rhs` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastDivOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Maximum operator (with optional broadcasting) +/// Returns `max(lhs, rhs)` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastMaxOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Minimum operator (with optional broadcasting) +/// Returns `min(lhs, rhs)` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastMinOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Multiplication operator (with optional broadcasting) +/// Returns `lhs * rhs` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastMulOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// std::nextafter operator (with optional broadcasting) +/// Returns the next representable value of `lhs` in the direction of `rhs`, +/// element-wise. It can also return a subnormal number. +/// +/// Equivalent to the C++ std::nextafter function. +class BroadcastNextAfterOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Logical or operator (with optional broadcasting) +/// Returns `logical_or(lhs, rhs)` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastOrOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Polygamma function (with optional broadcasting) +/// Returns `Polygamma(operand, operand)` element-wise. +class BroadcastPolygammaOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Power operator (with optional broadcasting) +/// Returns `lhs ^ rhs` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastPowOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Remainder operator (with optional broadcasting) +/// Returns `lhs % rhs` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastRemOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Select operator (with optional numpy-style broadcasting) +/// Constructs an output array from elements of two input arrays, based on the +/// values of a predicate array. +/// +/// See https://www.tensorflow.org/xla/operation_semantics#select +class BroadcastSelectOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Shift left operator (with optional broadcasting) +/// Returns `lhs << rhs` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastShiftLeftOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Shift right arithmetic operator (with optional broadcasting) +/// Returns `lhs >> rhs` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastShiftRightArithmeticOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Shift right logical operator (with optional broadcasting) +/// Returns `lhs >> rhs` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastShiftRightLogicalOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Subtraction operator (with optional broadcasting) +/// Returns `lhs - rhs` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastSubOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Logical xor operator (with optional broadcasting) +/// Returns `logical_xor(lhs, rhs)` element-wise. +/// +/// See +/// https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. +class BroadcastXorOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Hurwitz zeta function +/// Returns `Zeta(operand, operand)` element-wise. +/// +/// $$ +/// \(\zeta(x, q) = \sum_{n=0}^{\infty} (q + n)^{-x}\) +/// $$ +class BroadcastZetaOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Conj operator +/// Returns `Conj(operand)` element-wise. +/// +/// $$ +/// \conj(x) = (\real(x), \neg(\imag(x))) +/// $$ +class ConjOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Constant like operator +/// Returns a splat constant of the same shape as the operand. +class ConstantLikeOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Constant operator +/// Represents a constant value. +class ConstantOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Cosh operator +/// Returns `Cosh(operand)` element-wise. +/// +/// $$ +/// \cosh(x) = (e^x + e^-x) / 2 +/// $$ +class CoshOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Digamma function +/// Returns `Digamma(operand)` element-wise. +class DigammaOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Inverse Erf +/// Returns `ErfInv(operand)` element-wise. +class ErfInvOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Erfc operator +/// Computes the Gauss error function of `x` element-wise. +/// +/// erf(x) = erf_impl(x) if |x| < 1 +/// = 1 - erfc_impl(x) otherwise +class ErfOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Erfc operator +/// Computes an approximation of the error function complement (1 - erf(x)). +/// +/// erfc(x) = erfc_impl(x) if |x| > 1 +/// = 1 - erf_impl(x) otherwise +class ErfcOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// IsInf predicate +/// Returns if a value is +/-inf element-wise. +class IsInfOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// IsNegInf predicate +/// Returns if a value is -inf element-wise. +class IsNegInfOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// IsPosInf predicate +/// Returns if a value is +inf element-wise. +class IsPosInfOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Lgamma function +/// Returns `Lgamma(operand)` element-wise. +class LgammaOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// std::nextafter operator +/// Returns the next representable value of `x` in the direction of `y`, +/// element-wise. It can also return a subnormal number. +/// +/// Equivalent to the C++ std::nextafter function. +class NextAfterOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Polygamma function +/// Returns `Polygamma(operand, operand)` element-wise. +class PolygammaOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Computes a matmul over a single ragged dimension +/// This operation takes three tensor args---lhs, rhs, and group_sizes---and +/// a "ragged_dot_dimension_numbers" attribute. Like dot_general, the lhs and +/// rhs are allowed arbitrary batch and contracting dimensions. Additionally, +/// the lhs is required to have one ragged dimension, and the rhs may have at +/// most one group dimension. The op has three modes, depending on the kind of +/// the lhs ragged dimension. +/// +/// In mode 1, the shape-signature is `[b,m,k], [g,b,k,n], [b,g] -> [b,m,n]`. +/// Here the ragged dimension is an lhs non-contracting dimension (`m`). The +/// dimensions `b` and `k` represent batch and contracting dimensions +/// respectively. The rhs is required to have a group dimension (`g`). +/// +/// In mode 2, the shape-signature is `[b,m,k], [b,k,n], [b,g] -> [g,b,m,n]`. +/// Here the ragged dimension is an lhs/rhs contracting dimension (`k`). +/// +/// In mode 3, the shape-signature is `[b,m,k], [b,k,n], [g] -> [b,m,n]`. Here +/// the ragged dimension is an lhs/rhs batch dimension (`b`). +class RaggedDotOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Sinh operation +/// Returns `Sinh(operand)` element-wise. +/// +/// $$ +/// \sinh(x) = (e^x - e^-x) / 2 if |x| < 1 +/// = e^(x + log(1/2)) - e^(-x + log(1/2)) otherwise. +/// $$ +class SinhOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Square operation +/// Returns `Square(operand)` element-wise. +/// +/// $$ +/// \square(x) = complex((x.real - x.imag) * (x.real + x.imag), x.real * x.imag * 2) if x is a complex number +/// = x * x otherwise +/// $$ +class SquareOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Tan operation +/// Returns `Tan(operand)` element-wise. +/// +/// $$ +/// \tan(x) = \sin(x) / \cos(x) +/// $$ +class TanOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Finds values and indices of the `k` largest elements for the last dimension +/// If the input is a vector (rank-1), finds the `k` largest entries in the +/// vector and outputs their values and indices as vectors. Thus `values[j]` is +/// the `j`-th largest entry in `input`, and its index is `indices[j]`. +/// +/// For matrices (resp. higher rank input), computes the top `k` entries in each +/// row (resp. vector along the last dimension). Thus, +/// +/// ``` +/// values.shape = indices.shape = input.shape[:-1] + [k] +/// ``` +/// +/// If two elements are equal, the lower-index element appears first. +class TopKOp; +} // namespace chlo +} // namespace mlir +namespace mlir { +namespace chlo { +/// Hurwitz zeta function +/// Returns `Zeta(operand, operand)` element-wise. +/// +/// $$ +/// \(\zeta(x, q) = \sum_{n=0}^{\infty} (q + n)^{-x}\) +/// $$ +class ZetaOp; +} // namespace chlo +} // namespace mlir +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AcosOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AcosOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AcosOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.acos", odsAttrs.getContext()); + } + + AcosOpGenericAdaptorBase(AcosOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AcosOpGenericAdaptor : public detail::AcosOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AcosOpGenericAdaptorBase; +public: + AcosOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AcosOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AcosOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AcosOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AcosOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AcosOpGenericAdaptor(RangeT values, const AcosOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AcosOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AcosOpAdaptor : public AcosOpGenericAdaptor<::mlir::ValueRange> { +public: + using AcosOpGenericAdaptor::AcosOpGenericAdaptor; + AcosOpAdaptor(AcosOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AcosOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = AcosOpAdaptor; + template + using GenericAdaptor = AcosOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.acos"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::AcosOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AcoshOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AcoshOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AcoshOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.acosh", odsAttrs.getContext()); + } + + AcoshOpGenericAdaptorBase(AcoshOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AcoshOpGenericAdaptor : public detail::AcoshOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AcoshOpGenericAdaptorBase; +public: + AcoshOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AcoshOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AcoshOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AcoshOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AcoshOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AcoshOpGenericAdaptor(RangeT values, const AcoshOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AcoshOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AcoshOpAdaptor : public AcoshOpGenericAdaptor<::mlir::ValueRange> { +public: + using AcoshOpGenericAdaptor::AcoshOpGenericAdaptor; + AcoshOpAdaptor(AcoshOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AcoshOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = AcoshOpAdaptor; + template + using GenericAdaptor = AcoshOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.acosh"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::AcoshOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AsinAcosKernelOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AsinAcosKernelOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AsinAcosKernelOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo._asin_acos_kernel", odsAttrs.getContext()); + } + + AsinAcosKernelOpGenericAdaptorBase(AsinAcosKernelOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AsinAcosKernelOpGenericAdaptor : public detail::AsinAcosKernelOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AsinAcosKernelOpGenericAdaptorBase; +public: + AsinAcosKernelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AsinAcosKernelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AsinAcosKernelOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AsinAcosKernelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AsinAcosKernelOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AsinAcosKernelOpGenericAdaptor(RangeT values, const AsinAcosKernelOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AsinAcosKernelOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AsinAcosKernelOpAdaptor : public AsinAcosKernelOpGenericAdaptor<::mlir::ValueRange> { +public: + using AsinAcosKernelOpGenericAdaptor::AsinAcosKernelOpGenericAdaptor; + AsinAcosKernelOpAdaptor(AsinAcosKernelOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AsinAcosKernelOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = AsinAcosKernelOpAdaptor; + template + using GenericAdaptor = AsinAcosKernelOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo._asin_acos_kernel"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::AsinAcosKernelOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AsinOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AsinOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AsinOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.asin", odsAttrs.getContext()); + } + + AsinOpGenericAdaptorBase(AsinOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AsinOpGenericAdaptor : public detail::AsinOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AsinOpGenericAdaptorBase; +public: + AsinOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AsinOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AsinOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AsinOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AsinOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AsinOpGenericAdaptor(RangeT values, const AsinOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AsinOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AsinOpAdaptor : public AsinOpGenericAdaptor<::mlir::ValueRange> { +public: + using AsinOpGenericAdaptor::AsinOpGenericAdaptor; + AsinOpAdaptor(AsinOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AsinOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = AsinOpAdaptor; + template + using GenericAdaptor = AsinOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.asin"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::AsinOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AsinhOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AsinhOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AsinhOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.asinh", odsAttrs.getContext()); + } + + AsinhOpGenericAdaptorBase(AsinhOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AsinhOpGenericAdaptor : public detail::AsinhOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AsinhOpGenericAdaptorBase; +public: + AsinhOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AsinhOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AsinhOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AsinhOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AsinhOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AsinhOpGenericAdaptor(RangeT values, const AsinhOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AsinhOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AsinhOpAdaptor : public AsinhOpGenericAdaptor<::mlir::ValueRange> { +public: + using AsinhOpGenericAdaptor::AsinhOpGenericAdaptor; + AsinhOpAdaptor(AsinhOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AsinhOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = AsinhOpAdaptor; + template + using GenericAdaptor = AsinhOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.asinh"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::AsinhOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AtanOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AtanOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AtanOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.atan", odsAttrs.getContext()); + } + + AtanOpGenericAdaptorBase(AtanOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AtanOpGenericAdaptor : public detail::AtanOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AtanOpGenericAdaptorBase; +public: + AtanOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AtanOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AtanOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AtanOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AtanOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AtanOpGenericAdaptor(RangeT values, const AtanOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AtanOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AtanOpAdaptor : public AtanOpGenericAdaptor<::mlir::ValueRange> { +public: + using AtanOpGenericAdaptor::AtanOpGenericAdaptor; + AtanOpAdaptor(AtanOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AtanOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = AtanOpAdaptor; + template + using GenericAdaptor = AtanOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.atan"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::AtanOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::AtanhOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AtanhOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AtanhOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.atanh", odsAttrs.getContext()); + } + + AtanhOpGenericAdaptorBase(AtanhOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AtanhOpGenericAdaptor : public detail::AtanhOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AtanhOpGenericAdaptorBase; +public: + AtanhOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AtanhOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AtanhOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AtanhOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AtanhOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AtanhOpGenericAdaptor(RangeT values, const AtanhOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AtanhOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AtanhOpAdaptor : public AtanhOpGenericAdaptor<::mlir::ValueRange> { +public: + using AtanhOpGenericAdaptor::AtanhOpGenericAdaptor; + AtanhOpAdaptor(AtanhOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AtanhOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = AtanhOpAdaptor; + template + using GenericAdaptor = AtanhOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.atanh"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::AtanhOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BesselI1eOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BesselI1eOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BesselI1eOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.bessel_i1e", odsAttrs.getContext()); + } + + BesselI1eOpGenericAdaptorBase(BesselI1eOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class BesselI1eOpGenericAdaptor : public detail::BesselI1eOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BesselI1eOpGenericAdaptorBase; +public: + BesselI1eOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BesselI1eOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BesselI1eOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BesselI1eOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BesselI1eOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BesselI1eOpGenericAdaptor(RangeT values, const BesselI1eOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BesselI1eOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BesselI1eOpAdaptor : public BesselI1eOpGenericAdaptor<::mlir::ValueRange> { +public: + using BesselI1eOpGenericAdaptor::BesselI1eOpGenericAdaptor; + BesselI1eOpAdaptor(BesselI1eOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BesselI1eOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = BesselI1eOpAdaptor; + template + using GenericAdaptor = BesselI1eOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.bessel_i1e"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BesselI1eOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastAddOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastAddOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastAddOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_add", odsAttrs.getContext()); + } + + BroadcastAddOpGenericAdaptorBase(BroadcastAddOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastAddOpGenericAdaptor : public detail::BroadcastAddOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastAddOpGenericAdaptorBase; +public: + BroadcastAddOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastAddOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastAddOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastAddOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastAddOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastAddOpGenericAdaptor(RangeT values, const BroadcastAddOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastAddOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastAddOpAdaptor : public BroadcastAddOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastAddOpGenericAdaptor::BroadcastAddOpGenericAdaptor; + BroadcastAddOpAdaptor(BroadcastAddOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastAddOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastAddOpAdaptor; + template + using GenericAdaptor = BroadcastAddOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_add"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastAddOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastAndOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastAndOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastAndOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_and", odsAttrs.getContext()); + } + + BroadcastAndOpGenericAdaptorBase(BroadcastAndOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastAndOpGenericAdaptor : public detail::BroadcastAndOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastAndOpGenericAdaptorBase; +public: + BroadcastAndOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastAndOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastAndOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastAndOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastAndOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastAndOpGenericAdaptor(RangeT values, const BroadcastAndOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastAndOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastAndOpAdaptor : public BroadcastAndOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastAndOpGenericAdaptor::BroadcastAndOpGenericAdaptor; + BroadcastAndOpAdaptor(BroadcastAndOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastAndOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastAndOpAdaptor; + template + using GenericAdaptor = BroadcastAndOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_and"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastAndOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastAtan2Op declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastAtan2OpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastAtan2OpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_atan2", odsAttrs.getContext()); + } + + BroadcastAtan2OpGenericAdaptorBase(BroadcastAtan2Op op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastAtan2OpGenericAdaptor : public detail::BroadcastAtan2OpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastAtan2OpGenericAdaptorBase; +public: + BroadcastAtan2OpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastAtan2OpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastAtan2OpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastAtan2OpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastAtan2OpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastAtan2OpGenericAdaptor(RangeT values, const BroadcastAtan2OpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastAtan2OpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastAtan2OpAdaptor : public BroadcastAtan2OpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastAtan2OpGenericAdaptor::BroadcastAtan2OpGenericAdaptor; + BroadcastAtan2OpAdaptor(BroadcastAtan2Op op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastAtan2Op : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastAtan2OpAdaptor; + template + using GenericAdaptor = BroadcastAtan2OpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_atan2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastAtan2Op) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastCompareOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastCompareOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + using compare_typeTy = ::mlir::chlo::ComparisonTypeAttr; + compare_typeTy compare_type; + + auto getCompareType() const { + auto &propStorage = this->compare_type; + return ::llvm::dyn_cast_or_null<::mlir::chlo::ComparisonTypeAttr>(propStorage); + } + void setCompareType(const ::mlir::chlo::ComparisonTypeAttr &propValue) { + this->compare_type = propValue; + } + using comparison_directionTy = ::mlir::chlo::ComparisonDirectionAttr; + comparison_directionTy comparison_direction; + + auto getComparisonDirection() const { + auto &propStorage = this->comparison_direction; + return ::llvm::cast<::mlir::chlo::ComparisonDirectionAttr>(propStorage); + } + void setComparisonDirection(const ::mlir::chlo::ComparisonDirectionAttr &propValue) { + this->comparison_direction = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + rhs.compare_type == this->compare_type && + rhs.comparison_direction == this->comparison_direction && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastCompareOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_compare", odsAttrs.getContext()); + } + + BroadcastCompareOpGenericAdaptorBase(BroadcastCompareOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + ::mlir::chlo::ComparisonDirectionAttr getComparisonDirectionAttr() { + auto attr = ::llvm::cast<::mlir::chlo::ComparisonDirectionAttr>(getProperties().comparison_direction); + return attr; + } + + ::mlir::chlo::ComparisonDirection getComparisonDirection(); + ::mlir::chlo::ComparisonTypeAttr getCompareTypeAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::chlo::ComparisonTypeAttr>(getProperties().compare_type); + return attr; + } + + ::std::optional<::mlir::chlo::ComparisonType> getCompareType(); +}; +} // namespace detail +template +class BroadcastCompareOpGenericAdaptor : public detail::BroadcastCompareOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastCompareOpGenericAdaptorBase; +public: + BroadcastCompareOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastCompareOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastCompareOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastCompareOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastCompareOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastCompareOpGenericAdaptor(RangeT values, const BroadcastCompareOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastCompareOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastCompareOpAdaptor : public BroadcastCompareOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastCompareOpGenericAdaptor::BroadcastCompareOpGenericAdaptor; + BroadcastCompareOpAdaptor(BroadcastCompareOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastCompareOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastCompareOpAdaptor; + template + using GenericAdaptor = BroadcastCompareOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions"), ::llvm::StringRef("compare_type"), ::llvm::StringRef("comparison_direction")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getCompareTypeAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getCompareTypeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getComparisonDirectionAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getComparisonDirectionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_compare"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + ::mlir::chlo::ComparisonDirectionAttr getComparisonDirectionAttr() { + return ::llvm::cast<::mlir::chlo::ComparisonDirectionAttr>(getProperties().comparison_direction); + } + + ::mlir::chlo::ComparisonDirection getComparisonDirection(); + ::mlir::chlo::ComparisonTypeAttr getCompareTypeAttr() { + return ::llvm::dyn_cast_or_null<::mlir::chlo::ComparisonTypeAttr>(getProperties().compare_type); + } + + ::std::optional<::mlir::chlo::ComparisonType> getCompareType(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + void setComparisonDirectionAttr(::mlir::chlo::ComparisonDirectionAttr attr) { + getProperties().comparison_direction = attr; + } + + void setComparisonDirection(::mlir::chlo::ComparisonDirection attrValue); + void setCompareTypeAttr(::mlir::chlo::ComparisonTypeAttr attr) { + getProperties().compare_type = attr; + } + + void setCompareType(::std::optional<::mlir::chlo::ComparisonType> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + ::mlir::Attribute removeCompareTypeAttr() { + auto attr = getProperties().compare_type; + getProperties().compare_type = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, DenseI64ArrayAttr broadcast_dimensions, ::mlir::chlo::ComparisonDirection comparison_direction, ::mlir::chlo::ComparisonType compare_type = ::mlir::chlo::ComparisonType::NOTYPE); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions, ::mlir::chlo::ComparisonDirectionAttr comparison_direction, /*optional*/::mlir::chlo::ComparisonTypeAttr compare_type); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions, ::mlir::chlo::ComparisonDirectionAttr comparison_direction, /*optional*/::mlir::chlo::ComparisonTypeAttr compare_type); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions, ::mlir::chlo::ComparisonDirectionAttr comparison_direction, /*optional*/::mlir::chlo::ComparisonTypeAttr compare_type); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions, ::mlir::chlo::ComparisonDirection comparison_direction, /*optional*/::mlir::chlo::ComparisonTypeAttr compare_type); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions, ::mlir::chlo::ComparisonDirection comparison_direction, /*optional*/::mlir::chlo::ComparisonTypeAttr compare_type); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions, ::mlir::chlo::ComparisonDirection comparison_direction, /*optional*/::mlir::chlo::ComparisonTypeAttr compare_type); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastCompareOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastComplexOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastComplexOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastComplexOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_complex", odsAttrs.getContext()); + } + + BroadcastComplexOpGenericAdaptorBase(BroadcastComplexOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastComplexOpGenericAdaptor : public detail::BroadcastComplexOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastComplexOpGenericAdaptorBase; +public: + BroadcastComplexOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastComplexOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastComplexOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastComplexOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastComplexOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastComplexOpGenericAdaptor(RangeT values, const BroadcastComplexOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastComplexOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastComplexOpAdaptor : public BroadcastComplexOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastComplexOpGenericAdaptor::BroadcastComplexOpGenericAdaptor; + BroadcastComplexOpAdaptor(BroadcastComplexOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastComplexOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastComplexOpAdaptor; + template + using GenericAdaptor = BroadcastComplexOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_complex"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastComplexOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastDivOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastDivOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastDivOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_divide", odsAttrs.getContext()); + } + + BroadcastDivOpGenericAdaptorBase(BroadcastDivOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastDivOpGenericAdaptor : public detail::BroadcastDivOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastDivOpGenericAdaptorBase; +public: + BroadcastDivOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastDivOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastDivOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastDivOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastDivOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastDivOpGenericAdaptor(RangeT values, const BroadcastDivOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastDivOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastDivOpAdaptor : public BroadcastDivOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastDivOpGenericAdaptor::BroadcastDivOpGenericAdaptor; + BroadcastDivOpAdaptor(BroadcastDivOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastDivOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastDivOpAdaptor; + template + using GenericAdaptor = BroadcastDivOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_divide"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastDivOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastMaxOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastMaxOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastMaxOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_maximum", odsAttrs.getContext()); + } + + BroadcastMaxOpGenericAdaptorBase(BroadcastMaxOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastMaxOpGenericAdaptor : public detail::BroadcastMaxOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastMaxOpGenericAdaptorBase; +public: + BroadcastMaxOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastMaxOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastMaxOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastMaxOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastMaxOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastMaxOpGenericAdaptor(RangeT values, const BroadcastMaxOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastMaxOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastMaxOpAdaptor : public BroadcastMaxOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastMaxOpGenericAdaptor::BroadcastMaxOpGenericAdaptor; + BroadcastMaxOpAdaptor(BroadcastMaxOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastMaxOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastMaxOpAdaptor; + template + using GenericAdaptor = BroadcastMaxOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_maximum"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastMaxOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastMinOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastMinOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastMinOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_minimum", odsAttrs.getContext()); + } + + BroadcastMinOpGenericAdaptorBase(BroadcastMinOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastMinOpGenericAdaptor : public detail::BroadcastMinOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastMinOpGenericAdaptorBase; +public: + BroadcastMinOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastMinOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastMinOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastMinOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastMinOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastMinOpGenericAdaptor(RangeT values, const BroadcastMinOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastMinOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastMinOpAdaptor : public BroadcastMinOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastMinOpGenericAdaptor::BroadcastMinOpGenericAdaptor; + BroadcastMinOpAdaptor(BroadcastMinOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastMinOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastMinOpAdaptor; + template + using GenericAdaptor = BroadcastMinOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_minimum"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastMinOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastMulOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastMulOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastMulOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_multiply", odsAttrs.getContext()); + } + + BroadcastMulOpGenericAdaptorBase(BroadcastMulOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastMulOpGenericAdaptor : public detail::BroadcastMulOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastMulOpGenericAdaptorBase; +public: + BroadcastMulOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastMulOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastMulOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastMulOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastMulOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastMulOpGenericAdaptor(RangeT values, const BroadcastMulOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastMulOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastMulOpAdaptor : public BroadcastMulOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastMulOpGenericAdaptor::BroadcastMulOpGenericAdaptor; + BroadcastMulOpAdaptor(BroadcastMulOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastMulOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastMulOpAdaptor; + template + using GenericAdaptor = BroadcastMulOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_multiply"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastMulOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastNextAfterOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastNextAfterOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastNextAfterOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_next_after", odsAttrs.getContext()); + } + + BroadcastNextAfterOpGenericAdaptorBase(BroadcastNextAfterOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastNextAfterOpGenericAdaptor : public detail::BroadcastNextAfterOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastNextAfterOpGenericAdaptorBase; +public: + BroadcastNextAfterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastNextAfterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastNextAfterOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastNextAfterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastNextAfterOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastNextAfterOpGenericAdaptor(RangeT values, const BroadcastNextAfterOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastNextAfterOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastNextAfterOpAdaptor : public BroadcastNextAfterOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastNextAfterOpGenericAdaptor::BroadcastNextAfterOpGenericAdaptor; + BroadcastNextAfterOpAdaptor(BroadcastNextAfterOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastNextAfterOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastNextAfterOpAdaptor; + template + using GenericAdaptor = BroadcastNextAfterOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_next_after"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastNextAfterOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastOrOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastOrOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastOrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_or", odsAttrs.getContext()); + } + + BroadcastOrOpGenericAdaptorBase(BroadcastOrOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastOrOpGenericAdaptor : public detail::BroadcastOrOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastOrOpGenericAdaptorBase; +public: + BroadcastOrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastOrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastOrOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastOrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastOrOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastOrOpGenericAdaptor(RangeT values, const BroadcastOrOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastOrOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastOrOpAdaptor : public BroadcastOrOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastOrOpGenericAdaptor::BroadcastOrOpGenericAdaptor; + BroadcastOrOpAdaptor(BroadcastOrOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastOrOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastOrOpAdaptor; + template + using GenericAdaptor = BroadcastOrOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_or"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastOrOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastPolygammaOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastPolygammaOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastPolygammaOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_polygamma", odsAttrs.getContext()); + } + + BroadcastPolygammaOpGenericAdaptorBase(BroadcastPolygammaOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastPolygammaOpGenericAdaptor : public detail::BroadcastPolygammaOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastPolygammaOpGenericAdaptorBase; +public: + BroadcastPolygammaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastPolygammaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastPolygammaOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastPolygammaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastPolygammaOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastPolygammaOpGenericAdaptor(RangeT values, const BroadcastPolygammaOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastPolygammaOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastPolygammaOpAdaptor : public BroadcastPolygammaOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastPolygammaOpGenericAdaptor::BroadcastPolygammaOpGenericAdaptor; + BroadcastPolygammaOpAdaptor(BroadcastPolygammaOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastPolygammaOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastPolygammaOpAdaptor; + template + using GenericAdaptor = BroadcastPolygammaOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_polygamma"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastPolygammaOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastPowOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastPowOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastPowOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_power", odsAttrs.getContext()); + } + + BroadcastPowOpGenericAdaptorBase(BroadcastPowOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastPowOpGenericAdaptor : public detail::BroadcastPowOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastPowOpGenericAdaptorBase; +public: + BroadcastPowOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastPowOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastPowOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastPowOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastPowOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastPowOpGenericAdaptor(RangeT values, const BroadcastPowOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastPowOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastPowOpAdaptor : public BroadcastPowOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastPowOpGenericAdaptor::BroadcastPowOpGenericAdaptor; + BroadcastPowOpAdaptor(BroadcastPowOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastPowOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastPowOpAdaptor; + template + using GenericAdaptor = BroadcastPowOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_power"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastPowOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastRemOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastRemOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastRemOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_remainder", odsAttrs.getContext()); + } + + BroadcastRemOpGenericAdaptorBase(BroadcastRemOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastRemOpGenericAdaptor : public detail::BroadcastRemOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastRemOpGenericAdaptorBase; +public: + BroadcastRemOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastRemOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastRemOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastRemOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastRemOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastRemOpGenericAdaptor(RangeT values, const BroadcastRemOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastRemOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastRemOpAdaptor : public BroadcastRemOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastRemOpGenericAdaptor::BroadcastRemOpGenericAdaptor; + BroadcastRemOpAdaptor(BroadcastRemOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastRemOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastRemOpAdaptor; + template + using GenericAdaptor = BroadcastRemOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_remainder"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastRemOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastSelectOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastSelectOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastSelectOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_select", odsAttrs.getContext()); + } + + BroadcastSelectOpGenericAdaptorBase(BroadcastSelectOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class BroadcastSelectOpGenericAdaptor : public detail::BroadcastSelectOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastSelectOpGenericAdaptorBase; +public: + BroadcastSelectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastSelectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastSelectOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastSelectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastSelectOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastSelectOpGenericAdaptor(RangeT values, const BroadcastSelectOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastSelectOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getPred() { + return (*getODSOperands(0).begin()); + } + + ValueT getOnTrue() { + return (*getODSOperands(1).begin()); + } + + ValueT getOnFalse() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastSelectOpAdaptor : public BroadcastSelectOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastSelectOpGenericAdaptor::BroadcastSelectOpGenericAdaptor; + BroadcastSelectOpAdaptor(BroadcastSelectOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastSelectOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastSelectOpAdaptor; + template + using GenericAdaptor = BroadcastSelectOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_select"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getPred() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getOnTrue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getOnFalse() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getPredMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOnTrueMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOnFalseMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return succeeded(mlir::verifyCompatibleShapes(l, r)); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastSelectOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastShiftLeftOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastShiftLeftOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastShiftLeftOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_shift_left", odsAttrs.getContext()); + } + + BroadcastShiftLeftOpGenericAdaptorBase(BroadcastShiftLeftOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastShiftLeftOpGenericAdaptor : public detail::BroadcastShiftLeftOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastShiftLeftOpGenericAdaptorBase; +public: + BroadcastShiftLeftOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastShiftLeftOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastShiftLeftOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastShiftLeftOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastShiftLeftOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastShiftLeftOpGenericAdaptor(RangeT values, const BroadcastShiftLeftOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastShiftLeftOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastShiftLeftOpAdaptor : public BroadcastShiftLeftOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastShiftLeftOpGenericAdaptor::BroadcastShiftLeftOpGenericAdaptor; + BroadcastShiftLeftOpAdaptor(BroadcastShiftLeftOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastShiftLeftOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastShiftLeftOpAdaptor; + template + using GenericAdaptor = BroadcastShiftLeftOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_shift_left"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastShiftLeftOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastShiftRightArithmeticOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastShiftRightArithmeticOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastShiftRightArithmeticOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_shift_right_arithmetic", odsAttrs.getContext()); + } + + BroadcastShiftRightArithmeticOpGenericAdaptorBase(BroadcastShiftRightArithmeticOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastShiftRightArithmeticOpGenericAdaptor : public detail::BroadcastShiftRightArithmeticOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastShiftRightArithmeticOpGenericAdaptorBase; +public: + BroadcastShiftRightArithmeticOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastShiftRightArithmeticOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastShiftRightArithmeticOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastShiftRightArithmeticOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastShiftRightArithmeticOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastShiftRightArithmeticOpGenericAdaptor(RangeT values, const BroadcastShiftRightArithmeticOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastShiftRightArithmeticOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastShiftRightArithmeticOpAdaptor : public BroadcastShiftRightArithmeticOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastShiftRightArithmeticOpGenericAdaptor::BroadcastShiftRightArithmeticOpGenericAdaptor; + BroadcastShiftRightArithmeticOpAdaptor(BroadcastShiftRightArithmeticOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastShiftRightArithmeticOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastShiftRightArithmeticOpAdaptor; + template + using GenericAdaptor = BroadcastShiftRightArithmeticOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_shift_right_arithmetic"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastShiftRightArithmeticOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastShiftRightLogicalOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastShiftRightLogicalOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastShiftRightLogicalOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_shift_right_logical", odsAttrs.getContext()); + } + + BroadcastShiftRightLogicalOpGenericAdaptorBase(BroadcastShiftRightLogicalOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastShiftRightLogicalOpGenericAdaptor : public detail::BroadcastShiftRightLogicalOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastShiftRightLogicalOpGenericAdaptorBase; +public: + BroadcastShiftRightLogicalOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastShiftRightLogicalOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastShiftRightLogicalOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastShiftRightLogicalOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastShiftRightLogicalOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastShiftRightLogicalOpGenericAdaptor(RangeT values, const BroadcastShiftRightLogicalOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastShiftRightLogicalOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastShiftRightLogicalOpAdaptor : public BroadcastShiftRightLogicalOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastShiftRightLogicalOpGenericAdaptor::BroadcastShiftRightLogicalOpGenericAdaptor; + BroadcastShiftRightLogicalOpAdaptor(BroadcastShiftRightLogicalOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastShiftRightLogicalOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastShiftRightLogicalOpAdaptor; + template + using GenericAdaptor = BroadcastShiftRightLogicalOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_shift_right_logical"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastShiftRightLogicalOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastSubOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastSubOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastSubOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_subtract", odsAttrs.getContext()); + } + + BroadcastSubOpGenericAdaptorBase(BroadcastSubOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastSubOpGenericAdaptor : public detail::BroadcastSubOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastSubOpGenericAdaptorBase; +public: + BroadcastSubOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastSubOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastSubOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastSubOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastSubOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastSubOpGenericAdaptor(RangeT values, const BroadcastSubOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastSubOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastSubOpAdaptor : public BroadcastSubOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastSubOpGenericAdaptor::BroadcastSubOpGenericAdaptor; + BroadcastSubOpAdaptor(BroadcastSubOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastSubOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastSubOpAdaptor; + template + using GenericAdaptor = BroadcastSubOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_subtract"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastSubOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastXorOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastXorOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastXorOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_xor", odsAttrs.getContext()); + } + + BroadcastXorOpGenericAdaptorBase(BroadcastXorOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastXorOpGenericAdaptor : public detail::BroadcastXorOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastXorOpGenericAdaptorBase; +public: + BroadcastXorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastXorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastXorOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastXorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastXorOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastXorOpGenericAdaptor(RangeT values, const BroadcastXorOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastXorOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastXorOpAdaptor : public BroadcastXorOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastXorOpGenericAdaptor::BroadcastXorOpGenericAdaptor; + BroadcastXorOpAdaptor(BroadcastXorOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastXorOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastXorOpAdaptor; + template + using GenericAdaptor = BroadcastXorOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_xor"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastXorOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::BroadcastZetaOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastZetaOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastZetaOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.broadcast_zeta", odsAttrs.getContext()); + } + + BroadcastZetaOpGenericAdaptorBase(BroadcastZetaOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastZetaOpGenericAdaptor : public detail::BroadcastZetaOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastZetaOpGenericAdaptorBase; +public: + BroadcastZetaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastZetaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastZetaOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastZetaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastZetaOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastZetaOpGenericAdaptor(RangeT values, const BroadcastZetaOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastZetaOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastZetaOpAdaptor : public BroadcastZetaOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastZetaOpGenericAdaptor::BroadcastZetaOpGenericAdaptor; + BroadcastZetaOpAdaptor(BroadcastZetaOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastZetaOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastZetaOpAdaptor; + template + using GenericAdaptor = BroadcastZetaOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.broadcast_zeta"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeBroadcastDimensionsAttr() { + auto attr = getProperties().broadcast_dimensions; + getProperties().broadcast_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::BroadcastZetaOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ConjOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConjOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConjOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.conj", odsAttrs.getContext()); + } + + ConjOpGenericAdaptorBase(ConjOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ConjOpGenericAdaptor : public detail::ConjOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConjOpGenericAdaptorBase; +public: + ConjOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConjOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConjOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ConjOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ConjOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ConjOpGenericAdaptor(RangeT values, const ConjOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ConjOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConjOpAdaptor : public ConjOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConjOpGenericAdaptor::ConjOpGenericAdaptor; + ConjOpAdaptor(ConjOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ConjOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConjOpAdaptor; + template + using GenericAdaptor = ConjOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.conj"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::ConjOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ConstantLikeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConstantLikeOpGenericAdaptorBase { +public: + struct Properties { + using valueTy = ::mlir::TypedAttr; + valueTy value; + + auto getValue() const { + auto &propStorage = this->value; + return ::llvm::cast<::mlir::TypedAttr>(propStorage); + } + void setValue(const ::mlir::TypedAttr &propValue) { + this->value = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.value == this->value && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConstantLikeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.constant_like", odsAttrs.getContext()); + } + + ConstantLikeOpGenericAdaptorBase(ConstantLikeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::TypedAttr getValueAttr() { + auto attr = ::llvm::cast<::mlir::TypedAttr>(getProperties().value); + return attr; + } + + ::mlir::TypedAttr getValue(); +}; +} // namespace detail +template +class ConstantLikeOpGenericAdaptor : public detail::ConstantLikeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConstantLikeOpGenericAdaptorBase; +public: + ConstantLikeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConstantLikeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConstantLikeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ConstantLikeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ConstantLikeOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ConstantLikeOpGenericAdaptor(RangeT values, const ConstantLikeOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ConstantLikeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConstantLikeOpAdaptor : public ConstantLikeOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConstantLikeOpGenericAdaptor::ConstantLikeOpGenericAdaptor; + ConstantLikeOpAdaptor(ConstantLikeOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ConstantLikeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::chlo::OpTrait::Broadcasting, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConstantLikeOpAdaptor; + template + using GenericAdaptor = ConstantLikeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("value")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getValueAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getValueAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.constant_like"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::TypedAttr getValueAttr() { + return ::llvm::cast<::mlir::TypedAttr>(getProperties().value); + } + + ::mlir::TypedAttr getValue(); + void setValueAttr(::mlir::TypedAttr attr) { + getProperties().value = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::TypedAttr value, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypedAttr value, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::TypedAttr value, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::ConstantLikeOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ConstantOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConstantOpGenericAdaptorBase { +public: + struct Properties { + using valueTy = ::mlir::ElementsAttr; + valueTy value; + + auto getValue() const { + auto &propStorage = this->value; + return ::llvm::cast<::mlir::ElementsAttr>(propStorage); + } + void setValue(const ::mlir::ElementsAttr &propValue) { + this->value = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.value == this->value && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConstantOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.constant", odsAttrs.getContext()); + } + + ConstantOpGenericAdaptorBase(ConstantOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::ElementsAttr getValueAttr() { + auto attr = ::llvm::cast<::mlir::ElementsAttr>(getProperties().value); + return attr; + } + + ::mlir::ElementsAttr getValue(); +}; +} // namespace detail +template +class ConstantOpGenericAdaptor : public detail::ConstantOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConstantOpGenericAdaptorBase; +public: + ConstantOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConstantOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConstantOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ConstantOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ConstantOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ConstantOpGenericAdaptor(RangeT values, const ConstantOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ConstantOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConstantOpAdaptor : public ConstantOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConstantOpGenericAdaptor::ConstantOpGenericAdaptor; + ConstantOpAdaptor(ConstantOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ConstantOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::ConstantLike, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConstantOpAdaptor; + template + using GenericAdaptor = ConstantOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("value")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getValueAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getValueAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.constant"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ElementsAttr getValueAttr() { + return ::llvm::cast<::mlir::ElementsAttr>(getProperties().value); + } + + ::mlir::ElementsAttr getValue(); + void setValueAttr(::mlir::ElementsAttr attr) { + getProperties().value = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::ElementsAttr value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ElementsAttr value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ElementsAttr value); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::ConstantOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::CoshOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CoshOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CoshOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.cosh", odsAttrs.getContext()); + } + + CoshOpGenericAdaptorBase(CoshOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class CoshOpGenericAdaptor : public detail::CoshOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CoshOpGenericAdaptorBase; +public: + CoshOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CoshOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CoshOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CoshOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CoshOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + CoshOpGenericAdaptor(RangeT values, const CoshOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CoshOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CoshOpAdaptor : public CoshOpGenericAdaptor<::mlir::ValueRange> { +public: + using CoshOpGenericAdaptor::CoshOpGenericAdaptor; + CoshOpAdaptor(CoshOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CoshOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = CoshOpAdaptor; + template + using GenericAdaptor = CoshOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.cosh"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::CoshOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::DigammaOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DigammaOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DigammaOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.digamma", odsAttrs.getContext()); + } + + DigammaOpGenericAdaptorBase(DigammaOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class DigammaOpGenericAdaptor : public detail::DigammaOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DigammaOpGenericAdaptorBase; +public: + DigammaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DigammaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DigammaOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DigammaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DigammaOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + DigammaOpGenericAdaptor(RangeT values, const DigammaOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DigammaOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DigammaOpAdaptor : public DigammaOpGenericAdaptor<::mlir::ValueRange> { +public: + using DigammaOpGenericAdaptor::DigammaOpGenericAdaptor; + DigammaOpAdaptor(DigammaOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DigammaOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = DigammaOpAdaptor; + template + using GenericAdaptor = DigammaOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.digamma"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::DigammaOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ErfInvOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ErfInvOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ErfInvOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.erf_inv", odsAttrs.getContext()); + } + + ErfInvOpGenericAdaptorBase(ErfInvOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ErfInvOpGenericAdaptor : public detail::ErfInvOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ErfInvOpGenericAdaptorBase; +public: + ErfInvOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ErfInvOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ErfInvOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ErfInvOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ErfInvOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ErfInvOpGenericAdaptor(RangeT values, const ErfInvOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ErfInvOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ErfInvOpAdaptor : public ErfInvOpGenericAdaptor<::mlir::ValueRange> { +public: + using ErfInvOpGenericAdaptor::ErfInvOpGenericAdaptor; + ErfInvOpAdaptor(ErfInvOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ErfInvOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = ErfInvOpAdaptor; + template + using GenericAdaptor = ErfInvOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.erf_inv"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::ErfInvOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ErfOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ErfOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ErfOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.erf", odsAttrs.getContext()); + } + + ErfOpGenericAdaptorBase(ErfOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ErfOpGenericAdaptor : public detail::ErfOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ErfOpGenericAdaptorBase; +public: + ErfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ErfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ErfOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ErfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ErfOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ErfOpGenericAdaptor(RangeT values, const ErfOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ErfOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ErfOpAdaptor : public ErfOpGenericAdaptor<::mlir::ValueRange> { +public: + using ErfOpGenericAdaptor::ErfOpGenericAdaptor; + ErfOpAdaptor(ErfOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ErfOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = ErfOpAdaptor; + template + using GenericAdaptor = ErfOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.erf"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::ErfOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ErfcOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ErfcOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ErfcOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.erfc", odsAttrs.getContext()); + } + + ErfcOpGenericAdaptorBase(ErfcOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ErfcOpGenericAdaptor : public detail::ErfcOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ErfcOpGenericAdaptorBase; +public: + ErfcOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ErfcOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ErfcOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ErfcOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ErfcOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ErfcOpGenericAdaptor(RangeT values, const ErfcOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ErfcOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ErfcOpAdaptor : public ErfcOpGenericAdaptor<::mlir::ValueRange> { +public: + using ErfcOpGenericAdaptor::ErfcOpGenericAdaptor; + ErfcOpAdaptor(ErfcOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ErfcOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = ErfcOpAdaptor; + template + using GenericAdaptor = ErfcOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.erfc"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::ErfcOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::IsInfOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IsInfOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + IsInfOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.is_inf", odsAttrs.getContext()); + } + + IsInfOpGenericAdaptorBase(IsInfOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class IsInfOpGenericAdaptor : public detail::IsInfOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IsInfOpGenericAdaptorBase; +public: + IsInfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IsInfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IsInfOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + IsInfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : IsInfOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + IsInfOpGenericAdaptor(RangeT values, const IsInfOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + IsInfOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class IsInfOpAdaptor : public IsInfOpGenericAdaptor<::mlir::ValueRange> { +public: + using IsInfOpGenericAdaptor::IsInfOpGenericAdaptor; + IsInfOpAdaptor(IsInfOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class IsInfOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = IsInfOpAdaptor; + template + using GenericAdaptor = IsInfOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.is_inf"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::IsInfOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::IsNegInfOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IsNegInfOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + IsNegInfOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.is_neg_inf", odsAttrs.getContext()); + } + + IsNegInfOpGenericAdaptorBase(IsNegInfOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class IsNegInfOpGenericAdaptor : public detail::IsNegInfOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IsNegInfOpGenericAdaptorBase; +public: + IsNegInfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IsNegInfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IsNegInfOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + IsNegInfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : IsNegInfOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + IsNegInfOpGenericAdaptor(RangeT values, const IsNegInfOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + IsNegInfOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class IsNegInfOpAdaptor : public IsNegInfOpGenericAdaptor<::mlir::ValueRange> { +public: + using IsNegInfOpGenericAdaptor::IsNegInfOpGenericAdaptor; + IsNegInfOpAdaptor(IsNegInfOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class IsNegInfOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = IsNegInfOpAdaptor; + template + using GenericAdaptor = IsNegInfOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.is_neg_inf"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::IsNegInfOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::IsPosInfOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IsPosInfOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + IsPosInfOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.is_pos_inf", odsAttrs.getContext()); + } + + IsPosInfOpGenericAdaptorBase(IsPosInfOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class IsPosInfOpGenericAdaptor : public detail::IsPosInfOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IsPosInfOpGenericAdaptorBase; +public: + IsPosInfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IsPosInfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IsPosInfOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + IsPosInfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : IsPosInfOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + IsPosInfOpGenericAdaptor(RangeT values, const IsPosInfOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + IsPosInfOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class IsPosInfOpAdaptor : public IsPosInfOpGenericAdaptor<::mlir::ValueRange> { +public: + using IsPosInfOpGenericAdaptor::IsPosInfOpGenericAdaptor; + IsPosInfOpAdaptor(IsPosInfOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class IsPosInfOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = IsPosInfOpAdaptor; + template + using GenericAdaptor = IsPosInfOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.is_pos_inf"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::IsPosInfOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::LgammaOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class LgammaOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + LgammaOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.lgamma", odsAttrs.getContext()); + } + + LgammaOpGenericAdaptorBase(LgammaOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class LgammaOpGenericAdaptor : public detail::LgammaOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::LgammaOpGenericAdaptorBase; +public: + LgammaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + LgammaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : LgammaOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + LgammaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : LgammaOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + LgammaOpGenericAdaptor(RangeT values, const LgammaOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + LgammaOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class LgammaOpAdaptor : public LgammaOpGenericAdaptor<::mlir::ValueRange> { +public: + using LgammaOpGenericAdaptor::LgammaOpGenericAdaptor; + LgammaOpAdaptor(LgammaOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class LgammaOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = LgammaOpAdaptor; + template + using GenericAdaptor = LgammaOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.lgamma"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::LgammaOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::NextAfterOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class NextAfterOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + NextAfterOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.next_after", odsAttrs.getContext()); + } + + NextAfterOpGenericAdaptorBase(NextAfterOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class NextAfterOpGenericAdaptor : public detail::NextAfterOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::NextAfterOpGenericAdaptorBase; +public: + NextAfterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + NextAfterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : NextAfterOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + NextAfterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : NextAfterOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + NextAfterOpGenericAdaptor(RangeT values, const NextAfterOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + NextAfterOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getX() { + return (*getODSOperands(0).begin()); + } + + ValueT getY() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class NextAfterOpAdaptor : public NextAfterOpGenericAdaptor<::mlir::ValueRange> { +public: + using NextAfterOpGenericAdaptor::NextAfterOpGenericAdaptor; + NextAfterOpAdaptor(NextAfterOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class NextAfterOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType> { +public: + using Op::Op; + using Op::print; + using Adaptor = NextAfterOpAdaptor; + template + using GenericAdaptor = NextAfterOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.next_after"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getX() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getY() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getXMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getYMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value x, ::mlir::Value y); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, ::mlir::Value y); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value y); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::NextAfterOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::PolygammaOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PolygammaOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PolygammaOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.polygamma", odsAttrs.getContext()); + } + + PolygammaOpGenericAdaptorBase(PolygammaOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class PolygammaOpGenericAdaptor : public detail::PolygammaOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PolygammaOpGenericAdaptorBase; +public: + PolygammaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PolygammaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PolygammaOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + PolygammaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : PolygammaOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + PolygammaOpGenericAdaptor(RangeT values, const PolygammaOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + PolygammaOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getN() { + return (*getODSOperands(0).begin()); + } + + ValueT getX() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PolygammaOpAdaptor : public PolygammaOpGenericAdaptor<::mlir::ValueRange> { +public: + using PolygammaOpGenericAdaptor::PolygammaOpGenericAdaptor; + PolygammaOpAdaptor(PolygammaOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class PolygammaOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType> { +public: + using Op::Op; + using Op::print; + using Adaptor = PolygammaOpAdaptor; + template + using GenericAdaptor = PolygammaOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.polygamma"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getN() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getX() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getNMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getXMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value n, ::mlir::Value x); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value n, ::mlir::Value x); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value n, ::mlir::Value x); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::PolygammaOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::RaggedDotOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RaggedDotOpGenericAdaptorBase { +public: + struct Properties { + using precision_configTy = ::mlir::ArrayAttr; + precision_configTy precision_config; + + auto getPrecisionConfig() const { + auto &propStorage = this->precision_config; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setPrecisionConfig(const ::mlir::ArrayAttr &propValue) { + this->precision_config = propValue; + } + using ragged_dot_dimension_numbersTy = ::mlir::chlo::RaggedDotDimensionNumbersAttr; + ragged_dot_dimension_numbersTy ragged_dot_dimension_numbers; + + auto getRaggedDotDimensionNumbers() const { + auto &propStorage = this->ragged_dot_dimension_numbers; + return ::llvm::cast<::mlir::chlo::RaggedDotDimensionNumbersAttr>(propStorage); + } + void setRaggedDotDimensionNumbers(const ::mlir::chlo::RaggedDotDimensionNumbersAttr &propValue) { + this->ragged_dot_dimension_numbers = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.precision_config == this->precision_config && + rhs.ragged_dot_dimension_numbers == this->ragged_dot_dimension_numbers && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RaggedDotOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.ragged_dot", odsAttrs.getContext()); + } + + RaggedDotOpGenericAdaptorBase(RaggedDotOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::chlo::RaggedDotDimensionNumbersAttr getRaggedDotDimensionNumbersAttr() { + auto attr = ::llvm::cast<::mlir::chlo::RaggedDotDimensionNumbersAttr>(getProperties().ragged_dot_dimension_numbers); + return attr; + } + + ::mlir::chlo::RaggedDotDimensionNumbersAttr getRaggedDotDimensionNumbers(); + ::mlir::ArrayAttr getPrecisionConfigAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().precision_config); + return attr; + } + + ::std::optional< ::mlir::ArrayAttr > getPrecisionConfig(); +}; +} // namespace detail +template +class RaggedDotOpGenericAdaptor : public detail::RaggedDotOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RaggedDotOpGenericAdaptorBase; +public: + RaggedDotOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RaggedDotOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RaggedDotOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RaggedDotOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RaggedDotOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + RaggedDotOpGenericAdaptor(RangeT values, const RaggedDotOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RaggedDotOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + ValueT getGroupSizes() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RaggedDotOpAdaptor : public RaggedDotOpGenericAdaptor<::mlir::ValueRange> { +public: + using RaggedDotOpGenericAdaptor::RaggedDotOpGenericAdaptor; + RaggedDotOpAdaptor(RaggedDotOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RaggedDotOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RaggedDotOpAdaptor; + template + using GenericAdaptor = RaggedDotOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("precision_config"), ::llvm::StringRef("ragged_dot_dimension_numbers")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getPrecisionConfigAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getPrecisionConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getRaggedDotDimensionNumbersAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getRaggedDotDimensionNumbersAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.ragged_dot"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getGroupSizes() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getGroupSizesMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::chlo::RaggedDotDimensionNumbersAttr getRaggedDotDimensionNumbersAttr() { + return ::llvm::cast<::mlir::chlo::RaggedDotDimensionNumbersAttr>(getProperties().ragged_dot_dimension_numbers); + } + + ::mlir::chlo::RaggedDotDimensionNumbersAttr getRaggedDotDimensionNumbers(); + ::mlir::ArrayAttr getPrecisionConfigAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().precision_config); + } + + ::std::optional< ::mlir::ArrayAttr > getPrecisionConfig(); + void setRaggedDotDimensionNumbersAttr(::mlir::chlo::RaggedDotDimensionNumbersAttr attr) { + getProperties().ragged_dot_dimension_numbers = attr; + } + + void setPrecisionConfigAttr(::mlir::ArrayAttr attr) { + getProperties().precision_config = attr; + } + + ::mlir::Attribute removePrecisionConfigAttr() { + auto attr = getProperties().precision_config; + getProperties().precision_config = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value group_sizes, ::mlir::chlo::RaggedDotDimensionNumbersAttr ragged_dot_dimension_numbers, /*optional*/::mlir::ArrayAttr precision_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value group_sizes, ::mlir::chlo::RaggedDotDimensionNumbersAttr ragged_dot_dimension_numbers, /*optional*/::mlir::ArrayAttr precision_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::RaggedDotOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::SinhOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SinhOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SinhOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.sinh", odsAttrs.getContext()); + } + + SinhOpGenericAdaptorBase(SinhOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class SinhOpGenericAdaptor : public detail::SinhOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SinhOpGenericAdaptorBase; +public: + SinhOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SinhOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SinhOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SinhOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SinhOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + SinhOpGenericAdaptor(RangeT values, const SinhOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SinhOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SinhOpAdaptor : public SinhOpGenericAdaptor<::mlir::ValueRange> { +public: + using SinhOpGenericAdaptor::SinhOpGenericAdaptor; + SinhOpAdaptor(SinhOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SinhOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = SinhOpAdaptor; + template + using GenericAdaptor = SinhOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.sinh"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::SinhOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::SquareOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SquareOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SquareOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.square", odsAttrs.getContext()); + } + + SquareOpGenericAdaptorBase(SquareOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class SquareOpGenericAdaptor : public detail::SquareOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SquareOpGenericAdaptorBase; +public: + SquareOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SquareOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SquareOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SquareOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SquareOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + SquareOpGenericAdaptor(RangeT values, const SquareOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SquareOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SquareOpAdaptor : public SquareOpGenericAdaptor<::mlir::ValueRange> { +public: + using SquareOpGenericAdaptor::SquareOpGenericAdaptor; + SquareOpAdaptor(SquareOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SquareOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = SquareOpAdaptor; + template + using GenericAdaptor = SquareOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.square"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::SquareOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::TanOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TanOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TanOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.tan", odsAttrs.getContext()); + } + + TanOpGenericAdaptorBase(TanOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class TanOpGenericAdaptor : public detail::TanOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TanOpGenericAdaptorBase; +public: + TanOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TanOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TanOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TanOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TanOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + TanOpGenericAdaptor(RangeT values, const TanOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TanOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TanOpAdaptor : public TanOpGenericAdaptor<::mlir::ValueRange> { +public: + using TanOpGenericAdaptor::TanOpGenericAdaptor; + TanOpAdaptor(TanOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TanOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape> { +public: + using Op::Op; + using Op::print; + using Adaptor = TanOpAdaptor; + template + using GenericAdaptor = TanOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.tan"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes(OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), &reifiedReturnShapes); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::TanOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::TopKOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TopKOpGenericAdaptorBase { +public: + struct Properties { + using kTy = ::mlir::IntegerAttr; + kTy k; + + auto getK() const { + auto &propStorage = this->k; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setK(const ::mlir::IntegerAttr &propValue) { + this->k = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.k == this->k && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TopKOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.top_k", odsAttrs.getContext()); + } + + TopKOpGenericAdaptorBase(TopKOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::IntegerAttr getKAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().k); + return attr; + } + + uint64_t getK(); +}; +} // namespace detail +template +class TopKOpGenericAdaptor : public detail::TopKOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TopKOpGenericAdaptorBase; +public: + TopKOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TopKOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TopKOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TopKOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TopKOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + TopKOpGenericAdaptor(RangeT values, const TopKOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TopKOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TopKOpAdaptor : public TopKOpGenericAdaptor<::mlir::ValueRange> { +public: + using TopKOpGenericAdaptor::TopKOpGenericAdaptor; + TopKOpAdaptor(TopKOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TopKOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TopKOpAdaptor; + template + using GenericAdaptor = TopKOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("k")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getKAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getKAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.top_k"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getValues() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(1).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getKAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().k); + } + + uint64_t getK(); + void setKAttr(::mlir::IntegerAttr attr) { + getProperties().k = attr; + } + + void setK(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type values, ::mlir::Type indices, ::mlir::Value operand, ::mlir::IntegerAttr k); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::IntegerAttr k); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::IntegerAttr k); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type values, ::mlir::Type indices, ::mlir::Value operand, uint64_t k); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, uint64_t k); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, uint64_t k); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::TopKOp) + +namespace mlir { +namespace chlo { + +//===----------------------------------------------------------------------===// +// ::mlir::chlo::ZetaOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ZetaOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ZetaOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("chlo.zeta", odsAttrs.getContext()); + } + + ZetaOpGenericAdaptorBase(ZetaOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ZetaOpGenericAdaptor : public detail::ZetaOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ZetaOpGenericAdaptorBase; +public: + ZetaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ZetaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ZetaOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ZetaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ZetaOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ZetaOpGenericAdaptor(RangeT values, const ZetaOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ZetaOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getX() { + return (*getODSOperands(0).begin()); + } + + ValueT getQ() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ZetaOpAdaptor : public ZetaOpGenericAdaptor<::mlir::ValueRange> { +public: + using ZetaOpGenericAdaptor::ZetaOpGenericAdaptor; + ZetaOpAdaptor(ZetaOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ZetaOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType> { +public: + using Op::Op; + using Op::print; + using Adaptor = ZetaOpAdaptor; + template + using GenericAdaptor = ZetaOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("chlo.zeta"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getX() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::TensorType> getQ() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getXMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getQMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::TensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value x, ::mlir::Value q); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, ::mlir::Value q); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value q); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace chlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::chlo::ZetaOp) + + +#endif // GET_OP_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/Register.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/Register.h new file mode 100644 index 0000000000000000000000000000000000000000..2946c8181d5a7c96538afe9b8d5c7658ae6fe347 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/Register.h @@ -0,0 +1,31 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + Copyright 2022 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_REGISTER_H +#define STABLEHLO_DIALECT_REGISTER_H + +#include "mlir/IR/DialectRegistry.h" + +namespace mlir { +namespace stablehlo { + +// Add chlo and stablehlo dialects to the provided registry. +void registerAllDialects(DialectRegistry ®istry); + +} // namespace stablehlo +} // namespace mlir + +#endif // STABLEHLO_DIALECT_REGISTER_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/Serialization.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/Serialization.h new file mode 100644 index 0000000000000000000000000000000000000000..811ca97be1f76635536507bad1fe77b9ee8924cf --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/Serialization.h @@ -0,0 +1,62 @@ +/* Copyright 2023 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_SERIALIZATION_H +#define STABLEHLO_DIALECT_SERIALIZATION_H + +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/MLIRContext.h" +#include "mlir/Support/LogicalResult.h" +#include "stablehlo/dialect/Version.h" + +namespace mlir { +namespace stablehlo { + +// Write a StableHLO program to a portable artifact +// Writes a stable payload for `module` to `os`. If compatibility with a +// previous version of StableHLO is required, provide the required version +// string `#.#.#` for `targetVersion`. +// +// Can fail if `module` cannot be expressed in the `targetVersion` version of +// StableHLO, e.g. if it's using new or removed features, or if it involves +// unsupported dialects. +LogicalResult serializePortableArtifact(ModuleOp module, + StringRef targetVersion, + raw_ostream& os, + bool allowOtherDialects = false); + +// Read StableHLO portable artifact +// +// Can fail if `sourceStr` cannot be expressed in the current version of +// StableHLO, e.g. if it's using incompatible features. Returns nullptr if +// `sourceStr` is invalid or fails to deserialize. +OwningOpRef deserializePortableArtifact(StringRef sourceStr, + MLIRContext* context); + +// Get portable artifact version from the producer string after the MLIR +// Bytecode magic number `MLïRStableHLO_vX.Y.Z` -> X.Y.Z +// Returns failure if input string is not a valid portable artifact produced by +// serializePortableArtifact APIs, which would cause the bytecode artifact to +// not have the proper producer string. +// +// This method should be safe, since any changes to the bytecode format would +// warrant a bytecode version bump, and MLIR bytecode gives the option to +// specify a forward compatible bytecode version to target. +FailureOr getPortableArtifactVersion(llvm::StringRef bytecode); + +} // namespace stablehlo +} // namespace mlir + +#endif // STABLEHLO_DIALECT_SERIALIZATION_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloAttrs.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloAttrs.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..9861650038c679edf4caf4d8f648abee3f3131ce --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloAttrs.cpp.inc @@ -0,0 +1,1713 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_ATTRDEF_LIST +#undef GET_ATTRDEF_LIST + +::mlir::stablehlo::PrecisionAttr, +::mlir::stablehlo::ResultAccuracyModeAttr, +::mlir::stablehlo::FftTypeAttr, +::mlir::stablehlo::ComparisonDirectionAttr, +::mlir::stablehlo::ComparisonTypeAttr, +::mlir::stablehlo::TransposeAttr, +::mlir::stablehlo::RngDistributionAttr, +::mlir::stablehlo::RngAlgorithmAttr, +::mlir::stablehlo::ScatterDimensionNumbersAttr, +::mlir::stablehlo::GatherDimensionNumbersAttr, +::mlir::stablehlo::DotAlgorithmAttr, +::mlir::stablehlo::DotDimensionNumbersAttr, +::mlir::stablehlo::OutputOperandAliasAttr, +::mlir::stablehlo::ChannelHandleAttr, +::mlir::stablehlo::TypeExtensionsAttr, +::mlir::stablehlo::ConvDimensionNumbersAttr, +::mlir::stablehlo::ResultAccuracyAttr + +#endif // GET_ATTRDEF_LIST + +#ifdef GET_ATTRDEF_CLASSES +#undef GET_ATTRDEF_CLASSES + +static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) { + return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser) + .Case(::mlir::stablehlo::PrecisionAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::PrecisionAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::ResultAccuracyModeAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::ResultAccuracyModeAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::FftTypeAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::FftTypeAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::ComparisonDirectionAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::ComparisonDirectionAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::ComparisonTypeAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::ComparisonTypeAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::TransposeAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::TransposeAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::RngDistributionAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::RngDistributionAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::RngAlgorithmAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::RngAlgorithmAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::ScatterDimensionNumbersAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::ScatterDimensionNumbersAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::GatherDimensionNumbersAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::GatherDimensionNumbersAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::DotAlgorithmAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::DotAlgorithmAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::DotDimensionNumbersAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::DotDimensionNumbersAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::OutputOperandAliasAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::OutputOperandAliasAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::ChannelHandleAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::ChannelHandleAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::TypeExtensionsAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::TypeExtensionsAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::ConvDimensionNumbersAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::ConvDimensionNumbersAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::stablehlo::ResultAccuracyAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::ResultAccuracyAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Default([&](llvm::StringRef keyword, llvm::SMLoc) { + *mnemonic = keyword; + return std::nullopt; + }); +} + +static ::llvm::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) { + return ::llvm::TypeSwitch<::mlir::Attribute, ::llvm::LogicalResult>(def) .Case<::mlir::stablehlo::PrecisionAttr>([&](auto t) { + printer << ::mlir::stablehlo::PrecisionAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::ResultAccuracyModeAttr>([&](auto t) { + printer << ::mlir::stablehlo::ResultAccuracyModeAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::FftTypeAttr>([&](auto t) { + printer << ::mlir::stablehlo::FftTypeAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::ComparisonDirectionAttr>([&](auto t) { + printer << ::mlir::stablehlo::ComparisonDirectionAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::ComparisonTypeAttr>([&](auto t) { + printer << ::mlir::stablehlo::ComparisonTypeAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::TransposeAttr>([&](auto t) { + printer << ::mlir::stablehlo::TransposeAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::RngDistributionAttr>([&](auto t) { + printer << ::mlir::stablehlo::RngDistributionAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::RngAlgorithmAttr>([&](auto t) { + printer << ::mlir::stablehlo::RngAlgorithmAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::ScatterDimensionNumbersAttr>([&](auto t) { + printer << ::mlir::stablehlo::ScatterDimensionNumbersAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::GatherDimensionNumbersAttr>([&](auto t) { + printer << ::mlir::stablehlo::GatherDimensionNumbersAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::DotAlgorithmAttr>([&](auto t) { + printer << ::mlir::stablehlo::DotAlgorithmAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::DotDimensionNumbersAttr>([&](auto t) { + printer << ::mlir::stablehlo::DotDimensionNumbersAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::OutputOperandAliasAttr>([&](auto t) { + printer << ::mlir::stablehlo::OutputOperandAliasAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::ChannelHandleAttr>([&](auto t) { + printer << ::mlir::stablehlo::ChannelHandleAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::TypeExtensionsAttr>([&](auto t) { + printer << ::mlir::stablehlo::TypeExtensionsAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::ConvDimensionNumbersAttr>([&](auto t) { + printer << ::mlir::stablehlo::ConvDimensionNumbersAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::stablehlo::ResultAccuracyAttr>([&](auto t) { + printer << ::mlir::stablehlo::ResultAccuracyAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Default([](auto) { return ::mlir::failure(); }); +} + +namespace mlir { +namespace stablehlo { +namespace detail { +struct PrecisionAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::stablehlo::Precision>; + PrecisionAttrStorage(::mlir::stablehlo::Precision value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static PrecisionAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) PrecisionAttrStorage(std::move(value)); + } + + ::mlir::stablehlo::Precision value; +}; +} // namespace detail +PrecisionAttr PrecisionAttr::get(::mlir::MLIRContext *context, ::mlir::stablehlo::Precision value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute PrecisionAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::stablehlo::Precision> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::stablehlo::Precision> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::stablehlo::symbolizePrecision(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::stablehlo::Precision" << " to be one of: " << "DEFAULT" << ", " << "HIGH" << ", " << "HIGHEST")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_PrecisionAttr parameter 'value' which is to be a `::mlir::stablehlo::Precision`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return PrecisionAttr::get(odsParser.getContext(), + ::mlir::stablehlo::Precision((*_result_value))); +} + +void PrecisionAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyPrecision(getValue()); +} + +::mlir::stablehlo::Precision PrecisionAttr::getValue() const { + return getImpl()->value; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::PrecisionAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct ResultAccuracyModeAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::stablehlo::ResultAccuracyMode>; + ResultAccuracyModeAttrStorage(::mlir::stablehlo::ResultAccuracyMode value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static ResultAccuracyModeAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) ResultAccuracyModeAttrStorage(std::move(value)); + } + + ::mlir::stablehlo::ResultAccuracyMode value; +}; +} // namespace detail +ResultAccuracyModeAttr ResultAccuracyModeAttr::get(::mlir::MLIRContext *context, ::mlir::stablehlo::ResultAccuracyMode value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute ResultAccuracyModeAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::stablehlo::ResultAccuracyMode> _result_value; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::stablehlo::ResultAccuracyMode> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::stablehlo::symbolizeResultAccuracyMode(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::stablehlo::ResultAccuracyMode" << " to be one of: " << "DEFAULT" << ", " << "HIGHEST" << ", " << "TOLERANCE")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_ResultAccuracyModeAttr parameter 'value' which is to be a `::mlir::stablehlo::ResultAccuracyMode`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_value)); + return ResultAccuracyModeAttr::get(odsParser.getContext(), + ::mlir::stablehlo::ResultAccuracyMode((*_result_value))); +} + +void ResultAccuracyModeAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter << stringifyResultAccuracyMode(getValue()); + odsPrinter << ">"; +} + +::mlir::stablehlo::ResultAccuracyMode ResultAccuracyModeAttr::getValue() const { + return getImpl()->value; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ResultAccuracyModeAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct FftTypeAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::stablehlo::FftType>; + FftTypeAttrStorage(::mlir::stablehlo::FftType value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static FftTypeAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) FftTypeAttrStorage(std::move(value)); + } + + ::mlir::stablehlo::FftType value; +}; +} // namespace detail +FftTypeAttr FftTypeAttr::get(::mlir::MLIRContext *context, ::mlir::stablehlo::FftType value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute FftTypeAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::stablehlo::FftType> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::stablehlo::FftType> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::stablehlo::symbolizeFftType(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::stablehlo::FftType" << " to be one of: " << "FFT" << ", " << "IFFT" << ", " << "RFFT" << ", " << "IRFFT")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_FftTypeAttr parameter 'value' which is to be a `::mlir::stablehlo::FftType`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return FftTypeAttr::get(odsParser.getContext(), + ::mlir::stablehlo::FftType((*_result_value))); +} + +void FftTypeAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyFftType(getValue()); +} + +::mlir::stablehlo::FftType FftTypeAttr::getValue() const { + return getImpl()->value; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::FftTypeAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct ComparisonDirectionAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::stablehlo::ComparisonDirection>; + ComparisonDirectionAttrStorage(::mlir::stablehlo::ComparisonDirection value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static ComparisonDirectionAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) ComparisonDirectionAttrStorage(std::move(value)); + } + + ::mlir::stablehlo::ComparisonDirection value; +}; +} // namespace detail +ComparisonDirectionAttr ComparisonDirectionAttr::get(::mlir::MLIRContext *context, ::mlir::stablehlo::ComparisonDirection value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute ComparisonDirectionAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::stablehlo::ComparisonDirection> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::stablehlo::ComparisonDirection> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::stablehlo::symbolizeComparisonDirection(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::stablehlo::ComparisonDirection" << " to be one of: " << "EQ" << ", " << "NE" << ", " << "GE" << ", " << "GT" << ", " << "LE" << ", " << "LT")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_ComparisonDirectionAttr parameter 'value' which is to be a `::mlir::stablehlo::ComparisonDirection`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return ComparisonDirectionAttr::get(odsParser.getContext(), + ::mlir::stablehlo::ComparisonDirection((*_result_value))); +} + +void ComparisonDirectionAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyComparisonDirection(getValue()); +} + +::mlir::stablehlo::ComparisonDirection ComparisonDirectionAttr::getValue() const { + return getImpl()->value; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ComparisonDirectionAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct ComparisonTypeAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::stablehlo::ComparisonType>; + ComparisonTypeAttrStorage(::mlir::stablehlo::ComparisonType value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static ComparisonTypeAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) ComparisonTypeAttrStorage(std::move(value)); + } + + ::mlir::stablehlo::ComparisonType value; +}; +} // namespace detail +ComparisonTypeAttr ComparisonTypeAttr::get(::mlir::MLIRContext *context, ::mlir::stablehlo::ComparisonType value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute ComparisonTypeAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::stablehlo::ComparisonType> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::stablehlo::ComparisonType> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::stablehlo::symbolizeComparisonType(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::stablehlo::ComparisonType" << " to be one of: " << "NOTYPE" << ", " << "FLOAT" << ", " << "TOTALORDER" << ", " << "SIGNED" << ", " << "UNSIGNED")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_ComparisonTypeAttr parameter 'value' which is to be a `::mlir::stablehlo::ComparisonType`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return ComparisonTypeAttr::get(odsParser.getContext(), + ::mlir::stablehlo::ComparisonType((*_result_value))); +} + +void ComparisonTypeAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyComparisonType(getValue()); +} + +::mlir::stablehlo::ComparisonType ComparisonTypeAttr::getValue() const { + return getImpl()->value; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ComparisonTypeAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct TransposeAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::stablehlo::Transpose>; + TransposeAttrStorage(::mlir::stablehlo::Transpose value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static TransposeAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) TransposeAttrStorage(std::move(value)); + } + + ::mlir::stablehlo::Transpose value; +}; +} // namespace detail +TransposeAttr TransposeAttr::get(::mlir::MLIRContext *context, ::mlir::stablehlo::Transpose value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute TransposeAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::stablehlo::Transpose> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::stablehlo::Transpose> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::stablehlo::symbolizeTranspose(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::stablehlo::Transpose" << " to be one of: " << "TRANSPOSE_INVALID" << ", " << "NO_TRANSPOSE" << ", " << "TRANSPOSE" << ", " << "ADJOINT")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_TransposeAttr parameter 'value' which is to be a `::mlir::stablehlo::Transpose`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return TransposeAttr::get(odsParser.getContext(), + ::mlir::stablehlo::Transpose((*_result_value))); +} + +void TransposeAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyTranspose(getValue()); +} + +::mlir::stablehlo::Transpose TransposeAttr::getValue() const { + return getImpl()->value; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TransposeAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct RngDistributionAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::stablehlo::RngDistribution>; + RngDistributionAttrStorage(::mlir::stablehlo::RngDistribution value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static RngDistributionAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) RngDistributionAttrStorage(std::move(value)); + } + + ::mlir::stablehlo::RngDistribution value; +}; +} // namespace detail +RngDistributionAttr RngDistributionAttr::get(::mlir::MLIRContext *context, ::mlir::stablehlo::RngDistribution value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute RngDistributionAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::stablehlo::RngDistribution> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::stablehlo::RngDistribution> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::stablehlo::symbolizeRngDistribution(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::stablehlo::RngDistribution" << " to be one of: " << "UNIFORM" << ", " << "NORMAL")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_RngDistributionAttr parameter 'value' which is to be a `::mlir::stablehlo::RngDistribution`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return RngDistributionAttr::get(odsParser.getContext(), + ::mlir::stablehlo::RngDistribution((*_result_value))); +} + +void RngDistributionAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyRngDistribution(getValue()); +} + +::mlir::stablehlo::RngDistribution RngDistributionAttr::getValue() const { + return getImpl()->value; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RngDistributionAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct RngAlgorithmAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::stablehlo::RngAlgorithm>; + RngAlgorithmAttrStorage(::mlir::stablehlo::RngAlgorithm value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static RngAlgorithmAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) RngAlgorithmAttrStorage(std::move(value)); + } + + ::mlir::stablehlo::RngAlgorithm value; +}; +} // namespace detail +RngAlgorithmAttr RngAlgorithmAttr::get(::mlir::MLIRContext *context, ::mlir::stablehlo::RngAlgorithm value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute RngAlgorithmAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::stablehlo::RngAlgorithm> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::stablehlo::RngAlgorithm> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::stablehlo::symbolizeRngAlgorithm(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::stablehlo::RngAlgorithm" << " to be one of: " << "DEFAULT" << ", " << "THREE_FRY" << ", " << "PHILOX")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_RngAlgorithmAttr parameter 'value' which is to be a `::mlir::stablehlo::RngAlgorithm`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return RngAlgorithmAttr::get(odsParser.getContext(), + ::mlir::stablehlo::RngAlgorithm((*_result_value))); +} + +void RngAlgorithmAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyRngAlgorithm(getValue()); +} + +::mlir::stablehlo::RngAlgorithm RngAlgorithmAttr::getValue() const { + return getImpl()->value; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RngAlgorithmAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct ScatterDimensionNumbersAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef, ::llvm::ArrayRef, ::llvm::ArrayRef, ::llvm::ArrayRef, ::llvm::ArrayRef, int64_t>; + ScatterDimensionNumbersAttrStorage(::llvm::ArrayRef updateWindowDims, ::llvm::ArrayRef insertedWindowDims, ::llvm::ArrayRef inputBatchingDims, ::llvm::ArrayRef scatterIndicesBatchingDims, ::llvm::ArrayRef scatterDimsToOperandDims, int64_t indexVectorDim) : updateWindowDims(std::move(updateWindowDims)), insertedWindowDims(std::move(insertedWindowDims)), inputBatchingDims(std::move(inputBatchingDims)), scatterIndicesBatchingDims(std::move(scatterIndicesBatchingDims)), scatterDimsToOperandDims(std::move(scatterDimsToOperandDims)), indexVectorDim(std::move(indexVectorDim)) {} + + KeyTy getAsKey() const { + return KeyTy(updateWindowDims, insertedWindowDims, inputBatchingDims, scatterIndicesBatchingDims, scatterDimsToOperandDims, indexVectorDim); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (updateWindowDims == std::get<0>(tblgenKey)) && (insertedWindowDims == std::get<1>(tblgenKey)) && (inputBatchingDims == std::get<2>(tblgenKey)) && (scatterIndicesBatchingDims == std::get<3>(tblgenKey)) && (scatterDimsToOperandDims == std::get<4>(tblgenKey)) && (indexVectorDim == std::get<5>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey), std::get<4>(tblgenKey), std::get<5>(tblgenKey)); + } + + static ScatterDimensionNumbersAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto updateWindowDims = std::move(std::get<0>(tblgenKey)); + auto insertedWindowDims = std::move(std::get<1>(tblgenKey)); + auto inputBatchingDims = std::move(std::get<2>(tblgenKey)); + auto scatterIndicesBatchingDims = std::move(std::get<3>(tblgenKey)); + auto scatterDimsToOperandDims = std::move(std::get<4>(tblgenKey)); + auto indexVectorDim = std::move(std::get<5>(tblgenKey)); + updateWindowDims = allocator.copyInto(updateWindowDims); + insertedWindowDims = allocator.copyInto(insertedWindowDims); + inputBatchingDims = allocator.copyInto(inputBatchingDims); + scatterIndicesBatchingDims = allocator.copyInto(scatterIndicesBatchingDims); + scatterDimsToOperandDims = allocator.copyInto(scatterDimsToOperandDims); + return new (allocator.allocate()) ScatterDimensionNumbersAttrStorage(std::move(updateWindowDims), std::move(insertedWindowDims), std::move(inputBatchingDims), std::move(scatterIndicesBatchingDims), std::move(scatterDimsToOperandDims), std::move(indexVectorDim)); + } + + ::llvm::ArrayRef updateWindowDims; + ::llvm::ArrayRef insertedWindowDims; + ::llvm::ArrayRef inputBatchingDims; + ::llvm::ArrayRef scatterIndicesBatchingDims; + ::llvm::ArrayRef scatterDimsToOperandDims; + int64_t indexVectorDim; +}; +} // namespace detail +ScatterDimensionNumbersAttr ScatterDimensionNumbersAttr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef updateWindowDims, ::llvm::ArrayRef insertedWindowDims, ::llvm::ArrayRef inputBatchingDims, ::llvm::ArrayRef scatterIndicesBatchingDims, ::llvm::ArrayRef scatterDimsToOperandDims, int64_t indexVectorDim) { + return Base::get(context, std::move(updateWindowDims), std::move(insertedWindowDims), std::move(inputBatchingDims), std::move(scatterIndicesBatchingDims), std::move(scatterDimsToOperandDims), std::move(indexVectorDim)); +} + +::llvm::ArrayRef ScatterDimensionNumbersAttr::getUpdateWindowDims() const { + return getImpl()->updateWindowDims; +} + +::llvm::ArrayRef ScatterDimensionNumbersAttr::getInsertedWindowDims() const { + return getImpl()->insertedWindowDims; +} + +::llvm::ArrayRef ScatterDimensionNumbersAttr::getInputBatchingDims() const { + return getImpl()->inputBatchingDims; +} + +::llvm::ArrayRef ScatterDimensionNumbersAttr::getScatterIndicesBatchingDims() const { + return getImpl()->scatterIndicesBatchingDims; +} + +::llvm::ArrayRef ScatterDimensionNumbersAttr::getScatterDimsToOperandDims() const { + return getImpl()->scatterDimsToOperandDims; +} + +int64_t ScatterDimensionNumbersAttr::getIndexVectorDim() const { + return getImpl()->indexVectorDim; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ScatterDimensionNumbersAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct GatherDimensionNumbersAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef, ::llvm::ArrayRef, ::llvm::ArrayRef, ::llvm::ArrayRef, ::llvm::ArrayRef, int64_t>; + GatherDimensionNumbersAttrStorage(::llvm::ArrayRef offsetDims, ::llvm::ArrayRef collapsedSliceDims, ::llvm::ArrayRef operandBatchingDims, ::llvm::ArrayRef startIndicesBatchingDims, ::llvm::ArrayRef startIndexMap, int64_t indexVectorDim) : offsetDims(std::move(offsetDims)), collapsedSliceDims(std::move(collapsedSliceDims)), operandBatchingDims(std::move(operandBatchingDims)), startIndicesBatchingDims(std::move(startIndicesBatchingDims)), startIndexMap(std::move(startIndexMap)), indexVectorDim(std::move(indexVectorDim)) {} + + KeyTy getAsKey() const { + return KeyTy(offsetDims, collapsedSliceDims, operandBatchingDims, startIndicesBatchingDims, startIndexMap, indexVectorDim); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (offsetDims == std::get<0>(tblgenKey)) && (collapsedSliceDims == std::get<1>(tblgenKey)) && (operandBatchingDims == std::get<2>(tblgenKey)) && (startIndicesBatchingDims == std::get<3>(tblgenKey)) && (startIndexMap == std::get<4>(tblgenKey)) && (indexVectorDim == std::get<5>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey), std::get<4>(tblgenKey), std::get<5>(tblgenKey)); + } + + static GatherDimensionNumbersAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto offsetDims = std::move(std::get<0>(tblgenKey)); + auto collapsedSliceDims = std::move(std::get<1>(tblgenKey)); + auto operandBatchingDims = std::move(std::get<2>(tblgenKey)); + auto startIndicesBatchingDims = std::move(std::get<3>(tblgenKey)); + auto startIndexMap = std::move(std::get<4>(tblgenKey)); + auto indexVectorDim = std::move(std::get<5>(tblgenKey)); + offsetDims = allocator.copyInto(offsetDims); + collapsedSliceDims = allocator.copyInto(collapsedSliceDims); + operandBatchingDims = allocator.copyInto(operandBatchingDims); + startIndicesBatchingDims = allocator.copyInto(startIndicesBatchingDims); + startIndexMap = allocator.copyInto(startIndexMap); + return new (allocator.allocate()) GatherDimensionNumbersAttrStorage(std::move(offsetDims), std::move(collapsedSliceDims), std::move(operandBatchingDims), std::move(startIndicesBatchingDims), std::move(startIndexMap), std::move(indexVectorDim)); + } + + ::llvm::ArrayRef offsetDims; + ::llvm::ArrayRef collapsedSliceDims; + ::llvm::ArrayRef operandBatchingDims; + ::llvm::ArrayRef startIndicesBatchingDims; + ::llvm::ArrayRef startIndexMap; + int64_t indexVectorDim; +}; +} // namespace detail +GatherDimensionNumbersAttr GatherDimensionNumbersAttr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef offsetDims, ::llvm::ArrayRef collapsedSliceDims, ::llvm::ArrayRef operandBatchingDims, ::llvm::ArrayRef startIndicesBatchingDims, ::llvm::ArrayRef startIndexMap, int64_t indexVectorDim) { + return Base::get(context, std::move(offsetDims), std::move(collapsedSliceDims), std::move(operandBatchingDims), std::move(startIndicesBatchingDims), std::move(startIndexMap), std::move(indexVectorDim)); +} + +::llvm::ArrayRef GatherDimensionNumbersAttr::getOffsetDims() const { + return getImpl()->offsetDims; +} + +::llvm::ArrayRef GatherDimensionNumbersAttr::getCollapsedSliceDims() const { + return getImpl()->collapsedSliceDims; +} + +::llvm::ArrayRef GatherDimensionNumbersAttr::getOperandBatchingDims() const { + return getImpl()->operandBatchingDims; +} + +::llvm::ArrayRef GatherDimensionNumbersAttr::getStartIndicesBatchingDims() const { + return getImpl()->startIndicesBatchingDims; +} + +::llvm::ArrayRef GatherDimensionNumbersAttr::getStartIndexMap() const { + return getImpl()->startIndexMap; +} + +int64_t GatherDimensionNumbersAttr::getIndexVectorDim() const { + return getImpl()->indexVectorDim; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::GatherDimensionNumbersAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct DotAlgorithmAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple; + DotAlgorithmAttrStorage(Type lhsPrecisionType, Type rhsPrecisionType, Type accumulationType, int64_t lhsComponentCount, int64_t rhsComponentCount, int64_t numPrimitiveOperations, bool allowImpreciseAccumulation) : lhsPrecisionType(std::move(lhsPrecisionType)), rhsPrecisionType(std::move(rhsPrecisionType)), accumulationType(std::move(accumulationType)), lhsComponentCount(std::move(lhsComponentCount)), rhsComponentCount(std::move(rhsComponentCount)), numPrimitiveOperations(std::move(numPrimitiveOperations)), allowImpreciseAccumulation(std::move(allowImpreciseAccumulation)) {} + + KeyTy getAsKey() const { + return KeyTy(lhsPrecisionType, rhsPrecisionType, accumulationType, lhsComponentCount, rhsComponentCount, numPrimitiveOperations, allowImpreciseAccumulation); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (lhsPrecisionType == std::get<0>(tblgenKey)) && (rhsPrecisionType == std::get<1>(tblgenKey)) && (accumulationType == std::get<2>(tblgenKey)) && (lhsComponentCount == std::get<3>(tblgenKey)) && (rhsComponentCount == std::get<4>(tblgenKey)) && (numPrimitiveOperations == std::get<5>(tblgenKey)) && (allowImpreciseAccumulation == std::get<6>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey), std::get<4>(tblgenKey), std::get<5>(tblgenKey), std::get<6>(tblgenKey)); + } + + static DotAlgorithmAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto lhsPrecisionType = std::move(std::get<0>(tblgenKey)); + auto rhsPrecisionType = std::move(std::get<1>(tblgenKey)); + auto accumulationType = std::move(std::get<2>(tblgenKey)); + auto lhsComponentCount = std::move(std::get<3>(tblgenKey)); + auto rhsComponentCount = std::move(std::get<4>(tblgenKey)); + auto numPrimitiveOperations = std::move(std::get<5>(tblgenKey)); + auto allowImpreciseAccumulation = std::move(std::get<6>(tblgenKey)); + return new (allocator.allocate()) DotAlgorithmAttrStorage(std::move(lhsPrecisionType), std::move(rhsPrecisionType), std::move(accumulationType), std::move(lhsComponentCount), std::move(rhsComponentCount), std::move(numPrimitiveOperations), std::move(allowImpreciseAccumulation)); + } + + Type lhsPrecisionType; + Type rhsPrecisionType; + Type accumulationType; + int64_t lhsComponentCount; + int64_t rhsComponentCount; + int64_t numPrimitiveOperations; + bool allowImpreciseAccumulation; +}; +} // namespace detail +DotAlgorithmAttr DotAlgorithmAttr::get(::mlir::MLIRContext *context, Type lhsPrecisionType, Type rhsPrecisionType, Type accumulationType, int64_t lhsComponentCount, int64_t rhsComponentCount, int64_t numPrimitiveOperations, bool allowImpreciseAccumulation) { + return Base::get(context, std::move(lhsPrecisionType), std::move(rhsPrecisionType), std::move(accumulationType), std::move(lhsComponentCount), std::move(rhsComponentCount), std::move(numPrimitiveOperations), std::move(allowImpreciseAccumulation)); +} + +DotAlgorithmAttr DotAlgorithmAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, Type lhsPrecisionType, Type rhsPrecisionType, Type accumulationType, int64_t lhsComponentCount, int64_t rhsComponentCount, int64_t numPrimitiveOperations, bool allowImpreciseAccumulation) { + return Base::getChecked(emitError, context, lhsPrecisionType, rhsPrecisionType, accumulationType, lhsComponentCount, rhsComponentCount, numPrimitiveOperations, allowImpreciseAccumulation); +} + +::llvm::LogicalResult DotAlgorithmAttr::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, Type lhsPrecisionType, Type rhsPrecisionType, Type accumulationType, int64_t lhsComponentCount, int64_t rhsComponentCount, int64_t numPrimitiveOperations, bool allowImpreciseAccumulation) { + if (::mlir::failed(verify(emitError, lhsPrecisionType, rhsPrecisionType, accumulationType, lhsComponentCount, rhsComponentCount, numPrimitiveOperations, allowImpreciseAccumulation))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::Attribute DotAlgorithmAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr _result_lhsPrecisionType; + ::mlir::FailureOr _result_rhsPrecisionType; + ::mlir::FailureOr _result_accumulationType; + ::mlir::FailureOr _result_lhsComponentCount; + ::mlir::FailureOr _result_rhsComponentCount; + ::mlir::FailureOr _result_numPrimitiveOperations; + ::mlir::FailureOr _result_allowImpreciseAccumulation; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + // Parse literal 'lhs_precision_type' + if (odsParser.parseKeyword("lhs_precision_type")) return {}; + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + + // Parse variable 'lhsPrecisionType' + _result_lhsPrecisionType = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_lhsPrecisionType)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_DotAlgorithm parameter 'lhsPrecisionType' which is to be a `Type`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + // Parse literal 'rhs_precision_type' + if (odsParser.parseKeyword("rhs_precision_type")) return {}; + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + + // Parse variable 'rhsPrecisionType' + _result_rhsPrecisionType = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_rhsPrecisionType)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_DotAlgorithm parameter 'rhsPrecisionType' which is to be a `Type`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + // Parse literal 'accumulation_type' + if (odsParser.parseKeyword("accumulation_type")) return {}; + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + + // Parse variable 'accumulationType' + _result_accumulationType = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_accumulationType)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_DotAlgorithm parameter 'accumulationType' which is to be a `Type`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + // Parse literal 'lhs_component_count' + if (odsParser.parseKeyword("lhs_component_count")) return {}; + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + + // Parse variable 'lhsComponentCount' + _result_lhsComponentCount = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_lhsComponentCount)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_DotAlgorithm parameter 'lhsComponentCount' which is to be a `int64_t`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + // Parse literal 'rhs_component_count' + if (odsParser.parseKeyword("rhs_component_count")) return {}; + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + + // Parse variable 'rhsComponentCount' + _result_rhsComponentCount = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_rhsComponentCount)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_DotAlgorithm parameter 'rhsComponentCount' which is to be a `int64_t`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + // Parse literal 'num_primitive_operations' + if (odsParser.parseKeyword("num_primitive_operations")) return {}; + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + + // Parse variable 'numPrimitiveOperations' + _result_numPrimitiveOperations = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_numPrimitiveOperations)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_DotAlgorithm parameter 'numPrimitiveOperations' which is to be a `int64_t`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + // Parse literal 'allow_imprecise_accumulation' + if (odsParser.parseKeyword("allow_imprecise_accumulation")) return {}; + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + + // Parse variable 'allowImpreciseAccumulation' + _result_allowImpreciseAccumulation = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_allowImpreciseAccumulation)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_DotAlgorithm parameter 'allowImpreciseAccumulation' which is to be a `bool`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_lhsPrecisionType)); + assert(::mlir::succeeded(_result_rhsPrecisionType)); + assert(::mlir::succeeded(_result_accumulationType)); + assert(::mlir::succeeded(_result_lhsComponentCount)); + assert(::mlir::succeeded(_result_rhsComponentCount)); + assert(::mlir::succeeded(_result_numPrimitiveOperations)); + assert(::mlir::succeeded(_result_allowImpreciseAccumulation)); + return odsParser.getChecked(odsLoc, odsParser.getContext(), + Type((*_result_lhsPrecisionType)), + Type((*_result_rhsPrecisionType)), + Type((*_result_accumulationType)), + int64_t((*_result_lhsComponentCount)), + int64_t((*_result_rhsComponentCount)), + int64_t((*_result_numPrimitiveOperations)), + bool((*_result_allowImpreciseAccumulation))); +} + +void DotAlgorithmAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter << "lhs_precision_type"; + odsPrinter << ' ' << "="; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getLhsPrecisionType()); + odsPrinter << ","; + odsPrinter << ' ' << "rhs_precision_type"; + odsPrinter << ' ' << "="; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getRhsPrecisionType()); + odsPrinter << ","; + odsPrinter << ' ' << "accumulation_type"; + odsPrinter << ' ' << "="; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getAccumulationType()); + odsPrinter << ","; + odsPrinter << ' ' << "lhs_component_count"; + odsPrinter << ' ' << "="; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getLhsComponentCount()); + odsPrinter << ","; + odsPrinter << ' ' << "rhs_component_count"; + odsPrinter << ' ' << "="; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getRhsComponentCount()); + odsPrinter << ","; + odsPrinter << ' ' << "num_primitive_operations"; + odsPrinter << ' ' << "="; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getNumPrimitiveOperations()); + odsPrinter << ","; + odsPrinter << ' ' << "allow_imprecise_accumulation"; + odsPrinter << ' ' << "="; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getAllowImpreciseAccumulation()); + odsPrinter << ">"; +} + +Type DotAlgorithmAttr::getLhsPrecisionType() const { + return getImpl()->lhsPrecisionType; +} + +Type DotAlgorithmAttr::getRhsPrecisionType() const { + return getImpl()->rhsPrecisionType; +} + +Type DotAlgorithmAttr::getAccumulationType() const { + return getImpl()->accumulationType; +} + +int64_t DotAlgorithmAttr::getLhsComponentCount() const { + return getImpl()->lhsComponentCount; +} + +int64_t DotAlgorithmAttr::getRhsComponentCount() const { + return getImpl()->rhsComponentCount; +} + +int64_t DotAlgorithmAttr::getNumPrimitiveOperations() const { + return getImpl()->numPrimitiveOperations; +} + +bool DotAlgorithmAttr::getAllowImpreciseAccumulation() const { + return getImpl()->allowImpreciseAccumulation; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DotAlgorithmAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct DotDimensionNumbersAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef, ::llvm::ArrayRef, ::llvm::ArrayRef, ::llvm::ArrayRef>; + DotDimensionNumbersAttrStorage(::llvm::ArrayRef lhsBatchingDimensions, ::llvm::ArrayRef rhsBatchingDimensions, ::llvm::ArrayRef lhsContractingDimensions, ::llvm::ArrayRef rhsContractingDimensions) : lhsBatchingDimensions(std::move(lhsBatchingDimensions)), rhsBatchingDimensions(std::move(rhsBatchingDimensions)), lhsContractingDimensions(std::move(lhsContractingDimensions)), rhsContractingDimensions(std::move(rhsContractingDimensions)) {} + + KeyTy getAsKey() const { + return KeyTy(lhsBatchingDimensions, rhsBatchingDimensions, lhsContractingDimensions, rhsContractingDimensions); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (lhsBatchingDimensions == std::get<0>(tblgenKey)) && (rhsBatchingDimensions == std::get<1>(tblgenKey)) && (lhsContractingDimensions == std::get<2>(tblgenKey)) && (rhsContractingDimensions == std::get<3>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey)); + } + + static DotDimensionNumbersAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto lhsBatchingDimensions = std::move(std::get<0>(tblgenKey)); + auto rhsBatchingDimensions = std::move(std::get<1>(tblgenKey)); + auto lhsContractingDimensions = std::move(std::get<2>(tblgenKey)); + auto rhsContractingDimensions = std::move(std::get<3>(tblgenKey)); + lhsBatchingDimensions = allocator.copyInto(lhsBatchingDimensions); + rhsBatchingDimensions = allocator.copyInto(rhsBatchingDimensions); + lhsContractingDimensions = allocator.copyInto(lhsContractingDimensions); + rhsContractingDimensions = allocator.copyInto(rhsContractingDimensions); + return new (allocator.allocate()) DotDimensionNumbersAttrStorage(std::move(lhsBatchingDimensions), std::move(rhsBatchingDimensions), std::move(lhsContractingDimensions), std::move(rhsContractingDimensions)); + } + + ::llvm::ArrayRef lhsBatchingDimensions; + ::llvm::ArrayRef rhsBatchingDimensions; + ::llvm::ArrayRef lhsContractingDimensions; + ::llvm::ArrayRef rhsContractingDimensions; +}; +} // namespace detail +DotDimensionNumbersAttr DotDimensionNumbersAttr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef lhsBatchingDimensions, ::llvm::ArrayRef rhsBatchingDimensions, ::llvm::ArrayRef lhsContractingDimensions, ::llvm::ArrayRef rhsContractingDimensions) { + return Base::get(context, std::move(lhsBatchingDimensions), std::move(rhsBatchingDimensions), std::move(lhsContractingDimensions), std::move(rhsContractingDimensions)); +} + +::llvm::ArrayRef DotDimensionNumbersAttr::getLhsBatchingDimensions() const { + return getImpl()->lhsBatchingDimensions; +} + +::llvm::ArrayRef DotDimensionNumbersAttr::getRhsBatchingDimensions() const { + return getImpl()->rhsBatchingDimensions; +} + +::llvm::ArrayRef DotDimensionNumbersAttr::getLhsContractingDimensions() const { + return getImpl()->lhsContractingDimensions; +} + +::llvm::ArrayRef DotDimensionNumbersAttr::getRhsContractingDimensions() const { + return getImpl()->rhsContractingDimensions; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DotDimensionNumbersAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct OutputOperandAliasAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef, int64_t, ::llvm::ArrayRef>; + OutputOperandAliasAttrStorage(::llvm::ArrayRef outputTupleIndices, int64_t operandIndex, ::llvm::ArrayRef operandTupleIndices) : outputTupleIndices(std::move(outputTupleIndices)), operandIndex(std::move(operandIndex)), operandTupleIndices(std::move(operandTupleIndices)) {} + + KeyTy getAsKey() const { + return KeyTy(outputTupleIndices, operandIndex, operandTupleIndices); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (outputTupleIndices == std::get<0>(tblgenKey)) && (operandIndex == std::get<1>(tblgenKey)) && (operandTupleIndices == std::get<2>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey)); + } + + static OutputOperandAliasAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto outputTupleIndices = std::move(std::get<0>(tblgenKey)); + auto operandIndex = std::move(std::get<1>(tblgenKey)); + auto operandTupleIndices = std::move(std::get<2>(tblgenKey)); + outputTupleIndices = allocator.copyInto(outputTupleIndices); + operandTupleIndices = allocator.copyInto(operandTupleIndices); + return new (allocator.allocate()) OutputOperandAliasAttrStorage(std::move(outputTupleIndices), std::move(operandIndex), std::move(operandTupleIndices)); + } + + ::llvm::ArrayRef outputTupleIndices; + int64_t operandIndex; + ::llvm::ArrayRef operandTupleIndices; +}; +} // namespace detail +OutputOperandAliasAttr OutputOperandAliasAttr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef outputTupleIndices, int64_t operandIndex, ::llvm::ArrayRef operandTupleIndices) { + return Base::get(context, std::move(outputTupleIndices), std::move(operandIndex), std::move(operandTupleIndices)); +} + +::mlir::Attribute OutputOperandAliasAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::llvm::SmallVector> _result_outputTupleIndices; + ::mlir::FailureOr _result_operandIndex; + ::mlir::FailureOr<::llvm::SmallVector> _result_operandTupleIndices; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + // Parse literal 'output_tuple_indices' + if (odsParser.parseKeyword("output_tuple_indices")) return {}; + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + + // Parse variable 'outputTupleIndices' + _result_outputTupleIndices = parseDimSizes(odsParser); + if (::mlir::failed(_result_outputTupleIndices)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_OutputOperandAlias parameter 'outputTupleIndices' which is to be a `::llvm::ArrayRef`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + // Parse literal 'operand_index' + if (odsParser.parseKeyword("operand_index")) return {}; + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + + // Parse variable 'operandIndex' + _result_operandIndex = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_operandIndex)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_OutputOperandAlias parameter 'operandIndex' which is to be a `int64_t`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + // Parse literal 'operand_tuple_indices' + if (odsParser.parseKeyword("operand_tuple_indices")) return {}; + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + + // Parse variable 'operandTupleIndices' + _result_operandTupleIndices = parseDimSizes(odsParser); + if (::mlir::failed(_result_operandTupleIndices)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_OutputOperandAlias parameter 'operandTupleIndices' which is to be a `::llvm::ArrayRef`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_outputTupleIndices)); + assert(::mlir::succeeded(_result_operandIndex)); + assert(::mlir::succeeded(_result_operandTupleIndices)); + return OutputOperandAliasAttr::get(odsParser.getContext(), + ::llvm::ArrayRef((*_result_outputTupleIndices)), + int64_t((*_result_operandIndex)), + ::llvm::ArrayRef((*_result_operandTupleIndices))); +} + +void OutputOperandAliasAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter << "output_tuple_indices"; + odsPrinter << ' ' << "="; + odsPrinter << ' '; + printDimSizes(odsPrinter, getOutputTupleIndices()); + odsPrinter << ","; + odsPrinter << ' ' << "operand_index"; + odsPrinter << ' ' << "="; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getOperandIndex()); + odsPrinter << ","; + odsPrinter << ' ' << "operand_tuple_indices"; + odsPrinter << ' ' << "="; + odsPrinter << ' '; + printDimSizes(odsPrinter, getOperandTupleIndices()); + odsPrinter << ">"; +} + +::llvm::ArrayRef OutputOperandAliasAttr::getOutputTupleIndices() const { + return getImpl()->outputTupleIndices; +} + +int64_t OutputOperandAliasAttr::getOperandIndex() const { + return getImpl()->operandIndex; +} + +::llvm::ArrayRef OutputOperandAliasAttr::getOperandTupleIndices() const { + return getImpl()->operandTupleIndices; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::OutputOperandAliasAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct ChannelHandleAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple; + ChannelHandleAttrStorage(int64_t handle, int64_t type) : handle(std::move(handle)), type(std::move(type)) {} + + KeyTy getAsKey() const { + return KeyTy(handle, type); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (handle == std::get<0>(tblgenKey)) && (type == std::get<1>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); + } + + static ChannelHandleAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto handle = std::move(std::get<0>(tblgenKey)); + auto type = std::move(std::get<1>(tblgenKey)); + return new (allocator.allocate()) ChannelHandleAttrStorage(std::move(handle), std::move(type)); + } + + int64_t handle; + int64_t type; +}; +} // namespace detail +ChannelHandleAttr ChannelHandleAttr::get(::mlir::MLIRContext *context, int64_t handle, int64_t type) { + return Base::get(context, std::move(handle), std::move(type)); +} + +::mlir::Attribute ChannelHandleAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr _result_handle; + ::mlir::FailureOr _result_type; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + // Parse parameter struct + bool _seen_handle = false; + bool _seen_type = false; + { + const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool { + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + if (!_seen_handle && _paramKey == "handle") { + _seen_handle = true; + + // Parse variable 'handle' + _result_handle = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_handle)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_ChannelHandle parameter 'handle' which is to be a `int64_t`"); + return {}; + } + } else if (!_seen_type && _paramKey == "type") { + _seen_type = true; + + // Parse variable 'type' + _result_type = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_type)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse StableHLO_ChannelHandle parameter 'type' which is to be a `int64_t`"); + return {}; + } + } else { + odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey; + return {}; + } + return true; + }; + for (unsigned odsStructIndex = 0; odsStructIndex < 2; ++odsStructIndex) { + ::llvm::StringRef _paramKey; + if (odsParser.parseKeyword(&_paramKey)) { + odsParser.emitError(odsParser.getCurrentLocation(), + "expected a parameter name in struct"); + return {}; + } + if (!_loop_body(_paramKey)) return {}; + if ((odsStructIndex != 2 - 1) && odsParser.parseComma()) + return {}; + } + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_handle)); + assert(::mlir::succeeded(_result_type)); + return ChannelHandleAttr::get(odsParser.getContext(), + int64_t((*_result_handle)), + int64_t((*_result_type))); +} + +void ChannelHandleAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + { + bool _firstPrinted = true; + if (!_firstPrinted) odsPrinter << ", "; + _firstPrinted = false; + odsPrinter << "handle = "; + odsPrinter.printStrippedAttrOrType(getHandle()); + if (!_firstPrinted) odsPrinter << ", "; + _firstPrinted = false; + odsPrinter << "type = "; + odsPrinter.printStrippedAttrOrType(getType()); + } + odsPrinter << ">"; +} + +int64_t ChannelHandleAttr::getHandle() const { + return getImpl()->handle; +} + +int64_t ChannelHandleAttr::getType() const { + return getImpl()->type; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ChannelHandleAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct TypeExtensionsAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef>; + TypeExtensionsAttrStorage(::llvm::ArrayRef bounds) : bounds(std::move(bounds)) {} + + KeyTy getAsKey() const { + return KeyTy(bounds); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (bounds == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static TypeExtensionsAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto bounds = std::move(std::get<0>(tblgenKey)); + bounds = allocator.copyInto(bounds); + return new (allocator.allocate()) TypeExtensionsAttrStorage(std::move(bounds)); + } + + ::llvm::ArrayRef bounds; +}; +} // namespace detail +TypeExtensionsAttr TypeExtensionsAttr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef bounds) { + return Base::get(context, std::move(bounds)); +} + +::mlir::Attribute TypeExtensionsAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::llvm::SmallVector> _result_bounds; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + // Parse literal 'bounds' + if (odsParser.parseKeyword("bounds")) return {}; + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + { + auto odsCustomLoc = odsParser.getCurrentLocation(); + (void)odsCustomLoc; + auto odsCustomResult = parseDimSizes(odsParser, + ::mlir::detail::unwrapForCustomParse(_result_bounds)); + if (::mlir::failed(odsCustomResult)) return {}; + if (::mlir::failed(_result_bounds)) { + odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'bounds'"); + return {}; + } + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_bounds)); + return TypeExtensionsAttr::get(odsParser.getContext(), + ::llvm::ArrayRef((*_result_bounds))); +} + +void TypeExtensionsAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter << "bounds"; + odsPrinter << ' ' << "="; + odsPrinter << " "; + printDimSizes(odsPrinter, + getBounds()); + odsPrinter << ">"; +} + +::llvm::ArrayRef TypeExtensionsAttr::getBounds() const { + return getImpl()->bounds; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TypeExtensionsAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct ConvDimensionNumbersAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple, int64_t, int64_t, ::llvm::ArrayRef, int64_t, int64_t, ::llvm::ArrayRef>; + ConvDimensionNumbersAttrStorage(int64_t inputBatchDimension, int64_t inputFeatureDimension, ::llvm::ArrayRef inputSpatialDimensions, int64_t kernelInputFeatureDimension, int64_t kernelOutputFeatureDimension, ::llvm::ArrayRef kernelSpatialDimensions, int64_t outputBatchDimension, int64_t outputFeatureDimension, ::llvm::ArrayRef outputSpatialDimensions) : inputBatchDimension(std::move(inputBatchDimension)), inputFeatureDimension(std::move(inputFeatureDimension)), inputSpatialDimensions(std::move(inputSpatialDimensions)), kernelInputFeatureDimension(std::move(kernelInputFeatureDimension)), kernelOutputFeatureDimension(std::move(kernelOutputFeatureDimension)), kernelSpatialDimensions(std::move(kernelSpatialDimensions)), outputBatchDimension(std::move(outputBatchDimension)), outputFeatureDimension(std::move(outputFeatureDimension)), outputSpatialDimensions(std::move(outputSpatialDimensions)) {} + + KeyTy getAsKey() const { + return KeyTy(inputBatchDimension, inputFeatureDimension, inputSpatialDimensions, kernelInputFeatureDimension, kernelOutputFeatureDimension, kernelSpatialDimensions, outputBatchDimension, outputFeatureDimension, outputSpatialDimensions); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (inputBatchDimension == std::get<0>(tblgenKey)) && (inputFeatureDimension == std::get<1>(tblgenKey)) && (inputSpatialDimensions == std::get<2>(tblgenKey)) && (kernelInputFeatureDimension == std::get<3>(tblgenKey)) && (kernelOutputFeatureDimension == std::get<4>(tblgenKey)) && (kernelSpatialDimensions == std::get<5>(tblgenKey)) && (outputBatchDimension == std::get<6>(tblgenKey)) && (outputFeatureDimension == std::get<7>(tblgenKey)) && (outputSpatialDimensions == std::get<8>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey), std::get<4>(tblgenKey), std::get<5>(tblgenKey), std::get<6>(tblgenKey), std::get<7>(tblgenKey), std::get<8>(tblgenKey)); + } + + static ConvDimensionNumbersAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto inputBatchDimension = std::move(std::get<0>(tblgenKey)); + auto inputFeatureDimension = std::move(std::get<1>(tblgenKey)); + auto inputSpatialDimensions = std::move(std::get<2>(tblgenKey)); + auto kernelInputFeatureDimension = std::move(std::get<3>(tblgenKey)); + auto kernelOutputFeatureDimension = std::move(std::get<4>(tblgenKey)); + auto kernelSpatialDimensions = std::move(std::get<5>(tblgenKey)); + auto outputBatchDimension = std::move(std::get<6>(tblgenKey)); + auto outputFeatureDimension = std::move(std::get<7>(tblgenKey)); + auto outputSpatialDimensions = std::move(std::get<8>(tblgenKey)); + inputSpatialDimensions = allocator.copyInto(inputSpatialDimensions); + kernelSpatialDimensions = allocator.copyInto(kernelSpatialDimensions); + outputSpatialDimensions = allocator.copyInto(outputSpatialDimensions); + return new (allocator.allocate()) ConvDimensionNumbersAttrStorage(std::move(inputBatchDimension), std::move(inputFeatureDimension), std::move(inputSpatialDimensions), std::move(kernelInputFeatureDimension), std::move(kernelOutputFeatureDimension), std::move(kernelSpatialDimensions), std::move(outputBatchDimension), std::move(outputFeatureDimension), std::move(outputSpatialDimensions)); + } + + int64_t inputBatchDimension; + int64_t inputFeatureDimension; + ::llvm::ArrayRef inputSpatialDimensions; + int64_t kernelInputFeatureDimension; + int64_t kernelOutputFeatureDimension; + ::llvm::ArrayRef kernelSpatialDimensions; + int64_t outputBatchDimension; + int64_t outputFeatureDimension; + ::llvm::ArrayRef outputSpatialDimensions; +}; +} // namespace detail +ConvDimensionNumbersAttr ConvDimensionNumbersAttr::get(::mlir::MLIRContext *context, int64_t inputBatchDimension, int64_t inputFeatureDimension, ::llvm::ArrayRef inputSpatialDimensions, int64_t kernelInputFeatureDimension, int64_t kernelOutputFeatureDimension, ::llvm::ArrayRef kernelSpatialDimensions, int64_t outputBatchDimension, int64_t outputFeatureDimension, ::llvm::ArrayRef outputSpatialDimensions) { + return Base::get(context, std::move(inputBatchDimension), std::move(inputFeatureDimension), std::move(inputSpatialDimensions), std::move(kernelInputFeatureDimension), std::move(kernelOutputFeatureDimension), std::move(kernelSpatialDimensions), std::move(outputBatchDimension), std::move(outputFeatureDimension), std::move(outputSpatialDimensions)); +} + +int64_t ConvDimensionNumbersAttr::getInputBatchDimension() const { + return getImpl()->inputBatchDimension; +} + +int64_t ConvDimensionNumbersAttr::getInputFeatureDimension() const { + return getImpl()->inputFeatureDimension; +} + +::llvm::ArrayRef ConvDimensionNumbersAttr::getInputSpatialDimensions() const { + return getImpl()->inputSpatialDimensions; +} + +int64_t ConvDimensionNumbersAttr::getKernelInputFeatureDimension() const { + return getImpl()->kernelInputFeatureDimension; +} + +int64_t ConvDimensionNumbersAttr::getKernelOutputFeatureDimension() const { + return getImpl()->kernelOutputFeatureDimension; +} + +::llvm::ArrayRef ConvDimensionNumbersAttr::getKernelSpatialDimensions() const { + return getImpl()->kernelSpatialDimensions; +} + +int64_t ConvDimensionNumbersAttr::getOutputBatchDimension() const { + return getImpl()->outputBatchDimension; +} + +int64_t ConvDimensionNumbersAttr::getOutputFeatureDimension() const { + return getImpl()->outputFeatureDimension; +} + +::llvm::ArrayRef ConvDimensionNumbersAttr::getOutputSpatialDimensions() const { + return getImpl()->outputSpatialDimensions; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ConvDimensionNumbersAttr) +namespace mlir { +namespace stablehlo { +namespace detail { +struct ResultAccuracyAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple; + ResultAccuracyAttrStorage(APFloat atol, APFloat rtol, int64_t ulps, ::mlir::stablehlo::ResultAccuracyModeAttr mode) : atol(std::move(atol)), rtol(std::move(rtol)), ulps(std::move(ulps)), mode(std::move(mode)) {} + + KeyTy getAsKey() const { + return KeyTy(atol, rtol, ulps, mode); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (atol == std::get<0>(tblgenKey)) && (rtol == std::get<1>(tblgenKey)) && (ulps == std::get<2>(tblgenKey)) && (mode == std::get<3>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey)); + } + + static ResultAccuracyAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto atol = std::move(std::get<0>(tblgenKey)); + auto rtol = std::move(std::get<1>(tblgenKey)); + auto ulps = std::move(std::get<2>(tblgenKey)); + auto mode = std::move(std::get<3>(tblgenKey)); + return new (allocator.allocate()) ResultAccuracyAttrStorage(std::move(atol), std::move(rtol), std::move(ulps), std::move(mode)); + } + + APFloat atol; + APFloat rtol; + int64_t ulps; + ::mlir::stablehlo::ResultAccuracyModeAttr mode; +}; +} // namespace detail +ResultAccuracyAttr ResultAccuracyAttr::get(::mlir::MLIRContext *context, APFloat atol, APFloat rtol, int64_t ulps, ::mlir::stablehlo::ResultAccuracyModeAttr mode) { + return Base::get(context, std::move(atol), std::move(rtol), std::move(ulps), std::move(mode)); +} + +ResultAccuracyAttr ResultAccuracyAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, APFloat atol, APFloat rtol, int64_t ulps, ::mlir::stablehlo::ResultAccuracyModeAttr mode) { + return Base::getChecked(emitError, context, atol, rtol, ulps, mode); +} + +::llvm::LogicalResult ResultAccuracyAttr::verifyInvariantsImpl(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, APFloat atol, APFloat rtol, int64_t ulps, ::mlir::stablehlo::ResultAccuracyModeAttr mode) { + if (!((::llvm::isa<::mlir::stablehlo::ResultAccuracyModeAttr>(mode)))) { + emitError() << "failed to verify 'mode': XLA result accuracy mode."; + return ::mlir::failure(); + } + + return ::mlir::success(); +} + +::llvm::LogicalResult ResultAccuracyAttr::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, APFloat atol, APFloat rtol, int64_t ulps, ::mlir::stablehlo::ResultAccuracyModeAttr mode) { + if (::mlir::failed(verifyInvariantsImpl(emitError, atol, rtol, ulps, mode))) + return ::mlir::failure(); + if (::mlir::failed(verify(emitError, atol, rtol, ulps, mode))) + return ::mlir::failure(); + return ::mlir::success(); +} + +APFloat ResultAccuracyAttr::getAtol() const { + return getImpl()->atol; +} + +APFloat ResultAccuracyAttr::getRtol() const { + return getImpl()->rtol; +} + +int64_t ResultAccuracyAttr::getUlps() const { + return getImpl()->ulps; +} + +::mlir::stablehlo::ResultAccuracyModeAttr ResultAccuracyAttr::getMode() const { + return getImpl()->mode; +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ResultAccuracyAttr) + +#endif // GET_ATTRDEF_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloAttrs.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloAttrs.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..06a530eb6e59351a7c2dac76bfb690a45ab9f033 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloAttrs.h.inc @@ -0,0 +1,436 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_ATTRDEF_CLASSES +#undef GET_ATTRDEF_CLASSES + + +namespace mlir { +class AsmParser; +class AsmPrinter; +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// XLA precision for an operand. Has backend specific meaning. +class PrecisionAttr; +/// XLA result accuracy mode. +class ResultAccuracyModeAttr; +/// XLA fast fourier transform type. +class FftTypeAttr; +/// Which comparison operation to perform. +class ComparisonDirectionAttr; +/// Which comparison type to use. +class ComparisonTypeAttr; +/// Transpose options +class TransposeAttr; +/// XLA PRNG distribution to be used. +class RngDistributionAttr; +/// XLA PRNG algorithm to be used. +class RngAlgorithmAttr; +/// Attribute that models the dimension information for scatter +class ScatterDimensionNumbersAttr; +/// Attribute that models the dimension information for gather +class GatherDimensionNumbersAttr; +/// Attribute that models the algorithm constraints to use for computing dot. +class DotAlgorithmAttr; +/// Attribute that models the dimension information for dot. +class DotDimensionNumbersAttr; +/// Attribute that models the alias relationship of output and operand of a CustomCall op +/// This attribute captures the alias relationship of the output to one of the +/// operands for a CustomCall op, denoted by `operand_index`. The +/// `output_tuple_indices` and `operand_tuple_indices` are used to index into +/// output and operand types. These indices lists are empty if the corresponding +/// types are not tuple types, and can be arbitrarily long in case of +/// arbitrarily nested tuple types. +/// +/// See https://www.tensorflow.org/xla/aliasing. +/// +/// Example when used as array with in stablehlo.custom-call: +/// +/// ```mlir +/// %0 = "stablehlo.custom_call"(%arg0, %arg1) { +/// // other attributes +/// output_operand_alias = [ +/// #stablehlo.output_operand_alias +/// ] +/// } : (tuple, tensor<2x3xf32>>, tensor<5x5xf32>) -> tuple> +/// +/// The output and the 0th operand are both tuples. The aliasing shows the +/// relationship between the 0th element in output tuple with the 1st element in +/// the 0th operand. And both of them are of the same type: tensor<2x3xf32>. +/// ``` +class OutputOperandAliasAttr; +/// two 64-bit integers 'handle' and 'type' +class ChannelHandleAttr; +/// Attribute that extends tensor type with StableHLO type properties. +/// This attribute is used to extend MLIR tensor type with StableHLO tensor +/// specific properties. These properties aren't modeled in the MLIR type. This +/// attribute is set in the `encoding` field of the tensor type. +/// +/// See `HLO_BoundedAttrInterface` for documentation for `bounds`. +class TypeExtensionsAttr; +/// Structure of dimension information for conv op +class ConvDimensionNumbersAttr; +/// The requested accuracy for transcendental unary ops. +class ResultAccuracyAttr; +namespace detail { +struct PrecisionAttrStorage; +} // namespace detail +class PrecisionAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.precision"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static PrecisionAttr get(::mlir::MLIRContext *context, ::mlir::stablehlo::Precision value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"precision"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::stablehlo::Precision getValue() const; +}; +namespace detail { +struct ResultAccuracyModeAttrStorage; +} // namespace detail +class ResultAccuracyModeAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.result_accuracy_mode"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static ResultAccuracyModeAttr get(::mlir::MLIRContext *context, ::mlir::stablehlo::ResultAccuracyMode value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"result_accuracy_mode"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::stablehlo::ResultAccuracyMode getValue() const; +}; +namespace detail { +struct FftTypeAttrStorage; +} // namespace detail +class FftTypeAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.fft_type"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static FftTypeAttr get(::mlir::MLIRContext *context, ::mlir::stablehlo::FftType value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"fft_type"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::stablehlo::FftType getValue() const; +}; +namespace detail { +struct ComparisonDirectionAttrStorage; +} // namespace detail +class ComparisonDirectionAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.comparison_direction"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static ComparisonDirectionAttr get(::mlir::MLIRContext *context, ::mlir::stablehlo::ComparisonDirection value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"comparison_direction"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::stablehlo::ComparisonDirection getValue() const; +}; +namespace detail { +struct ComparisonTypeAttrStorage; +} // namespace detail +class ComparisonTypeAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.comparison_type"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static ComparisonTypeAttr get(::mlir::MLIRContext *context, ::mlir::stablehlo::ComparisonType value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"comparison_type"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::stablehlo::ComparisonType getValue() const; +}; +namespace detail { +struct TransposeAttrStorage; +} // namespace detail +class TransposeAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.transpose"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static TransposeAttr get(::mlir::MLIRContext *context, ::mlir::stablehlo::Transpose value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"transpose"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::stablehlo::Transpose getValue() const; +}; +namespace detail { +struct RngDistributionAttrStorage; +} // namespace detail +class RngDistributionAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.rng_distribution"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static RngDistributionAttr get(::mlir::MLIRContext *context, ::mlir::stablehlo::RngDistribution value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"rng_distribution"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::stablehlo::RngDistribution getValue() const; +}; +namespace detail { +struct RngAlgorithmAttrStorage; +} // namespace detail +class RngAlgorithmAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.rng_algorithm"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static RngAlgorithmAttr get(::mlir::MLIRContext *context, ::mlir::stablehlo::RngAlgorithm value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"rng_algorithm"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::stablehlo::RngAlgorithm getValue() const; +}; +namespace detail { +struct ScatterDimensionNumbersAttrStorage; +} // namespace detail +class ScatterDimensionNumbersAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.scatter"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static ScatterDimensionNumbersAttr get(::mlir::MLIRContext *context, ::llvm::ArrayRef updateWindowDims, ::llvm::ArrayRef insertedWindowDims, ::llvm::ArrayRef inputBatchingDims, ::llvm::ArrayRef scatterIndicesBatchingDims, ::llvm::ArrayRef scatterDimsToOperandDims, int64_t indexVectorDim); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"scatter"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef getUpdateWindowDims() const; + ::llvm::ArrayRef getInsertedWindowDims() const; + ::llvm::ArrayRef getInputBatchingDims() const; + ::llvm::ArrayRef getScatterIndicesBatchingDims() const; + ::llvm::ArrayRef getScatterDimsToOperandDims() const; + int64_t getIndexVectorDim() const; +}; +namespace detail { +struct GatherDimensionNumbersAttrStorage; +} // namespace detail +class GatherDimensionNumbersAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.gather"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static GatherDimensionNumbersAttr get(::mlir::MLIRContext *context, ::llvm::ArrayRef offsetDims, ::llvm::ArrayRef collapsedSliceDims, ::llvm::ArrayRef operandBatchingDims, ::llvm::ArrayRef startIndicesBatchingDims, ::llvm::ArrayRef startIndexMap, int64_t indexVectorDim); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"gather"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef getOffsetDims() const; + ::llvm::ArrayRef getCollapsedSliceDims() const; + ::llvm::ArrayRef getOperandBatchingDims() const; + ::llvm::ArrayRef getStartIndicesBatchingDims() const; + ::llvm::ArrayRef getStartIndexMap() const; + int64_t getIndexVectorDim() const; +}; +namespace detail { +struct DotAlgorithmAttrStorage; +} // namespace detail +class DotAlgorithmAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.dot_algorithm"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + using Base::getChecked; + static DotAlgorithmAttr get(::mlir::MLIRContext *context, Type lhsPrecisionType, Type rhsPrecisionType, Type accumulationType, int64_t lhsComponentCount, int64_t rhsComponentCount, int64_t numPrimitiveOperations, bool allowImpreciseAccumulation); + static DotAlgorithmAttr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, Type lhsPrecisionType, Type rhsPrecisionType, Type accumulationType, int64_t lhsComponentCount, int64_t rhsComponentCount, int64_t numPrimitiveOperations, bool allowImpreciseAccumulation); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, Type lhsPrecisionType, Type rhsPrecisionType, Type accumulationType, int64_t lhsComponentCount, int64_t rhsComponentCount, int64_t numPrimitiveOperations, bool allowImpreciseAccumulation); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, Type lhsPrecisionType, Type rhsPrecisionType, Type accumulationType, int64_t lhsComponentCount, int64_t rhsComponentCount, int64_t numPrimitiveOperations, bool allowImpreciseAccumulation); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"dot_algorithm"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + Type getLhsPrecisionType() const; + Type getRhsPrecisionType() const; + Type getAccumulationType() const; + int64_t getLhsComponentCount() const; + int64_t getRhsComponentCount() const; + int64_t getNumPrimitiveOperations() const; + bool getAllowImpreciseAccumulation() const; +}; +namespace detail { +struct DotDimensionNumbersAttrStorage; +} // namespace detail +class DotDimensionNumbersAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.dot"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static DotDimensionNumbersAttr get(::mlir::MLIRContext *context, ::llvm::ArrayRef lhsBatchingDimensions, ::llvm::ArrayRef rhsBatchingDimensions, ::llvm::ArrayRef lhsContractingDimensions, ::llvm::ArrayRef rhsContractingDimensions); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"dot"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef getLhsBatchingDimensions() const; + ::llvm::ArrayRef getRhsBatchingDimensions() const; + ::llvm::ArrayRef getLhsContractingDimensions() const; + ::llvm::ArrayRef getRhsContractingDimensions() const; +}; +namespace detail { +struct OutputOperandAliasAttrStorage; +} // namespace detail +class OutputOperandAliasAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.output_operand_alias"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static OutputOperandAliasAttr get(::mlir::MLIRContext *context, ::llvm::ArrayRef outputTupleIndices, int64_t operandIndex, ::llvm::ArrayRef operandTupleIndices); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"output_operand_alias"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef getOutputTupleIndices() const; + int64_t getOperandIndex() const; + ::llvm::ArrayRef getOperandTupleIndices() const; +}; +namespace detail { +struct ChannelHandleAttrStorage; +} // namespace detail +class ChannelHandleAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.channel_handle"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static ChannelHandleAttr get(::mlir::MLIRContext *context, int64_t handle, int64_t type); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"channel_handle"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + int64_t getHandle() const; + int64_t getType() const; +}; +namespace detail { +struct TypeExtensionsAttrStorage; +} // namespace detail +class TypeExtensionsAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.type_extensions"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static TypeExtensionsAttr get(::mlir::MLIRContext *context, ::llvm::ArrayRef bounds); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"type_extensions"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef getBounds() const; + ::llvm::LogicalResult verifyEncoding(::mlir::ArrayRef shape, ::mlir::Type elementType, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) const; +}; +namespace detail { +struct ConvDimensionNumbersAttrStorage; +} // namespace detail +class ConvDimensionNumbersAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.conv"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static ConvDimensionNumbersAttr get(::mlir::MLIRContext *context, int64_t inputBatchDimension, int64_t inputFeatureDimension, ::llvm::ArrayRef inputSpatialDimensions, int64_t kernelInputFeatureDimension, int64_t kernelOutputFeatureDimension, ::llvm::ArrayRef kernelSpatialDimensions, int64_t outputBatchDimension, int64_t outputFeatureDimension, ::llvm::ArrayRef outputSpatialDimensions); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"conv"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + int64_t getInputBatchDimension() const; + int64_t getInputFeatureDimension() const; + ::llvm::ArrayRef getInputSpatialDimensions() const; + int64_t getKernelInputFeatureDimension() const; + int64_t getKernelOutputFeatureDimension() const; + ::llvm::ArrayRef getKernelSpatialDimensions() const; + int64_t getOutputBatchDimension() const; + int64_t getOutputFeatureDimension() const; + ::llvm::ArrayRef getOutputSpatialDimensions() const; +}; +namespace detail { +struct ResultAccuracyAttrStorage; +} // namespace detail +class ResultAccuracyAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.result_accuracy"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + using Base::getChecked; + static ResultAccuracyAttr get(::mlir::MLIRContext *context, APFloat atol, APFloat rtol, int64_t ulps, ::mlir::stablehlo::ResultAccuracyModeAttr mode); + static ResultAccuracyAttr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, APFloat atol, APFloat rtol, int64_t ulps, ::mlir::stablehlo::ResultAccuracyModeAttr mode); + static ::llvm::LogicalResult verifyInvariantsImpl(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, APFloat atol, APFloat rtol, int64_t ulps, ::mlir::stablehlo::ResultAccuracyModeAttr mode); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, APFloat atol, APFloat rtol, int64_t ulps, ::mlir::stablehlo::ResultAccuracyModeAttr mode); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, APFloat atol, APFloat rtol, int64_t ulps, ::mlir::stablehlo::ResultAccuracyModeAttr mode); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"result_accuracy"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + APFloat getAtol() const; + APFloat getRtol() const; + int64_t getUlps() const; + ::mlir::stablehlo::ResultAccuracyModeAttr getMode() const; +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::PrecisionAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ResultAccuracyModeAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::FftTypeAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ComparisonDirectionAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ComparisonTypeAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TransposeAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RngDistributionAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RngAlgorithmAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ScatterDimensionNumbersAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::GatherDimensionNumbersAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DotAlgorithmAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DotDimensionNumbersAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::OutputOperandAliasAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ChannelHandleAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TypeExtensionsAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ConvDimensionNumbersAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ResultAccuracyAttr) + +#endif // GET_ATTRDEF_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloBytecode.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloBytecode.h new file mode 100644 index 0000000000000000000000000000000000000000..16d6a7fe97712a0553f36845e73057dd3638e1c1 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloBytecode.h @@ -0,0 +1,28 @@ +/* Copyright 2022 The StableHLO Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_STABLEHLO_BYTECODE_H +#define STABLEHLO_DIALECT_STABLEHLO_BYTECODE_H + +namespace mlir { +namespace stablehlo { +class StablehloDialect; + +// Add the interface necessary for encoding and decoding StableHLO dialect +// components in bytecode. +void addBytecodeInterface(StablehloDialect *dialect); +} // namespace stablehlo +} // namespace mlir + +#endif // STABLEHLO_DIALECT_STABLEHLO_BYTECODE_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloEnums.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloEnums.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..ffbc2e180ec30da28064faa82c2c6f6e0ac83748 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloEnums.cpp.inc @@ -0,0 +1,314 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: StablehloOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace stablehlo { +::llvm::StringRef stringifyComparisonDirection(ComparisonDirection val) { + switch (val) { + case ComparisonDirection::EQ: return "EQ"; + case ComparisonDirection::NE: return "NE"; + case ComparisonDirection::GE: return "GE"; + case ComparisonDirection::GT: return "GT"; + case ComparisonDirection::LE: return "LE"; + case ComparisonDirection::LT: return "LT"; + } + return ""; +} + +::std::optional symbolizeComparisonDirection(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("EQ", ComparisonDirection::EQ) + .Case("NE", ComparisonDirection::NE) + .Case("GE", ComparisonDirection::GE) + .Case("GT", ComparisonDirection::GT) + .Case("LE", ComparisonDirection::LE) + .Case("LT", ComparisonDirection::LT) + .Default(::std::nullopt); +} +::std::optional symbolizeComparisonDirection(uint32_t value) { + switch (value) { + case 0: return ComparisonDirection::EQ; + case 1: return ComparisonDirection::NE; + case 2: return ComparisonDirection::GE; + case 3: return ComparisonDirection::GT; + case 4: return ComparisonDirection::LE; + case 5: return ComparisonDirection::LT; + default: return ::std::nullopt; + } +} + +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +namespace stablehlo { +::llvm::StringRef stringifyComparisonType(ComparisonType val) { + switch (val) { + case ComparisonType::NOTYPE: return "NOTYPE"; + case ComparisonType::FLOAT: return "FLOAT"; + case ComparisonType::TOTALORDER: return "TOTALORDER"; + case ComparisonType::SIGNED: return "SIGNED"; + case ComparisonType::UNSIGNED: return "UNSIGNED"; + } + return ""; +} + +::std::optional symbolizeComparisonType(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("NOTYPE", ComparisonType::NOTYPE) + .Case("FLOAT", ComparisonType::FLOAT) + .Case("TOTALORDER", ComparisonType::TOTALORDER) + .Case("SIGNED", ComparisonType::SIGNED) + .Case("UNSIGNED", ComparisonType::UNSIGNED) + .Default(::std::nullopt); +} +::std::optional symbolizeComparisonType(uint32_t value) { + switch (value) { + case 0: return ComparisonType::NOTYPE; + case 1: return ComparisonType::FLOAT; + case 2: return ComparisonType::TOTALORDER; + case 3: return ComparisonType::SIGNED; + case 4: return ComparisonType::UNSIGNED; + default: return ::std::nullopt; + } +} + +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +namespace stablehlo { +::llvm::StringRef stringifyCustomCallApiVersion(CustomCallApiVersion val) { + switch (val) { + case CustomCallApiVersion::API_VERSION_UNSPECIFIED: return "API_VERSION_UNSPECIFIED"; + case CustomCallApiVersion::API_VERSION_ORIGINAL: return "API_VERSION_ORIGINAL"; + case CustomCallApiVersion::API_VERSION_STATUS_RETURNING: return "API_VERSION_STATUS_RETURNING"; + case CustomCallApiVersion::API_VERSION_STATUS_RETURNING_UNIFIED: return "API_VERSION_STATUS_RETURNING_UNIFIED"; + case CustomCallApiVersion::API_VERSION_TYPED_FFI: return "API_VERSION_TYPED_FFI"; + } + return ""; +} + +::std::optional symbolizeCustomCallApiVersion(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("API_VERSION_UNSPECIFIED", CustomCallApiVersion::API_VERSION_UNSPECIFIED) + .Case("API_VERSION_ORIGINAL", CustomCallApiVersion::API_VERSION_ORIGINAL) + .Case("API_VERSION_STATUS_RETURNING", CustomCallApiVersion::API_VERSION_STATUS_RETURNING) + .Case("API_VERSION_STATUS_RETURNING_UNIFIED", CustomCallApiVersion::API_VERSION_STATUS_RETURNING_UNIFIED) + .Case("API_VERSION_TYPED_FFI", CustomCallApiVersion::API_VERSION_TYPED_FFI) + .Default(::std::nullopt); +} +::std::optional symbolizeCustomCallApiVersion(uint32_t value) { + switch (value) { + case 0: return CustomCallApiVersion::API_VERSION_UNSPECIFIED; + case 1: return CustomCallApiVersion::API_VERSION_ORIGINAL; + case 2: return CustomCallApiVersion::API_VERSION_STATUS_RETURNING; + case 3: return CustomCallApiVersion::API_VERSION_STATUS_RETURNING_UNIFIED; + case 4: return CustomCallApiVersion::API_VERSION_TYPED_FFI; + default: return ::std::nullopt; + } +} + +bool CustomCallApiVersionAttr::classof(::mlir::Attribute attr) { + return (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))) && (((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 0)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 1)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 2)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 3)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 4))); +} +CustomCallApiVersionAttr CustomCallApiVersionAttr::get(::mlir::MLIRContext *context, CustomCallApiVersion val) { + ::mlir::IntegerType intType = ::mlir::IntegerType::get(context, 32); + ::mlir::IntegerAttr baseAttr = ::mlir::IntegerAttr::get(intType, static_cast(val)); + return ::llvm::cast(baseAttr); +} +CustomCallApiVersion CustomCallApiVersionAttr::getValue() const { + return static_cast(::mlir::IntegerAttr::getInt()); +} +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +namespace stablehlo { +::llvm::StringRef stringifyFftType(FftType val) { + switch (val) { + case FftType::FFT: return "FFT"; + case FftType::IFFT: return "IFFT"; + case FftType::RFFT: return "RFFT"; + case FftType::IRFFT: return "IRFFT"; + } + return ""; +} + +::std::optional symbolizeFftType(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("FFT", FftType::FFT) + .Case("IFFT", FftType::IFFT) + .Case("RFFT", FftType::RFFT) + .Case("IRFFT", FftType::IRFFT) + .Default(::std::nullopt); +} +::std::optional symbolizeFftType(uint32_t value) { + switch (value) { + case 0: return FftType::FFT; + case 1: return FftType::IFFT; + case 2: return FftType::RFFT; + case 3: return FftType::IRFFT; + default: return ::std::nullopt; + } +} + +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +namespace stablehlo { +::llvm::StringRef stringifyPrecision(Precision val) { + switch (val) { + case Precision::DEFAULT: return "DEFAULT"; + case Precision::HIGH: return "HIGH"; + case Precision::HIGHEST: return "HIGHEST"; + } + return ""; +} + +::std::optional symbolizePrecision(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("DEFAULT", Precision::DEFAULT) + .Case("HIGH", Precision::HIGH) + .Case("HIGHEST", Precision::HIGHEST) + .Default(::std::nullopt); +} +::std::optional symbolizePrecision(uint32_t value) { + switch (value) { + case 0: return Precision::DEFAULT; + case 1: return Precision::HIGH; + case 2: return Precision::HIGHEST; + default: return ::std::nullopt; + } +} + +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +namespace stablehlo { +::llvm::StringRef stringifyResultAccuracyMode(ResultAccuracyMode val) { + switch (val) { + case ResultAccuracyMode::DEFAULT: return "DEFAULT"; + case ResultAccuracyMode::HIGHEST: return "HIGHEST"; + case ResultAccuracyMode::TOLERANCE: return "TOLERANCE"; + } + return ""; +} + +::std::optional symbolizeResultAccuracyMode(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("DEFAULT", ResultAccuracyMode::DEFAULT) + .Case("HIGHEST", ResultAccuracyMode::HIGHEST) + .Case("TOLERANCE", ResultAccuracyMode::TOLERANCE) + .Default(::std::nullopt); +} +::std::optional symbolizeResultAccuracyMode(uint32_t value) { + switch (value) { + case 0: return ResultAccuracyMode::DEFAULT; + case 1: return ResultAccuracyMode::HIGHEST; + case 2: return ResultAccuracyMode::TOLERANCE; + default: return ::std::nullopt; + } +} + +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +namespace stablehlo { +::llvm::StringRef stringifyRngAlgorithm(RngAlgorithm val) { + switch (val) { + case RngAlgorithm::DEFAULT: return "DEFAULT"; + case RngAlgorithm::THREE_FRY: return "THREE_FRY"; + case RngAlgorithm::PHILOX: return "PHILOX"; + } + return ""; +} + +::std::optional symbolizeRngAlgorithm(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("DEFAULT", RngAlgorithm::DEFAULT) + .Case("THREE_FRY", RngAlgorithm::THREE_FRY) + .Case("PHILOX", RngAlgorithm::PHILOX) + .Default(::std::nullopt); +} +::std::optional symbolizeRngAlgorithm(uint32_t value) { + switch (value) { + case 0: return RngAlgorithm::DEFAULT; + case 1: return RngAlgorithm::THREE_FRY; + case 2: return RngAlgorithm::PHILOX; + default: return ::std::nullopt; + } +} + +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +namespace stablehlo { +::llvm::StringRef stringifyRngDistribution(RngDistribution val) { + switch (val) { + case RngDistribution::UNIFORM: return "UNIFORM"; + case RngDistribution::NORMAL: return "NORMAL"; + } + return ""; +} + +::std::optional symbolizeRngDistribution(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("UNIFORM", RngDistribution::UNIFORM) + .Case("NORMAL", RngDistribution::NORMAL) + .Default(::std::nullopt); +} +::std::optional symbolizeRngDistribution(uint32_t value) { + switch (value) { + case 1: return RngDistribution::UNIFORM; + case 2: return RngDistribution::NORMAL; + default: return ::std::nullopt; + } +} + +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +namespace stablehlo { +::llvm::StringRef stringifyTranspose(Transpose val) { + switch (val) { + case Transpose::TRANSPOSE_INVALID: return "TRANSPOSE_INVALID"; + case Transpose::NO_TRANSPOSE: return "NO_TRANSPOSE"; + case Transpose::TRANSPOSE: return "TRANSPOSE"; + case Transpose::ADJOINT: return "ADJOINT"; + } + return ""; +} + +::std::optional symbolizeTranspose(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("TRANSPOSE_INVALID", Transpose::TRANSPOSE_INVALID) + .Case("NO_TRANSPOSE", Transpose::NO_TRANSPOSE) + .Case("TRANSPOSE", Transpose::TRANSPOSE) + .Case("ADJOINT", Transpose::ADJOINT) + .Default(::std::nullopt); +} +::std::optional symbolizeTranspose(uint32_t value) { + switch (value) { + case 0: return Transpose::TRANSPOSE_INVALID; + case 1: return Transpose::NO_TRANSPOSE; + case 2: return Transpose::TRANSPOSE; + case 3: return Transpose::ADJOINT; + default: return ::std::nullopt; + } +} + +} // namespace stablehlo +} // namespace mlir + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloEnums.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloEnums.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..9da026f2fc134df13e177127e03cd903c0dd5f01 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloEnums.h.inc @@ -0,0 +1,953 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: StablehloOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace stablehlo { +// Which comparison operation to perform. +enum class ComparisonDirection : uint32_t { + EQ = 0, + NE = 1, + GE = 2, + GT = 3, + LE = 4, + LT = 5, +}; + +::std::optional symbolizeComparisonDirection(uint32_t); +::llvm::StringRef stringifyComparisonDirection(ComparisonDirection); +::std::optional symbolizeComparisonDirection(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForComparisonDirection() { + return 5; +} + + +inline ::llvm::StringRef stringifyEnum(ComparisonDirection enumValue) { + return stringifyComparisonDirection(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeComparisonDirection(str); +} +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::stablehlo::ComparisonDirection, ::mlir::stablehlo::ComparisonDirection> { + template + static FailureOr<::mlir::stablehlo::ComparisonDirection> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for Which comparison operation to perform."); + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::ComparisonDirection> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::ComparisonDirection>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [EQ, NE, GE, GT, LE, LT] for Which comparison operation to perform., got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::stablehlo::ComparisonDirection>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::stablehlo::ComparisonDirection>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::ComparisonDirection> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::ComparisonDirection>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [EQ, NE, GE, GT, LE, LT] for Which comparison operation to perform., got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::stablehlo::ComparisonDirection value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::stablehlo::ComparisonDirection> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::stablehlo::ComparisonDirection getEmptyKey() { + return static_cast<::mlir::stablehlo::ComparisonDirection>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::stablehlo::ComparisonDirection getTombstoneKey() { + return static_cast<::mlir::stablehlo::ComparisonDirection>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::stablehlo::ComparisonDirection &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::stablehlo::ComparisonDirection &lhs, const ::mlir::stablehlo::ComparisonDirection &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace stablehlo { +// Which comparison type to use. +enum class ComparisonType : uint32_t { + NOTYPE = 0, + FLOAT = 1, + TOTALORDER = 2, + SIGNED = 3, + UNSIGNED = 4, +}; + +::std::optional symbolizeComparisonType(uint32_t); +::llvm::StringRef stringifyComparisonType(ComparisonType); +::std::optional symbolizeComparisonType(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForComparisonType() { + return 4; +} + + +inline ::llvm::StringRef stringifyEnum(ComparisonType enumValue) { + return stringifyComparisonType(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeComparisonType(str); +} +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::stablehlo::ComparisonType, ::mlir::stablehlo::ComparisonType> { + template + static FailureOr<::mlir::stablehlo::ComparisonType> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for Which comparison type to use."); + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::ComparisonType> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::ComparisonType>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [NOTYPE, FLOAT, TOTALORDER, SIGNED, UNSIGNED] for Which comparison type to use., got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::stablehlo::ComparisonType>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::stablehlo::ComparisonType>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::ComparisonType> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::ComparisonType>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [NOTYPE, FLOAT, TOTALORDER, SIGNED, UNSIGNED] for Which comparison type to use., got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::stablehlo::ComparisonType value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::stablehlo::ComparisonType> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::stablehlo::ComparisonType getEmptyKey() { + return static_cast<::mlir::stablehlo::ComparisonType>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::stablehlo::ComparisonType getTombstoneKey() { + return static_cast<::mlir::stablehlo::ComparisonType>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::stablehlo::ComparisonType &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::stablehlo::ComparisonType &lhs, const ::mlir::stablehlo::ComparisonType &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace stablehlo { +// Custom call API version +enum class CustomCallApiVersion : uint32_t { + API_VERSION_UNSPECIFIED = 0, + API_VERSION_ORIGINAL = 1, + API_VERSION_STATUS_RETURNING = 2, + API_VERSION_STATUS_RETURNING_UNIFIED = 3, + API_VERSION_TYPED_FFI = 4, +}; + +::std::optional symbolizeCustomCallApiVersion(uint32_t); +::llvm::StringRef stringifyCustomCallApiVersion(CustomCallApiVersion); +::std::optional symbolizeCustomCallApiVersion(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForCustomCallApiVersion() { + return 4; +} + + +inline ::llvm::StringRef stringifyEnum(CustomCallApiVersion enumValue) { + return stringifyCustomCallApiVersion(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeCustomCallApiVersion(str); +} + +class CustomCallApiVersionAttr : public ::mlir::IntegerAttr { +public: + using ValueType = CustomCallApiVersion; + using ::mlir::IntegerAttr::IntegerAttr; + static bool classof(::mlir::Attribute attr); + static CustomCallApiVersionAttr get(::mlir::MLIRContext *context, CustomCallApiVersion val); + CustomCallApiVersion getValue() const; +}; +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::stablehlo::CustomCallApiVersion, ::mlir::stablehlo::CustomCallApiVersion> { + template + static FailureOr<::mlir::stablehlo::CustomCallApiVersion> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for Custom call API version"); + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::CustomCallApiVersion> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::CustomCallApiVersion>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [API_VERSION_UNSPECIFIED, API_VERSION_ORIGINAL, API_VERSION_STATUS_RETURNING, API_VERSION_STATUS_RETURNING_UNIFIED, API_VERSION_TYPED_FFI] for Custom call API version, got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::stablehlo::CustomCallApiVersion>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::stablehlo::CustomCallApiVersion>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::CustomCallApiVersion> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::CustomCallApiVersion>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [API_VERSION_UNSPECIFIED, API_VERSION_ORIGINAL, API_VERSION_STATUS_RETURNING, API_VERSION_STATUS_RETURNING_UNIFIED, API_VERSION_TYPED_FFI] for Custom call API version, got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::stablehlo::CustomCallApiVersion value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::stablehlo::CustomCallApiVersion> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::stablehlo::CustomCallApiVersion getEmptyKey() { + return static_cast<::mlir::stablehlo::CustomCallApiVersion>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::stablehlo::CustomCallApiVersion getTombstoneKey() { + return static_cast<::mlir::stablehlo::CustomCallApiVersion>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::stablehlo::CustomCallApiVersion &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::stablehlo::CustomCallApiVersion &lhs, const ::mlir::stablehlo::CustomCallApiVersion &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace stablehlo { +// XLA fast fourier transform type. +enum class FftType : uint32_t { + FFT = 0, + IFFT = 1, + RFFT = 2, + IRFFT = 3, +}; + +::std::optional symbolizeFftType(uint32_t); +::llvm::StringRef stringifyFftType(FftType); +::std::optional symbolizeFftType(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForFftType() { + return 3; +} + + +inline ::llvm::StringRef stringifyEnum(FftType enumValue) { + return stringifyFftType(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeFftType(str); +} +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::stablehlo::FftType, ::mlir::stablehlo::FftType> { + template + static FailureOr<::mlir::stablehlo::FftType> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for XLA fast fourier transform type."); + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::FftType> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::FftType>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [FFT, IFFT, RFFT, IRFFT] for XLA fast fourier transform type., got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::stablehlo::FftType>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::stablehlo::FftType>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::FftType> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::FftType>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [FFT, IFFT, RFFT, IRFFT] for XLA fast fourier transform type., got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::stablehlo::FftType value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::stablehlo::FftType> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::stablehlo::FftType getEmptyKey() { + return static_cast<::mlir::stablehlo::FftType>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::stablehlo::FftType getTombstoneKey() { + return static_cast<::mlir::stablehlo::FftType>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::stablehlo::FftType &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::stablehlo::FftType &lhs, const ::mlir::stablehlo::FftType &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace stablehlo { +// XLA precision for an operand. Has backend specific meaning. +enum class Precision : uint32_t { + DEFAULT = 0, + HIGH = 1, + HIGHEST = 2, +}; + +::std::optional symbolizePrecision(uint32_t); +::llvm::StringRef stringifyPrecision(Precision); +::std::optional symbolizePrecision(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForPrecision() { + return 2; +} + + +inline ::llvm::StringRef stringifyEnum(Precision enumValue) { + return stringifyPrecision(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizePrecision(str); +} +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::stablehlo::Precision, ::mlir::stablehlo::Precision> { + template + static FailureOr<::mlir::stablehlo::Precision> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for XLA precision for an operand. Has backend specific meaning."); + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::Precision> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::Precision>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [DEFAULT, HIGH, HIGHEST] for XLA precision for an operand. Has backend specific meaning., got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::stablehlo::Precision>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::stablehlo::Precision>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::Precision> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::Precision>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [DEFAULT, HIGH, HIGHEST] for XLA precision for an operand. Has backend specific meaning., got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::stablehlo::Precision value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::stablehlo::Precision> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::stablehlo::Precision getEmptyKey() { + return static_cast<::mlir::stablehlo::Precision>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::stablehlo::Precision getTombstoneKey() { + return static_cast<::mlir::stablehlo::Precision>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::stablehlo::Precision &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::stablehlo::Precision &lhs, const ::mlir::stablehlo::Precision &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace stablehlo { +// XLA result accuracy mode. +enum class ResultAccuracyMode : uint32_t { + DEFAULT = 0, + HIGHEST = 1, + TOLERANCE = 2, +}; + +::std::optional symbolizeResultAccuracyMode(uint32_t); +::llvm::StringRef stringifyResultAccuracyMode(ResultAccuracyMode); +::std::optional symbolizeResultAccuracyMode(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForResultAccuracyMode() { + return 2; +} + + +inline ::llvm::StringRef stringifyEnum(ResultAccuracyMode enumValue) { + return stringifyResultAccuracyMode(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeResultAccuracyMode(str); +} +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::stablehlo::ResultAccuracyMode, ::mlir::stablehlo::ResultAccuracyMode> { + template + static FailureOr<::mlir::stablehlo::ResultAccuracyMode> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for XLA result accuracy mode."); + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::ResultAccuracyMode> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::ResultAccuracyMode>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [DEFAULT, HIGHEST, TOLERANCE] for XLA result accuracy mode., got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::stablehlo::ResultAccuracyMode>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::stablehlo::ResultAccuracyMode>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::ResultAccuracyMode> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::ResultAccuracyMode>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [DEFAULT, HIGHEST, TOLERANCE] for XLA result accuracy mode., got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::stablehlo::ResultAccuracyMode value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::stablehlo::ResultAccuracyMode> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::stablehlo::ResultAccuracyMode getEmptyKey() { + return static_cast<::mlir::stablehlo::ResultAccuracyMode>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::stablehlo::ResultAccuracyMode getTombstoneKey() { + return static_cast<::mlir::stablehlo::ResultAccuracyMode>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::stablehlo::ResultAccuracyMode &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::stablehlo::ResultAccuracyMode &lhs, const ::mlir::stablehlo::ResultAccuracyMode &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace stablehlo { +// XLA PRNG algorithm to be used. +enum class RngAlgorithm : uint32_t { + DEFAULT = 0, + THREE_FRY = 1, + PHILOX = 2, +}; + +::std::optional symbolizeRngAlgorithm(uint32_t); +::llvm::StringRef stringifyRngAlgorithm(RngAlgorithm); +::std::optional symbolizeRngAlgorithm(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForRngAlgorithm() { + return 2; +} + + +inline ::llvm::StringRef stringifyEnum(RngAlgorithm enumValue) { + return stringifyRngAlgorithm(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeRngAlgorithm(str); +} +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::stablehlo::RngAlgorithm, ::mlir::stablehlo::RngAlgorithm> { + template + static FailureOr<::mlir::stablehlo::RngAlgorithm> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for XLA PRNG algorithm to be used."); + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::RngAlgorithm> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::RngAlgorithm>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [DEFAULT, THREE_FRY, PHILOX] for XLA PRNG algorithm to be used., got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::stablehlo::RngAlgorithm>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::stablehlo::RngAlgorithm>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::RngAlgorithm> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::RngAlgorithm>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [DEFAULT, THREE_FRY, PHILOX] for XLA PRNG algorithm to be used., got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::stablehlo::RngAlgorithm value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::stablehlo::RngAlgorithm> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::stablehlo::RngAlgorithm getEmptyKey() { + return static_cast<::mlir::stablehlo::RngAlgorithm>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::stablehlo::RngAlgorithm getTombstoneKey() { + return static_cast<::mlir::stablehlo::RngAlgorithm>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::stablehlo::RngAlgorithm &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::stablehlo::RngAlgorithm &lhs, const ::mlir::stablehlo::RngAlgorithm &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace stablehlo { +// XLA PRNG distribution to be used. +enum class RngDistribution : uint32_t { + UNIFORM = 1, + NORMAL = 2, +}; + +::std::optional symbolizeRngDistribution(uint32_t); +::llvm::StringRef stringifyRngDistribution(RngDistribution); +::std::optional symbolizeRngDistribution(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForRngDistribution() { + return 2; +} + + +inline ::llvm::StringRef stringifyEnum(RngDistribution enumValue) { + return stringifyRngDistribution(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeRngDistribution(str); +} +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::stablehlo::RngDistribution, ::mlir::stablehlo::RngDistribution> { + template + static FailureOr<::mlir::stablehlo::RngDistribution> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for XLA PRNG distribution to be used."); + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::RngDistribution> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::RngDistribution>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [UNIFORM, NORMAL] for XLA PRNG distribution to be used., got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::stablehlo::RngDistribution>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::stablehlo::RngDistribution>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::RngDistribution> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::RngDistribution>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [UNIFORM, NORMAL] for XLA PRNG distribution to be used., got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::stablehlo::RngDistribution value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::stablehlo::RngDistribution> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::stablehlo::RngDistribution getEmptyKey() { + return static_cast<::mlir::stablehlo::RngDistribution>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::stablehlo::RngDistribution getTombstoneKey() { + return static_cast<::mlir::stablehlo::RngDistribution>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::stablehlo::RngDistribution &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::stablehlo::RngDistribution &lhs, const ::mlir::stablehlo::RngDistribution &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace stablehlo { +// Transpose options +enum class Transpose : uint32_t { + TRANSPOSE_INVALID = 0, + NO_TRANSPOSE = 1, + TRANSPOSE = 2, + ADJOINT = 3, +}; + +::std::optional symbolizeTranspose(uint32_t); +::llvm::StringRef stringifyTranspose(Transpose); +::std::optional symbolizeTranspose(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForTranspose() { + return 3; +} + + +inline ::llvm::StringRef stringifyEnum(Transpose enumValue) { + return stringifyTranspose(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeTranspose(str); +} +} // namespace stablehlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::stablehlo::Transpose, ::mlir::stablehlo::Transpose> { + template + static FailureOr<::mlir::stablehlo::Transpose> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for Transpose options"); + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::Transpose> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::Transpose>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [TRANSPOSE_INVALID, NO_TRANSPOSE, TRANSPOSE, ADJOINT] for Transpose options, got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::stablehlo::Transpose>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::stablehlo::Transpose>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::stablehlo::Transpose> attr = ::mlir::stablehlo::symbolizeEnum<::mlir::stablehlo::Transpose>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [TRANSPOSE_INVALID, NO_TRANSPOSE, TRANSPOSE, ADJOINT] for Transpose options, got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::stablehlo::Transpose value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::stablehlo::Transpose> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::stablehlo::Transpose getEmptyKey() { + return static_cast<::mlir::stablehlo::Transpose>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::stablehlo::Transpose getTombstoneKey() { + return static_cast<::mlir::stablehlo::Transpose>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::stablehlo::Transpose &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::stablehlo::Transpose &lhs, const ::mlir::stablehlo::Transpose &rhs) { + return lhs == rhs; + } +}; +} + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloOps.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloOps.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..6cec96995e239ba3b22d2e7b82c60de6d5c2b717 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloOps.cpp.inc @@ -0,0 +1,38274 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: StablehloOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_OP_LIST +#undef GET_OP_LIST + +::mlir::stablehlo::AbsOp, +::mlir::stablehlo::AddOp, +::mlir::stablehlo::AfterAllOp, +::mlir::stablehlo::AllGatherOp, +::mlir::stablehlo::AllReduceOp, +::mlir::stablehlo::AllToAllOp, +::mlir::stablehlo::AndOp, +::mlir::stablehlo::Atan2Op, +::mlir::stablehlo::BatchNormGradOp, +::mlir::stablehlo::BatchNormInferenceOp, +::mlir::stablehlo::BatchNormTrainingOp, +::mlir::stablehlo::BitcastConvertOp, +::mlir::stablehlo::BroadcastInDimOp, +::mlir::stablehlo::BroadcastOp, +::mlir::stablehlo::CaseOp, +::mlir::stablehlo::CbrtOp, +::mlir::stablehlo::CeilOp, +::mlir::stablehlo::CholeskyOp, +::mlir::stablehlo::ClampOp, +::mlir::stablehlo::ClzOp, +::mlir::stablehlo::CollectiveBroadcastOp, +::mlir::stablehlo::CollectivePermuteOp, +::mlir::stablehlo::CompareOp, +::mlir::stablehlo::ComplexOp, +::mlir::stablehlo::CompositeOp, +::mlir::stablehlo::ConcatenateOp, +::mlir::stablehlo::ConstantOp, +::mlir::stablehlo::ConvertOp, +::mlir::stablehlo::ConvolutionOp, +::mlir::stablehlo::CosineOp, +::mlir::stablehlo::CreateTokenOp, +::mlir::stablehlo::CrossReplicaSumOp, +::mlir::stablehlo::CustomCallOp, +::mlir::stablehlo::DivOp, +::mlir::stablehlo::DotGeneralOp, +::mlir::stablehlo::DotOp, +::mlir::stablehlo::DynamicBroadcastInDimOp, +::mlir::stablehlo::DynamicConvOp, +::mlir::stablehlo::DynamicGatherOp, +::mlir::stablehlo::DynamicIotaOp, +::mlir::stablehlo::DynamicPadOp, +::mlir::stablehlo::DynamicReshapeOp, +::mlir::stablehlo::DynamicSliceOp, +::mlir::stablehlo::DynamicUpdateSliceOp, +::mlir::stablehlo::EinsumOp, +::mlir::stablehlo::ExpOp, +::mlir::stablehlo::Expm1Op, +::mlir::stablehlo::FftOp, +::mlir::stablehlo::FloorOp, +::mlir::stablehlo::GatherOp, +::mlir::stablehlo::GetDimensionSizeOp, +::mlir::stablehlo::GetTupleElementOp, +::mlir::stablehlo::IfOp, +::mlir::stablehlo::ImagOp, +::mlir::stablehlo::InfeedOp, +::mlir::stablehlo::IotaOp, +::mlir::stablehlo::IsFiniteOp, +::mlir::stablehlo::Log1pOp, +::mlir::stablehlo::LogOp, +::mlir::stablehlo::LogisticOp, +::mlir::stablehlo::MapOp, +::mlir::stablehlo::MaxOp, +::mlir::stablehlo::MinOp, +::mlir::stablehlo::MulOp, +::mlir::stablehlo::NegOp, +::mlir::stablehlo::NotOp, +::mlir::stablehlo::OptimizationBarrierOp, +::mlir::stablehlo::OrOp, +::mlir::stablehlo::OutfeedOp, +::mlir::stablehlo::PadOp, +::mlir::stablehlo::PartitionIdOp, +::mlir::stablehlo::PopulationCountOp, +::mlir::stablehlo::PowOp, +::mlir::stablehlo::RealDynamicSliceOp, +::mlir::stablehlo::RealOp, +::mlir::stablehlo::RecvOp, +::mlir::stablehlo::ReduceOp, +::mlir::stablehlo::ReducePrecisionOp, +::mlir::stablehlo::ReduceScatterOp, +::mlir::stablehlo::ReduceWindowOp, +::mlir::stablehlo::RemOp, +::mlir::stablehlo::ReplicaIdOp, +::mlir::stablehlo::ReshapeOp, +::mlir::stablehlo::ReturnOp, +::mlir::stablehlo::ReverseOp, +::mlir::stablehlo::RngBitGeneratorOp, +::mlir::stablehlo::RngOp, +::mlir::stablehlo::RoundNearestEvenOp, +::mlir::stablehlo::RoundOp, +::mlir::stablehlo::RsqrtOp, +::mlir::stablehlo::ScatterOp, +::mlir::stablehlo::SelectAndScatterOp, +::mlir::stablehlo::SelectOp, +::mlir::stablehlo::SendOp, +::mlir::stablehlo::SetDimensionSizeOp, +::mlir::stablehlo::ShiftLeftOp, +::mlir::stablehlo::ShiftRightArithmeticOp, +::mlir::stablehlo::ShiftRightLogicalOp, +::mlir::stablehlo::SignOp, +::mlir::stablehlo::SineOp, +::mlir::stablehlo::SliceOp, +::mlir::stablehlo::SortOp, +::mlir::stablehlo::SqrtOp, +::mlir::stablehlo::SubtractOp, +::mlir::stablehlo::TanOp, +::mlir::stablehlo::TanhOp, +::mlir::stablehlo::TorchIndexSelectOp, +::mlir::stablehlo::TransposeOp, +::mlir::stablehlo::TriangularSolveOp, +::mlir::stablehlo::TupleOp, +::mlir::stablehlo::UnaryEinsumOp, +::mlir::stablehlo::UniformDequantizeOp, +::mlir::stablehlo::UniformQuantizeOp, +::mlir::stablehlo::WhileOp, +::mlir::stablehlo::XorOp +#endif // GET_OP_LIST + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace stablehlo { + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps1( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 2/4/8/16/32/64-bit signless integer or 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements or per-tensor integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps2( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 2/4/8/16/32/64-bit signless integer or 4/6/8/16/32/64-bit float or per-tensor integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps3( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((mlir::hlo::isValidQuantizedDimension(type)))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps4( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((isa(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be variadic of token, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps5( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((isa(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be token, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps6( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be variadic of ranked tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps7( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of bool or 2/4/8/16/32/64-bit integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps8( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps9( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements or per-tensor integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps10( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 4/6/8/16/32/64-bit float or per-tensor integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps11( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1)))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 1D tensor of 4/6/8/16/32/64-bit float or per-tensor integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps12( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((mlir::hlo::isValidQuantizedDimension(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape())) || ((mlir::hlo::hasSingleBoundedDimension(type))))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be statically shaped or single bounded dimension tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps13( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(32)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 32-bit signless integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps14( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((mlir::hlo::isValidQuantizedDimension(type)))) && ([](::mlir::Type elementType) { return ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((isa(type))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be variadic of ranked tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized values or ranked tensor of per-axis integer quantized values or token, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps15( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64)))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 2/4/8/16/32/64-bit integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps16( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of bool values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps17( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return ((elementType.isF32())) || ((elementType.isF64())); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 32/64-bit float values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps18( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64()))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of complex type with 32/64-bit float elements values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps19( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((mlir::hlo::isValidQuantizedDimension(type)))) && ([](::mlir::Type elementType) { return ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((isa(type))) || (((::llvm::isa<::mlir::TupleType>(type))) && (::llvm::all_of(getFlattenedTypes(::llvm::cast<::mlir::TupleType>(type)), [](::mlir::Type t) { return t && ((((::llvm::isa<::mlir::RankedTensorType>(t))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(t).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(t))) && ((mlir::hlo::isValidQuantizedDimension(t)))) && ([](::mlir::Type elementType) { return ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))); }(::llvm::cast<::mlir::ShapedType>(t).getElementType()))) || ((isa(t)))); }))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be variadic of ranked tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized values or ranked tensor of per-axis integer quantized values or token or nested tuple with any combination of ranked tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized values or ranked tensor of per-axis integer quantized values or token values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps20( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((mlir::hlo::isValidQuantizedDimension(type))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape()))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be statically shaped tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps21( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps22( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::TensorType>(type))) && ((mlir::hlo::isValidQuantizedDimension(type)))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((isa(type))) || (((::llvm::isa<::mlir::TupleType>(type))) && (::llvm::all_of(getFlattenedTypes(::llvm::cast<::mlir::TupleType>(type)), [](::mlir::Type t) { return t && (((((::llvm::isa<::mlir::TensorType>(t))) && ((mlir::hlo::isValidQuantizedDimension(t)))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(t).getElementType()))) || ((isa(t)))); }))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be variadic of tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values or token or nested tuple with any combination of tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values or token values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps23( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 2/4/8/16/32/64-bit integer or 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements or per-tensor integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps24( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape())) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1)))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::IndexType>(elementType))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be statically shaped 1-dimensional tensor of index or 2/4/8/16/32/64-bit integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps25( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape())) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 2)))) && ([](::mlir::Type elementType) { return (((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64)))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be statically shaped 2-dimensional integer tensor of 2/4/8/16/32/64-bit integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps26( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape())) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1)))) && ([](::mlir::Type elementType) { return (((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64)))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be statically shaped 1-dimensional integer tensor of 2/4/8/16/32/64-bit integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps27( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 0)))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 0D tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps28( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 0)))) && ([](::mlir::Type elementType) { return (((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64)))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be variadic of 0D tensor of 2/4/8/16/32/64-bit integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps29( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps30( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::TupleType>(type))) && (::llvm::all_of(getFlattenedTypes(::llvm::cast<::mlir::TupleType>(type)), [](::mlir::Type t) { return t && ((((::llvm::isa<::mlir::RankedTensorType>(t))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(t).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(t))) && ((mlir::hlo::isValidQuantizedDimension(t)))) && ([](::mlir::Type elementType) { return ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))); }(::llvm::cast<::mlir::ShapedType>(t).getElementType()))) || ((isa(t)))); })))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be nested tuple with any combination of ranked tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized values or ranked tensor of per-axis integer quantized values or token values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps31( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((mlir::hlo::isValidQuantizedDimension(type)))) && ([](::mlir::Type elementType) { return ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((isa(type))) || (((::llvm::isa<::mlir::TupleType>(type))) && (::llvm::all_of(getFlattenedTypes(::llvm::cast<::mlir::TupleType>(type)), [](::mlir::Type t) { return t && ((((::llvm::isa<::mlir::RankedTensorType>(t))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(t).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(t))) && ((mlir::hlo::isValidQuantizedDimension(t)))) && ([](::mlir::Type elementType) { return ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))); }(::llvm::cast<::mlir::ShapedType>(t).getElementType()))) || ((isa(t)))); }))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized values or ranked tensor of per-axis integer quantized values or token or nested tuple with any combination of ranked tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized values or ranked tensor of per-axis integer quantized values or token values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps32( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 4/6/8/16/32/64-bit float values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps33( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape()))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((mlir::hlo::isValidQuantizedDimension(type))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape()))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((isa(type))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be variadic of statically shaped tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized values or statically shaped tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values or token, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps34( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape()))) && ([](::mlir::Type elementType) { return ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be statically shaped tensor of 2/4/8/16/32/64-bit integer or 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements or per-tensor integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps35( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((isa(type))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be variadic of ranked tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized values or token, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps36( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((mlir::hlo::isValidQuantizedDimension(type)))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::ComplexType>(elementType))) && (((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF32())) || ((::llvm::cast<::mlir::ComplexType>(elementType).getElementType().isF64())))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be variadic of ranked tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps37( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (elementType.isUnsignedInteger(32)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 32-bit unsigned integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps38( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1)))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::IndexType>(elementType))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 1D tensor of index or 2/4/8/16/32/64-bit integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps39( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 2/4/8/16/32/64-bit integer or 4/6/8/16/32/64-bit float values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps40( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape()))) && ([](::mlir::Type elementType) { return ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be statically shaped tensor of 2/4/8/16/32/64-bit integer or 4/6/8/16/32/64-bit float values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps41( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 0)))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 0D tensor of bool or 2/4/8/16/32/64-bit integer or 4/6/8/16/32/64-bit float values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps42( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger(1))) || ((((elementType.isSignlessInteger(2))) || ((elementType.isSignlessInteger(4))) || ((elementType.isSignlessInteger(8))) || ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64)))) || (((elementType.isUnsignedInteger(2))) || ((elementType.isUnsignedInteger(4))) || ((elementType.isUnsignedInteger(8))) || ((elementType.isUnsignedInteger(16))) || ((elementType.isUnsignedInteger(32))) || ((elementType.isUnsignedInteger(64))))) || (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of bool or 2/4/8/16/32/64-bit integer or 4/6/8/16/32/64-bit float values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps43( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::IntegerType>(elementType))) || ((::llvm::isa<::mlir::IndexType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of integer or index values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps44( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((mlir::hlo::isValidQuantizedDimension(type)))) && ([](::mlir::Type elementType) { return (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of per-tensor integer quantized or per-axis integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloOps45( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((mlir::hlo::isValidQuantizedDimension(type)))) && ([](::mlir::Type elementType) { return (((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E3M4Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3Type>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E4M3B11FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2FNUZType>(elementType))) || ((::llvm::isa<::mlir::Float8E8M0FNUType>(elementType))) || ((elementType.isF16())) || ((elementType.isF32())) || ((elementType.isF64())) || ((::llvm::isa<::mlir::BFloat16Type>(elementType)))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))) || (((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((cast(cast(elementType).getStorageType()).isSignless())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType))))) || ((((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 2)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 4)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 8)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 16)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))) || (((isa(elementType))) && ((cast(elementType).getStorageTypeIntegralWidth() == 32)) && ((!cast(elementType).isSigned())) && ((mlir::hlo::isValidStablehloQuantizedElementType(elementType)))))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of 4/6/8/16/32/64-bit float or per-tensor integer quantized or per-axis integer quantized values, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps1( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))) && ((!::llvm::cast<::mlir::IntegerAttr>(attr).getValue().isNegative())))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps1( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps1(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps2( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(attr))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(attr).getType().getElementType().isSignlessInteger(64))))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 64-bit signless integer elements attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps2( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps2(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps3( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::ChannelHandleAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: two 64-bit integers 'handle' and 'type'"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps3( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps3(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps4( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::UnitAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: unit attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps4( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps4(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps5( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getValue().isStrictlyPositive())))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps5( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps5(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps6( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::FloatAttr>(attr))) && ((::llvm::cast<::mlir::FloatAttr>(attr).getType().isF32())))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 32-bit float attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps6( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps6(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps7( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: i64 dense array attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps7( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps7(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps8( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::ResultAccuracyAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: The requested accuracy for transcendental unary ops."; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps8( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps8(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps9( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::BoolAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: bool attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps9( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps9(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps10( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::ComparisonDirectionAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Which comparison operation to perform."; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps10( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps10(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps11( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::ComparisonTypeAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Which comparison type to use."; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps11( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps11(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps12( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::StringAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: string attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps12( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps12(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps13( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::DictionaryAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: dictionary of named attribute values"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps13( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps13(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps14( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::FlatSymbolRefAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: flat symbol reference attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps14( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps14(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps15( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32))))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 32-bit signless integer attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps15( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps15(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps16( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::ElementsAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: constant vector/tensor attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps16( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps16(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps17( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: i1 dense array attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps17( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps17(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps18( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::ConvDimensionNumbersAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Structure of dimension information for conv op"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps18( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps18(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps19( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::stablehlo::PrecisionAttr>(attr))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Precision Config attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps19( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps19(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps20( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::StringAttr>(attr))) || ((::llvm::isa<::mlir::DictionaryAttr>(attr))))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: string attribute or dictionary of named attribute values"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps20( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps20(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps21( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::CustomCallApiVersionAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Custom call API version"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps21( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps21(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps22( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::FlatSymbolRefAttr>(attr))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: flat symbol ref array attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps22( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps22(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps23( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((((::llvm::isa<::mlir::DenseIntElementsAttr>(attr))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(attr) + .getType() + .getElementType() + .isIndex()))) && ((cast<::mlir::DenseIntElementsAttr>(attr).getType().getRank() + == 1))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Array of layout (1D tensor of index type) attributes"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps23( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps23(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps24( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::stablehlo::OutputOperandAliasAttr>(attr))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Aliasing attribute for outputs and operands of CustomCall"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps24( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps24(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps25( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::DotDimensionNumbersAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Attribute that models the dimension information for dot."; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps25( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps25(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps26( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::DotAlgorithmAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Attribute that models the algorithm constraints to use for computing dot."; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps26( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps26(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps27( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::GatherDimensionNumbersAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Attribute that models the dimension information for gather"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps27( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps27(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps28( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::FftTypeAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: XLA fast fourier transform type."; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps28( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps28(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps29( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))) && ((!::llvm::cast<::mlir::IntegerAttr>(attr).getValue().isNegative())))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 32-bit signless integer attribute whose value is non-negative"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps29( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps29(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps30( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::ArrayAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: array attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps30( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps30(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps31( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getValue().isStrictlyPositive())))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 32-bit signless integer attribute whose value is positive"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps31( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps31(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps32( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::RngAlgorithmAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: XLA PRNG algorithm to be used."; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps32( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps32(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps33( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::RngDistributionAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: XLA PRNG distribution to be used."; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps33( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps33(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps34( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::ScatterDimensionNumbersAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Attribute that models the dimension information for scatter"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps34( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps34(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps35( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64))))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 64-bit signless integer attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps35( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps35(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps36( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::stablehlo::TransposeAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Transpose options"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloOps36( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_StablehloOps36(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_region_constraint_StablehloOps1( + ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, + unsigned regionIndex) { + if (!((::llvm::hasNItems(region, 1)))) { + return op->emitOpError("region #") << regionIndex + << (regionName.empty() ? " " : " ('" + regionName + "') ") + << "failed to verify constraint: region with 1 blocks"; + } + return ::mlir::success(); +} +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AbsOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AbsOpGenericAdaptorBase::AbsOpGenericAdaptorBase(AbsOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +AbsOpAdaptor::AbsOpAdaptor(AbsOp op) : AbsOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AbsOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult AbsOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AbsOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AbsOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AbsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AbsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AbsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AbsOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AbsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void AbsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AbsOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AbsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AbsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AbsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AbsOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void AbsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AbsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AbsOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult AbsOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AbsOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult AbsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AbsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void AbsOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AbsOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AddOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AddOpGenericAdaptorBase::AddOpGenericAdaptorBase(AddOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +AddOpAdaptor::AddOpAdaptor(AddOp op) : AddOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AddOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult AddOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AddOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AddOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AddOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AddOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AddOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AddOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void AddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AddOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AddOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AddOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void AddOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AddOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult AddOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AddOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult AddOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AddOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void AddOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AddOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AfterAllOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AfterAllOpGenericAdaptorBase::AfterAllOpGenericAdaptorBase(AfterAllOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair AfterAllOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +} // namespace detail +AfterAllOpAdaptor::AfterAllOpAdaptor(AfterAllOp op) : AfterAllOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AfterAllOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair AfterAllOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange AfterAllOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult AfterAllOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AfterAllOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AfterAllOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AfterAllOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AfterAllOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AfterAllOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AfterAllOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AfterAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs) { + odsState.addOperands(inputs); + odsState.addTypes(result); +} + +void AfterAllOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AfterAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AfterAllOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void AfterAllOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AfterAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AfterAllOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult AfterAllOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AfterAllOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult AfterAllOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> inputsOperands; + ::llvm::SMLoc inputsOperandsLoc; + (void)inputsOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> inputsTypes; + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + inputsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(inputsOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseVariadicSameOperandsAndResultType(parser, inputsOperands, inputsTypes, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(inputsOperands, inputsTypes, inputsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AfterAllOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getInputs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printVariadicSameOperandsAndResultType(_odsPrinter, *this, getInputs(), getInputs().getTypes(), getResult().getType()); +} + +void AfterAllOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AfterAllOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AllGatherOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AllGatherOpGenericAdaptorBase::AllGatherOpGenericAdaptorBase(AllGatherOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair AllGatherOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +uint64_t AllGatherOpGenericAdaptorBase::getAllGatherDim() { + auto attr = getAllGatherDimAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::DenseIntElementsAttr AllGatherOpGenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::std::optional<::mlir::stablehlo::ChannelHandleAttr> AllGatherOpGenericAdaptorBase::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ChannelHandleAttr>(::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr)) : (::std::nullopt); +} + +::mlir::UnitAttr AllGatherOpGenericAdaptorBase::getUseGlobalDeviceIdsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().use_global_device_ids); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool AllGatherOpGenericAdaptorBase::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +} // namespace detail +AllGatherOpAdaptor::AllGatherOpAdaptor(AllGatherOp op) : AllGatherOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AllGatherOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_all_gather_dim = getProperties().all_gather_dim; (void)tblgen_all_gather_dim; + if (!tblgen_all_gather_dim) return emitError(loc, "'stablehlo.all_gather' op ""requires attribute 'all_gather_dim'"); + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'stablehlo.all_gather' op ""requires attribute 'replica_groups'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + + if (tblgen_all_gather_dim && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_all_gather_dim))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_all_gather_dim).getType().isSignlessInteger(64)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_all_gather_dim).getValue().isNegative())))) + return emitError(loc, "'stablehlo.all_gather' op ""attribute 'all_gather_dim' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative"); + + if (tblgen_replica_groups && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(tblgen_replica_groups))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(tblgen_replica_groups).getType().getElementType().isSignlessInteger(64))))) + return emitError(loc, "'stablehlo.all_gather' op ""attribute 'replica_groups' failed to satisfy constraint: 64-bit signless integer elements attribute"); + + if (tblgen_channel_handle && !((::llvm::isa<::mlir::stablehlo::ChannelHandleAttr>(tblgen_channel_handle)))) + return emitError(loc, "'stablehlo.all_gather' op ""attribute 'channel_handle' failed to satisfy constraint: two 64-bit integers 'handle' and 'type'"); + + if (tblgen_use_global_device_ids && !((::llvm::isa<::mlir::UnitAttr>(tblgen_use_global_device_ids)))) + return emitError(loc, "'stablehlo.all_gather' op ""attribute 'use_global_device_ids' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +std::pair AllGatherOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange AllGatherOp::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair AllGatherOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult AllGatherOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.all_gather_dim; + auto attr = dict.get("all_gather_dim"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `all_gather_dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.channel_handle; + auto attr = dict.get("channel_handle"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_handle` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.use_global_device_ids; + auto attr = dict.get("use_global_device_ids"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `use_global_device_ids` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute AllGatherOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.all_gather_dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("all_gather_dim", + propStorage)); + } + + { + const auto &propStorage = prop.channel_handle; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_handle", + propStorage)); + } + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + { + const auto &propStorage = prop.use_global_device_ids; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("use_global_device_ids", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AllGatherOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.all_gather_dim.getAsOpaquePointer()), + llvm::hash_value(prop.channel_handle.getAsOpaquePointer()), + llvm::hash_value(prop.replica_groups.getAsOpaquePointer()), + llvm::hash_value(prop.use_global_device_ids.getAsOpaquePointer())); +} + +std::optional AllGatherOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "all_gather_dim") + return prop.all_gather_dim; + + if (name == "channel_handle") + return prop.channel_handle; + + if (name == "replica_groups") + return prop.replica_groups; + + if (name == "use_global_device_ids") + return prop.use_global_device_ids; + return std::nullopt; +} + +void AllGatherOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "all_gather_dim") { + prop.all_gather_dim = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "channel_handle") { + prop.channel_handle = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "use_global_device_ids") { + prop.use_global_device_ids = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void AllGatherOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.all_gather_dim) attrs.append("all_gather_dim", prop.all_gather_dim); + + if (prop.channel_handle) attrs.append("channel_handle", prop.channel_handle); + + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); + + if (prop.use_global_device_ids) attrs.append("use_global_device_ids", prop.use_global_device_ids); +} + +::llvm::LogicalResult AllGatherOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getAllGatherDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(attr, "all_gather_dim", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getChannelHandleAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(attr, "channel_handle", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUseGlobalDeviceIdsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps4(attr, "use_global_device_ids", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllGatherOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.all_gather_dim))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.channel_handle))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.use_global_device_ids))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AllGatherOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.all_gather_dim); + + writer.writeOptionalAttribute(prop.channel_handle); + writer.writeAttribute(prop.replica_groups); + + writer.writeOptionalAttribute(prop.use_global_device_ids); +} + +uint64_t AllGatherOp::getAllGatherDim() { + auto attr = getAllGatherDimAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::DenseIntElementsAttr AllGatherOp::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::std::optional<::mlir::stablehlo::ChannelHandleAttr> AllGatherOp::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ChannelHandleAttr>(::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr)) : (::std::nullopt); +} + +bool AllGatherOp::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void AllGatherOp::setAllGatherDim(uint64_t attrValue) { + getProperties().all_gather_dim = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void AllGatherOp::setUseGlobalDeviceIds(bool attrValue) { + auto &odsProp = getProperties().use_global_device_ids; + if (attrValue) + odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); + else + odsProp = nullptr; +} + +void AllGatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange operands, ::mlir::IntegerAttr all_gather_dim, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::UnitAttr use_global_device_ids) { + odsState.addOperands(operands); + odsState.getOrAddProperties().all_gather_dim = all_gather_dim; + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + if (use_global_device_ids) { + odsState.getOrAddProperties().use_global_device_ids = use_global_device_ids; + } + odsState.addTypes(resultType0); +} + +void AllGatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange operands, uint64_t all_gather_dim, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool use_global_device_ids) { + odsState.addOperands(operands); + odsState.getOrAddProperties().all_gather_dim = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), all_gather_dim); + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + if (use_global_device_ids) { + odsState.getOrAddProperties().use_global_device_ids = ((use_global_device_ids) ? odsBuilder.getUnitAttr() : nullptr); + } + odsState.addTypes(resultType0); +} + +void AllGatherOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void AllGatherOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult AllGatherOp::verifyInvariantsImpl() { + auto tblgen_all_gather_dim = getProperties().all_gather_dim; (void)tblgen_all_gather_dim; + if (!tblgen_all_gather_dim) return emitOpError("requires attribute 'all_gather_dim'"); + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(*this, tblgen_all_gather_dim, "all_gather_dim"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(*this, tblgen_channel_handle, "channel_handle"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps4(*this, tblgen_use_global_device_ids, "use_global_device_ids"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllGatherOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AllGatherOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AllReduceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AllReduceOpGenericAdaptorBase::AllReduceOpGenericAdaptorBase(AllReduceOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair AllReduceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DenseIntElementsAttr AllReduceOpGenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::std::optional<::mlir::stablehlo::ChannelHandleAttr> AllReduceOpGenericAdaptorBase::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ChannelHandleAttr>(::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr)) : (::std::nullopt); +} + +::mlir::UnitAttr AllReduceOpGenericAdaptorBase::getUseGlobalDeviceIdsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().use_global_device_ids); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool AllReduceOpGenericAdaptorBase::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +} // namespace detail +AllReduceOpAdaptor::AllReduceOpAdaptor(AllReduceOp op) : AllReduceOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AllReduceOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'stablehlo.all_reduce' op ""requires attribute 'replica_groups'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + + if (tblgen_replica_groups && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(tblgen_replica_groups))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(tblgen_replica_groups).getType().getElementType().isSignlessInteger(64))))) + return emitError(loc, "'stablehlo.all_reduce' op ""attribute 'replica_groups' failed to satisfy constraint: 64-bit signless integer elements attribute"); + + if (tblgen_channel_handle && !((::llvm::isa<::mlir::stablehlo::ChannelHandleAttr>(tblgen_channel_handle)))) + return emitError(loc, "'stablehlo.all_reduce' op ""attribute 'channel_handle' failed to satisfy constraint: two 64-bit integers 'handle' and 'type'"); + + if (tblgen_use_global_device_ids && !((::llvm::isa<::mlir::UnitAttr>(tblgen_use_global_device_ids)))) + return emitError(loc, "'stablehlo.all_reduce' op ""attribute 'use_global_device_ids' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +std::pair AllReduceOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange AllReduceOp::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair AllReduceOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult AllReduceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_handle; + auto attr = dict.get("channel_handle"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_handle` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.use_global_device_ids; + auto attr = dict.get("use_global_device_ids"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `use_global_device_ids` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute AllReduceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_handle; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_handle", + propStorage)); + } + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + { + const auto &propStorage = prop.use_global_device_ids; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("use_global_device_ids", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AllReduceOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_handle.getAsOpaquePointer()), + llvm::hash_value(prop.replica_groups.getAsOpaquePointer()), + llvm::hash_value(prop.use_global_device_ids.getAsOpaquePointer())); +} + +std::optional AllReduceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_handle") + return prop.channel_handle; + + if (name == "replica_groups") + return prop.replica_groups; + + if (name == "use_global_device_ids") + return prop.use_global_device_ids; + return std::nullopt; +} + +void AllReduceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_handle") { + prop.channel_handle = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "use_global_device_ids") { + prop.use_global_device_ids = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void AllReduceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_handle) attrs.append("channel_handle", prop.channel_handle); + + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); + + if (prop.use_global_device_ids) attrs.append("use_global_device_ids", prop.use_global_device_ids); +} + +::llvm::LogicalResult AllReduceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelHandleAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(attr, "channel_handle", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUseGlobalDeviceIdsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps4(attr, "use_global_device_ids", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllReduceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.channel_handle))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.use_global_device_ids))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AllReduceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.channel_handle); + writer.writeAttribute(prop.replica_groups); + + writer.writeOptionalAttribute(prop.use_global_device_ids); +} + +::mlir::DenseIntElementsAttr AllReduceOp::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::std::optional<::mlir::stablehlo::ChannelHandleAttr> AllReduceOp::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ChannelHandleAttr>(::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr)) : (::std::nullopt); +} + +bool AllReduceOp::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void AllReduceOp::setUseGlobalDeviceIds(bool attrValue) { + auto &odsProp = getProperties().use_global_device_ids; + if (attrValue) + odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); + else + odsProp = nullptr; +} + +void AllReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange operands, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::UnitAttr use_global_device_ids) { + odsState.addOperands(operands); + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + if (use_global_device_ids) { + odsState.getOrAddProperties().use_global_device_ids = use_global_device_ids; + } + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void AllReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::UnitAttr use_global_device_ids) { + odsState.addOperands(operands); + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + if (use_global_device_ids) { + odsState.getOrAddProperties().use_global_device_ids = use_global_device_ids; + } + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AllReduceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AllReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange operands, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool use_global_device_ids) { + odsState.addOperands(operands); + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + if (use_global_device_ids) { + odsState.getOrAddProperties().use_global_device_ids = ((use_global_device_ids) ? odsBuilder.getUnitAttr() : nullptr); + } + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void AllReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool use_global_device_ids) { + odsState.addOperands(operands); + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + if (use_global_device_ids) { + odsState.getOrAddProperties().use_global_device_ids = ((use_global_device_ids) ? odsBuilder.getUnitAttr() : nullptr); + } + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AllReduceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AllReduceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void AllReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AllReduceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void AllReduceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void AllReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AllReduceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult AllReduceOp::verifyInvariantsImpl() { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(*this, tblgen_channel_handle, "channel_handle"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps4(*this, tblgen_use_global_device_ids, "use_global_device_ids"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "computation", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllReduceOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::llvm::LogicalResult +AllReduceOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(AllReduceOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AllReduceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AllToAllOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AllToAllOpGenericAdaptorBase::AllToAllOpGenericAdaptorBase(AllToAllOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair AllToAllOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +uint64_t AllToAllOpGenericAdaptorBase::getSplitDimension() { + auto attr = getSplitDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +uint64_t AllToAllOpGenericAdaptorBase::getConcatDimension() { + auto attr = getConcatDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +uint64_t AllToAllOpGenericAdaptorBase::getSplitCount() { + auto attr = getSplitCountAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::DenseIntElementsAttr AllToAllOpGenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::std::optional<::mlir::stablehlo::ChannelHandleAttr> AllToAllOpGenericAdaptorBase::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ChannelHandleAttr>(::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr)) : (::std::nullopt); +} + +} // namespace detail +AllToAllOpAdaptor::AllToAllOpAdaptor(AllToAllOp op) : AllToAllOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AllToAllOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + auto tblgen_concat_dimension = getProperties().concat_dimension; (void)tblgen_concat_dimension; + if (!tblgen_concat_dimension) return emitError(loc, "'stablehlo.all_to_all' op ""requires attribute 'concat_dimension'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'stablehlo.all_to_all' op ""requires attribute 'replica_groups'"); + auto tblgen_split_count = getProperties().split_count; (void)tblgen_split_count; + if (!tblgen_split_count) return emitError(loc, "'stablehlo.all_to_all' op ""requires attribute 'split_count'"); + auto tblgen_split_dimension = getProperties().split_dimension; (void)tblgen_split_dimension; + if (!tblgen_split_dimension) return emitError(loc, "'stablehlo.all_to_all' op ""requires attribute 'split_dimension'"); + + if (tblgen_split_dimension && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_split_dimension))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_split_dimension).getType().isSignlessInteger(64)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_split_dimension).getValue().isNegative())))) + return emitError(loc, "'stablehlo.all_to_all' op ""attribute 'split_dimension' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative"); + + if (tblgen_concat_dimension && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_concat_dimension))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_concat_dimension).getType().isSignlessInteger(64)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_concat_dimension).getValue().isNegative())))) + return emitError(loc, "'stablehlo.all_to_all' op ""attribute 'concat_dimension' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative"); + + if (tblgen_split_count && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_split_count))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_split_count).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_split_count).getValue().isStrictlyPositive())))) + return emitError(loc, "'stablehlo.all_to_all' op ""attribute 'split_count' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive"); + + if (tblgen_replica_groups && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(tblgen_replica_groups))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(tblgen_replica_groups).getType().getElementType().isSignlessInteger(64))))) + return emitError(loc, "'stablehlo.all_to_all' op ""attribute 'replica_groups' failed to satisfy constraint: 64-bit signless integer elements attribute"); + + if (tblgen_channel_handle && !((::llvm::isa<::mlir::stablehlo::ChannelHandleAttr>(tblgen_channel_handle)))) + return emitError(loc, "'stablehlo.all_to_all' op ""attribute 'channel_handle' failed to satisfy constraint: two 64-bit integers 'handle' and 'type'"); + return ::mlir::success(); +} + +std::pair AllToAllOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange AllToAllOp::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair AllToAllOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult AllToAllOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_handle; + auto attr = dict.get("channel_handle"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_handle` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.concat_dimension; + auto attr = dict.get("concat_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `concat_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.split_count; + auto attr = dict.get("split_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `split_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.split_dimension; + auto attr = dict.get("split_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `split_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute AllToAllOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_handle; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_handle", + propStorage)); + } + + { + const auto &propStorage = prop.concat_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("concat_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + { + const auto &propStorage = prop.split_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("split_count", + propStorage)); + } + + { + const auto &propStorage = prop.split_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("split_dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AllToAllOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_handle.getAsOpaquePointer()), + llvm::hash_value(prop.concat_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.replica_groups.getAsOpaquePointer()), + llvm::hash_value(prop.split_count.getAsOpaquePointer()), + llvm::hash_value(prop.split_dimension.getAsOpaquePointer())); +} + +std::optional AllToAllOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_handle") + return prop.channel_handle; + + if (name == "concat_dimension") + return prop.concat_dimension; + + if (name == "replica_groups") + return prop.replica_groups; + + if (name == "split_count") + return prop.split_count; + + if (name == "split_dimension") + return prop.split_dimension; + return std::nullopt; +} + +void AllToAllOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_handle") { + prop.channel_handle = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "concat_dimension") { + prop.concat_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "split_count") { + prop.split_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "split_dimension") { + prop.split_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void AllToAllOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_handle) attrs.append("channel_handle", prop.channel_handle); + + if (prop.concat_dimension) attrs.append("concat_dimension", prop.concat_dimension); + + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); + + if (prop.split_count) attrs.append("split_count", prop.split_count); + + if (prop.split_dimension) attrs.append("split_dimension", prop.split_dimension); +} + +::llvm::LogicalResult AllToAllOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelHandleAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(attr, "channel_handle", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getConcatDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(attr, "concat_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSplitCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps5(attr, "split_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSplitDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(attr, "split_dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllToAllOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.channel_handle))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.concat_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.split_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.split_dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AllToAllOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.channel_handle); + writer.writeAttribute(prop.concat_dimension); + writer.writeAttribute(prop.replica_groups); + writer.writeAttribute(prop.split_count); + writer.writeAttribute(prop.split_dimension); +} + +uint64_t AllToAllOp::getSplitDimension() { + auto attr = getSplitDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +uint64_t AllToAllOp::getConcatDimension() { + auto attr = getConcatDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +uint64_t AllToAllOp::getSplitCount() { + auto attr = getSplitCountAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::DenseIntElementsAttr AllToAllOp::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::std::optional<::mlir::stablehlo::ChannelHandleAttr> AllToAllOp::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ChannelHandleAttr>(::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr)) : (::std::nullopt); +} + +void AllToAllOp::setSplitDimension(uint64_t attrValue) { + getProperties().split_dimension = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void AllToAllOp::setConcatDimension(uint64_t attrValue) { + getProperties().concat_dimension = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void AllToAllOp::setSplitCount(uint64_t attrValue) { + getProperties().split_count = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void AllToAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange operands, ::mlir::IntegerAttr split_dimension, ::mlir::IntegerAttr concat_dimension, ::mlir::IntegerAttr split_count, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle) { + odsState.addOperands(operands); + odsState.getOrAddProperties().split_dimension = split_dimension; + odsState.getOrAddProperties().concat_dimension = concat_dimension; + odsState.getOrAddProperties().split_count = split_count; + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + odsState.addTypes(resultType0); +} + +void AllToAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::mlir::IntegerAttr split_dimension, ::mlir::IntegerAttr concat_dimension, ::mlir::IntegerAttr split_count, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle) { + odsState.addOperands(operands); + odsState.getOrAddProperties().split_dimension = split_dimension; + odsState.getOrAddProperties().concat_dimension = concat_dimension; + odsState.getOrAddProperties().split_count = split_count; + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AllToAllOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AllToAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange operands, uint64_t split_dimension, uint64_t concat_dimension, uint64_t split_count, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle) { + odsState.addOperands(operands); + odsState.getOrAddProperties().split_dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), split_dimension); + odsState.getOrAddProperties().concat_dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), concat_dimension); + odsState.getOrAddProperties().split_count = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), split_count); + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + odsState.addTypes(resultType0); +} + +void AllToAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, uint64_t split_dimension, uint64_t concat_dimension, uint64_t split_count, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle) { + odsState.addOperands(operands); + odsState.getOrAddProperties().split_dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), split_dimension); + odsState.getOrAddProperties().concat_dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), concat_dimension); + odsState.getOrAddProperties().split_count = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), split_count); + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AllToAllOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AllToAllOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void AllToAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AllToAllOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void AllToAllOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +void AllToAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AllToAllOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult AllToAllOp::verifyInvariantsImpl() { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + auto tblgen_concat_dimension = getProperties().concat_dimension; (void)tblgen_concat_dimension; + if (!tblgen_concat_dimension) return emitOpError("requires attribute 'concat_dimension'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + auto tblgen_split_count = getProperties().split_count; (void)tblgen_split_count; + if (!tblgen_split_count) return emitOpError("requires attribute 'split_count'"); + auto tblgen_split_dimension = getProperties().split_dimension; (void)tblgen_split_dimension; + if (!tblgen_split_dimension) return emitOpError("requires attribute 'split_dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(*this, tblgen_split_dimension, "split_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(*this, tblgen_concat_dimension, "concat_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps5(*this, tblgen_split_count, "split_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(*this, tblgen_channel_handle, "channel_handle"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllToAllOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::llvm::LogicalResult +AllToAllOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(AllToAllOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AllToAllOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AndOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AndOpGenericAdaptorBase::AndOpGenericAdaptorBase(AndOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +AndOpAdaptor::AndOpAdaptor(AndOp op) : AndOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AndOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult AndOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AndOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AndOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AndOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AndOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AndOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AndOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void AndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AndOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void AndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AndOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AndOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void AndOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AndOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult AndOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AndOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult AndOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AndOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void AndOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AndOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::Atan2Op definitions +//===----------------------------------------------------------------------===// + +namespace detail { +Atan2OpGenericAdaptorBase::Atan2OpGenericAdaptorBase(Atan2Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +Atan2OpAdaptor::Atan2OpAdaptor(Atan2Op op) : Atan2OpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult Atan2OpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult Atan2Op::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute Atan2Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code Atan2Op::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional Atan2Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void Atan2Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void Atan2Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult Atan2Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void Atan2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void Atan2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(Atan2Op::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void Atan2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void Atan2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void Atan2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(Atan2Op::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void Atan2Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void Atan2Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(Atan2Op::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult Atan2Op::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult Atan2Op::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult Atan2Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void Atan2Op::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void Atan2Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::Atan2Op) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::BatchNormGradOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BatchNormGradOpGenericAdaptorBase::BatchNormGradOpGenericAdaptorBase(BatchNormGradOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::llvm::APFloat BatchNormGradOpGenericAdaptorBase::getEpsilon() { + auto attr = getEpsilonAttr(); + return attr.getValue(); +} + +uint64_t BatchNormGradOpGenericAdaptorBase::getFeatureIndex() { + auto attr = getFeatureIndexAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +BatchNormGradOpAdaptor::BatchNormGradOpAdaptor(BatchNormGradOp op) : BatchNormGradOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BatchNormGradOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_epsilon = getProperties().epsilon; (void)tblgen_epsilon; + if (!tblgen_epsilon) return emitError(loc, "'stablehlo.batch_norm_grad' op ""requires attribute 'epsilon'"); + auto tblgen_feature_index = getProperties().feature_index; (void)tblgen_feature_index; + if (!tblgen_feature_index) return emitError(loc, "'stablehlo.batch_norm_grad' op ""requires attribute 'feature_index'"); + + if (tblgen_epsilon && !(((::llvm::isa<::mlir::FloatAttr>(tblgen_epsilon))) && ((::llvm::cast<::mlir::FloatAttr>(tblgen_epsilon).getType().isF32())))) + return emitError(loc, "'stablehlo.batch_norm_grad' op ""attribute 'epsilon' failed to satisfy constraint: 32-bit float attribute"); + + if (tblgen_feature_index && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_feature_index))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_feature_index).getType().isSignlessInteger(64)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_feature_index).getValue().isNegative())))) + return emitError(loc, "'stablehlo.batch_norm_grad' op ""attribute 'feature_index' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative"); + return ::mlir::success(); +} + +void BatchNormGradOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { + auto resultGroup0 = getODSResults(0); + if (!resultGroup0.empty()) + setNameFn(*resultGroup0.begin(), "grad_operand"); + auto resultGroup1 = getODSResults(1); + if (!resultGroup1.empty()) + setNameFn(*resultGroup1.begin(), "grad_scale"); + auto resultGroup2 = getODSResults(2); + if (!resultGroup2.empty()) + setNameFn(*resultGroup2.begin(), "grad_offset"); +} + +::llvm::LogicalResult BatchNormGradOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.epsilon; + auto attr = dict.get("epsilon"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `epsilon` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.feature_index; + auto attr = dict.get("feature_index"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `feature_index` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BatchNormGradOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.epsilon; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("epsilon", + propStorage)); + } + + { + const auto &propStorage = prop.feature_index; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("feature_index", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BatchNormGradOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.epsilon.getAsOpaquePointer()), + llvm::hash_value(prop.feature_index.getAsOpaquePointer())); +} + +std::optional BatchNormGradOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "epsilon") + return prop.epsilon; + + if (name == "feature_index") + return prop.feature_index; + return std::nullopt; +} + +void BatchNormGradOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "epsilon") { + prop.epsilon = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "feature_index") { + prop.feature_index = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BatchNormGradOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.epsilon) attrs.append("epsilon", prop.epsilon); + + if (prop.feature_index) attrs.append("feature_index", prop.feature_index); +} + +::llvm::LogicalResult BatchNormGradOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getEpsilonAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps6(attr, "epsilon", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFeatureIndexAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(attr, "feature_index", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormGradOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.epsilon))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.feature_index))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BatchNormGradOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.epsilon); + writer.writeAttribute(prop.feature_index); +} + +::llvm::APFloat BatchNormGradOp::getEpsilon() { + auto attr = getEpsilonAttr(); + return attr.getValue(); +} + +uint64_t BatchNormGradOp::getFeatureIndex() { + auto attr = getFeatureIndexAttr(); + return attr.getValue().getZExtValue(); +} + +void BatchNormGradOp::setEpsilon(::llvm::APFloat attrValue) { + getProperties().epsilon = ::mlir::Builder((*this)->getContext()).getFloatAttr(::mlir::Builder((*this)->getContext()).getF32Type(), attrValue); +} + +void BatchNormGradOp::setFeatureIndex(uint64_t attrValue) { + getProperties().feature_index = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void BatchNormGradOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type grad_operand, ::mlir::Type grad_scale, ::mlir::Type grad_offset, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.addOperands(grad_output); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + odsState.addTypes(grad_operand); + odsState.addTypes(grad_scale); + odsState.addTypes(grad_offset); +} + +void BatchNormGradOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.addOperands(grad_output); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BatchNormGradOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BatchNormGradOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.addOperands(grad_output); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + assert(resultTypes.size() == 3u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BatchNormGradOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type grad_operand, ::mlir::Type grad_scale, ::mlir::Type grad_offset, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::llvm::APFloat epsilon, uint64_t feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.addOperands(grad_output); + odsState.getOrAddProperties().epsilon = odsBuilder.getFloatAttr(odsBuilder.getF32Type(), epsilon); + odsState.getOrAddProperties().feature_index = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), feature_index); + odsState.addTypes(grad_operand); + odsState.addTypes(grad_scale); + odsState.addTypes(grad_offset); +} + +void BatchNormGradOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::llvm::APFloat epsilon, uint64_t feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.addOperands(grad_output); + odsState.getOrAddProperties().epsilon = odsBuilder.getFloatAttr(odsBuilder.getF32Type(), epsilon); + odsState.getOrAddProperties().feature_index = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), feature_index); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BatchNormGradOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BatchNormGradOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::llvm::APFloat epsilon, uint64_t feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.addOperands(grad_output); + odsState.getOrAddProperties().epsilon = odsBuilder.getFloatAttr(odsBuilder.getF32Type(), epsilon); + odsState.getOrAddProperties().feature_index = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), feature_index); + assert(resultTypes.size() == 3u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BatchNormGradOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 3u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BatchNormGradOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BatchNormGradOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 3u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BatchNormGradOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 3u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BatchNormGradOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BatchNormGradOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 3u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BatchNormGradOp::verifyInvariantsImpl() { + auto tblgen_epsilon = getProperties().epsilon; (void)tblgen_epsilon; + if (!tblgen_epsilon) return emitOpError("requires attribute 'epsilon'"); + auto tblgen_feature_index = getProperties().feature_index; (void)tblgen_feature_index; + if (!tblgen_feature_index) return emitOpError("requires attribute 'feature_index'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps6(*this, tblgen_epsilon, "epsilon"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(*this, tblgen_feature_index, "feature_index"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSResults(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps11(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSResults(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps11(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormGradOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void BatchNormGradOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BatchNormGradOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BatchNormGradOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::BatchNormGradOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::BatchNormInferenceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BatchNormInferenceOpGenericAdaptorBase::BatchNormInferenceOpGenericAdaptorBase(BatchNormInferenceOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::llvm::APFloat BatchNormInferenceOpGenericAdaptorBase::getEpsilon() { + auto attr = getEpsilonAttr(); + return attr.getValue(); +} + +uint64_t BatchNormInferenceOpGenericAdaptorBase::getFeatureIndex() { + auto attr = getFeatureIndexAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +BatchNormInferenceOpAdaptor::BatchNormInferenceOpAdaptor(BatchNormInferenceOp op) : BatchNormInferenceOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BatchNormInferenceOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_epsilon = getProperties().epsilon; (void)tblgen_epsilon; + if (!tblgen_epsilon) return emitError(loc, "'stablehlo.batch_norm_inference' op ""requires attribute 'epsilon'"); + auto tblgen_feature_index = getProperties().feature_index; (void)tblgen_feature_index; + if (!tblgen_feature_index) return emitError(loc, "'stablehlo.batch_norm_inference' op ""requires attribute 'feature_index'"); + + if (tblgen_epsilon && !(((::llvm::isa<::mlir::FloatAttr>(tblgen_epsilon))) && ((::llvm::cast<::mlir::FloatAttr>(tblgen_epsilon).getType().isF32())))) + return emitError(loc, "'stablehlo.batch_norm_inference' op ""attribute 'epsilon' failed to satisfy constraint: 32-bit float attribute"); + + if (tblgen_feature_index && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_feature_index))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_feature_index).getType().isSignlessInteger(64)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_feature_index).getValue().isNegative())))) + return emitError(loc, "'stablehlo.batch_norm_inference' op ""attribute 'feature_index' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative"); + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormInferenceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.epsilon; + auto attr = dict.get("epsilon"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `epsilon` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.feature_index; + auto attr = dict.get("feature_index"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `feature_index` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BatchNormInferenceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.epsilon; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("epsilon", + propStorage)); + } + + { + const auto &propStorage = prop.feature_index; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("feature_index", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BatchNormInferenceOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.epsilon.getAsOpaquePointer()), + llvm::hash_value(prop.feature_index.getAsOpaquePointer())); +} + +std::optional BatchNormInferenceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "epsilon") + return prop.epsilon; + + if (name == "feature_index") + return prop.feature_index; + return std::nullopt; +} + +void BatchNormInferenceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "epsilon") { + prop.epsilon = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "feature_index") { + prop.feature_index = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BatchNormInferenceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.epsilon) attrs.append("epsilon", prop.epsilon); + + if (prop.feature_index) attrs.append("feature_index", prop.feature_index); +} + +::llvm::LogicalResult BatchNormInferenceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getEpsilonAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps6(attr, "epsilon", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFeatureIndexAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(attr, "feature_index", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormInferenceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.epsilon))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.feature_index))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BatchNormInferenceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.epsilon); + writer.writeAttribute(prop.feature_index); +} + +::llvm::APFloat BatchNormInferenceOp::getEpsilon() { + auto attr = getEpsilonAttr(); + return attr.getValue(); +} + +uint64_t BatchNormInferenceOp::getFeatureIndex() { + auto attr = getFeatureIndexAttr(); + return attr.getValue().getZExtValue(); +} + +void BatchNormInferenceOp::setEpsilon(::llvm::APFloat attrValue) { + getProperties().epsilon = ::mlir::Builder((*this)->getContext()).getFloatAttr(::mlir::Builder((*this)->getContext()).getF32Type(), attrValue); +} + +void BatchNormInferenceOp::setFeatureIndex(uint64_t attrValue) { + getProperties().feature_index = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void BatchNormInferenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + odsState.addTypes(result); +} + +void BatchNormInferenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BatchNormInferenceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BatchNormInferenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BatchNormInferenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::llvm::APFloat epsilon, uint64_t feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.getOrAddProperties().epsilon = odsBuilder.getFloatAttr(odsBuilder.getF32Type(), epsilon); + odsState.getOrAddProperties().feature_index = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), feature_index); + odsState.addTypes(result); +} + +void BatchNormInferenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::llvm::APFloat epsilon, uint64_t feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.getOrAddProperties().epsilon = odsBuilder.getFloatAttr(odsBuilder.getF32Type(), epsilon); + odsState.getOrAddProperties().feature_index = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), feature_index); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BatchNormInferenceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BatchNormInferenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::llvm::APFloat epsilon, uint64_t feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.getOrAddProperties().epsilon = odsBuilder.getFloatAttr(odsBuilder.getF32Type(), epsilon); + odsState.getOrAddProperties().feature_index = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), feature_index); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BatchNormInferenceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BatchNormInferenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BatchNormInferenceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BatchNormInferenceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BatchNormInferenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BatchNormInferenceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BatchNormInferenceOp::verifyInvariantsImpl() { + auto tblgen_epsilon = getProperties().epsilon; (void)tblgen_epsilon; + if (!tblgen_epsilon) return emitOpError("requires attribute 'epsilon'"); + auto tblgen_feature_index = getProperties().feature_index; (void)tblgen_feature_index; + if (!tblgen_feature_index) return emitOpError("requires attribute 'feature_index'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps6(*this, tblgen_epsilon, "epsilon"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(*this, tblgen_feature_index, "feature_index"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormInferenceOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void BatchNormInferenceOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BatchNormInferenceOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BatchNormInferenceOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::BatchNormInferenceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::BatchNormTrainingOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BatchNormTrainingOpGenericAdaptorBase::BatchNormTrainingOpGenericAdaptorBase(BatchNormTrainingOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::llvm::APFloat BatchNormTrainingOpGenericAdaptorBase::getEpsilon() { + auto attr = getEpsilonAttr(); + return attr.getValue(); +} + +uint64_t BatchNormTrainingOpGenericAdaptorBase::getFeatureIndex() { + auto attr = getFeatureIndexAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +BatchNormTrainingOpAdaptor::BatchNormTrainingOpAdaptor(BatchNormTrainingOp op) : BatchNormTrainingOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BatchNormTrainingOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_epsilon = getProperties().epsilon; (void)tblgen_epsilon; + if (!tblgen_epsilon) return emitError(loc, "'stablehlo.batch_norm_training' op ""requires attribute 'epsilon'"); + auto tblgen_feature_index = getProperties().feature_index; (void)tblgen_feature_index; + if (!tblgen_feature_index) return emitError(loc, "'stablehlo.batch_norm_training' op ""requires attribute 'feature_index'"); + + if (tblgen_epsilon && !(((::llvm::isa<::mlir::FloatAttr>(tblgen_epsilon))) && ((::llvm::cast<::mlir::FloatAttr>(tblgen_epsilon).getType().isF32())))) + return emitError(loc, "'stablehlo.batch_norm_training' op ""attribute 'epsilon' failed to satisfy constraint: 32-bit float attribute"); + + if (tblgen_feature_index && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_feature_index))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_feature_index).getType().isSignlessInteger(64)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_feature_index).getValue().isNegative())))) + return emitError(loc, "'stablehlo.batch_norm_training' op ""attribute 'feature_index' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative"); + return ::mlir::success(); +} + +void BatchNormTrainingOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { + auto resultGroup0 = getODSResults(0); + if (!resultGroup0.empty()) + setNameFn(*resultGroup0.begin(), "output"); + auto resultGroup1 = getODSResults(1); + if (!resultGroup1.empty()) + setNameFn(*resultGroup1.begin(), "batch_mean"); + auto resultGroup2 = getODSResults(2); + if (!resultGroup2.empty()) + setNameFn(*resultGroup2.begin(), "batch_var"); +} + +::llvm::LogicalResult BatchNormTrainingOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.epsilon; + auto attr = dict.get("epsilon"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `epsilon` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.feature_index; + auto attr = dict.get("feature_index"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `feature_index` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BatchNormTrainingOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.epsilon; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("epsilon", + propStorage)); + } + + { + const auto &propStorage = prop.feature_index; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("feature_index", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BatchNormTrainingOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.epsilon.getAsOpaquePointer()), + llvm::hash_value(prop.feature_index.getAsOpaquePointer())); +} + +std::optional BatchNormTrainingOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "epsilon") + return prop.epsilon; + + if (name == "feature_index") + return prop.feature_index; + return std::nullopt; +} + +void BatchNormTrainingOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "epsilon") { + prop.epsilon = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "feature_index") { + prop.feature_index = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BatchNormTrainingOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.epsilon) attrs.append("epsilon", prop.epsilon); + + if (prop.feature_index) attrs.append("feature_index", prop.feature_index); +} + +::llvm::LogicalResult BatchNormTrainingOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getEpsilonAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps6(attr, "epsilon", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFeatureIndexAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(attr, "feature_index", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormTrainingOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.epsilon))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.feature_index))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BatchNormTrainingOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.epsilon); + writer.writeAttribute(prop.feature_index); +} + +::llvm::APFloat BatchNormTrainingOp::getEpsilon() { + auto attr = getEpsilonAttr(); + return attr.getValue(); +} + +uint64_t BatchNormTrainingOp::getFeatureIndex() { + auto attr = getFeatureIndexAttr(); + return attr.getValue().getZExtValue(); +} + +void BatchNormTrainingOp::setEpsilon(::llvm::APFloat attrValue) { + getProperties().epsilon = ::mlir::Builder((*this)->getContext()).getFloatAttr(::mlir::Builder((*this)->getContext()).getF32Type(), attrValue); +} + +void BatchNormTrainingOp::setFeatureIndex(uint64_t attrValue) { + getProperties().feature_index = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void BatchNormTrainingOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Type batch_mean, ::mlir::Type batch_var, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + odsState.addTypes(output); + odsState.addTypes(batch_mean); + odsState.addTypes(batch_var); +} + +void BatchNormTrainingOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BatchNormTrainingOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BatchNormTrainingOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + assert(resultTypes.size() == 3u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BatchNormTrainingOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Type batch_mean, ::mlir::Type batch_var, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::llvm::APFloat epsilon, uint64_t feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.getOrAddProperties().epsilon = odsBuilder.getFloatAttr(odsBuilder.getF32Type(), epsilon); + odsState.getOrAddProperties().feature_index = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), feature_index); + odsState.addTypes(output); + odsState.addTypes(batch_mean); + odsState.addTypes(batch_var); +} + +void BatchNormTrainingOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::llvm::APFloat epsilon, uint64_t feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.getOrAddProperties().epsilon = odsBuilder.getFloatAttr(odsBuilder.getF32Type(), epsilon); + odsState.getOrAddProperties().feature_index = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), feature_index); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BatchNormTrainingOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BatchNormTrainingOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::llvm::APFloat epsilon, uint64_t feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.getOrAddProperties().epsilon = odsBuilder.getFloatAttr(odsBuilder.getF32Type(), epsilon); + odsState.getOrAddProperties().feature_index = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), feature_index); + assert(resultTypes.size() == 3u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BatchNormTrainingOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 3u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BatchNormTrainingOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BatchNormTrainingOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 3u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BatchNormTrainingOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 3u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BatchNormTrainingOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BatchNormTrainingOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 3u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BatchNormTrainingOp::verifyInvariantsImpl() { + auto tblgen_epsilon = getProperties().epsilon; (void)tblgen_epsilon; + if (!tblgen_epsilon) return emitOpError("requires attribute 'epsilon'"); + auto tblgen_feature_index = getProperties().feature_index; (void)tblgen_feature_index; + if (!tblgen_feature_index) return emitOpError("requires attribute 'feature_index'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps6(*this, tblgen_epsilon, "epsilon"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(*this, tblgen_feature_index, "feature_index"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSResults(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps11(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSResults(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps11(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormTrainingOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void BatchNormTrainingOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BatchNormTrainingOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BatchNormTrainingOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::BatchNormTrainingOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::BitcastConvertOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BitcastConvertOpGenericAdaptorBase::BitcastConvertOpGenericAdaptorBase(BitcastConvertOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +BitcastConvertOpAdaptor::BitcastConvertOpAdaptor(BitcastConvertOp op) : BitcastConvertOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BitcastConvertOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult BitcastConvertOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute BitcastConvertOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BitcastConvertOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional BitcastConvertOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void BitcastConvertOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void BitcastConvertOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult BitcastConvertOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void BitcastConvertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(resultType0); +} + +void BitcastConvertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BitcastConvertOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BitcastConvertOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult BitcastConvertOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BitcastConvertOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult BitcastConvertOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + [[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(allOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(allOperands, allOperandTypes, allOperandLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BitcastConvertOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperation()->getOperands(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void BitcastConvertOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::BitcastConvertOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::BroadcastInDimOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastInDimOpGenericAdaptorBase::BroadcastInDimOpGenericAdaptorBase(BroadcastInDimOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::llvm::ArrayRef BroadcastInDimOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr; +} + +} // namespace detail +BroadcastInDimOpAdaptor::BroadcastInDimOpAdaptor(BroadcastInDimOp op) : BroadcastInDimOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastInDimOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + if (!tblgen_broadcast_dimensions) return emitError(loc, "'stablehlo.broadcast_in_dim' op ""requires attribute 'broadcast_dimensions'"); + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'stablehlo.broadcast_in_dim' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastInDimOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastInDimOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastInDimOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastInDimOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastInDimOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastInDimOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastInDimOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastInDimOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastInDimOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.broadcast_dimensions); +} + +::llvm::ArrayRef BroadcastInDimOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr; +} + +void BroadcastInDimOp::setBroadcastDimensions(::llvm::ArrayRef attrValue) { + getProperties().broadcast_dimensions = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void BroadcastInDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + odsState.addTypes(resultType0); +} + +void BroadcastInDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr broadcast_dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastInDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::llvm::ArrayRef broadcast_dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_dimensions = odsBuilder.getDenseI64ArrayAttr(broadcast_dimensions); + odsState.addTypes(resultType0); +} + +void BroadcastInDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::llvm::ArrayRef broadcast_dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_dimensions = odsBuilder.getDenseI64ArrayAttr(broadcast_dimensions); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastInDimOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastInDimOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult BroadcastInDimOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + if (!tblgen_broadcast_dimensions) return emitOpError("requires attribute 'broadcast_dimensions'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps12(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastInDimOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult BroadcastInDimOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::DenseI64ArrayAttr broadcast_dimensionsAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("dims")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(broadcast_dimensionsAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (broadcast_dimensionsAttr) result.getOrAddProperties().broadcast_dimensions = broadcast_dimensionsAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(operandOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastInDimOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' ' << "dims"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getBroadcastDimensionsAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("broadcast_dimensions"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void BroadcastInDimOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::BroadcastInDimOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::BroadcastOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastOpGenericAdaptorBase::BroadcastOpGenericAdaptorBase(BroadcastOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::llvm::ArrayRef BroadcastOpGenericAdaptorBase::getBroadcastSizes() { + auto attr = getBroadcastSizesAttr(); + return attr; +} + +} // namespace detail +BroadcastOpAdaptor::BroadcastOpAdaptor(BroadcastOp op) : BroadcastOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_sizes = getProperties().broadcast_sizes; (void)tblgen_broadcast_sizes; + if (!tblgen_broadcast_sizes) return emitError(loc, "'stablehlo.broadcast' op ""requires attribute 'broadcast_sizes'"); + + if (tblgen_broadcast_sizes && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_sizes)))) + return emitError(loc, "'stablehlo.broadcast' op ""attribute 'broadcast_sizes' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_sizes; + auto attr = dict.get("broadcast_sizes"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_sizes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_sizes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_sizes", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_sizes.getAsOpaquePointer())); +} + +std::optional BroadcastOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_sizes") + return prop.broadcast_sizes; + return std::nullopt; +} + +void BroadcastOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_sizes") { + prop.broadcast_sizes = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_sizes) attrs.append("broadcast_sizes", prop.broadcast_sizes); +} + +::llvm::LogicalResult BroadcastOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastSizesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "broadcast_sizes", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.broadcast_sizes))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.broadcast_sizes); +} + +::llvm::ArrayRef BroadcastOp::getBroadcastSizes() { + auto attr = getBroadcastSizesAttr(); + return attr; +} + +void BroadcastOp::setBroadcastSizes(::llvm::ArrayRef attrValue) { + getProperties().broadcast_sizes = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void BroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr broadcast_sizes) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_sizes = broadcast_sizes; + odsState.addTypes(resultType0); +} + +void BroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr broadcast_sizes) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_sizes = broadcast_sizes; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr broadcast_sizes) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_sizes = broadcast_sizes; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::llvm::ArrayRef broadcast_sizes) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_sizes = odsBuilder.getDenseI64ArrayAttr(broadcast_sizes); + odsState.addTypes(resultType0); +} + +void BroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::llvm::ArrayRef broadcast_sizes) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_sizes = odsBuilder.getDenseI64ArrayAttr(broadcast_sizes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void BroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::llvm::ArrayRef broadcast_sizes) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_sizes = odsBuilder.getDenseI64ArrayAttr(broadcast_sizes); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void BroadcastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(BroadcastOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult BroadcastOp::verifyInvariantsImpl() { + auto tblgen_broadcast_sizes = getProperties().broadcast_sizes; (void)tblgen_broadcast_sizes; + if (!tblgen_broadcast_sizes) return emitOpError("requires attribute 'broadcast_sizes'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_broadcast_sizes, "broadcast_sizes"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BroadcastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::DenseI64ArrayAttr broadcast_sizesAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("sizes")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(broadcast_sizesAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (broadcast_sizesAttr) result.getOrAddProperties().broadcast_sizes = broadcast_sizesAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(operandOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' ' << "sizes"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getBroadcastSizesAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("broadcast_sizes"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void BroadcastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +BroadcastOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(BroadcastOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::BroadcastOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CaseOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CaseOpGenericAdaptorBase::CaseOpGenericAdaptorBase(CaseOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +CaseOpAdaptor::CaseOpAdaptor(CaseOp op) : CaseOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CaseOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair CaseOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult CaseOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute CaseOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CaseOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional CaseOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void CaseOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void CaseOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult CaseOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void CaseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::Value index, unsigned branchesCount) { + odsState.addOperands(index); + for (unsigned i = 0; i < branchesCount; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void CaseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value index, unsigned branchesCount) { + odsState.addOperands(index); + for (unsigned i = 0; i < branchesCount; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CaseOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void CaseOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != numRegions; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void CaseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != numRegions; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CaseOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void CaseOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != numRegions; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void CaseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != numRegions; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CaseOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult CaseOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps13(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps14(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : getBranches()) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "branches", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CaseOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CaseOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CbrtOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CbrtOpGenericAdaptorBase::CbrtOpGenericAdaptorBase(CbrtOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ResultAccuracyAttr CbrtOpGenericAdaptorBase::getResultAccuracyAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + if (!attr) + attr = ::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + return attr; +} + +::mlir::stablehlo::ResultAccuracyAttr CbrtOpGenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +} // namespace detail +CbrtOpAdaptor::CbrtOpAdaptor(CbrtOp op) : CbrtOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CbrtOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (tblgen_result_accuracy && !((::llvm::isa<::mlir::stablehlo::ResultAccuracyAttr>(tblgen_result_accuracy)))) + return emitError(loc, "'stablehlo.cbrt' op ""attribute 'result_accuracy' failed to satisfy constraint: The requested accuracy for transcendental unary ops."); + return ::mlir::success(); +} + +::llvm::LogicalResult CbrtOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CbrtOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CbrtOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional CbrtOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void CbrtOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CbrtOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult CbrtOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CbrtOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CbrtOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.result_accuracy); +} + +::mlir::stablehlo::ResultAccuracyAttr CbrtOp::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder((*this)->getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +void CbrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + odsState.addTypes(result); +} + +void CbrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CbrtOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void CbrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CbrtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CbrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CbrtOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void CbrtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CbrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CbrtOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult CbrtOp::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CbrtOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult CbrtOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CbrtOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getResultAccuracyAttr(); + if(attr && (attr == ::mlir::stablehlo::ResultAccuracyAttr::get(odsBuilder.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(odsBuilder.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)))) + elidedAttrs.push_back("result_accuracy"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void CbrtOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CbrtOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CeilOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CeilOpGenericAdaptorBase::CeilOpGenericAdaptorBase(CeilOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +CeilOpAdaptor::CeilOpAdaptor(CeilOp op) : CeilOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CeilOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult CeilOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute CeilOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CeilOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional CeilOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void CeilOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void CeilOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult CeilOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void CeilOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void CeilOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CeilOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void CeilOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CeilOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CeilOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CeilOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void CeilOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CeilOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CeilOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult CeilOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CeilOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult CeilOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CeilOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void CeilOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CeilOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CholeskyOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CholeskyOpGenericAdaptorBase::CholeskyOpGenericAdaptorBase(CholeskyOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::BoolAttr CholeskyOpGenericAdaptorBase::getLowerAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().lower); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false); + return attr; +} + +bool CholeskyOpGenericAdaptorBase::getLower() { + auto attr = getLowerAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +} // namespace detail +CholeskyOpAdaptor::CholeskyOpAdaptor(CholeskyOp op) : CholeskyOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CholeskyOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_lower = getProperties().lower; (void)tblgen_lower; + + if (tblgen_lower && !((::llvm::isa<::mlir::BoolAttr>(tblgen_lower)))) + return emitError(loc, "'stablehlo.cholesky' op ""attribute 'lower' failed to satisfy constraint: bool attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult CholeskyOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.lower; + auto attr = dict.get("lower"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lower` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CholeskyOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.lower; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lower", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CholeskyOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.lower.getAsOpaquePointer())); +} + +std::optional CholeskyOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "lower") + return prop.lower; + return std::nullopt; +} + +void CholeskyOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "lower") { + prop.lower = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CholeskyOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.lower) attrs.append("lower", prop.lower); +} + +::llvm::LogicalResult CholeskyOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getLowerAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(attr, "lower", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CholeskyOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.lower))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CholeskyOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.lower); +} + +bool CholeskyOp::getLower() { + auto attr = getLowerAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +void CholeskyOp::setLower(::std::optional attrValue) { + auto &odsProp = getProperties().lower; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue); + else + odsProp = nullptr; +} + +void CholeskyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, /*optional*/::mlir::BoolAttr lower) { + odsState.addOperands(a); + if (lower) { + odsState.getOrAddProperties().lower = lower; + } + odsState.addTypes(result); +} + +void CholeskyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, /*optional*/::mlir::BoolAttr lower) { + odsState.addOperands(a); + if (lower) { + odsState.getOrAddProperties().lower = lower; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CholeskyOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void CholeskyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, /*optional*/::mlir::BoolAttr lower) { + odsState.addOperands(a); + if (lower) { + odsState.getOrAddProperties().lower = lower; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CholeskyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, /*optional*/bool lower) { + odsState.addOperands(a); + odsState.getOrAddProperties().lower = odsBuilder.getBoolAttr(lower); + odsState.addTypes(result); +} + +void CholeskyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, /*optional*/bool lower) { + odsState.addOperands(a); + odsState.getOrAddProperties().lower = odsBuilder.getBoolAttr(lower); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CholeskyOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void CholeskyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, /*optional*/bool lower) { + odsState.addOperands(a); + odsState.getOrAddProperties().lower = odsBuilder.getBoolAttr(lower); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CholeskyOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CholeskyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CholeskyOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void CholeskyOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CholeskyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CholeskyOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult CholeskyOp::verifyInvariantsImpl() { + auto tblgen_lower = getProperties().lower; (void)tblgen_lower; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(*this, tblgen_lower, "lower"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CholeskyOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult CholeskyOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand aRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(&aRawOperand, 1); ::llvm::SMLoc aOperandsLoc; + (void)aOperandsLoc; + ::mlir::BoolAttr lowerAttr; + ::mlir::Type aRawType{}; + ::llvm::ArrayRef<::mlir::Type> aTypes(&aRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + aOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(aRawOperand)) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalComma())) { + if (parser.parseKeyword("lower")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(lowerAttr, parser.getBuilder().getIntegerType(1))) { + return ::mlir::failure(); + } + if (lowerAttr) result.getOrAddProperties().lower = lowerAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, aRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(aOperands, aTypes, aOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CholeskyOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getA(); + if ((getLowerAttr() && getLowerAttr() != ::mlir::OpBuilder((*this)->getContext()).getBoolAttr(false))) { + _odsPrinter << ","; + _odsPrinter << ' ' << "lower"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getLowerAttr()); + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("lower"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getLowerAttr(); + if(attr && (attr == odsBuilder.getBoolAttr(false))) + elidedAttrs.push_back("lower"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getA().getType(), getResult().getType()); +} + +void CholeskyOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +CholeskyOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(CholeskyOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CholeskyOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ClampOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ClampOpGenericAdaptorBase::ClampOpGenericAdaptorBase(ClampOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ClampOpAdaptor::ClampOpAdaptor(ClampOp op) : ClampOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ClampOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ClampOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ClampOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ClampOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ClampOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ClampOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ClampOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ClampOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ClampOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value min, ::mlir::Value operand, ::mlir::Value max) { + odsState.addOperands(min); + odsState.addOperands(operand); + odsState.addOperands(max); + odsState.addTypes(result); +} + +void ClampOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value min, ::mlir::Value operand, ::mlir::Value max) { + odsState.addOperands(min); + odsState.addOperands(operand); + odsState.addOperands(max); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ClampOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ClampOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value min, ::mlir::Value operand, ::mlir::Value max) { + odsState.addOperands(min); + odsState.addOperands(operand); + odsState.addOperands(max); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ClampOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ClampOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ClampOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ClampOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ClampOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ClampOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ClampOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ClampOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ClampOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand minRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> minOperands(&minRawOperand, 1); ::llvm::SMLoc minOperandsLoc; + (void)minOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand maxRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> maxOperands(&maxRawOperand, 1); ::llvm::SMLoc maxOperandsLoc; + (void)maxOperandsLoc; + ::mlir::Type minRawType{}; + ::llvm::ArrayRef<::mlir::Type> minTypes(&minRawType, 1); + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type maxRawType{}; + ::llvm::ArrayRef<::mlir::Type> maxTypes(&maxRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + minOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(minRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + maxOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(maxRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, minRawType, operandRawType, maxRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(minOperands, minTypes, minOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(maxOperands, maxTypes, maxOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ClampOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getMin(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getMax(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getMin().getType(), getOperand().getType(), getMax().getType(), getResult().getType()); +} + +void ClampOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +ClampOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(ClampOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ClampOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ClzOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ClzOpGenericAdaptorBase::ClzOpGenericAdaptorBase(ClzOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ClzOpAdaptor::ClzOpAdaptor(ClzOp op) : ClzOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ClzOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ClzOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ClzOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ClzOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ClzOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ClzOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ClzOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ClzOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ClzOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void ClzOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ClzOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ClzOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ClzOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ClzOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ClzOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ClzOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ClzOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ClzOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ClzOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ClzOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ClzOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ClzOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void ClzOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ClzOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CollectiveBroadcastOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CollectiveBroadcastOpGenericAdaptorBase::CollectiveBroadcastOpGenericAdaptorBase(CollectiveBroadcastOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::DenseIntElementsAttr CollectiveBroadcastOpGenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::std::optional<::mlir::stablehlo::ChannelHandleAttr> CollectiveBroadcastOpGenericAdaptorBase::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ChannelHandleAttr>(::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr)) : (::std::nullopt); +} + +} // namespace detail +CollectiveBroadcastOpAdaptor::CollectiveBroadcastOpAdaptor(CollectiveBroadcastOp op) : CollectiveBroadcastOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CollectiveBroadcastOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'stablehlo.collective_broadcast' op ""requires attribute 'replica_groups'"); + + if (tblgen_replica_groups && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(tblgen_replica_groups))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(tblgen_replica_groups).getType().getElementType().isSignlessInteger(64))))) + return emitError(loc, "'stablehlo.collective_broadcast' op ""attribute 'replica_groups' failed to satisfy constraint: 64-bit signless integer elements attribute"); + + if (tblgen_channel_handle && !((::llvm::isa<::mlir::stablehlo::ChannelHandleAttr>(tblgen_channel_handle)))) + return emitError(loc, "'stablehlo.collective_broadcast' op ""attribute 'channel_handle' failed to satisfy constraint: two 64-bit integers 'handle' and 'type'"); + return ::mlir::success(); +} + +::llvm::LogicalResult CollectiveBroadcastOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_handle; + auto attr = dict.get("channel_handle"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_handle` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CollectiveBroadcastOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_handle; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_handle", + propStorage)); + } + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CollectiveBroadcastOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_handle.getAsOpaquePointer()), + llvm::hash_value(prop.replica_groups.getAsOpaquePointer())); +} + +std::optional CollectiveBroadcastOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_handle") + return prop.channel_handle; + + if (name == "replica_groups") + return prop.replica_groups; + return std::nullopt; +} + +void CollectiveBroadcastOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_handle") { + prop.channel_handle = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CollectiveBroadcastOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_handle) attrs.append("channel_handle", prop.channel_handle); + + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); +} + +::llvm::LogicalResult CollectiveBroadcastOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelHandleAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(attr, "channel_handle", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CollectiveBroadcastOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.channel_handle))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CollectiveBroadcastOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.channel_handle); + writer.writeAttribute(prop.replica_groups); +} + +::mlir::DenseIntElementsAttr CollectiveBroadcastOp::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::std::optional<::mlir::stablehlo::ChannelHandleAttr> CollectiveBroadcastOp::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ChannelHandleAttr>(::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr)) : (::std::nullopt); +} + +void CollectiveBroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle) { + odsState.addOperands(operand); + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + odsState.addTypes(resultType0); +} + +void CollectiveBroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle) { + odsState.addOperands(operand); + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CollectiveBroadcastOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void CollectiveBroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle) { + odsState.addOperands(operand); + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CollectiveBroadcastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CollectiveBroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CollectiveBroadcastOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void CollectiveBroadcastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CollectiveBroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CollectiveBroadcastOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult CollectiveBroadcastOp::verifyInvariantsImpl() { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(*this, tblgen_channel_handle, "channel_handle"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CollectiveBroadcastOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CollectiveBroadcastOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CollectivePermuteOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CollectivePermuteOpGenericAdaptorBase::CollectivePermuteOpGenericAdaptorBase(CollectivePermuteOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::DenseIntElementsAttr CollectivePermuteOpGenericAdaptorBase::getSourceTargetPairs() { + auto attr = getSourceTargetPairsAttr(); + return attr; +} + +::std::optional<::mlir::stablehlo::ChannelHandleAttr> CollectivePermuteOpGenericAdaptorBase::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ChannelHandleAttr>(::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr)) : (::std::nullopt); +} + +} // namespace detail +CollectivePermuteOpAdaptor::CollectivePermuteOpAdaptor(CollectivePermuteOp op) : CollectivePermuteOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CollectivePermuteOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + auto tblgen_source_target_pairs = getProperties().source_target_pairs; (void)tblgen_source_target_pairs; + if (!tblgen_source_target_pairs) return emitError(loc, "'stablehlo.collective_permute' op ""requires attribute 'source_target_pairs'"); + + if (tblgen_source_target_pairs && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(tblgen_source_target_pairs))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(tblgen_source_target_pairs).getType().getElementType().isSignlessInteger(64))))) + return emitError(loc, "'stablehlo.collective_permute' op ""attribute 'source_target_pairs' failed to satisfy constraint: 64-bit signless integer elements attribute"); + + if (tblgen_channel_handle && !((::llvm::isa<::mlir::stablehlo::ChannelHandleAttr>(tblgen_channel_handle)))) + return emitError(loc, "'stablehlo.collective_permute' op ""attribute 'channel_handle' failed to satisfy constraint: two 64-bit integers 'handle' and 'type'"); + return ::mlir::success(); +} + +::llvm::LogicalResult CollectivePermuteOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_handle; + auto attr = dict.get("channel_handle"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_handle` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.source_target_pairs; + auto attr = dict.get("source_target_pairs"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `source_target_pairs` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CollectivePermuteOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_handle; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_handle", + propStorage)); + } + + { + const auto &propStorage = prop.source_target_pairs; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("source_target_pairs", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CollectivePermuteOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_handle.getAsOpaquePointer()), + llvm::hash_value(prop.source_target_pairs.getAsOpaquePointer())); +} + +std::optional CollectivePermuteOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_handle") + return prop.channel_handle; + + if (name == "source_target_pairs") + return prop.source_target_pairs; + return std::nullopt; +} + +void CollectivePermuteOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_handle") { + prop.channel_handle = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "source_target_pairs") { + prop.source_target_pairs = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CollectivePermuteOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_handle) attrs.append("channel_handle", prop.channel_handle); + + if (prop.source_target_pairs) attrs.append("source_target_pairs", prop.source_target_pairs); +} + +::llvm::LogicalResult CollectivePermuteOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelHandleAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(attr, "channel_handle", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSourceTargetPairsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(attr, "source_target_pairs", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CollectivePermuteOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.channel_handle))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.source_target_pairs))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CollectivePermuteOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.channel_handle); + writer.writeAttribute(prop.source_target_pairs); +} + +::mlir::DenseIntElementsAttr CollectivePermuteOp::getSourceTargetPairs() { + auto attr = getSourceTargetPairsAttr(); + return attr; +} + +::std::optional<::mlir::stablehlo::ChannelHandleAttr> CollectivePermuteOp::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ChannelHandleAttr>(::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr)) : (::std::nullopt); +} + +void CollectivePermuteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::DenseIntElementsAttr source_target_pairs, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle) { + odsState.addOperands(operand); + odsState.getOrAddProperties().source_target_pairs = source_target_pairs; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + odsState.addTypes(resultType0); +} + +void CollectivePermuteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseIntElementsAttr source_target_pairs, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle) { + odsState.addOperands(operand); + odsState.getOrAddProperties().source_target_pairs = source_target_pairs; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CollectivePermuteOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void CollectivePermuteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseIntElementsAttr source_target_pairs, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle) { + odsState.addOperands(operand); + odsState.getOrAddProperties().source_target_pairs = source_target_pairs; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CollectivePermuteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CollectivePermuteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CollectivePermuteOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void CollectivePermuteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CollectivePermuteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CollectivePermuteOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult CollectivePermuteOp::verifyInvariantsImpl() { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + auto tblgen_source_target_pairs = getProperties().source_target_pairs; (void)tblgen_source_target_pairs; + if (!tblgen_source_target_pairs) return emitOpError("requires attribute 'source_target_pairs'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(*this, tblgen_source_target_pairs, "source_target_pairs"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(*this, tblgen_channel_handle, "channel_handle"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CollectivePermuteOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CollectivePermuteOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CompareOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CompareOpGenericAdaptorBase::CompareOpGenericAdaptorBase(CompareOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ComparisonDirection CompareOpGenericAdaptorBase::getComparisonDirection() { + auto attr = getComparisonDirectionAttr(); + return attr.getValue(); +} + +::std::optional<::mlir::stablehlo::ComparisonType> CompareOpGenericAdaptorBase::getCompareType() { + auto attr = getCompareTypeAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ComparisonType>(attr.getValue()) : (::std::nullopt); +} + +} // namespace detail +CompareOpAdaptor::CompareOpAdaptor(CompareOp op) : CompareOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CompareOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_compare_type = getProperties().compare_type; (void)tblgen_compare_type; + auto tblgen_comparison_direction = getProperties().comparison_direction; (void)tblgen_comparison_direction; + if (!tblgen_comparison_direction) return emitError(loc, "'stablehlo.compare' op ""requires attribute 'comparison_direction'"); + + if (tblgen_comparison_direction && !((::llvm::isa<::mlir::stablehlo::ComparisonDirectionAttr>(tblgen_comparison_direction)))) + return emitError(loc, "'stablehlo.compare' op ""attribute 'comparison_direction' failed to satisfy constraint: Which comparison operation to perform."); + + if (tblgen_compare_type && !((::llvm::isa<::mlir::stablehlo::ComparisonTypeAttr>(tblgen_compare_type)))) + return emitError(loc, "'stablehlo.compare' op ""attribute 'compare_type' failed to satisfy constraint: Which comparison type to use."); + return ::mlir::success(); +} + +::llvm::LogicalResult CompareOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.compare_type; + auto attr = dict.get("compare_type"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `compare_type` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.comparison_direction; + auto attr = dict.get("comparison_direction"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `comparison_direction` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CompareOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.compare_type; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("compare_type", + propStorage)); + } + + { + const auto &propStorage = prop.comparison_direction; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("comparison_direction", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CompareOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.compare_type.getAsOpaquePointer()), + llvm::hash_value(prop.comparison_direction.getAsOpaquePointer())); +} + +std::optional CompareOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "compare_type") + return prop.compare_type; + + if (name == "comparison_direction") + return prop.comparison_direction; + return std::nullopt; +} + +void CompareOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "compare_type") { + prop.compare_type = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "comparison_direction") { + prop.comparison_direction = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CompareOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.compare_type) attrs.append("compare_type", prop.compare_type); + + if (prop.comparison_direction) attrs.append("comparison_direction", prop.comparison_direction); +} + +::llvm::LogicalResult CompareOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getCompareTypeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps11(attr, "compare_type", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getComparisonDirectionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps10(attr, "comparison_direction", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CompareOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.compare_type))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.comparison_direction))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CompareOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.compare_type); + writer.writeAttribute(prop.comparison_direction); +} + +::mlir::stablehlo::ComparisonDirection CompareOp::getComparisonDirection() { + auto attr = getComparisonDirectionAttr(); + return attr.getValue(); +} + +::std::optional<::mlir::stablehlo::ComparisonType> CompareOp::getCompareType() { + auto attr = getCompareTypeAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ComparisonType>(attr.getValue()) : (::std::nullopt); +} + +void CompareOp::setComparisonDirection(::mlir::stablehlo::ComparisonDirection attrValue) { + getProperties().comparison_direction = ::mlir::stablehlo::ComparisonDirectionAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); +} + +void CompareOp::setCompareType(::std::optional<::mlir::stablehlo::ComparisonType> attrValue) { + auto &odsProp = getProperties().compare_type; + if (attrValue) + odsProp = ::mlir::stablehlo::ComparisonTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); + else + odsProp = nullptr; +} + +void CompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::ComparisonDirectionAttr comparison_direction, /*optional*/::mlir::stablehlo::ComparisonTypeAttr compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().comparison_direction = comparison_direction; + if (compare_type) { + odsState.getOrAddProperties().compare_type = compare_type; + } + odsState.addTypes(resultType0); +} + +void CompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::ComparisonDirectionAttr comparison_direction, /*optional*/::mlir::stablehlo::ComparisonTypeAttr compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().comparison_direction = comparison_direction; + if (compare_type) { + odsState.getOrAddProperties().compare_type = compare_type; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CompareOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void CompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::ComparisonDirectionAttr comparison_direction, /*optional*/::mlir::stablehlo::ComparisonTypeAttr compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().comparison_direction = comparison_direction; + if (compare_type) { + odsState.getOrAddProperties().compare_type = compare_type; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::ComparisonDirection comparison_direction, /*optional*/::mlir::stablehlo::ComparisonTypeAttr compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().comparison_direction = ::mlir::stablehlo::ComparisonDirectionAttr::get(odsBuilder.getContext(), comparison_direction); + if (compare_type) { + odsState.getOrAddProperties().compare_type = compare_type; + } + odsState.addTypes(resultType0); +} + +void CompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::ComparisonDirection comparison_direction, /*optional*/::mlir::stablehlo::ComparisonTypeAttr compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().comparison_direction = ::mlir::stablehlo::ComparisonDirectionAttr::get(odsBuilder.getContext(), comparison_direction); + if (compare_type) { + odsState.getOrAddProperties().compare_type = compare_type; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CompareOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void CompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::ComparisonDirection comparison_direction, /*optional*/::mlir::stablehlo::ComparisonTypeAttr compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().comparison_direction = ::mlir::stablehlo::ComparisonDirectionAttr::get(odsBuilder.getContext(), comparison_direction); + if (compare_type) { + odsState.getOrAddProperties().compare_type = compare_type; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CompareOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CompareOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void CompareOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CompareOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CompareOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult CompareOp::verifyInvariantsImpl() { + auto tblgen_compare_type = getProperties().compare_type; (void)tblgen_compare_type; + auto tblgen_comparison_direction = getProperties().comparison_direction; (void)tblgen_comparison_direction; + if (!tblgen_comparison_direction) return emitOpError("requires attribute 'comparison_direction'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps10(*this, tblgen_comparison_direction, "comparison_direction"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps11(*this, tblgen_compare_type, "compare_type"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps16(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CompareOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult CompareOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::stablehlo::ComparisonDirectionAttr comparison_directionAttr; + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::stablehlo::ComparisonTypeAttr compare_typeAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + if (parser.parseCustomAttributeWithFallback(comparison_directionAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (comparison_directionAttr) result.getOrAddProperties().comparison_direction = comparison_directionAttr; + if (parser.parseComma()) + return ::mlir::failure(); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalComma())) { + + if (parser.parseCustomAttributeWithFallback(compare_typeAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (compare_typeAttr) result.getOrAddProperties().compare_type = compare_typeAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(::llvm::concat(lhsOperands, rhsOperands), allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CompareOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getComparisonDirectionAttr()); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + if (getCompareTypeAttr()) { + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter.printStrippedAttrOrType(getCompareTypeAttr()); + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("comparison_direction"); + elidedAttrs.push_back("compare_type"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void CompareOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +CompareOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(CompareOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CompareOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ComplexOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ComplexOpGenericAdaptorBase::ComplexOpGenericAdaptorBase(ComplexOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ComplexOpAdaptor::ComplexOpAdaptor(ComplexOp op) : ComplexOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ComplexOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ComplexOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ComplexOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ComplexOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ComplexOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ComplexOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ComplexOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ComplexOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ComplexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void ComplexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ComplexOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ComplexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ComplexOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ComplexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ComplexOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ComplexOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ComplexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ComplexOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ComplexOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps17(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps17(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps18(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ComplexOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ComplexOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + [[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(allOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseComplexOpType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(allOperands, ::llvm::concat(::llvm::ArrayRef<::mlir::Type>(lhsTypes), ::llvm::ArrayRef<::mlir::Type>(rhsTypes)), allOperandLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ComplexOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperation()->getOperands(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printComplexOpType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void ComplexOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ComplexOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CompositeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CompositeOpGenericAdaptorBase::CompositeOpGenericAdaptorBase(CompositeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair CompositeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::StringRef CompositeOpGenericAdaptorBase::getName() { + auto attr = getNameAttr(); + return attr.getValue(); +} + +::mlir::DictionaryAttr CompositeOpGenericAdaptorBase::getCompositeAttributesAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DictionaryAttr>(getProperties().composite_attributes); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getDictionaryAttr({}); + return attr; +} + +::mlir::DictionaryAttr CompositeOpGenericAdaptorBase::getCompositeAttributes() { + auto attr = getCompositeAttributesAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getDictionaryAttr({}); + return attr; +} + +::llvm::StringRef CompositeOpGenericAdaptorBase::getDecomposition() { + auto attr = getDecompositionAttr(); + return attr.getValue(); +} + +::mlir::IntegerAttr CompositeOpGenericAdaptorBase::getVersionAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().version); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(32), 0); + return attr; +} + +uint32_t CompositeOpGenericAdaptorBase::getVersion() { + auto attr = getVersionAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(32), 0).getValue().getZExtValue(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +CompositeOpAdaptor::CompositeOpAdaptor(CompositeOp op) : CompositeOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CompositeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_composite_attributes = getProperties().composite_attributes; (void)tblgen_composite_attributes; + auto tblgen_decomposition = getProperties().decomposition; (void)tblgen_decomposition; + if (!tblgen_decomposition) return emitError(loc, "'stablehlo.composite' op ""requires attribute 'decomposition'"); + auto tblgen_name = getProperties().name; (void)tblgen_name; + if (!tblgen_name) return emitError(loc, "'stablehlo.composite' op ""requires attribute 'name'"); + auto tblgen_version = getProperties().version; (void)tblgen_version; + + if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) + return emitError(loc, "'stablehlo.composite' op ""attribute 'name' failed to satisfy constraint: string attribute"); + + if (tblgen_composite_attributes && !((::llvm::isa<::mlir::DictionaryAttr>(tblgen_composite_attributes)))) + return emitError(loc, "'stablehlo.composite' op ""attribute 'composite_attributes' failed to satisfy constraint: dictionary of named attribute values"); + + if (tblgen_decomposition && !((::llvm::isa<::mlir::FlatSymbolRefAttr>(tblgen_decomposition)))) + return emitError(loc, "'stablehlo.composite' op ""attribute 'decomposition' failed to satisfy constraint: flat symbol reference attribute"); + + if (tblgen_version && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_version))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_version).getType().isSignlessInteger(32))))) + return emitError(loc, "'stablehlo.composite' op ""attribute 'version' failed to satisfy constraint: 32-bit signless integer attribute"); + return ::mlir::success(); +} + +std::pair CompositeOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange CompositeOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair CompositeOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult CompositeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.composite_attributes; + auto attr = dict.get("composite_attributes"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `composite_attributes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.decomposition; + auto attr = dict.get("decomposition"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `decomposition` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.name; + auto attr = dict.get("name"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.version; + auto attr = dict.get("version"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `version` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CompositeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.composite_attributes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("composite_attributes", + propStorage)); + } + + { + const auto &propStorage = prop.decomposition; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("decomposition", + propStorage)); + } + + { + const auto &propStorage = prop.name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("name", + propStorage)); + } + + { + const auto &propStorage = prop.version; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("version", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CompositeOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.composite_attributes.getAsOpaquePointer()), + llvm::hash_value(prop.decomposition.getAsOpaquePointer()), + llvm::hash_value(prop.name.getAsOpaquePointer()), + llvm::hash_value(prop.version.getAsOpaquePointer())); +} + +std::optional CompositeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "composite_attributes") + return prop.composite_attributes; + + if (name == "decomposition") + return prop.decomposition; + + if (name == "name") + return prop.name; + + if (name == "version") + return prop.version; + return std::nullopt; +} + +void CompositeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "composite_attributes") { + prop.composite_attributes = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "decomposition") { + prop.decomposition = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "name") { + prop.name = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "version") { + prop.version = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CompositeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.composite_attributes) attrs.append("composite_attributes", prop.composite_attributes); + + if (prop.decomposition) attrs.append("decomposition", prop.decomposition); + + if (prop.name) attrs.append("name", prop.name); + + if (prop.version) attrs.append("version", prop.version); +} + +::llvm::LogicalResult CompositeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getCompositeAttributesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps13(attr, "composite_attributes", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getDecompositionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps14(attr, "decomposition", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps12(attr, "name", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getVersionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps15(attr, "version", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CompositeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.composite_attributes))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.decomposition))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.name))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.version))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CompositeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.composite_attributes); + writer.writeAttribute(prop.decomposition); + writer.writeAttribute(prop.name); + + writer.writeOptionalAttribute(prop.version); +} + +::llvm::StringRef CompositeOp::getName() { + auto attr = getNameAttr(); + return attr.getValue(); +} + +::mlir::DictionaryAttr CompositeOp::getCompositeAttributes() { + auto attr = getCompositeAttributesAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getDictionaryAttr({}); + return attr; +} + +::llvm::StringRef CompositeOp::getDecomposition() { + auto attr = getDecompositionAttr(); + return attr.getValue(); +} + +uint32_t CompositeOp::getVersion() { + auto attr = getVersionAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), 0).getValue().getZExtValue(); + return attr.getValue().getZExtValue(); +} + +void CompositeOp::setName(::llvm::StringRef attrValue) { + getProperties().name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); +} + +void CompositeOp::setDecomposition(::llvm::StringRef attrValue) { + getProperties().decomposition = ::mlir::SymbolRefAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); +} + +void CompositeOp::setVersion(::std::optional attrValue) { + auto &odsProp = getProperties().version; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), *attrValue); + else + odsProp = nullptr; +} + +void CompositeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::StringAttr name, /*optional*/::mlir::DictionaryAttr composite_attributes, ::mlir::FlatSymbolRefAttr decomposition, /*optional*/::mlir::IntegerAttr version) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().name = name; + if (composite_attributes) { + odsState.getOrAddProperties().composite_attributes = composite_attributes; + } + odsState.getOrAddProperties().decomposition = decomposition; + if (version) { + odsState.getOrAddProperties().version = version; + } + odsState.addTypes(resultType0); +} + +void CompositeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::llvm::StringRef name, /*optional*/::mlir::DictionaryAttr composite_attributes, ::llvm::StringRef decomposition, /*optional*/uint32_t version) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().name = odsBuilder.getStringAttr(name); + odsState.getOrAddProperties().composite_attributes = composite_attributes; + odsState.getOrAddProperties().decomposition = ::mlir::SymbolRefAttr::get(odsBuilder.getContext(), decomposition); + odsState.getOrAddProperties().version = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), version); + odsState.addTypes(resultType0); +} + +void CompositeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CompositeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CompositeOp::verifyInvariantsImpl() { + auto tblgen_composite_attributes = getProperties().composite_attributes; (void)tblgen_composite_attributes; + auto tblgen_decomposition = getProperties().decomposition; (void)tblgen_decomposition; + if (!tblgen_decomposition) return emitOpError("requires attribute 'decomposition'"); + auto tblgen_name = getProperties().name; (void)tblgen_name; + if (!tblgen_name) return emitOpError("requires attribute 'name'"); + auto tblgen_version = getProperties().version; (void)tblgen_version; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps12(*this, tblgen_name, "name"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps13(*this, tblgen_composite_attributes, "composite_attributes"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps14(*this, tblgen_decomposition, "decomposition"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps15(*this, tblgen_version, "version"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps19(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps19(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CompositeOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult CompositeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::StringAttr nameAttr; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> inputsOperands; + ::llvm::SMLoc inputsOperandsLoc; + (void)inputsOperandsLoc; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + if (parser.parseCustomAttributeWithFallback(nameAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (nameAttr) result.getOrAddProperties().name = nameAttr; + + inputsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(inputsOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(inputsOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CompositeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getNameAttr()); + _odsPrinter << ' '; + _odsPrinter << getInputs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("name"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getCompositeAttributesAttr(); + if(attr && (attr == odsBuilder.getDictionaryAttr({}))) + elidedAttrs.push_back("composite_attributes"); + } + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getVersionAttr(); + if(attr && (attr == odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), 0))) + elidedAttrs.push_back("version"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CompositeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ConcatenateOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConcatenateOpGenericAdaptorBase::ConcatenateOpGenericAdaptorBase(ConcatenateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair ConcatenateOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +uint64_t ConcatenateOpGenericAdaptorBase::getDimension() { + auto attr = getDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +ConcatenateOpAdaptor::ConcatenateOpAdaptor(ConcatenateOp op) : ConcatenateOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ConcatenateOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitError(loc, "'stablehlo.concatenate' op ""requires attribute 'dimension'"); + + if (tblgen_dimension && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_dimension))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_dimension).getType().isSignlessInteger(64)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_dimension).getValue().isNegative())))) + return emitError(loc, "'stablehlo.concatenate' op ""attribute 'dimension' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative"); + return ::mlir::success(); +} + +std::pair ConcatenateOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange ConcatenateOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult ConcatenateOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimension; + auto attr = dict.get("dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ConcatenateOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConcatenateOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimension.getAsOpaquePointer())); +} + +std::optional ConcatenateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimension") + return prop.dimension; + return std::nullopt; +} + +void ConcatenateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimension") { + prop.dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ConcatenateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimension) attrs.append("dimension", prop.dimension); +} + +::llvm::LogicalResult ConcatenateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(attr, "dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConcatenateOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConcatenateOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimension); +} + +uint64_t ConcatenateOp::getDimension() { + auto attr = getDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +void ConcatenateOp::setDimension(uint64_t attrValue) { + getProperties().dimension = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void ConcatenateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::mlir::IntegerAttr dimension) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = dimension; + odsState.addTypes(resultType0); +} + +void ConcatenateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::IntegerAttr dimension) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = dimension; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConcatenateOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ConcatenateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::IntegerAttr dimension) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = dimension; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConcatenateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, uint64_t dimension) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), dimension); + odsState.addTypes(resultType0); +} + +void ConcatenateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, uint64_t dimension) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), dimension); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConcatenateOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ConcatenateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, uint64_t dimension) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), dimension); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConcatenateOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ConcatenateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConcatenateOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ConcatenateOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ConcatenateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConcatenateOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ConcatenateOp::verifyInvariantsImpl() { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitOpError("requires attribute 'dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(*this, tblgen_dimension, "dimension"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConcatenateOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ConcatenateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> inputsOperands; + ::llvm::SMLoc inputsOperandsLoc; + (void)inputsOperandsLoc; + ::mlir::IntegerAttr dimensionAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + { + inputsOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseVariadicOperandWithAttribute(parser, inputsOperands); + if (odsResult) return ::mlir::failure(); + } + if (parser.parseKeyword("dim")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(dimensionAttr, parser.getBuilder().getIntegerType(64))) { + return ::mlir::failure(); + } + if (dimensionAttr) result.getOrAddProperties().dimension = dimensionAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(inputsOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConcatenateOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + printVariadicOperandWithAttribute(_odsPrinter, *this, getInputs()); + _odsPrinter << ' ' << "dim"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getDimensionAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("dimension"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void ConcatenateOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ConcatenateOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ConstantOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConstantOpGenericAdaptorBase::ConstantOpGenericAdaptorBase(ConstantOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::ElementsAttr ConstantOpGenericAdaptorBase::getValue() { + auto attr = getValueAttr(); + return attr; +} + +} // namespace detail +ConstantOpAdaptor::ConstantOpAdaptor(ConstantOp op) : ConstantOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ConstantOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_value = getProperties().value; (void)tblgen_value; + if (!tblgen_value) return emitError(loc, "'stablehlo.constant' op ""requires attribute 'value'"); + + if (tblgen_value && !((::llvm::isa<::mlir::ElementsAttr>(tblgen_value)))) + return emitError(loc, "'stablehlo.constant' op ""attribute 'value' failed to satisfy constraint: constant vector/tensor attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult ConstantOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.value; + auto attr = dict.get("value"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `value` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ConstantOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.value; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("value", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConstantOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.value.getAsOpaquePointer())); +} + +std::optional ConstantOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "value") + return prop.value; + return std::nullopt; +} + +void ConstantOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "value") { + prop.value = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ConstantOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.value) attrs.append("value", prop.value); +} + +::llvm::LogicalResult ConstantOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getValueAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps16(attr, "value", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConstantOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.value))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConstantOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.value); +} + +::mlir::ElementsAttr ConstantOp::getValue() { + auto attr = getValueAttr(); + return attr; +} + +void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::ElementsAttr value) { + odsState.getOrAddProperties().value = value; + odsState.addTypes(output); +} + +void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ElementsAttr value) { + odsState.getOrAddProperties().value = value; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstantOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ElementsAttr value) { + odsState.getOrAddProperties().value = value; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConstantOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstantOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ConstantOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstantOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ConstantOp::verifyInvariantsImpl() { + auto tblgen_value = getProperties().value; (void)tblgen_value; + if (!tblgen_value) return emitOpError("requires attribute 'value'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps16(*this, tblgen_value, "value"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps20(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConstantOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void ConstantOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ConstantOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ConvertOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConvertOpGenericAdaptorBase::ConvertOpGenericAdaptorBase(ConvertOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ConvertOpAdaptor::ConvertOpAdaptor(ConvertOp op) : ConvertOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ConvertOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ConvertOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ConvertOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConvertOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ConvertOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ConvertOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ConvertOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ConvertOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ConvertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void ConvertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConvertOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ConvertOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ConvertOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps21(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps21(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConvertOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ConvertOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConvertOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void ConvertOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ConvertOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ConvolutionOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConvolutionOpGenericAdaptorBase::ConvolutionOpGenericAdaptorBase(ConvolutionOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> ConvolutionOpGenericAdaptorBase::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional< ::mlir::DenseIntElementsAttr > ConvolutionOpGenericAdaptorBase::getPadding() { + auto attr = getPaddingAttr(); + return attr ? ::std::optional< ::mlir::DenseIntElementsAttr >(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> ConvolutionOpGenericAdaptorBase::getLhsDilation() { + auto attr = getLhsDilationAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> ConvolutionOpGenericAdaptorBase::getRhsDilation() { + auto attr = getRhsDilationAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> ConvolutionOpGenericAdaptorBase::getWindowReversal() { + auto attr = getWindowReversalAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::mlir::stablehlo::ConvDimensionNumbersAttr ConvolutionOpGenericAdaptorBase::getDimensionNumbers() { + auto attr = getDimensionNumbersAttr(); + return ::llvm::cast<::mlir::stablehlo::ConvDimensionNumbersAttr>(attr); +} + +uint64_t ConvolutionOpGenericAdaptorBase::getFeatureGroupCount() { + auto attr = getFeatureGroupCountAttr(); + return attr.getValue().getZExtValue(); +} + +uint64_t ConvolutionOpGenericAdaptorBase::getBatchGroupCount() { + auto attr = getBatchGroupCountAttr(); + return attr.getValue().getZExtValue(); +} + +::std::optional< ::mlir::ArrayAttr > ConvolutionOpGenericAdaptorBase::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +} // namespace detail +ConvolutionOpAdaptor::ConvolutionOpAdaptor(ConvolutionOp op) : ConvolutionOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ConvolutionOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_batch_group_count = getProperties().batch_group_count; (void)tblgen_batch_group_count; + if (!tblgen_batch_group_count) return emitError(loc, "'stablehlo.convolution' op ""requires attribute 'batch_group_count'"); + auto tblgen_dimension_numbers = getProperties().dimension_numbers; (void)tblgen_dimension_numbers; + if (!tblgen_dimension_numbers) return emitError(loc, "'stablehlo.convolution' op ""requires attribute 'dimension_numbers'"); + auto tblgen_feature_group_count = getProperties().feature_group_count; (void)tblgen_feature_group_count; + if (!tblgen_feature_group_count) return emitError(loc, "'stablehlo.convolution' op ""requires attribute 'feature_group_count'"); + auto tblgen_lhs_dilation = getProperties().lhs_dilation; (void)tblgen_lhs_dilation; + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + auto tblgen_rhs_dilation = getProperties().rhs_dilation; (void)tblgen_rhs_dilation; + auto tblgen_window_reversal = getProperties().window_reversal; (void)tblgen_window_reversal; + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + + if (tblgen_window_strides && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_window_strides)))) + return emitError(loc, "'stablehlo.convolution' op ""attribute 'window_strides' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_padding && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(tblgen_padding))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(tblgen_padding).getType().getElementType().isSignlessInteger(64))))) + return emitError(loc, "'stablehlo.convolution' op ""attribute 'padding' failed to satisfy constraint: 64-bit signless integer elements attribute"); + + if (tblgen_lhs_dilation && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_lhs_dilation)))) + return emitError(loc, "'stablehlo.convolution' op ""attribute 'lhs_dilation' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_rhs_dilation && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_rhs_dilation)))) + return emitError(loc, "'stablehlo.convolution' op ""attribute 'rhs_dilation' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_window_reversal && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_window_reversal)))) + return emitError(loc, "'stablehlo.convolution' op ""attribute 'window_reversal' failed to satisfy constraint: i1 dense array attribute"); + + if (tblgen_dimension_numbers && !((::llvm::isa<::mlir::stablehlo::ConvDimensionNumbersAttr>(tblgen_dimension_numbers)))) + return emitError(loc, "'stablehlo.convolution' op ""attribute 'dimension_numbers' failed to satisfy constraint: Structure of dimension information for conv op"); + + if (tblgen_feature_group_count && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_feature_group_count))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_feature_group_count).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_feature_group_count).getValue().isStrictlyPositive())))) + return emitError(loc, "'stablehlo.convolution' op ""attribute 'feature_group_count' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive"); + + if (tblgen_batch_group_count && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_batch_group_count))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_batch_group_count).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_batch_group_count).getValue().isStrictlyPositive())))) + return emitError(loc, "'stablehlo.convolution' op ""attribute 'batch_group_count' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive"); + + if (tblgen_precision_config && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_precision_config))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_precision_config), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::stablehlo::PrecisionAttr>(attr))); })))) + return emitError(loc, "'stablehlo.convolution' op ""attribute 'precision_config' failed to satisfy constraint: Precision Config attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult ConvolutionOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.batch_group_count; + auto attr = dict.get("batch_group_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `batch_group_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.dimension_numbers; + auto attr = dict.get("dimension_numbers"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimension_numbers` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.feature_group_count; + auto attr = dict.get("feature_group_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `feature_group_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.lhs_dilation; + auto attr = dict.get("lhs_dilation"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lhs_dilation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.padding; + auto attr = dict.get("padding"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `padding` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.precision_config; + auto attr = dict.get("precision_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `precision_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.rhs_dilation; + auto attr = dict.get("rhs_dilation"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rhs_dilation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_reversal; + auto attr = dict.get("window_reversal"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_reversal` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_strides; + auto attr = dict.get("window_strides"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ConvolutionOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.batch_group_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("batch_group_count", + propStorage)); + } + + { + const auto &propStorage = prop.dimension_numbers; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimension_numbers", + propStorage)); + } + + { + const auto &propStorage = prop.feature_group_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("feature_group_count", + propStorage)); + } + + { + const auto &propStorage = prop.lhs_dilation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lhs_dilation", + propStorage)); + } + + { + const auto &propStorage = prop.padding; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("padding", + propStorage)); + } + + { + const auto &propStorage = prop.precision_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("precision_config", + propStorage)); + } + + { + const auto &propStorage = prop.rhs_dilation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rhs_dilation", + propStorage)); + } + + { + const auto &propStorage = prop.window_reversal; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_reversal", + propStorage)); + } + + { + const auto &propStorage = prop.window_strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_strides", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConvolutionOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.batch_group_count.getAsOpaquePointer()), + llvm::hash_value(prop.dimension_numbers.getAsOpaquePointer()), + llvm::hash_value(prop.feature_group_count.getAsOpaquePointer()), + llvm::hash_value(prop.lhs_dilation.getAsOpaquePointer()), + llvm::hash_value(prop.padding.getAsOpaquePointer()), + llvm::hash_value(prop.precision_config.getAsOpaquePointer()), + llvm::hash_value(prop.rhs_dilation.getAsOpaquePointer()), + llvm::hash_value(prop.window_reversal.getAsOpaquePointer()), + llvm::hash_value(prop.window_strides.getAsOpaquePointer())); +} + +std::optional ConvolutionOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "batch_group_count") + return prop.batch_group_count; + + if (name == "dimension_numbers") + return prop.dimension_numbers; + + if (name == "feature_group_count") + return prop.feature_group_count; + + if (name == "lhs_dilation") + return prop.lhs_dilation; + + if (name == "padding") + return prop.padding; + + if (name == "precision_config") + return prop.precision_config; + + if (name == "rhs_dilation") + return prop.rhs_dilation; + + if (name == "window_reversal") + return prop.window_reversal; + + if (name == "window_strides") + return prop.window_strides; + return std::nullopt; +} + +void ConvolutionOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "batch_group_count") { + prop.batch_group_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "dimension_numbers") { + prop.dimension_numbers = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "feature_group_count") { + prop.feature_group_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "lhs_dilation") { + prop.lhs_dilation = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "padding") { + prop.padding = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "precision_config") { + prop.precision_config = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "rhs_dilation") { + prop.rhs_dilation = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_reversal") { + prop.window_reversal = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_strides") { + prop.window_strides = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ConvolutionOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.batch_group_count) attrs.append("batch_group_count", prop.batch_group_count); + + if (prop.dimension_numbers) attrs.append("dimension_numbers", prop.dimension_numbers); + + if (prop.feature_group_count) attrs.append("feature_group_count", prop.feature_group_count); + + if (prop.lhs_dilation) attrs.append("lhs_dilation", prop.lhs_dilation); + + if (prop.padding) attrs.append("padding", prop.padding); + + if (prop.precision_config) attrs.append("precision_config", prop.precision_config); + + if (prop.rhs_dilation) attrs.append("rhs_dilation", prop.rhs_dilation); + + if (prop.window_reversal) attrs.append("window_reversal", prop.window_reversal); + + if (prop.window_strides) attrs.append("window_strides", prop.window_strides); +} + +::llvm::LogicalResult ConvolutionOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBatchGroupCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps5(attr, "batch_group_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getDimensionNumbersAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps18(attr, "dimension_numbers", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFeatureGroupCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps5(attr, "feature_group_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLhsDilationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "lhs_dilation", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPaddingAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(attr, "padding", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPrecisionConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps19(attr, "precision_config", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRhsDilationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "rhs_dilation", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowReversalAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps17(attr, "window_reversal", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "window_strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConvolutionOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.batch_group_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.dimension_numbers))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.feature_group_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.lhs_dilation))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.padding))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.precision_config))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.rhs_dilation))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.window_reversal))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.window_strides))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConvolutionOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.batch_group_count); + writer.writeAttribute(prop.dimension_numbers); + writer.writeAttribute(prop.feature_group_count); + + writer.writeOptionalAttribute(prop.lhs_dilation); + + writer.writeOptionalAttribute(prop.padding); + + writer.writeOptionalAttribute(prop.precision_config); + + writer.writeOptionalAttribute(prop.rhs_dilation); + + writer.writeOptionalAttribute(prop.window_reversal); + + writer.writeOptionalAttribute(prop.window_strides); +} + +::std::optional<::llvm::ArrayRef> ConvolutionOp::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional< ::mlir::DenseIntElementsAttr > ConvolutionOp::getPadding() { + auto attr = getPaddingAttr(); + return attr ? ::std::optional< ::mlir::DenseIntElementsAttr >(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> ConvolutionOp::getLhsDilation() { + auto attr = getLhsDilationAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> ConvolutionOp::getRhsDilation() { + auto attr = getRhsDilationAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> ConvolutionOp::getWindowReversal() { + auto attr = getWindowReversalAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::mlir::stablehlo::ConvDimensionNumbersAttr ConvolutionOp::getDimensionNumbers() { + auto attr = getDimensionNumbersAttr(); + return ::llvm::cast<::mlir::stablehlo::ConvDimensionNumbersAttr>(attr); +} + +uint64_t ConvolutionOp::getFeatureGroupCount() { + auto attr = getFeatureGroupCountAttr(); + return attr.getValue().getZExtValue(); +} + +uint64_t ConvolutionOp::getBatchGroupCount() { + auto attr = getBatchGroupCountAttr(); + return attr.getValue().getZExtValue(); +} + +::std::optional< ::mlir::ArrayAttr > ConvolutionOp::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +void ConvolutionOp::setWindowStrides(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().window_strides; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void ConvolutionOp::setLhsDilation(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().lhs_dilation; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void ConvolutionOp::setRhsDilation(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().rhs_dilation; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void ConvolutionOp::setWindowReversal(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().window_reversal; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void ConvolutionOp::setFeatureGroupCount(uint64_t attrValue) { + getProperties().feature_group_count = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void ConvolutionOp::setBatchGroupCount(uint64_t attrValue) { + getProperties().batch_group_count = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void ConvolutionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, ::mlir::IntegerAttr feature_group_count, ::mlir::IntegerAttr batch_group_count, /*optional*/::mlir::ArrayAttr precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (padding) { + odsState.getOrAddProperties().padding = padding; + } + if (lhs_dilation) { + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + } + if (rhs_dilation) { + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + } + if (window_reversal) { + odsState.getOrAddProperties().window_reversal = window_reversal; + } + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().feature_group_count = feature_group_count; + odsState.getOrAddProperties().batch_group_count = batch_group_count; + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + odsState.addTypes(resultType0); +} + +void ConvolutionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, ::mlir::IntegerAttr feature_group_count, ::mlir::IntegerAttr batch_group_count, /*optional*/::mlir::ArrayAttr precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (padding) { + odsState.getOrAddProperties().padding = padding; + } + if (lhs_dilation) { + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + } + if (rhs_dilation) { + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + } + if (window_reversal) { + odsState.getOrAddProperties().window_reversal = window_reversal; + } + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().feature_group_count = feature_group_count; + odsState.getOrAddProperties().batch_group_count = batch_group_count; + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConvolutionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, uint64_t feature_group_count, uint64_t batch_group_count, /*optional*/::mlir::ArrayAttr precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (padding) { + odsState.getOrAddProperties().padding = padding; + } + if (lhs_dilation) { + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + } + if (rhs_dilation) { + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + } + if (window_reversal) { + odsState.getOrAddProperties().window_reversal = window_reversal; + } + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().feature_group_count = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), feature_group_count); + odsState.getOrAddProperties().batch_group_count = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), batch_group_count); + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + odsState.addTypes(resultType0); +} + +void ConvolutionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, uint64_t feature_group_count, uint64_t batch_group_count, /*optional*/::mlir::ArrayAttr precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (padding) { + odsState.getOrAddProperties().padding = padding; + } + if (lhs_dilation) { + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + } + if (rhs_dilation) { + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + } + if (window_reversal) { + odsState.getOrAddProperties().window_reversal = window_reversal; + } + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().feature_group_count = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), feature_group_count); + odsState.getOrAddProperties().batch_group_count = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), batch_group_count); + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConvolutionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ConvolutionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ConvolutionOp::verifyInvariantsImpl() { + auto tblgen_batch_group_count = getProperties().batch_group_count; (void)tblgen_batch_group_count; + if (!tblgen_batch_group_count) return emitOpError("requires attribute 'batch_group_count'"); + auto tblgen_dimension_numbers = getProperties().dimension_numbers; (void)tblgen_dimension_numbers; + if (!tblgen_dimension_numbers) return emitOpError("requires attribute 'dimension_numbers'"); + auto tblgen_feature_group_count = getProperties().feature_group_count; (void)tblgen_feature_group_count; + if (!tblgen_feature_group_count) return emitOpError("requires attribute 'feature_group_count'"); + auto tblgen_lhs_dilation = getProperties().lhs_dilation; (void)tblgen_lhs_dilation; + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + auto tblgen_rhs_dilation = getProperties().rhs_dilation; (void)tblgen_rhs_dilation; + auto tblgen_window_reversal = getProperties().window_reversal; (void)tblgen_window_reversal; + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_window_strides, "window_strides"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(*this, tblgen_padding, "padding"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_lhs_dilation, "lhs_dilation"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_rhs_dilation, "rhs_dilation"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps17(*this, tblgen_window_reversal, "window_reversal"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps18(*this, tblgen_dimension_numbers, "dimension_numbers"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps5(*this, tblgen_feature_group_count, "feature_group_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps5(*this, tblgen_batch_group_count, "batch_group_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps19(*this, tblgen_precision_config, "precision_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConvolutionOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ConvolutionOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; + ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbersAttr; + ::mlir::DenseI64ArrayAttr window_stridesAttr; + ::mlir::DenseIntElementsAttr paddingAttr; + ::mlir::DenseI64ArrayAttr lhs_dilationAttr; + ::mlir::DenseI64ArrayAttr rhs_dilationAttr; + ::mlir::DenseBoolArrayAttr window_reversalAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + if (parser.parseLParen()) + return ::mlir::failure(); + [[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(allOperands)) + return ::mlir::failure(); + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseKeyword("dim_numbers")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + { + auto odsResult = parseConvolutionDimensions(parser, dimension_numbersAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().dimension_numbers = dimension_numbersAttr; + } + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("window")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + if (parser.parseLBrace()) + return ::mlir::failure(); + { + auto odsResult = parseWindowAttributes(parser, window_stridesAttr, paddingAttr, lhs_dilationAttr, rhs_dilationAttr, window_reversalAttr); + if (odsResult) return ::mlir::failure(); + if (window_stridesAttr) + result.getOrAddProperties().window_strides = window_stridesAttr; + if (paddingAttr) + result.getOrAddProperties().padding = paddingAttr; + if (lhs_dilationAttr) + result.getOrAddProperties().lhs_dilation = lhs_dilationAttr; + if (rhs_dilationAttr) + result.getOrAddProperties().rhs_dilation = rhs_dilationAttr; + if (window_reversalAttr) + result.getOrAddProperties().window_reversal = window_reversalAttr; + } + if (parser.parseRBrace()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(allOperands, allOperandTypes, allOperandLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConvolutionOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << "("; + _odsPrinter << getOperation()->getOperands(); + _odsPrinter << ")"; + _odsPrinter << ' ' << "dim_numbers"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + printConvolutionDimensions(_odsPrinter, *this, getDimensionNumbersAttr()); + _odsPrinter << ","; + _odsPrinter << ' ' << "window"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' ' << "{"; + printWindowAttributes(_odsPrinter, *this, getWindowStridesAttr(), getPaddingAttr(), getLhsDilationAttr(), getRhsDilationAttr(), getWindowReversalAttr()); + _odsPrinter << "}"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("dimension_numbers"); + elidedAttrs.push_back("window_strides"); + elidedAttrs.push_back("padding"); + elidedAttrs.push_back("lhs_dilation"); + elidedAttrs.push_back("rhs_dilation"); + elidedAttrs.push_back("window_reversal"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void ConvolutionOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ConvolutionOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CosineOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CosineOpGenericAdaptorBase::CosineOpGenericAdaptorBase(CosineOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ResultAccuracyAttr CosineOpGenericAdaptorBase::getResultAccuracyAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + if (!attr) + attr = ::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + return attr; +} + +::mlir::stablehlo::ResultAccuracyAttr CosineOpGenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +} // namespace detail +CosineOpAdaptor::CosineOpAdaptor(CosineOp op) : CosineOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CosineOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (tblgen_result_accuracy && !((::llvm::isa<::mlir::stablehlo::ResultAccuracyAttr>(tblgen_result_accuracy)))) + return emitError(loc, "'stablehlo.cosine' op ""attribute 'result_accuracy' failed to satisfy constraint: The requested accuracy for transcendental unary ops."); + return ::mlir::success(); +} + +::llvm::LogicalResult CosineOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CosineOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CosineOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional CosineOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void CosineOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CosineOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult CosineOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CosineOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CosineOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.result_accuracy); +} + +::mlir::stablehlo::ResultAccuracyAttr CosineOp::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder((*this)->getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +void CosineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + odsState.addTypes(result); +} + +void CosineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CosineOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void CosineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CosineOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CosineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CosineOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void CosineOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CosineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CosineOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult CosineOp::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CosineOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult CosineOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CosineOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getResultAccuracyAttr(); + if(attr && (attr == ::mlir::stablehlo::ResultAccuracyAttr::get(odsBuilder.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(odsBuilder.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)))) + elidedAttrs.push_back("result_accuracy"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void CosineOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CosineOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CreateTokenOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CreateTokenOpGenericAdaptorBase::CreateTokenOpGenericAdaptorBase(CreateTokenOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +CreateTokenOpAdaptor::CreateTokenOpAdaptor(CreateTokenOp op) : CreateTokenOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CreateTokenOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult CreateTokenOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute CreateTokenOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CreateTokenOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional CreateTokenOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void CreateTokenOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void CreateTokenOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult CreateTokenOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void CreateTokenOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output) { + odsState.addTypes(output); +} + +void CreateTokenOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CreateTokenOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void CreateTokenOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CreateTokenOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CreateTokenOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CreateTokenOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void CreateTokenOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CreateTokenOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CreateTokenOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult CreateTokenOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CreateTokenOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult CreateTokenOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + return ::mlir::success(); +} + +void CreateTokenOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void CreateTokenOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CreateTokenOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CrossReplicaSumOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CrossReplicaSumOpGenericAdaptorBase::CrossReplicaSumOpGenericAdaptorBase(CrossReplicaSumOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::DenseIntElementsAttr CrossReplicaSumOpGenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +} // namespace detail +CrossReplicaSumOpAdaptor::CrossReplicaSumOpAdaptor(CrossReplicaSumOp op) : CrossReplicaSumOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CrossReplicaSumOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'stablehlo.cross-replica-sum' op ""requires attribute 'replica_groups'"); + + if (tblgen_replica_groups && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(tblgen_replica_groups))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(tblgen_replica_groups).getType().getElementType().isSignlessInteger(64))))) + return emitError(loc, "'stablehlo.cross-replica-sum' op ""attribute 'replica_groups' failed to satisfy constraint: 64-bit signless integer elements attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult CrossReplicaSumOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CrossReplicaSumOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CrossReplicaSumOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.replica_groups.getAsOpaquePointer())); +} + +std::optional CrossReplicaSumOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "replica_groups") + return prop.replica_groups; + return std::nullopt; +} + +void CrossReplicaSumOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CrossReplicaSumOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); +} + +::llvm::LogicalResult CrossReplicaSumOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CrossReplicaSumOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CrossReplicaSumOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.replica_groups); +} + +::mlir::DenseIntElementsAttr CrossReplicaSumOp::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +void CrossReplicaSumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups) { + odsState.addOperands(operand); + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.addTypes(resultType0); +} + +void CrossReplicaSumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups) { + odsState.addOperands(operand); + odsState.getOrAddProperties().replica_groups = replica_groups; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CrossReplicaSumOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void CrossReplicaSumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups) { + odsState.addOperands(operand); + odsState.getOrAddProperties().replica_groups = replica_groups; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CrossReplicaSumOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CrossReplicaSumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CrossReplicaSumOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void CrossReplicaSumOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CrossReplicaSumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CrossReplicaSumOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult CrossReplicaSumOp::verifyInvariantsImpl() { + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CrossReplicaSumOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void CrossReplicaSumOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CrossReplicaSumOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CustomCallOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CustomCallOpGenericAdaptorBase::CustomCallOpGenericAdaptorBase(CustomCallOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair CustomCallOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::StringRef CustomCallOpGenericAdaptorBase::getCallTargetName() { + auto attr = getCallTargetNameAttr(); + return attr.getValue(); +} + +::mlir::BoolAttr CustomCallOpGenericAdaptorBase::getHasSideEffectAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().has_side_effect); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false); + return attr; +} + +bool CustomCallOpGenericAdaptorBase::getHasSideEffect() { + auto attr = getHasSideEffectAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +::std::optional<::mlir::Attribute> CustomCallOpGenericAdaptorBase::getBackendConfig() { + auto attr = getBackendConfigAttr(); + return attr ? ::std::optional<::mlir::Attribute>(attr) : (::std::nullopt); +} + +::mlir::stablehlo::CustomCallApiVersionAttr CustomCallOpGenericAdaptorBase::getApiVersionAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::CustomCallApiVersionAttr>(getProperties().api_version); + if (!attr) + attr = ::mlir::stablehlo::CustomCallApiVersionAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::CustomCallApiVersion::API_VERSION_ORIGINAL); + return attr; +} + +::mlir::stablehlo::CustomCallApiVersion CustomCallOpGenericAdaptorBase::getApiVersion() { + auto attr = getApiVersionAttr(); + if (!attr) + return ::mlir::stablehlo::CustomCallApiVersionAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::CustomCallApiVersion::API_VERSION_ORIGINAL).getValue(); + return attr.getValue(); +} + +::mlir::ArrayAttr CustomCallOpGenericAdaptorBase::getCalledComputationsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().called_computations); + if (!attr) + attr = ::mlir::ArrayAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), {}); + return attr; +} + +::mlir::ArrayAttr CustomCallOpGenericAdaptorBase::getCalledComputations() { + auto attr = getCalledComputationsAttr(); + if (!attr) + return ::mlir::ArrayAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), {}); + return attr; +} + +::std::optional< ::mlir::ArrayAttr > CustomCallOpGenericAdaptorBase::getOperandLayouts() { + auto attr = getOperandLayoutsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::std::optional< ::mlir::ArrayAttr > CustomCallOpGenericAdaptorBase::getResultLayouts() { + auto attr = getResultLayoutsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::ArrayAttr CustomCallOpGenericAdaptorBase::getOutputOperandAliasesAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().output_operand_aliases); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getArrayAttr({}); + return attr; +} + +::mlir::ArrayAttr CustomCallOpGenericAdaptorBase::getOutputOperandAliases() { + auto attr = getOutputOperandAliasesAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getArrayAttr({}); + return attr; +} + +} // namespace detail +CustomCallOpAdaptor::CustomCallOpAdaptor(CustomCallOp op) : CustomCallOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CustomCallOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_api_version = getProperties().api_version; (void)tblgen_api_version; + auto tblgen_backend_config = getProperties().backend_config; (void)tblgen_backend_config; + auto tblgen_call_target_name = getProperties().call_target_name; (void)tblgen_call_target_name; + if (!tblgen_call_target_name) return emitError(loc, "'stablehlo.custom_call' op ""requires attribute 'call_target_name'"); + auto tblgen_called_computations = getProperties().called_computations; (void)tblgen_called_computations; + auto tblgen_has_side_effect = getProperties().has_side_effect; (void)tblgen_has_side_effect; + auto tblgen_operand_layouts = getProperties().operand_layouts; (void)tblgen_operand_layouts; + auto tblgen_output_operand_aliases = getProperties().output_operand_aliases; (void)tblgen_output_operand_aliases; + auto tblgen_result_layouts = getProperties().result_layouts; (void)tblgen_result_layouts; + + if (tblgen_call_target_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_call_target_name)))) + return emitError(loc, "'stablehlo.custom_call' op ""attribute 'call_target_name' failed to satisfy constraint: string attribute"); + + if (tblgen_has_side_effect && !((::llvm::isa<::mlir::BoolAttr>(tblgen_has_side_effect)))) + return emitError(loc, "'stablehlo.custom_call' op ""attribute 'has_side_effect' failed to satisfy constraint: bool attribute"); + + if (tblgen_backend_config && !(((::llvm::isa<::mlir::StringAttr>(tblgen_backend_config))) || ((::llvm::isa<::mlir::DictionaryAttr>(tblgen_backend_config))))) + return emitError(loc, "'stablehlo.custom_call' op ""attribute 'backend_config' failed to satisfy constraint: string attribute or dictionary of named attribute values"); + + if (tblgen_api_version && !((::llvm::isa<::mlir::stablehlo::CustomCallApiVersionAttr>(tblgen_api_version)))) + return emitError(loc, "'stablehlo.custom_call' op ""attribute 'api_version' failed to satisfy constraint: Custom call API version"); + + if (tblgen_called_computations && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_called_computations))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_called_computations), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::FlatSymbolRefAttr>(attr))); })))) + return emitError(loc, "'stablehlo.custom_call' op ""attribute 'called_computations' failed to satisfy constraint: flat symbol ref array attribute"); + + if (tblgen_operand_layouts && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_operand_layouts))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_operand_layouts), [&](::mlir::Attribute attr) { return attr && ((((::llvm::isa<::mlir::DenseIntElementsAttr>(attr))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(attr) + .getType() + .getElementType() + .isIndex()))) && ((cast<::mlir::DenseIntElementsAttr>(attr).getType().getRank() + == 1))); })))) + return emitError(loc, "'stablehlo.custom_call' op ""attribute 'operand_layouts' failed to satisfy constraint: Array of layout (1D tensor of index type) attributes"); + + if (tblgen_result_layouts && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_result_layouts))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_result_layouts), [&](::mlir::Attribute attr) { return attr && ((((::llvm::isa<::mlir::DenseIntElementsAttr>(attr))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(attr) + .getType() + .getElementType() + .isIndex()))) && ((cast<::mlir::DenseIntElementsAttr>(attr).getType().getRank() + == 1))); })))) + return emitError(loc, "'stablehlo.custom_call' op ""attribute 'result_layouts' failed to satisfy constraint: Array of layout (1D tensor of index type) attributes"); + + if (tblgen_output_operand_aliases && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_output_operand_aliases))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_output_operand_aliases), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::stablehlo::OutputOperandAliasAttr>(attr))); })))) + return emitError(loc, "'stablehlo.custom_call' op ""attribute 'output_operand_aliases' failed to satisfy constraint: Aliasing attribute for outputs and operands of CustomCall"); + return ::mlir::success(); +} + +std::pair CustomCallOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange CustomCallOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair CustomCallOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult CustomCallOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.api_version; + auto attr = dict.get("api_version"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `api_version` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.backend_config; + auto attr = dict.get("backend_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `backend_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.call_target_name; + auto attr = dict.get("call_target_name"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `call_target_name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.called_computations; + auto attr = dict.get("called_computations"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `called_computations` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.has_side_effect; + auto attr = dict.get("has_side_effect"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `has_side_effect` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.operand_layouts; + auto attr = dict.get("operand_layouts"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `operand_layouts` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.output_operand_aliases; + auto attr = dict.get("output_operand_aliases"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `output_operand_aliases` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.result_layouts; + auto attr = dict.get("result_layouts"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_layouts` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CustomCallOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.api_version; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("api_version", + propStorage)); + } + + { + const auto &propStorage = prop.backend_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("backend_config", + propStorage)); + } + + { + const auto &propStorage = prop.call_target_name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("call_target_name", + propStorage)); + } + + { + const auto &propStorage = prop.called_computations; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("called_computations", + propStorage)); + } + + { + const auto &propStorage = prop.has_side_effect; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("has_side_effect", + propStorage)); + } + + { + const auto &propStorage = prop.operand_layouts; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("operand_layouts", + propStorage)); + } + + { + const auto &propStorage = prop.output_operand_aliases; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("output_operand_aliases", + propStorage)); + } + + { + const auto &propStorage = prop.result_layouts; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_layouts", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CustomCallOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.api_version.getAsOpaquePointer()), + llvm::hash_value(prop.backend_config.getAsOpaquePointer()), + llvm::hash_value(prop.call_target_name.getAsOpaquePointer()), + llvm::hash_value(prop.called_computations.getAsOpaquePointer()), + llvm::hash_value(prop.has_side_effect.getAsOpaquePointer()), + llvm::hash_value(prop.operand_layouts.getAsOpaquePointer()), + llvm::hash_value(prop.output_operand_aliases.getAsOpaquePointer()), + llvm::hash_value(prop.result_layouts.getAsOpaquePointer())); +} + +std::optional CustomCallOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "api_version") + return prop.api_version; + + if (name == "backend_config") + return prop.backend_config; + + if (name == "call_target_name") + return prop.call_target_name; + + if (name == "called_computations") + return prop.called_computations; + + if (name == "has_side_effect") + return prop.has_side_effect; + + if (name == "operand_layouts") + return prop.operand_layouts; + + if (name == "output_operand_aliases") + return prop.output_operand_aliases; + + if (name == "result_layouts") + return prop.result_layouts; + return std::nullopt; +} + +void CustomCallOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "api_version") { + prop.api_version = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "backend_config") { + prop.backend_config = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "call_target_name") { + prop.call_target_name = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "called_computations") { + prop.called_computations = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "has_side_effect") { + prop.has_side_effect = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "operand_layouts") { + prop.operand_layouts = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "output_operand_aliases") { + prop.output_operand_aliases = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "result_layouts") { + prop.result_layouts = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CustomCallOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.api_version) attrs.append("api_version", prop.api_version); + + if (prop.backend_config) attrs.append("backend_config", prop.backend_config); + + if (prop.call_target_name) attrs.append("call_target_name", prop.call_target_name); + + if (prop.called_computations) attrs.append("called_computations", prop.called_computations); + + if (prop.has_side_effect) attrs.append("has_side_effect", prop.has_side_effect); + + if (prop.operand_layouts) attrs.append("operand_layouts", prop.operand_layouts); + + if (prop.output_operand_aliases) attrs.append("output_operand_aliases", prop.output_operand_aliases); + + if (prop.result_layouts) attrs.append("result_layouts", prop.result_layouts); +} + +::llvm::LogicalResult CustomCallOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getApiVersionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps21(attr, "api_version", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getBackendConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps20(attr, "backend_config", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getCallTargetNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps12(attr, "call_target_name", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getCalledComputationsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps22(attr, "called_computations", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getHasSideEffectAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(attr, "has_side_effect", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOperandLayoutsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps23(attr, "operand_layouts", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOutputOperandAliasesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps24(attr, "output_operand_aliases", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getResultLayoutsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps23(attr, "result_layouts", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CustomCallOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.api_version))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.backend_config))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.call_target_name))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.called_computations))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.has_side_effect))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.operand_layouts))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.output_operand_aliases))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.result_layouts))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CustomCallOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.api_version); + + writer.writeOptionalAttribute(prop.backend_config); + writer.writeAttribute(prop.call_target_name); + + writer.writeOptionalAttribute(prop.called_computations); + + writer.writeOptionalAttribute(prop.has_side_effect); + + writer.writeOptionalAttribute(prop.operand_layouts); + + writer.writeOptionalAttribute(prop.output_operand_aliases); + + writer.writeOptionalAttribute(prop.result_layouts); +} + +::llvm::StringRef CustomCallOp::getCallTargetName() { + auto attr = getCallTargetNameAttr(); + return attr.getValue(); +} + +bool CustomCallOp::getHasSideEffect() { + auto attr = getHasSideEffectAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +::std::optional<::mlir::Attribute> CustomCallOp::getBackendConfig() { + auto attr = getBackendConfigAttr(); + return attr ? ::std::optional<::mlir::Attribute>(attr) : (::std::nullopt); +} + +::mlir::stablehlo::CustomCallApiVersion CustomCallOp::getApiVersion() { + auto attr = getApiVersionAttr(); + if (!attr) + return ::mlir::stablehlo::CustomCallApiVersionAttr::get(::mlir::Builder((*this)->getContext()).getContext(), ::mlir::stablehlo::CustomCallApiVersion::API_VERSION_ORIGINAL).getValue(); + return attr.getValue(); +} + +::mlir::ArrayAttr CustomCallOp::getCalledComputations() { + auto attr = getCalledComputationsAttr(); + if (!attr) + return ::mlir::ArrayAttr::get(::mlir::Builder((*this)->getContext()).getContext(), {}); + return attr; +} + +::std::optional< ::mlir::ArrayAttr > CustomCallOp::getOperandLayouts() { + auto attr = getOperandLayoutsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::std::optional< ::mlir::ArrayAttr > CustomCallOp::getResultLayouts() { + auto attr = getResultLayoutsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::ArrayAttr CustomCallOp::getOutputOperandAliases() { + auto attr = getOutputOperandAliasesAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getArrayAttr({}); + return attr; +} + +void CustomCallOp::setCallTargetName(::llvm::StringRef attrValue) { + getProperties().call_target_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); +} + +void CustomCallOp::setHasSideEffect(::std::optional attrValue) { + auto &odsProp = getProperties().has_side_effect; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue); + else + odsProp = nullptr; +} + +void CustomCallOp::setApiVersion(::std::optional<::mlir::stablehlo::CustomCallApiVersion> attrValue) { + auto &odsProp = getProperties().api_version; + if (attrValue) + odsProp = ::mlir::stablehlo::CustomCallApiVersionAttr::get(::mlir::Builder((*this)->getContext()).getContext(), *attrValue); + else + odsProp = nullptr; +} + +void CustomCallOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::StringAttr call_target_name, /*optional*/::mlir::BoolAttr has_side_effect, /*optional*/::mlir::Attribute backend_config, /*optional*/::mlir::stablehlo::CustomCallApiVersionAttr api_version, /*optional*/::mlir::ArrayAttr called_computations, /*optional*/::mlir::ArrayAttr operand_layouts, /*optional*/::mlir::ArrayAttr result_layouts, /*optional*/::mlir::ArrayAttr output_operand_aliases) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().call_target_name = call_target_name; + if (has_side_effect) { + odsState.getOrAddProperties().has_side_effect = has_side_effect; + } + if (backend_config) { + odsState.getOrAddProperties().backend_config = backend_config; + } + if (api_version) { + odsState.getOrAddProperties().api_version = api_version; + } + if (called_computations) { + odsState.getOrAddProperties().called_computations = called_computations; + } + if (operand_layouts) { + odsState.getOrAddProperties().operand_layouts = operand_layouts; + } + if (result_layouts) { + odsState.getOrAddProperties().result_layouts = result_layouts; + } + if (output_operand_aliases) { + odsState.getOrAddProperties().output_operand_aliases = output_operand_aliases; + } + odsState.addTypes(resultType0); +} + +void CustomCallOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::llvm::StringRef call_target_name, /*optional*/bool has_side_effect, /*optional*/::mlir::Attribute backend_config, /*optional*/::mlir::stablehlo::CustomCallApiVersion api_version, /*optional*/::mlir::ArrayAttr called_computations, /*optional*/::mlir::ArrayAttr operand_layouts, /*optional*/::mlir::ArrayAttr result_layouts, /*optional*/::mlir::ArrayAttr output_operand_aliases) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().call_target_name = odsBuilder.getStringAttr(call_target_name); + odsState.getOrAddProperties().has_side_effect = odsBuilder.getBoolAttr(has_side_effect); + if (backend_config) { + odsState.getOrAddProperties().backend_config = backend_config; + } + odsState.getOrAddProperties().api_version = ::mlir::stablehlo::CustomCallApiVersionAttr::get(odsBuilder.getContext(), api_version); + odsState.getOrAddProperties().called_computations = called_computations; + if (operand_layouts) { + odsState.getOrAddProperties().operand_layouts = operand_layouts; + } + if (result_layouts) { + odsState.getOrAddProperties().result_layouts = result_layouts; + } + odsState.getOrAddProperties().output_operand_aliases = output_operand_aliases; + odsState.addTypes(resultType0); +} + +void CustomCallOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CustomCallOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CustomCallOp::verifyInvariantsImpl() { + auto tblgen_api_version = getProperties().api_version; (void)tblgen_api_version; + auto tblgen_backend_config = getProperties().backend_config; (void)tblgen_backend_config; + auto tblgen_call_target_name = getProperties().call_target_name; (void)tblgen_call_target_name; + if (!tblgen_call_target_name) return emitOpError("requires attribute 'call_target_name'"); + auto tblgen_called_computations = getProperties().called_computations; (void)tblgen_called_computations; + auto tblgen_has_side_effect = getProperties().has_side_effect; (void)tblgen_has_side_effect; + auto tblgen_operand_layouts = getProperties().operand_layouts; (void)tblgen_operand_layouts; + auto tblgen_output_operand_aliases = getProperties().output_operand_aliases; (void)tblgen_output_operand_aliases; + auto tblgen_result_layouts = getProperties().result_layouts; (void)tblgen_result_layouts; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps12(*this, tblgen_call_target_name, "call_target_name"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(*this, tblgen_has_side_effect, "has_side_effect"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps20(*this, tblgen_backend_config, "backend_config"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps21(*this, tblgen_api_version, "api_version"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps22(*this, tblgen_called_computations, "called_computations"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps23(*this, tblgen_operand_layouts, "operand_layouts"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps23(*this, tblgen_result_layouts, "result_layouts"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps24(*this, tblgen_output_operand_aliases, "output_operand_aliases"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps22(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps22(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CustomCallOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult CustomCallOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::StringAttr call_target_nameAttr; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> inputsOperands; + ::llvm::SMLoc inputsOperandsLoc; + (void)inputsOperandsLoc; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + { + auto odsResult = parseCustomCallTarget(parser, call_target_nameAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().call_target_name = call_target_nameAttr; + } + if (parser.parseLParen()) + return ::mlir::failure(); + + inputsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(inputsOperands)) + return ::mlir::failure(); + if (parser.parseRParen()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(inputsOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CustomCallOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + printCustomCallTarget(_odsPrinter, *this, getCallTargetNameAttr()); + _odsPrinter << "("; + _odsPrinter << getInputs(); + _odsPrinter << ")"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("call_target_name"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getHasSideEffectAttr(); + if(attr && (attr == odsBuilder.getBoolAttr(false))) + elidedAttrs.push_back("has_side_effect"); + } + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getApiVersionAttr(); + if(attr && (attr == ::mlir::stablehlo::CustomCallApiVersionAttr::get(odsBuilder.getContext(), ::mlir::stablehlo::CustomCallApiVersion::API_VERSION_ORIGINAL))) + elidedAttrs.push_back("api_version"); + } + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getCalledComputationsAttr(); + if(attr && (attr == ::mlir::ArrayAttr::get(odsBuilder.getContext(), {}))) + elidedAttrs.push_back("called_computations"); + } + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getOutputOperandAliasesAttr(); + if(attr && (attr == odsBuilder.getArrayAttr({}))) + elidedAttrs.push_back("output_operand_aliases"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CustomCallOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DivOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DivOpGenericAdaptorBase::DivOpGenericAdaptorBase(DivOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +DivOpAdaptor::DivOpAdaptor(DivOp op) : DivOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DivOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult DivOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute DivOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DivOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional DivOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void DivOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void DivOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult DivOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void DivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void DivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DivOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void DivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DivOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DivOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void DivOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DivOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult DivOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DivOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult DivOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DivOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void DivOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DivOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DotGeneralOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DotGeneralOpGenericAdaptorBase::DotGeneralOpGenericAdaptorBase(DotGeneralOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::DotDimensionNumbersAttr DotGeneralOpGenericAdaptorBase::getDotDimensionNumbers() { + auto attr = getDotDimensionNumbersAttr(); + return ::llvm::cast<::mlir::stablehlo::DotDimensionNumbersAttr>(attr); +} + +::std::optional< ::mlir::ArrayAttr > DotGeneralOpGenericAdaptorBase::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::std::optional<::mlir::stablehlo::DotAlgorithmAttr> DotGeneralOpGenericAdaptorBase::getAlgorithm() { + auto attr = getAlgorithmAttr(); + return attr ? ::std::optional<::mlir::stablehlo::DotAlgorithmAttr>(::llvm::cast<::mlir::stablehlo::DotAlgorithmAttr>(attr)) : (::std::nullopt); +} + +} // namespace detail +DotGeneralOpAdaptor::DotGeneralOpAdaptor(DotGeneralOp op) : DotGeneralOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DotGeneralOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_algorithm = getProperties().algorithm; (void)tblgen_algorithm; + auto tblgen_dot_dimension_numbers = getProperties().dot_dimension_numbers; (void)tblgen_dot_dimension_numbers; + if (!tblgen_dot_dimension_numbers) return emitError(loc, "'stablehlo.dot_general' op ""requires attribute 'dot_dimension_numbers'"); + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + + if (tblgen_dot_dimension_numbers && !((::llvm::isa<::mlir::stablehlo::DotDimensionNumbersAttr>(tblgen_dot_dimension_numbers)))) + return emitError(loc, "'stablehlo.dot_general' op ""attribute 'dot_dimension_numbers' failed to satisfy constraint: Attribute that models the dimension information for dot."); + + if (tblgen_precision_config && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_precision_config))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_precision_config), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::stablehlo::PrecisionAttr>(attr))); })))) + return emitError(loc, "'stablehlo.dot_general' op ""attribute 'precision_config' failed to satisfy constraint: Precision Config attribute"); + + if (tblgen_algorithm && !((::llvm::isa<::mlir::stablehlo::DotAlgorithmAttr>(tblgen_algorithm)))) + return emitError(loc, "'stablehlo.dot_general' op ""attribute 'algorithm' failed to satisfy constraint: Attribute that models the algorithm constraints to use for computing dot."); + return ::mlir::success(); +} + +::llvm::LogicalResult DotGeneralOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.algorithm; + auto attr = dict.get("algorithm"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `algorithm` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.dot_dimension_numbers; + auto attr = dict.get("dot_dimension_numbers"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dot_dimension_numbers` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.precision_config; + auto attr = dict.get("precision_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `precision_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DotGeneralOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.algorithm; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("algorithm", + propStorage)); + } + + { + const auto &propStorage = prop.dot_dimension_numbers; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dot_dimension_numbers", + propStorage)); + } + + { + const auto &propStorage = prop.precision_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("precision_config", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DotGeneralOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.algorithm.getAsOpaquePointer()), + llvm::hash_value(prop.dot_dimension_numbers.getAsOpaquePointer()), + llvm::hash_value(prop.precision_config.getAsOpaquePointer())); +} + +std::optional DotGeneralOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "algorithm") + return prop.algorithm; + + if (name == "dot_dimension_numbers") + return prop.dot_dimension_numbers; + + if (name == "precision_config") + return prop.precision_config; + return std::nullopt; +} + +void DotGeneralOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "algorithm") { + prop.algorithm = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "dot_dimension_numbers") { + prop.dot_dimension_numbers = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "precision_config") { + prop.precision_config = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DotGeneralOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.algorithm) attrs.append("algorithm", prop.algorithm); + + if (prop.dot_dimension_numbers) attrs.append("dot_dimension_numbers", prop.dot_dimension_numbers); + + if (prop.precision_config) attrs.append("precision_config", prop.precision_config); +} + +::llvm::LogicalResult DotGeneralOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getAlgorithmAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps26(attr, "algorithm", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getDotDimensionNumbersAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps25(attr, "dot_dimension_numbers", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPrecisionConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps19(attr, "precision_config", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DotGeneralOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.algorithm))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.dot_dimension_numbers))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.precision_config))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DotGeneralOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.algorithm); + writer.writeAttribute(prop.dot_dimension_numbers); + + writer.writeOptionalAttribute(prop.precision_config); +} + +::mlir::stablehlo::DotDimensionNumbersAttr DotGeneralOp::getDotDimensionNumbers() { + auto attr = getDotDimensionNumbersAttr(); + return ::llvm::cast<::mlir::stablehlo::DotDimensionNumbersAttr>(attr); +} + +::std::optional< ::mlir::ArrayAttr > DotGeneralOp::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::std::optional<::mlir::stablehlo::DotAlgorithmAttr> DotGeneralOp::getAlgorithm() { + auto attr = getAlgorithmAttr(); + return attr ? ::std::optional<::mlir::stablehlo::DotAlgorithmAttr>(::llvm::cast<::mlir::stablehlo::DotAlgorithmAttr>(attr)) : (::std::nullopt); +} + +void DotGeneralOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::DotDimensionNumbersAttr dot_dimension_numbers, /*optional*/::mlir::ArrayAttr precision_config, /*optional*/::mlir::stablehlo::DotAlgorithmAttr algorithm) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().dot_dimension_numbers = dot_dimension_numbers; + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + if (algorithm) { + odsState.getOrAddProperties().algorithm = algorithm; + } + odsState.addTypes(resultType0); +} + +void DotGeneralOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::DotDimensionNumbersAttr dot_dimension_numbers, /*optional*/::mlir::ArrayAttr precision_config, /*optional*/::mlir::stablehlo::DotAlgorithmAttr algorithm) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().dot_dimension_numbers = dot_dimension_numbers; + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + if (algorithm) { + odsState.getOrAddProperties().algorithm = algorithm; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DotGeneralOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DotGeneralOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DotGeneralOp::verifyInvariantsImpl() { + auto tblgen_algorithm = getProperties().algorithm; (void)tblgen_algorithm; + auto tblgen_dot_dimension_numbers = getProperties().dot_dimension_numbers; (void)tblgen_dot_dimension_numbers; + if (!tblgen_dot_dimension_numbers) return emitOpError("requires attribute 'dot_dimension_numbers'"); + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps25(*this, tblgen_dot_dimension_numbers, "dot_dimension_numbers"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps19(*this, tblgen_precision_config, "precision_config"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps26(*this, tblgen_algorithm, "algorithm"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DotGeneralOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult DotGeneralOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::stablehlo::DotDimensionNumbersAttr dot_dimension_numbersAttr; + ::mlir::ArrayAttr precision_configAttr; + ::mlir::stablehlo::DotAlgorithmAttr algorithmAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + { + auto odsResult = parseDotDimensionNumbers(parser, dot_dimension_numbersAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().dot_dimension_numbers = dot_dimension_numbersAttr; + } + { + auto odsResult = parsePrecisionConfigAndAlgorithm(parser, precision_configAttr, algorithmAttr); + if (odsResult) return ::mlir::failure(); + if (precision_configAttr) + result.getOrAddProperties().precision_config = precision_configAttr; + if (algorithmAttr) + result.getOrAddProperties().algorithm = algorithmAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(::llvm::concat(lhsOperands, rhsOperands), allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DotGeneralOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + printDotDimensionNumbers(_odsPrinter, *this, getDotDimensionNumbersAttr()); + printPrecisionConfigAndAlgorithm(_odsPrinter, *this, getPrecisionConfigAttr(), getAlgorithmAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("dot_dimension_numbers"); + elidedAttrs.push_back("precision_config"); + elidedAttrs.push_back("algorithm"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void DotGeneralOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DotGeneralOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DotOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DotOpGenericAdaptorBase::DotOpGenericAdaptorBase(DotOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional< ::mlir::ArrayAttr > DotOpGenericAdaptorBase::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +} // namespace detail +DotOpAdaptor::DotOpAdaptor(DotOp op) : DotOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DotOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + + if (tblgen_precision_config && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_precision_config))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_precision_config), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::stablehlo::PrecisionAttr>(attr))); })))) + return emitError(loc, "'stablehlo.dot' op ""attribute 'precision_config' failed to satisfy constraint: Precision Config attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult DotOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.precision_config; + auto attr = dict.get("precision_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `precision_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DotOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.precision_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("precision_config", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DotOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.precision_config.getAsOpaquePointer())); +} + +std::optional DotOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "precision_config") + return prop.precision_config; + return std::nullopt; +} + +void DotOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "precision_config") { + prop.precision_config = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DotOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.precision_config) attrs.append("precision_config", prop.precision_config); +} + +::llvm::LogicalResult DotOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getPrecisionConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps19(attr, "precision_config", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DotOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.precision_config))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DotOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.precision_config); +} + +::std::optional< ::mlir::ArrayAttr > DotOp::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +void DotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::ArrayAttr precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + odsState.addTypes(resultType0); +} + +void DotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::ArrayAttr precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DotOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DotOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DotOp::verifyInvariantsImpl() { + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps19(*this, tblgen_precision_config, "precision_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DotOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult DotOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::ArrayAttr precision_configAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto odsResult = parsePrecisionConfig(parser, precision_configAttr); + if (odsResult) return ::mlir::failure(); + if (precision_configAttr) + result.getOrAddProperties().precision_config = precision_configAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(::llvm::concat(lhsOperands, rhsOperands), allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DotOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + printPrecisionConfig(_odsPrinter, *this, getPrecisionConfigAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("precision_config"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void DotOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DotOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicBroadcastInDimOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicBroadcastInDimOpGenericAdaptorBase::DynamicBroadcastInDimOpGenericAdaptorBase(DynamicBroadcastInDimOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::llvm::ArrayRef DynamicBroadcastInDimOpGenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr; +} + +::std::optional<::llvm::ArrayRef> DynamicBroadcastInDimOpGenericAdaptorBase::getKnownExpandingDimensions() { + auto attr = getKnownExpandingDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> DynamicBroadcastInDimOpGenericAdaptorBase::getKnownNonexpandingDimensions() { + auto attr = getKnownNonexpandingDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +} // namespace detail +DynamicBroadcastInDimOpAdaptor::DynamicBroadcastInDimOpAdaptor(DynamicBroadcastInDimOp op) : DynamicBroadcastInDimOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicBroadcastInDimOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + if (!tblgen_broadcast_dimensions) return emitError(loc, "'stablehlo.dynamic_broadcast_in_dim' op ""requires attribute 'broadcast_dimensions'"); + auto tblgen_known_expanding_dimensions = getProperties().known_expanding_dimensions; (void)tblgen_known_expanding_dimensions; + auto tblgen_known_nonexpanding_dimensions = getProperties().known_nonexpanding_dimensions; (void)tblgen_known_nonexpanding_dimensions; + + if (tblgen_broadcast_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_broadcast_dimensions)))) + return emitError(loc, "'stablehlo.dynamic_broadcast_in_dim' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_known_expanding_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_known_expanding_dimensions)))) + return emitError(loc, "'stablehlo.dynamic_broadcast_in_dim' op ""attribute 'known_expanding_dimensions' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_known_nonexpanding_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_known_nonexpanding_dimensions)))) + return emitError(loc, "'stablehlo.dynamic_broadcast_in_dim' op ""attribute 'known_nonexpanding_dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicBroadcastInDimOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.known_expanding_dimensions; + auto attr = dict.get("known_expanding_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `known_expanding_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.known_nonexpanding_dimensions; + auto attr = dict.get("known_nonexpanding_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `known_nonexpanding_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicBroadcastInDimOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.known_expanding_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("known_expanding_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.known_nonexpanding_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("known_nonexpanding_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicBroadcastInDimOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.known_expanding_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.known_nonexpanding_dimensions.getAsOpaquePointer())); +} + +std::optional DynamicBroadcastInDimOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + + if (name == "known_expanding_dimensions") + return prop.known_expanding_dimensions; + + if (name == "known_nonexpanding_dimensions") + return prop.known_nonexpanding_dimensions; + return std::nullopt; +} + +void DynamicBroadcastInDimOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "known_expanding_dimensions") { + prop.known_expanding_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "known_nonexpanding_dimensions") { + prop.known_nonexpanding_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DynamicBroadcastInDimOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); + + if (prop.known_expanding_dimensions) attrs.append("known_expanding_dimensions", prop.known_expanding_dimensions); + + if (prop.known_nonexpanding_dimensions) attrs.append("known_nonexpanding_dimensions", prop.known_nonexpanding_dimensions); +} + +::llvm::LogicalResult DynamicBroadcastInDimOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKnownExpandingDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "known_expanding_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKnownNonexpandingDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "known_nonexpanding_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicBroadcastInDimOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.known_expanding_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.known_nonexpanding_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicBroadcastInDimOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.broadcast_dimensions); + + writer.writeOptionalAttribute(prop.known_expanding_dimensions); + + writer.writeOptionalAttribute(prop.known_nonexpanding_dimensions); +} + +::llvm::ArrayRef DynamicBroadcastInDimOp::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr; +} + +::std::optional<::llvm::ArrayRef> DynamicBroadcastInDimOp::getKnownExpandingDimensions() { + auto attr = getKnownExpandingDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> DynamicBroadcastInDimOp::getKnownNonexpandingDimensions() { + auto attr = getKnownNonexpandingDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +void DynamicBroadcastInDimOp::setBroadcastDimensions(::llvm::ArrayRef attrValue) { + getProperties().broadcast_dimensions = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void DynamicBroadcastInDimOp::setKnownExpandingDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().known_expanding_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void DynamicBroadcastInDimOp::setKnownNonexpandingDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().known_nonexpanding_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void DynamicBroadcastInDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type result_type, Value operand, Value output_dimensions, DenseI64ArrayAttr broadcast_dimensions) { + build(odsBuilder, odsState, result_type, operand, output_dimensions, + broadcast_dimensions, /*known_expanding_dimensions=*/{}, + /*known_nonexpanding_dimensions=*/{}); + +} + +void DynamicBroadcastInDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value output_dimensions, ::mlir::DenseI64ArrayAttr broadcast_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_expanding_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_nonexpanding_dimensions) { + odsState.addOperands(operand); + odsState.addOperands(output_dimensions); + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + if (known_expanding_dimensions) { + odsState.getOrAddProperties().known_expanding_dimensions = known_expanding_dimensions; + } + if (known_nonexpanding_dimensions) { + odsState.getOrAddProperties().known_nonexpanding_dimensions = known_nonexpanding_dimensions; + } + odsState.addTypes(resultType0); +} + +void DynamicBroadcastInDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value output_dimensions, ::mlir::DenseI64ArrayAttr broadcast_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_expanding_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_nonexpanding_dimensions) { + odsState.addOperands(operand); + odsState.addOperands(output_dimensions); + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + if (known_expanding_dimensions) { + odsState.getOrAddProperties().known_expanding_dimensions = known_expanding_dimensions; + } + if (known_nonexpanding_dimensions) { + odsState.getOrAddProperties().known_nonexpanding_dimensions = known_nonexpanding_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicBroadcastInDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value output_dimensions, ::llvm::ArrayRef broadcast_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_expanding_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_nonexpanding_dimensions) { + odsState.addOperands(operand); + odsState.addOperands(output_dimensions); + odsState.getOrAddProperties().broadcast_dimensions = odsBuilder.getDenseI64ArrayAttr(broadcast_dimensions); + if (known_expanding_dimensions) { + odsState.getOrAddProperties().known_expanding_dimensions = known_expanding_dimensions; + } + if (known_nonexpanding_dimensions) { + odsState.getOrAddProperties().known_nonexpanding_dimensions = known_nonexpanding_dimensions; + } + odsState.addTypes(resultType0); +} + +void DynamicBroadcastInDimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value output_dimensions, ::llvm::ArrayRef broadcast_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_expanding_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_nonexpanding_dimensions) { + odsState.addOperands(operand); + odsState.addOperands(output_dimensions); + odsState.getOrAddProperties().broadcast_dimensions = odsBuilder.getDenseI64ArrayAttr(broadcast_dimensions); + if (known_expanding_dimensions) { + odsState.getOrAddProperties().known_expanding_dimensions = known_expanding_dimensions; + } + if (known_nonexpanding_dimensions) { + odsState.getOrAddProperties().known_nonexpanding_dimensions = known_nonexpanding_dimensions; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicBroadcastInDimOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DynamicBroadcastInDimOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicBroadcastInDimOp::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + if (!tblgen_broadcast_dimensions) return emitOpError("requires attribute 'broadcast_dimensions'"); + auto tblgen_known_expanding_dimensions = getProperties().known_expanding_dimensions; (void)tblgen_known_expanding_dimensions; + auto tblgen_known_nonexpanding_dimensions = getProperties().known_nonexpanding_dimensions; (void)tblgen_known_nonexpanding_dimensions; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_known_expanding_dimensions, "known_expanding_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_known_nonexpanding_dimensions, "known_nonexpanding_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps24(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicBroadcastInDimOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult DynamicBroadcastInDimOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand output_dimensionsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> output_dimensionsOperands(&output_dimensionsRawOperand, 1); ::llvm::SMLoc output_dimensionsOperandsLoc; + (void)output_dimensionsOperandsLoc; + ::mlir::DenseI64ArrayAttr broadcast_dimensionsAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + output_dimensionsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(output_dimensionsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("dims")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(broadcast_dimensionsAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (broadcast_dimensionsAttr) result.getOrAddProperties().broadcast_dimensions = broadcast_dimensionsAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(::llvm::concat(operandOperands, output_dimensionsOperands), allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicBroadcastInDimOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getOutputDimensions(); + _odsPrinter << ","; + _odsPrinter << ' ' << "dims"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getBroadcastDimensionsAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("broadcast_dimensions"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void DynamicBroadcastInDimOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicBroadcastInDimOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicConvOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicConvOpGenericAdaptorBase::DynamicConvOpGenericAdaptorBase(DynamicConvOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> DynamicConvOpGenericAdaptorBase::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> DynamicConvOpGenericAdaptorBase::getLhsDilation() { + auto attr = getLhsDilationAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> DynamicConvOpGenericAdaptorBase::getRhsDilation() { + auto attr = getRhsDilationAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> DynamicConvOpGenericAdaptorBase::getWindowReversal() { + auto attr = getWindowReversalAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::mlir::stablehlo::ConvDimensionNumbersAttr DynamicConvOpGenericAdaptorBase::getDimensionNumbers() { + auto attr = getDimensionNumbersAttr(); + return ::llvm::cast<::mlir::stablehlo::ConvDimensionNumbersAttr>(attr); +} + +uint64_t DynamicConvOpGenericAdaptorBase::getFeatureGroupCount() { + auto attr = getFeatureGroupCountAttr(); + return attr.getValue().getZExtValue(); +} + +uint64_t DynamicConvOpGenericAdaptorBase::getBatchGroupCount() { + auto attr = getBatchGroupCountAttr(); + return attr.getValue().getZExtValue(); +} + +::std::optional< ::mlir::ArrayAttr > DynamicConvOpGenericAdaptorBase::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +} // namespace detail +DynamicConvOpAdaptor::DynamicConvOpAdaptor(DynamicConvOp op) : DynamicConvOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicConvOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_batch_group_count = getProperties().batch_group_count; (void)tblgen_batch_group_count; + if (!tblgen_batch_group_count) return emitError(loc, "'stablehlo.dynamic_conv' op ""requires attribute 'batch_group_count'"); + auto tblgen_dimension_numbers = getProperties().dimension_numbers; (void)tblgen_dimension_numbers; + if (!tblgen_dimension_numbers) return emitError(loc, "'stablehlo.dynamic_conv' op ""requires attribute 'dimension_numbers'"); + auto tblgen_feature_group_count = getProperties().feature_group_count; (void)tblgen_feature_group_count; + if (!tblgen_feature_group_count) return emitError(loc, "'stablehlo.dynamic_conv' op ""requires attribute 'feature_group_count'"); + auto tblgen_lhs_dilation = getProperties().lhs_dilation; (void)tblgen_lhs_dilation; + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + auto tblgen_rhs_dilation = getProperties().rhs_dilation; (void)tblgen_rhs_dilation; + auto tblgen_window_reversal = getProperties().window_reversal; (void)tblgen_window_reversal; + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + + if (tblgen_window_strides && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_window_strides)))) + return emitError(loc, "'stablehlo.dynamic_conv' op ""attribute 'window_strides' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_lhs_dilation && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_lhs_dilation)))) + return emitError(loc, "'stablehlo.dynamic_conv' op ""attribute 'lhs_dilation' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_rhs_dilation && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_rhs_dilation)))) + return emitError(loc, "'stablehlo.dynamic_conv' op ""attribute 'rhs_dilation' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_window_reversal && !((::llvm::isa<::mlir::DenseBoolArrayAttr>(tblgen_window_reversal)))) + return emitError(loc, "'stablehlo.dynamic_conv' op ""attribute 'window_reversal' failed to satisfy constraint: i1 dense array attribute"); + + if (tblgen_dimension_numbers && !((::llvm::isa<::mlir::stablehlo::ConvDimensionNumbersAttr>(tblgen_dimension_numbers)))) + return emitError(loc, "'stablehlo.dynamic_conv' op ""attribute 'dimension_numbers' failed to satisfy constraint: Structure of dimension information for conv op"); + + if (tblgen_feature_group_count && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_feature_group_count))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_feature_group_count).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_feature_group_count).getValue().isStrictlyPositive())))) + return emitError(loc, "'stablehlo.dynamic_conv' op ""attribute 'feature_group_count' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive"); + + if (tblgen_batch_group_count && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_batch_group_count))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_batch_group_count).getType().isSignlessInteger(64)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_batch_group_count).getValue().isStrictlyPositive())))) + return emitError(loc, "'stablehlo.dynamic_conv' op ""attribute 'batch_group_count' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive"); + + if (tblgen_precision_config && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_precision_config))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_precision_config), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::stablehlo::PrecisionAttr>(attr))); })))) + return emitError(loc, "'stablehlo.dynamic_conv' op ""attribute 'precision_config' failed to satisfy constraint: Precision Config attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicConvOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.batch_group_count; + auto attr = dict.get("batch_group_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `batch_group_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.dimension_numbers; + auto attr = dict.get("dimension_numbers"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimension_numbers` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.feature_group_count; + auto attr = dict.get("feature_group_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `feature_group_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.lhs_dilation; + auto attr = dict.get("lhs_dilation"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lhs_dilation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.precision_config; + auto attr = dict.get("precision_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `precision_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.rhs_dilation; + auto attr = dict.get("rhs_dilation"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rhs_dilation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_reversal; + auto attr = dict.get("window_reversal"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_reversal` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_strides; + auto attr = dict.get("window_strides"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicConvOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.batch_group_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("batch_group_count", + propStorage)); + } + + { + const auto &propStorage = prop.dimension_numbers; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimension_numbers", + propStorage)); + } + + { + const auto &propStorage = prop.feature_group_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("feature_group_count", + propStorage)); + } + + { + const auto &propStorage = prop.lhs_dilation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lhs_dilation", + propStorage)); + } + + { + const auto &propStorage = prop.precision_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("precision_config", + propStorage)); + } + + { + const auto &propStorage = prop.rhs_dilation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rhs_dilation", + propStorage)); + } + + { + const auto &propStorage = prop.window_reversal; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_reversal", + propStorage)); + } + + { + const auto &propStorage = prop.window_strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_strides", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicConvOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.batch_group_count.getAsOpaquePointer()), + llvm::hash_value(prop.dimension_numbers.getAsOpaquePointer()), + llvm::hash_value(prop.feature_group_count.getAsOpaquePointer()), + llvm::hash_value(prop.lhs_dilation.getAsOpaquePointer()), + llvm::hash_value(prop.precision_config.getAsOpaquePointer()), + llvm::hash_value(prop.rhs_dilation.getAsOpaquePointer()), + llvm::hash_value(prop.window_reversal.getAsOpaquePointer()), + llvm::hash_value(prop.window_strides.getAsOpaquePointer())); +} + +std::optional DynamicConvOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "batch_group_count") + return prop.batch_group_count; + + if (name == "dimension_numbers") + return prop.dimension_numbers; + + if (name == "feature_group_count") + return prop.feature_group_count; + + if (name == "lhs_dilation") + return prop.lhs_dilation; + + if (name == "precision_config") + return prop.precision_config; + + if (name == "rhs_dilation") + return prop.rhs_dilation; + + if (name == "window_reversal") + return prop.window_reversal; + + if (name == "window_strides") + return prop.window_strides; + return std::nullopt; +} + +void DynamicConvOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "batch_group_count") { + prop.batch_group_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "dimension_numbers") { + prop.dimension_numbers = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "feature_group_count") { + prop.feature_group_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "lhs_dilation") { + prop.lhs_dilation = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "precision_config") { + prop.precision_config = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "rhs_dilation") { + prop.rhs_dilation = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_reversal") { + prop.window_reversal = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_strides") { + prop.window_strides = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DynamicConvOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.batch_group_count) attrs.append("batch_group_count", prop.batch_group_count); + + if (prop.dimension_numbers) attrs.append("dimension_numbers", prop.dimension_numbers); + + if (prop.feature_group_count) attrs.append("feature_group_count", prop.feature_group_count); + + if (prop.lhs_dilation) attrs.append("lhs_dilation", prop.lhs_dilation); + + if (prop.precision_config) attrs.append("precision_config", prop.precision_config); + + if (prop.rhs_dilation) attrs.append("rhs_dilation", prop.rhs_dilation); + + if (prop.window_reversal) attrs.append("window_reversal", prop.window_reversal); + + if (prop.window_strides) attrs.append("window_strides", prop.window_strides); +} + +::llvm::LogicalResult DynamicConvOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBatchGroupCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps5(attr, "batch_group_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getDimensionNumbersAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps18(attr, "dimension_numbers", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFeatureGroupCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps5(attr, "feature_group_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLhsDilationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "lhs_dilation", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPrecisionConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps19(attr, "precision_config", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRhsDilationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "rhs_dilation", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowReversalAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps17(attr, "window_reversal", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "window_strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicConvOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.batch_group_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.dimension_numbers))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.feature_group_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.lhs_dilation))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.precision_config))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.rhs_dilation))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.window_reversal))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.window_strides))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicConvOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.batch_group_count); + writer.writeAttribute(prop.dimension_numbers); + writer.writeAttribute(prop.feature_group_count); + + writer.writeOptionalAttribute(prop.lhs_dilation); + + writer.writeOptionalAttribute(prop.precision_config); + + writer.writeOptionalAttribute(prop.rhs_dilation); + + writer.writeOptionalAttribute(prop.window_reversal); + + writer.writeOptionalAttribute(prop.window_strides); +} + +::std::optional<::llvm::ArrayRef> DynamicConvOp::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> DynamicConvOp::getLhsDilation() { + auto attr = getLhsDilationAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> DynamicConvOp::getRhsDilation() { + auto attr = getRhsDilationAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> DynamicConvOp::getWindowReversal() { + auto attr = getWindowReversalAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::mlir::stablehlo::ConvDimensionNumbersAttr DynamicConvOp::getDimensionNumbers() { + auto attr = getDimensionNumbersAttr(); + return ::llvm::cast<::mlir::stablehlo::ConvDimensionNumbersAttr>(attr); +} + +uint64_t DynamicConvOp::getFeatureGroupCount() { + auto attr = getFeatureGroupCountAttr(); + return attr.getValue().getZExtValue(); +} + +uint64_t DynamicConvOp::getBatchGroupCount() { + auto attr = getBatchGroupCountAttr(); + return attr.getValue().getZExtValue(); +} + +::std::optional< ::mlir::ArrayAttr > DynamicConvOp::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +void DynamicConvOp::setWindowStrides(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().window_strides; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void DynamicConvOp::setLhsDilation(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().lhs_dilation; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void DynamicConvOp::setRhsDilation(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().rhs_dilation; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void DynamicConvOp::setWindowReversal(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().window_reversal; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseBoolArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void DynamicConvOp::setFeatureGroupCount(uint64_t attrValue) { + getProperties().feature_group_count = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void DynamicConvOp::setBatchGroupCount(uint64_t attrValue) { + getProperties().batch_group_count = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void DynamicConvOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value padding, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, ::mlir::IntegerAttr feature_group_count, ::mlir::IntegerAttr batch_group_count, /*optional*/::mlir::ArrayAttr precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(padding); + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (lhs_dilation) { + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + } + if (rhs_dilation) { + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + } + if (window_reversal) { + odsState.getOrAddProperties().window_reversal = window_reversal; + } + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().feature_group_count = feature_group_count; + odsState.getOrAddProperties().batch_group_count = batch_group_count; + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + odsState.addTypes(resultType0); +} + +void DynamicConvOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value padding, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, ::mlir::IntegerAttr feature_group_count, ::mlir::IntegerAttr batch_group_count, /*optional*/::mlir::ArrayAttr precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(padding); + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (lhs_dilation) { + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + } + if (rhs_dilation) { + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + } + if (window_reversal) { + odsState.getOrAddProperties().window_reversal = window_reversal; + } + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().feature_group_count = feature_group_count; + odsState.getOrAddProperties().batch_group_count = batch_group_count; + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicConvOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value padding, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, uint64_t feature_group_count, uint64_t batch_group_count, /*optional*/::mlir::ArrayAttr precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(padding); + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (lhs_dilation) { + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + } + if (rhs_dilation) { + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + } + if (window_reversal) { + odsState.getOrAddProperties().window_reversal = window_reversal; + } + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().feature_group_count = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), feature_group_count); + odsState.getOrAddProperties().batch_group_count = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), batch_group_count); + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + odsState.addTypes(resultType0); +} + +void DynamicConvOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value padding, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, uint64_t feature_group_count, uint64_t batch_group_count, /*optional*/::mlir::ArrayAttr precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(padding); + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (lhs_dilation) { + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + } + if (rhs_dilation) { + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + } + if (window_reversal) { + odsState.getOrAddProperties().window_reversal = window_reversal; + } + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().feature_group_count = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), feature_group_count); + odsState.getOrAddProperties().batch_group_count = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), batch_group_count); + if (precision_config) { + odsState.getOrAddProperties().precision_config = precision_config; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicConvOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DynamicConvOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicConvOp::verifyInvariantsImpl() { + auto tblgen_batch_group_count = getProperties().batch_group_count; (void)tblgen_batch_group_count; + if (!tblgen_batch_group_count) return emitOpError("requires attribute 'batch_group_count'"); + auto tblgen_dimension_numbers = getProperties().dimension_numbers; (void)tblgen_dimension_numbers; + if (!tblgen_dimension_numbers) return emitOpError("requires attribute 'dimension_numbers'"); + auto tblgen_feature_group_count = getProperties().feature_group_count; (void)tblgen_feature_group_count; + if (!tblgen_feature_group_count) return emitOpError("requires attribute 'feature_group_count'"); + auto tblgen_lhs_dilation = getProperties().lhs_dilation; (void)tblgen_lhs_dilation; + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + auto tblgen_rhs_dilation = getProperties().rhs_dilation; (void)tblgen_rhs_dilation; + auto tblgen_window_reversal = getProperties().window_reversal; (void)tblgen_window_reversal; + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_window_strides, "window_strides"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_lhs_dilation, "lhs_dilation"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_rhs_dilation, "rhs_dilation"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps17(*this, tblgen_window_reversal, "window_reversal"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps18(*this, tblgen_dimension_numbers, "dimension_numbers"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps5(*this, tblgen_feature_group_count, "feature_group_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps5(*this, tblgen_batch_group_count, "batch_group_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps19(*this, tblgen_precision_config, "precision_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps25(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicConvOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +void DynamicConvOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicConvOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicGatherOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicGatherOpGenericAdaptorBase::DynamicGatherOpGenericAdaptorBase(DynamicGatherOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::GatherDimensionNumbersAttr DynamicGatherOpGenericAdaptorBase::getDimensionNumbers() { + auto attr = getDimensionNumbersAttr(); + return ::llvm::cast<::mlir::stablehlo::GatherDimensionNumbersAttr>(attr); +} + +::mlir::BoolAttr DynamicGatherOpGenericAdaptorBase::getIndicesAreSortedAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().indices_are_sorted); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false); + return attr; +} + +bool DynamicGatherOpGenericAdaptorBase::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +} // namespace detail +DynamicGatherOpAdaptor::DynamicGatherOpAdaptor(DynamicGatherOp op) : DynamicGatherOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicGatherOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_dimension_numbers = getProperties().dimension_numbers; (void)tblgen_dimension_numbers; + if (!tblgen_dimension_numbers) return emitError(loc, "'stablehlo.dynamic_gather' op ""requires attribute 'dimension_numbers'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + + if (tblgen_dimension_numbers && !((::llvm::isa<::mlir::stablehlo::GatherDimensionNumbersAttr>(tblgen_dimension_numbers)))) + return emitError(loc, "'stablehlo.dynamic_gather' op ""attribute 'dimension_numbers' failed to satisfy constraint: Attribute that models the dimension information for gather"); + + if (tblgen_indices_are_sorted && !((::llvm::isa<::mlir::BoolAttr>(tblgen_indices_are_sorted)))) + return emitError(loc, "'stablehlo.dynamic_gather' op ""attribute 'indices_are_sorted' failed to satisfy constraint: bool attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicGatherOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimension_numbers; + auto attr = dict.get("dimension_numbers"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimension_numbers` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.indices_are_sorted; + auto attr = dict.get("indices_are_sorted"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `indices_are_sorted` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicGatherOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimension_numbers; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimension_numbers", + propStorage)); + } + + { + const auto &propStorage = prop.indices_are_sorted; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("indices_are_sorted", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicGatherOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimension_numbers.getAsOpaquePointer()), + llvm::hash_value(prop.indices_are_sorted.getAsOpaquePointer())); +} + +std::optional DynamicGatherOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimension_numbers") + return prop.dimension_numbers; + + if (name == "indices_are_sorted") + return prop.indices_are_sorted; + return std::nullopt; +} + +void DynamicGatherOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimension_numbers") { + prop.dimension_numbers = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "indices_are_sorted") { + prop.indices_are_sorted = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DynamicGatherOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimension_numbers) attrs.append("dimension_numbers", prop.dimension_numbers); + + if (prop.indices_are_sorted) attrs.append("indices_are_sorted", prop.indices_are_sorted); +} + +::llvm::LogicalResult DynamicGatherOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionNumbersAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps27(attr, "dimension_numbers", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIndicesAreSortedAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(attr, "indices_are_sorted", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicGatherOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimension_numbers))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.indices_are_sorted))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicGatherOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimension_numbers); + + writer.writeOptionalAttribute(prop.indices_are_sorted); +} + +::mlir::stablehlo::GatherDimensionNumbersAttr DynamicGatherOp::getDimensionNumbers() { + auto attr = getDimensionNumbersAttr(); + return ::llvm::cast<::mlir::stablehlo::GatherDimensionNumbersAttr>(attr); +} + +bool DynamicGatherOp::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +void DynamicGatherOp::setIndicesAreSorted(::std::optional attrValue) { + auto &odsProp = getProperties().indices_are_sorted; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue); + else + odsProp = nullptr; +} + +void DynamicGatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, /*optional*/::mlir::BoolAttr indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(slice_sizes); + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + if (indices_are_sorted) { + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + } + odsState.addTypes(resultType0); +} + +void DynamicGatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, /*optional*/::mlir::BoolAttr indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(slice_sizes); + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + if (indices_are_sorted) { + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DynamicGatherOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void DynamicGatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, /*optional*/::mlir::BoolAttr indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(slice_sizes); + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + if (indices_are_sorted) { + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicGatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, /*optional*/bool indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(slice_sizes); + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().indices_are_sorted = odsBuilder.getBoolAttr(indices_are_sorted); + odsState.addTypes(resultType0); +} + +void DynamicGatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, /*optional*/bool indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(slice_sizes); + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().indices_are_sorted = odsBuilder.getBoolAttr(indices_are_sorted); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DynamicGatherOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void DynamicGatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, /*optional*/bool indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(slice_sizes); + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().indices_are_sorted = odsBuilder.getBoolAttr(indices_are_sorted); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicGatherOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DynamicGatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DynamicGatherOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void DynamicGatherOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DynamicGatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DynamicGatherOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult DynamicGatherOp::verifyInvariantsImpl() { + auto tblgen_dimension_numbers = getProperties().dimension_numbers; (void)tblgen_dimension_numbers; + if (!tblgen_dimension_numbers) return emitOpError("requires attribute 'dimension_numbers'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps27(*this, tblgen_dimension_numbers, "dimension_numbers"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(*this, tblgen_indices_are_sorted, "indices_are_sorted"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps26(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicGatherOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void DynamicGatherOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +DynamicGatherOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(DynamicGatherOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicGatherOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicIotaOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicIotaOpGenericAdaptorBase::DynamicIotaOpGenericAdaptorBase(DynamicIotaOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +uint64_t DynamicIotaOpGenericAdaptorBase::getIotaDimension() { + auto attr = getIotaDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +DynamicIotaOpAdaptor::DynamicIotaOpAdaptor(DynamicIotaOp op) : DynamicIotaOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicIotaOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_iota_dimension = getProperties().iota_dimension; (void)tblgen_iota_dimension; + if (!tblgen_iota_dimension) return emitError(loc, "'stablehlo.dynamic_iota' op ""requires attribute 'iota_dimension'"); + + if (tblgen_iota_dimension && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_iota_dimension))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_iota_dimension).getType().isSignlessInteger(64)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_iota_dimension).getValue().isNegative())))) + return emitError(loc, "'stablehlo.dynamic_iota' op ""attribute 'iota_dimension' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative"); + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicIotaOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.iota_dimension; + auto attr = dict.get("iota_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `iota_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicIotaOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.iota_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("iota_dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicIotaOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.iota_dimension.getAsOpaquePointer())); +} + +std::optional DynamicIotaOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "iota_dimension") + return prop.iota_dimension; + return std::nullopt; +} + +void DynamicIotaOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "iota_dimension") { + prop.iota_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DynamicIotaOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.iota_dimension) attrs.append("iota_dimension", prop.iota_dimension); +} + +::llvm::LogicalResult DynamicIotaOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getIotaDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(attr, "iota_dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicIotaOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.iota_dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicIotaOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.iota_dimension); +} + +uint64_t DynamicIotaOp::getIotaDimension() { + auto attr = getIotaDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +void DynamicIotaOp::setIotaDimension(uint64_t attrValue) { + getProperties().iota_dimension = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void DynamicIotaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value output_shape, ::mlir::IntegerAttr iota_dimension) { + odsState.addOperands(output_shape); + odsState.getOrAddProperties().iota_dimension = iota_dimension; + odsState.addTypes(result); +} + +void DynamicIotaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value output_shape, ::mlir::IntegerAttr iota_dimension) { + odsState.addOperands(output_shape); + odsState.getOrAddProperties().iota_dimension = iota_dimension; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicIotaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value output_shape, uint64_t iota_dimension) { + odsState.addOperands(output_shape); + odsState.getOrAddProperties().iota_dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), iota_dimension); + odsState.addTypes(result); +} + +void DynamicIotaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value output_shape, uint64_t iota_dimension) { + odsState.addOperands(output_shape); + odsState.getOrAddProperties().iota_dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), iota_dimension); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicIotaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DynamicIotaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicIotaOp::verifyInvariantsImpl() { + auto tblgen_iota_dimension = getProperties().iota_dimension; (void)tblgen_iota_dimension; + if (!tblgen_iota_dimension) return emitOpError("requires attribute 'iota_dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(*this, tblgen_iota_dimension, "iota_dimension"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps24(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicIotaOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult DynamicIotaOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand output_shapeRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> output_shapeOperands(&output_shapeRawOperand, 1); ::llvm::SMLoc output_shapeOperandsLoc; + (void)output_shapeOperandsLoc; + ::mlir::IntegerAttr iota_dimensionAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + output_shapeOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(output_shapeRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("dim")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(iota_dimensionAttr, parser.getBuilder().getIntegerType(64))) { + return ::mlir::failure(); + } + if (iota_dimensionAttr) result.getOrAddProperties().iota_dimension = iota_dimensionAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(output_shapeOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicIotaOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOutputShape(); + _odsPrinter << ","; + _odsPrinter << ' ' << "dim"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getIotaDimensionAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("iota_dimension"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void DynamicIotaOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicIotaOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicPadOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicPadOpGenericAdaptorBase::DynamicPadOpGenericAdaptorBase(DynamicPadOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +DynamicPadOpAdaptor::DynamicPadOpAdaptor(DynamicPadOp op) : DynamicPadOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicPadOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicPadOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicPadOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicPadOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional DynamicPadOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void DynamicPadOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void DynamicPadOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult DynamicPadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void DynamicPadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::Value edge_padding_low, ::mlir::Value edge_padding_high, ::mlir::Value interior_padding) { + odsState.addOperands(operand); + odsState.addOperands(padding_value); + odsState.addOperands(edge_padding_low); + odsState.addOperands(edge_padding_high); + odsState.addOperands(interior_padding); + odsState.addTypes(result); +} + +void DynamicPadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::Value edge_padding_low, ::mlir::Value edge_padding_high, ::mlir::Value interior_padding) { + odsState.addOperands(operand); + odsState.addOperands(padding_value); + odsState.addOperands(edge_padding_low); + odsState.addOperands(edge_padding_high); + odsState.addOperands(interior_padding); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicPadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DynamicPadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicPadOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps27(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps24(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps24(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps24(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!(((getElementTypeOrSelf((*this->getODSOperands(0).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(1).begin()))) && (getElementTypeOrSelf((*this->getODSOperands(1).begin()))) == (getElementTypeOrSelf((*this->getODSResults(0).begin()))) && (getElementTypeOrSelf((*this->getODSResults(0).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(0).begin())))))) + return emitOpError("failed to verify that all of {operand, padding_value, result} have same element type"); + if (!((((*this->getODSOperands(2).begin()).getType()) == ((*this->getODSOperands(3).begin()).getType()) && ((*this->getODSOperands(3).begin()).getType()) == ((*this->getODSOperands(4).begin()).getType()) && ((*this->getODSOperands(4).begin()).getType()) == ((*this->getODSOperands(2).begin()).getType())))) + return emitOpError("failed to verify that all of {edge_padding_low, edge_padding_high, interior_padding} have same type"); + if (!(((::llvm::cast<::mlir::ShapedType>((*this->getODSOperands(0).begin()).getType()).getRank()) == (::llvm::cast<::mlir::ShapedType>((*this->getODSResults(0).begin()).getType()).getRank()) && (::llvm::cast<::mlir::ShapedType>((*this->getODSResults(0).begin()).getType()).getRank()) == (::llvm::cast<::mlir::ShapedType>((*this->getODSOperands(0).begin()).getType()).getRank())))) + return emitOpError("failed to verify that all of {operand, result} have same rank"); + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicPadOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult DynamicPadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + [[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(allOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(allOperands, allOperandTypes, allOperandLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicPadOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperation()->getOperands(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void DynamicPadOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicPadOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicReshapeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicReshapeOpGenericAdaptorBase::DynamicReshapeOpGenericAdaptorBase(DynamicReshapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +DynamicReshapeOpAdaptor::DynamicReshapeOpAdaptor(DynamicReshapeOp op) : DynamicReshapeOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicReshapeOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicReshapeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicReshapeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicReshapeOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional DynamicReshapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void DynamicReshapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void DynamicReshapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult DynamicReshapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void DynamicReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value output_shape) { + odsState.addOperands(operand); + odsState.addOperands(output_shape); + odsState.addTypes(result); +} + +void DynamicReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value output_shape) { + odsState.addOperands(operand); + odsState.addOperands(output_shape); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicReshapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DynamicReshapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicReshapeOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps24(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicReshapeOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult DynamicReshapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + [[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(allOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(allOperands, allOperandTypes, allOperandLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicReshapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperation()->getOperands(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void DynamicReshapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicReshapeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicSliceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicSliceOpGenericAdaptorBase::DynamicSliceOpGenericAdaptorBase(DynamicSliceOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair DynamicSliceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::ArrayRef DynamicSliceOpGenericAdaptorBase::getSliceSizes() { + auto attr = getSliceSizesAttr(); + return attr; +} + +} // namespace detail +DynamicSliceOpAdaptor::DynamicSliceOpAdaptor(DynamicSliceOp op) : DynamicSliceOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicSliceOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_slice_sizes = getProperties().slice_sizes; (void)tblgen_slice_sizes; + if (!tblgen_slice_sizes) return emitError(loc, "'stablehlo.dynamic_slice' op ""requires attribute 'slice_sizes'"); + + if (tblgen_slice_sizes && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_slice_sizes)))) + return emitError(loc, "'stablehlo.dynamic_slice' op ""attribute 'slice_sizes' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +std::pair DynamicSliceOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange DynamicSliceOp::getStartIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult DynamicSliceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.slice_sizes; + auto attr = dict.get("slice_sizes"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `slice_sizes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicSliceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.slice_sizes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("slice_sizes", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicSliceOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.slice_sizes.getAsOpaquePointer())); +} + +std::optional DynamicSliceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "slice_sizes") + return prop.slice_sizes; + return std::nullopt; +} + +void DynamicSliceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "slice_sizes") { + prop.slice_sizes = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DynamicSliceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.slice_sizes) attrs.append("slice_sizes", prop.slice_sizes); +} + +::llvm::LogicalResult DynamicSliceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getSliceSizesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "slice_sizes", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicSliceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.slice_sizes))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicSliceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.slice_sizes); +} + +::llvm::ArrayRef DynamicSliceOp::getSliceSizes() { + auto attr = getSliceSizesAttr(); + return attr; +} + +void DynamicSliceOp::setSliceSizes(::llvm::ArrayRef attrValue) { + getProperties().slice_sizes = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void DynamicSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::mlir::DenseI64ArrayAttr slice_sizes) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().slice_sizes = slice_sizes; + odsState.addTypes(result); +} + +void DynamicSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::mlir::DenseI64ArrayAttr slice_sizes) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().slice_sizes = slice_sizes; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DynamicSliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void DynamicSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::mlir::DenseI64ArrayAttr slice_sizes) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().slice_sizes = slice_sizes; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::llvm::ArrayRef slice_sizes) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().slice_sizes = odsBuilder.getDenseI64ArrayAttr(slice_sizes); + odsState.addTypes(result); +} + +void DynamicSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::llvm::ArrayRef slice_sizes) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().slice_sizes = odsBuilder.getDenseI64ArrayAttr(slice_sizes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DynamicSliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void DynamicSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::llvm::ArrayRef slice_sizes) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().slice_sizes = odsBuilder.getDenseI64ArrayAttr(slice_sizes); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicSliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DynamicSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DynamicSliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void DynamicSliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DynamicSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DynamicSliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult DynamicSliceOp::verifyInvariantsImpl() { + auto tblgen_slice_sizes = getProperties().slice_sizes; (void)tblgen_slice_sizes; + if (!tblgen_slice_sizes) return emitOpError("requires attribute 'slice_sizes'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_slice_sizes, "slice_sizes"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps28(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!(((getElementTypeOrSelf((*this->getODSOperands(0).begin()))) == (getElementTypeOrSelf((*this->getODSResults(0).begin()))) && (getElementTypeOrSelf((*this->getODSResults(0).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(0).begin())))))) + return emitOpError("failed to verify that all of {operand, result} have same element type"); + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicSliceOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult DynamicSliceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> start_indicesOperands; + ::llvm::SMLoc start_indicesOperandsLoc; + (void)start_indicesOperandsLoc; + ::mlir::DenseI64ArrayAttr slice_sizesAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + { + start_indicesOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseVariadicOperandWithAttribute(parser, start_indicesOperands); + if (odsResult) return ::mlir::failure(); + } + if (parser.parseKeyword("sizes")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(slice_sizesAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (slice_sizesAttr) result.getOrAddProperties().slice_sizes = slice_sizesAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(::llvm::concat(operandOperands, start_indicesOperands), allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicSliceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' '; + printVariadicOperandWithAttribute(_odsPrinter, *this, getStartIndices()); + _odsPrinter << ' ' << "sizes"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getSliceSizesAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("slice_sizes"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void DynamicSliceOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +DynamicSliceOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(DynamicSliceOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicSliceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicUpdateSliceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicUpdateSliceOpGenericAdaptorBase::DynamicUpdateSliceOpGenericAdaptorBase(DynamicUpdateSliceOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair DynamicUpdateSliceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +} // namespace detail +DynamicUpdateSliceOpAdaptor::DynamicUpdateSliceOpAdaptor(DynamicUpdateSliceOp op) : DynamicUpdateSliceOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicUpdateSliceOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair DynamicUpdateSliceOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange DynamicUpdateSliceOp::getStartIndicesMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult DynamicUpdateSliceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicUpdateSliceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicUpdateSliceOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional DynamicUpdateSliceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void DynamicUpdateSliceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void DynamicUpdateSliceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult DynamicUpdateSliceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void DynamicUpdateSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value update, ::mlir::ValueRange start_indices) { + odsState.addOperands(operand); + odsState.addOperands(update); + odsState.addOperands(start_indices); + odsState.addTypes(result); +} + +void DynamicUpdateSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value update, ::mlir::ValueRange start_indices) { + odsState.addOperands(operand); + odsState.addOperands(update); + odsState.addOperands(start_indices); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DynamicUpdateSliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void DynamicUpdateSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value update, ::mlir::ValueRange start_indices) { + odsState.addOperands(operand); + odsState.addOperands(update); + odsState.addOperands(start_indices); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicUpdateSliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DynamicUpdateSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DynamicUpdateSliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void DynamicUpdateSliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DynamicUpdateSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DynamicUpdateSliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult DynamicUpdateSliceOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps28(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!(((getElementTypeOrSelf((*this->getODSOperands(0).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(1).begin()))) && (getElementTypeOrSelf((*this->getODSOperands(1).begin()))) == (getElementTypeOrSelf((*this->getODSResults(0).begin()))) && (getElementTypeOrSelf((*this->getODSResults(0).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(0).begin())))))) + return emitOpError("failed to verify that all of {operand, update, result} have same element type"); + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicUpdateSliceOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult DynamicUpdateSliceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + [[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(allOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(allOperands, allOperandTypes, allOperandLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicUpdateSliceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperation()->getOperands(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void DynamicUpdateSliceOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +DynamicUpdateSliceOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(DynamicUpdateSliceOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicUpdateSliceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::EinsumOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +EinsumOpGenericAdaptorBase::EinsumOpGenericAdaptorBase(EinsumOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::llvm::StringRef EinsumOpGenericAdaptorBase::getEinsumConfig() { + auto attr = getEinsumConfigAttr(); + return attr.getValue(); +} + +} // namespace detail +EinsumOpAdaptor::EinsumOpAdaptor(EinsumOp op) : EinsumOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult EinsumOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_einsum_config = getProperties().einsum_config; (void)tblgen_einsum_config; + if (!tblgen_einsum_config) return emitError(loc, "'stablehlo.einsum' op ""requires attribute 'einsum_config'"); + + if (tblgen_einsum_config && !((::llvm::isa<::mlir::StringAttr>(tblgen_einsum_config)))) + return emitError(loc, "'stablehlo.einsum' op ""attribute 'einsum_config' failed to satisfy constraint: string attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult EinsumOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.einsum_config; + auto attr = dict.get("einsum_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `einsum_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute EinsumOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.einsum_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("einsum_config", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code EinsumOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.einsum_config.getAsOpaquePointer())); +} + +std::optional EinsumOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "einsum_config") + return prop.einsum_config; + return std::nullopt; +} + +void EinsumOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "einsum_config") { + prop.einsum_config = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void EinsumOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.einsum_config) attrs.append("einsum_config", prop.einsum_config); +} + +::llvm::LogicalResult EinsumOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getEinsumConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps12(attr, "einsum_config", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult EinsumOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.einsum_config))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void EinsumOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.einsum_config); +} + +::llvm::StringRef EinsumOp::getEinsumConfig() { + auto attr = getEinsumConfigAttr(); + return attr.getValue(); +} + +void EinsumOp::setEinsumConfig(::llvm::StringRef attrValue) { + getProperties().einsum_config = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); +} + +void EinsumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::StringAttr einsum_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().einsum_config = einsum_config; + odsState.addTypes(resultType0); +} + +void EinsumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::StringAttr einsum_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().einsum_config = einsum_config; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void EinsumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::llvm::StringRef einsum_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().einsum_config = odsBuilder.getStringAttr(einsum_config); + odsState.addTypes(resultType0); +} + +void EinsumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::llvm::StringRef einsum_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().einsum_config = odsBuilder.getStringAttr(einsum_config); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void EinsumOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void EinsumOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult EinsumOp::verifyInvariantsImpl() { + auto tblgen_einsum_config = getProperties().einsum_config; (void)tblgen_einsum_config; + if (!tblgen_einsum_config) return emitOpError("requires attribute 'einsum_config'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps12(*this, tblgen_einsum_config, "einsum_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult EinsumOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult EinsumOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::StringAttr einsum_configAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("config")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(einsum_configAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (einsum_configAttr) result.getOrAddProperties().einsum_config = einsum_configAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(::llvm::concat(lhsOperands, rhsOperands), allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void EinsumOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + _odsPrinter << ","; + _odsPrinter << ' ' << "config"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getEinsumConfigAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("einsum_config"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void EinsumOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::EinsumOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ExpOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ExpOpGenericAdaptorBase::ExpOpGenericAdaptorBase(ExpOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ResultAccuracyAttr ExpOpGenericAdaptorBase::getResultAccuracyAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + if (!attr) + attr = ::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + return attr; +} + +::mlir::stablehlo::ResultAccuracyAttr ExpOpGenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +} // namespace detail +ExpOpAdaptor::ExpOpAdaptor(ExpOp op) : ExpOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ExpOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (tblgen_result_accuracy && !((::llvm::isa<::mlir::stablehlo::ResultAccuracyAttr>(tblgen_result_accuracy)))) + return emitError(loc, "'stablehlo.exponential' op ""attribute 'result_accuracy' failed to satisfy constraint: The requested accuracy for transcendental unary ops."); + return ::mlir::success(); +} + +::llvm::LogicalResult ExpOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ExpOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ExpOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional ExpOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void ExpOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ExpOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult ExpOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ExpOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExpOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.result_accuracy); +} + +::mlir::stablehlo::ResultAccuracyAttr ExpOp::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder((*this)->getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +void ExpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + odsState.addTypes(result); +} + +void ExpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ExpOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ExpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ExpOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ExpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ExpOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ExpOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ExpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ExpOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ExpOp::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ExpOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ExpOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExpOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getResultAccuracyAttr(); + if(attr && (attr == ::mlir::stablehlo::ResultAccuracyAttr::get(odsBuilder.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(odsBuilder.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)))) + elidedAttrs.push_back("result_accuracy"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void ExpOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ExpOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::Expm1Op definitions +//===----------------------------------------------------------------------===// + +namespace detail { +Expm1OpGenericAdaptorBase::Expm1OpGenericAdaptorBase(Expm1Op op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ResultAccuracyAttr Expm1OpGenericAdaptorBase::getResultAccuracyAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + if (!attr) + attr = ::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + return attr; +} + +::mlir::stablehlo::ResultAccuracyAttr Expm1OpGenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +} // namespace detail +Expm1OpAdaptor::Expm1OpAdaptor(Expm1Op op) : Expm1OpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult Expm1OpAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (tblgen_result_accuracy && !((::llvm::isa<::mlir::stablehlo::ResultAccuracyAttr>(tblgen_result_accuracy)))) + return emitError(loc, "'stablehlo.exponential_minus_one' op ""attribute 'result_accuracy' failed to satisfy constraint: The requested accuracy for transcendental unary ops."); + return ::mlir::success(); +} + +::llvm::LogicalResult Expm1Op::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute Expm1Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code Expm1Op::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional Expm1Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void Expm1Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void Expm1Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult Expm1Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult Expm1Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void Expm1Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.result_accuracy); +} + +::mlir::stablehlo::ResultAccuracyAttr Expm1Op::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder((*this)->getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +void Expm1Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + odsState.addTypes(result); +} + +void Expm1Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(Expm1Op::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void Expm1Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void Expm1Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void Expm1Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(Expm1Op::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void Expm1Op::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void Expm1Op::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(Expm1Op::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult Expm1Op::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult Expm1Op::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult Expm1Op::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void Expm1Op::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getResultAccuracyAttr(); + if(attr && (attr == ::mlir::stablehlo::ResultAccuracyAttr::get(odsBuilder.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(odsBuilder.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)))) + elidedAttrs.push_back("result_accuracy"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void Expm1Op::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::Expm1Op) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::FftOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +FftOpGenericAdaptorBase::FftOpGenericAdaptorBase(FftOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::FftType FftOpGenericAdaptorBase::getFftType() { + auto attr = getFftTypeAttr(); + return attr.getValue(); +} + +::llvm::ArrayRef FftOpGenericAdaptorBase::getFftLength() { + auto attr = getFftLengthAttr(); + return attr; +} + +} // namespace detail +FftOpAdaptor::FftOpAdaptor(FftOp op) : FftOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult FftOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_fft_length = getProperties().fft_length; (void)tblgen_fft_length; + if (!tblgen_fft_length) return emitError(loc, "'stablehlo.fft' op ""requires attribute 'fft_length'"); + auto tblgen_fft_type = getProperties().fft_type; (void)tblgen_fft_type; + if (!tblgen_fft_type) return emitError(loc, "'stablehlo.fft' op ""requires attribute 'fft_type'"); + + if (tblgen_fft_type && !((::llvm::isa<::mlir::stablehlo::FftTypeAttr>(tblgen_fft_type)))) + return emitError(loc, "'stablehlo.fft' op ""attribute 'fft_type' failed to satisfy constraint: XLA fast fourier transform type."); + + if (tblgen_fft_length && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_fft_length)))) + return emitError(loc, "'stablehlo.fft' op ""attribute 'fft_length' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult FftOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.fft_length; + auto attr = dict.get("fft_length"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `fft_length` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.fft_type; + auto attr = dict.get("fft_type"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `fft_type` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute FftOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.fft_length; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("fft_length", + propStorage)); + } + + { + const auto &propStorage = prop.fft_type; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("fft_type", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code FftOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.fft_length.getAsOpaquePointer()), + llvm::hash_value(prop.fft_type.getAsOpaquePointer())); +} + +std::optional FftOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "fft_length") + return prop.fft_length; + + if (name == "fft_type") + return prop.fft_type; + return std::nullopt; +} + +void FftOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "fft_length") { + prop.fft_length = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "fft_type") { + prop.fft_type = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void FftOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.fft_length) attrs.append("fft_length", prop.fft_length); + + if (prop.fft_type) attrs.append("fft_type", prop.fft_type); +} + +::llvm::LogicalResult FftOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getFftLengthAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "fft_length", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFftTypeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps28(attr, "fft_type", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult FftOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.fft_length))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.fft_type))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void FftOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.fft_length); + writer.writeAttribute(prop.fft_type); +} + +::mlir::stablehlo::FftType FftOp::getFftType() { + auto attr = getFftTypeAttr(); + return attr.getValue(); +} + +::llvm::ArrayRef FftOp::getFftLength() { + auto attr = getFftLengthAttr(); + return attr; +} + +void FftOp::setFftType(::mlir::stablehlo::FftType attrValue) { + getProperties().fft_type = ::mlir::stablehlo::FftTypeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); +} + +void FftOp::setFftLength(::llvm::ArrayRef attrValue) { + getProperties().fft_length = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void FftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::stablehlo::FftTypeAttr fft_type, ::mlir::DenseI64ArrayAttr fft_length) { + odsState.addOperands(operand); + odsState.getOrAddProperties().fft_type = fft_type; + odsState.getOrAddProperties().fft_length = fft_length; + odsState.addTypes(resultType0); +} + +void FftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::stablehlo::FftTypeAttr fft_type, ::mlir::DenseI64ArrayAttr fft_length) { + odsState.addOperands(operand); + odsState.getOrAddProperties().fft_type = fft_type; + odsState.getOrAddProperties().fft_length = fft_length; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(FftOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void FftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::stablehlo::FftTypeAttr fft_type, ::mlir::DenseI64ArrayAttr fft_length) { + odsState.addOperands(operand); + odsState.getOrAddProperties().fft_type = fft_type; + odsState.getOrAddProperties().fft_length = fft_length; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void FftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::stablehlo::FftType fft_type, ::llvm::ArrayRef fft_length) { + odsState.addOperands(operand); + odsState.getOrAddProperties().fft_type = ::mlir::stablehlo::FftTypeAttr::get(odsBuilder.getContext(), fft_type); + odsState.getOrAddProperties().fft_length = odsBuilder.getDenseI64ArrayAttr(fft_length); + odsState.addTypes(resultType0); +} + +void FftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::stablehlo::FftType fft_type, ::llvm::ArrayRef fft_length) { + odsState.addOperands(operand); + odsState.getOrAddProperties().fft_type = ::mlir::stablehlo::FftTypeAttr::get(odsBuilder.getContext(), fft_type); + odsState.getOrAddProperties().fft_length = odsBuilder.getDenseI64ArrayAttr(fft_length); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(FftOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void FftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::stablehlo::FftType fft_type, ::llvm::ArrayRef fft_length) { + odsState.addOperands(operand); + odsState.getOrAddProperties().fft_type = ::mlir::stablehlo::FftTypeAttr::get(odsBuilder.getContext(), fft_type); + odsState.getOrAddProperties().fft_length = odsBuilder.getDenseI64ArrayAttr(fft_length); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void FftOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void FftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(FftOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void FftOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void FftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(FftOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult FftOp::verifyInvariantsImpl() { + auto tblgen_fft_length = getProperties().fft_length; (void)tblgen_fft_length; + if (!tblgen_fft_length) return emitOpError("requires attribute 'fft_length'"); + auto tblgen_fft_type = getProperties().fft_type; (void)tblgen_fft_type; + if (!tblgen_fft_type) return emitOpError("requires attribute 'fft_type'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps28(*this, tblgen_fft_type, "fft_type"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_fft_length, "fft_length"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps29(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps29(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult FftOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult FftOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::stablehlo::FftTypeAttr fft_typeAttr; + ::mlir::DenseI64ArrayAttr fft_lengthAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("type")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(fft_typeAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (fft_typeAttr) result.getOrAddProperties().fft_type = fft_typeAttr; + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("length")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(fft_lengthAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (fft_lengthAttr) result.getOrAddProperties().fft_length = fft_lengthAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(operandOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void FftOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' ' << "type"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getFftTypeAttr()); + _odsPrinter << ","; + _odsPrinter << ' ' << "length"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getFftLengthAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("fft_type"); + elidedAttrs.push_back("fft_length"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void FftOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +FftOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(FftOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::FftOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::FloorOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +FloorOpGenericAdaptorBase::FloorOpGenericAdaptorBase(FloorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +FloorOpAdaptor::FloorOpAdaptor(FloorOp op) : FloorOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult FloorOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult FloorOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute FloorOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code FloorOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional FloorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void FloorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void FloorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult FloorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void FloorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void FloorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(FloorOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void FloorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void FloorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void FloorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(FloorOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void FloorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void FloorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(FloorOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult FloorOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult FloorOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult FloorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void FloorOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void FloorOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::FloorOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::GatherOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GatherOpGenericAdaptorBase::GatherOpGenericAdaptorBase(GatherOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::GatherDimensionNumbersAttr GatherOpGenericAdaptorBase::getDimensionNumbers() { + auto attr = getDimensionNumbersAttr(); + return ::llvm::cast<::mlir::stablehlo::GatherDimensionNumbersAttr>(attr); +} + +::llvm::ArrayRef GatherOpGenericAdaptorBase::getSliceSizes() { + auto attr = getSliceSizesAttr(); + return attr; +} + +::mlir::BoolAttr GatherOpGenericAdaptorBase::getIndicesAreSortedAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().indices_are_sorted); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false); + return attr; +} + +bool GatherOpGenericAdaptorBase::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +} // namespace detail +GatherOpAdaptor::GatherOpAdaptor(GatherOp op) : GatherOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult GatherOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_dimension_numbers = getProperties().dimension_numbers; (void)tblgen_dimension_numbers; + if (!tblgen_dimension_numbers) return emitError(loc, "'stablehlo.gather' op ""requires attribute 'dimension_numbers'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + auto tblgen_slice_sizes = getProperties().slice_sizes; (void)tblgen_slice_sizes; + if (!tblgen_slice_sizes) return emitError(loc, "'stablehlo.gather' op ""requires attribute 'slice_sizes'"); + + if (tblgen_dimension_numbers && !((::llvm::isa<::mlir::stablehlo::GatherDimensionNumbersAttr>(tblgen_dimension_numbers)))) + return emitError(loc, "'stablehlo.gather' op ""attribute 'dimension_numbers' failed to satisfy constraint: Attribute that models the dimension information for gather"); + + if (tblgen_slice_sizes && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_slice_sizes)))) + return emitError(loc, "'stablehlo.gather' op ""attribute 'slice_sizes' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_indices_are_sorted && !((::llvm::isa<::mlir::BoolAttr>(tblgen_indices_are_sorted)))) + return emitError(loc, "'stablehlo.gather' op ""attribute 'indices_are_sorted' failed to satisfy constraint: bool attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult GatherOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimension_numbers; + auto attr = dict.get("dimension_numbers"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimension_numbers` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.indices_are_sorted; + auto attr = dict.get("indices_are_sorted"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `indices_are_sorted` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.slice_sizes; + auto attr = dict.get("slice_sizes"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `slice_sizes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GatherOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimension_numbers; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimension_numbers", + propStorage)); + } + + { + const auto &propStorage = prop.indices_are_sorted; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("indices_are_sorted", + propStorage)); + } + + { + const auto &propStorage = prop.slice_sizes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("slice_sizes", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GatherOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimension_numbers.getAsOpaquePointer()), + llvm::hash_value(prop.indices_are_sorted.getAsOpaquePointer()), + llvm::hash_value(prop.slice_sizes.getAsOpaquePointer())); +} + +std::optional GatherOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimension_numbers") + return prop.dimension_numbers; + + if (name == "indices_are_sorted") + return prop.indices_are_sorted; + + if (name == "slice_sizes") + return prop.slice_sizes; + return std::nullopt; +} + +void GatherOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimension_numbers") { + prop.dimension_numbers = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "indices_are_sorted") { + prop.indices_are_sorted = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "slice_sizes") { + prop.slice_sizes = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GatherOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimension_numbers) attrs.append("dimension_numbers", prop.dimension_numbers); + + if (prop.indices_are_sorted) attrs.append("indices_are_sorted", prop.indices_are_sorted); + + if (prop.slice_sizes) attrs.append("slice_sizes", prop.slice_sizes); +} + +::llvm::LogicalResult GatherOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionNumbersAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps27(attr, "dimension_numbers", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIndicesAreSortedAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(attr, "indices_are_sorted", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSliceSizesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "slice_sizes", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult GatherOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimension_numbers))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.indices_are_sorted))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.slice_sizes))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GatherOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimension_numbers); + + writer.writeOptionalAttribute(prop.indices_are_sorted); + writer.writeAttribute(prop.slice_sizes); +} + +::mlir::stablehlo::GatherDimensionNumbersAttr GatherOp::getDimensionNumbers() { + auto attr = getDimensionNumbersAttr(); + return ::llvm::cast<::mlir::stablehlo::GatherDimensionNumbersAttr>(attr); +} + +::llvm::ArrayRef GatherOp::getSliceSizes() { + auto attr = getSliceSizesAttr(); + return attr; +} + +bool GatherOp::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +void GatherOp::setSliceSizes(::llvm::ArrayRef attrValue) { + getProperties().slice_sizes = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void GatherOp::setIndicesAreSorted(::std::optional attrValue) { + auto &odsProp = getProperties().indices_are_sorted; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue); + else + odsProp = nullptr; +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, ::mlir::DenseI64ArrayAttr slice_sizes, /*optional*/::mlir::BoolAttr indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().slice_sizes = slice_sizes; + if (indices_are_sorted) { + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + } + odsState.addTypes(result); +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, ::mlir::DenseI64ArrayAttr slice_sizes, /*optional*/::mlir::BoolAttr indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().slice_sizes = slice_sizes; + if (indices_are_sorted) { + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GatherOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, ::mlir::DenseI64ArrayAttr slice_sizes, /*optional*/::mlir::BoolAttr indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().slice_sizes = slice_sizes; + if (indices_are_sorted) { + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, ::llvm::ArrayRef slice_sizes, /*optional*/bool indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().slice_sizes = odsBuilder.getDenseI64ArrayAttr(slice_sizes); + odsState.getOrAddProperties().indices_are_sorted = odsBuilder.getBoolAttr(indices_are_sorted); + odsState.addTypes(result); +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, ::llvm::ArrayRef slice_sizes, /*optional*/bool indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().slice_sizes = odsBuilder.getDenseI64ArrayAttr(slice_sizes); + odsState.getOrAddProperties().indices_are_sorted = odsBuilder.getBoolAttr(indices_are_sorted); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GatherOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, ::llvm::ArrayRef slice_sizes, /*optional*/bool indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().dimension_numbers = dimension_numbers; + odsState.getOrAddProperties().slice_sizes = odsBuilder.getDenseI64ArrayAttr(slice_sizes); + odsState.getOrAddProperties().indices_are_sorted = odsBuilder.getBoolAttr(indices_are_sorted); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GatherOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GatherOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void GatherOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GatherOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult GatherOp::verifyInvariantsImpl() { + auto tblgen_dimension_numbers = getProperties().dimension_numbers; (void)tblgen_dimension_numbers; + if (!tblgen_dimension_numbers) return emitOpError("requires attribute 'dimension_numbers'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + auto tblgen_slice_sizes = getProperties().slice_sizes; (void)tblgen_slice_sizes; + if (!tblgen_slice_sizes) return emitOpError("requires attribute 'slice_sizes'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps27(*this, tblgen_dimension_numbers, "dimension_numbers"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_slice_sizes, "slice_sizes"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(*this, tblgen_indices_are_sorted, "indices_are_sorted"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!(((getElementTypeOrSelf((*this->getODSOperands(0).begin()))) == (getElementTypeOrSelf((*this->getODSResults(0).begin()))) && (getElementTypeOrSelf((*this->getODSResults(0).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(0).begin())))))) + return emitOpError("failed to verify that all of {operand, result} have same element type"); + return ::mlir::success(); +} + +::llvm::LogicalResult GatherOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void GatherOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +GatherOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(GatherOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::GatherOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::GetDimensionSizeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GetDimensionSizeOpGenericAdaptorBase::GetDimensionSizeOpGenericAdaptorBase(GetDimensionSizeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +uint64_t GetDimensionSizeOpGenericAdaptorBase::getDimension() { + auto attr = getDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +GetDimensionSizeOpAdaptor::GetDimensionSizeOpAdaptor(GetDimensionSizeOp op) : GetDimensionSizeOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult GetDimensionSizeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitError(loc, "'stablehlo.get_dimension_size' op ""requires attribute 'dimension'"); + + if (tblgen_dimension && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_dimension))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_dimension).getType().isSignlessInteger(64)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_dimension).getValue().isNegative())))) + return emitError(loc, "'stablehlo.get_dimension_size' op ""attribute 'dimension' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative"); + return ::mlir::success(); +} + +::llvm::LogicalResult GetDimensionSizeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimension; + auto attr = dict.get("dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GetDimensionSizeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GetDimensionSizeOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimension.getAsOpaquePointer())); +} + +std::optional GetDimensionSizeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimension") + return prop.dimension; + return std::nullopt; +} + +void GetDimensionSizeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimension") { + prop.dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GetDimensionSizeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimension) attrs.append("dimension", prop.dimension); +} + +::llvm::LogicalResult GetDimensionSizeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(attr, "dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult GetDimensionSizeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetDimensionSizeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimension); +} + +uint64_t GetDimensionSizeOp::getDimension() { + auto attr = getDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +void GetDimensionSizeOp::setDimension(uint64_t attrValue) { + getProperties().dimension = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void GetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::IntegerAttr dimension) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimension = dimension; + odsState.addTypes(resultType0); +} + +void GetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::IntegerAttr dimension) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimension = dimension; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GetDimensionSizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void GetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::IntegerAttr dimension) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimension = dimension; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, uint64_t dimension) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), dimension); + odsState.addTypes(resultType0); +} + +void GetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, uint64_t dimension) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), dimension); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GetDimensionSizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void GetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, uint64_t dimension) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), dimension); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetDimensionSizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void GetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GetDimensionSizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void GetDimensionSizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void GetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GetDimensionSizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult GetDimensionSizeOp::verifyInvariantsImpl() { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitOpError("requires attribute 'dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(*this, tblgen_dimension, "dimension"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps13(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult GetDimensionSizeOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult GetDimensionSizeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::IntegerAttr dimensionAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("dim")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(dimensionAttr, parser.getBuilder().getIntegerType(64))) { + return ::mlir::failure(); + } + if (dimensionAttr) result.getOrAddProperties().dimension = dimensionAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(operandOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetDimensionSizeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' ' << "dim"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getDimensionAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("dimension"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void GetDimensionSizeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +GetDimensionSizeOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(GetDimensionSizeOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::GetDimensionSizeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::GetTupleElementOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GetTupleElementOpGenericAdaptorBase::GetTupleElementOpGenericAdaptorBase(GetTupleElementOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +uint32_t GetTupleElementOpGenericAdaptorBase::getIndex() { + auto attr = getIndexAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +GetTupleElementOpAdaptor::GetTupleElementOpAdaptor(GetTupleElementOp op) : GetTupleElementOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult GetTupleElementOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_index = getProperties().index; (void)tblgen_index; + if (!tblgen_index) return emitError(loc, "'stablehlo.get_tuple_element' op ""requires attribute 'index'"); + + if (tblgen_index && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_index))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_index).getType().isSignlessInteger(32)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_index).getValue().isNegative())))) + return emitError(loc, "'stablehlo.get_tuple_element' op ""attribute 'index' failed to satisfy constraint: 32-bit signless integer attribute whose value is non-negative"); + return ::mlir::success(); +} + +::llvm::LogicalResult GetTupleElementOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.index; + auto attr = dict.get("index"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `index` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GetTupleElementOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.index; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("index", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GetTupleElementOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.index.getAsOpaquePointer())); +} + +std::optional GetTupleElementOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "index") + return prop.index; + return std::nullopt; +} + +void GetTupleElementOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "index") { + prop.index = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GetTupleElementOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.index) attrs.append("index", prop.index); +} + +::llvm::LogicalResult GetTupleElementOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getIndexAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps29(attr, "index", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult GetTupleElementOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.index))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetTupleElementOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.index); +} + +uint32_t GetTupleElementOp::getIndex() { + auto attr = getIndexAttr(); + return attr.getValue().getZExtValue(); +} + +void GetTupleElementOp::setIndex(uint32_t attrValue) { + getProperties().index = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); +} + +void GetTupleElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::IntegerAttr index) { + odsState.addOperands(operand); + odsState.getOrAddProperties().index = index; + odsState.addTypes(resultType0); +} + +void GetTupleElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::IntegerAttr index) { + odsState.addOperands(operand); + odsState.getOrAddProperties().index = index; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GetTupleElementOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void GetTupleElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::IntegerAttr index) { + odsState.addOperands(operand); + odsState.getOrAddProperties().index = index; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetTupleElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, uint32_t index) { + odsState.addOperands(operand); + odsState.getOrAddProperties().index = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), index); + odsState.addTypes(resultType0); +} + +void GetTupleElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, uint32_t index) { + odsState.addOperands(operand); + odsState.getOrAddProperties().index = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), index); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GetTupleElementOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void GetTupleElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, uint32_t index) { + odsState.addOperands(operand); + odsState.getOrAddProperties().index = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), index); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetTupleElementOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void GetTupleElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GetTupleElementOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void GetTupleElementOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void GetTupleElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GetTupleElementOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult GetTupleElementOp::verifyInvariantsImpl() { + auto tblgen_index = getProperties().index; (void)tblgen_index; + if (!tblgen_index) return emitOpError("requires attribute 'index'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps29(*this, tblgen_index, "index"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps30(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps31(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult GetTupleElementOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult GetTupleElementOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::IntegerAttr indexAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(indexAttr, parser.getBuilder().getIntegerType(32))) { + return ::mlir::failure(); + } + if (indexAttr) result.getOrAddProperties().index = indexAttr; + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(operandOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetTupleElementOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << "["; + _odsPrinter.printAttributeWithoutType(getIndexAttr()); + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("index"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void GetTupleElementOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::GetTupleElementOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::IfOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IfOpGenericAdaptorBase::IfOpGenericAdaptorBase(IfOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +IfOpAdaptor::IfOpAdaptor(IfOp op) : IfOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult IfOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair IfOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult IfOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute IfOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code IfOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional IfOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void IfOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void IfOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult IfOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void IfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::Value pred) { + odsState.addOperands(pred); + (void)odsState.addRegion(); + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void IfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value pred) { + odsState.addOperands(pred); + (void)odsState.addRegion(); + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void IfOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void IfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void IfOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void IfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult IfOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps16(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps14(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "true_branch", index++))) + return ::mlir::failure(); + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "false_branch", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult IfOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::IfOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ImagOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ImagOpGenericAdaptorBase::ImagOpGenericAdaptorBase(ImagOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ImagOpAdaptor::ImagOpAdaptor(ImagOp op) : ImagOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ImagOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ImagOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ImagOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ImagOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ImagOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ImagOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ImagOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ImagOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ImagOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void ImagOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ImagOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ImagOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ImagOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ImagOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ImagOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ImagOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ImagOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ImagOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ImagOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps29(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps32(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ImagOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ImagOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ImagOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void ImagOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ImagOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::InfeedOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +InfeedOpGenericAdaptorBase::InfeedOpGenericAdaptorBase(InfeedOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::StringAttr InfeedOpGenericAdaptorBase::getInfeedConfigAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().infeed_config); + return attr; +} + +::llvm::StringRef InfeedOpGenericAdaptorBase::getInfeedConfig() { + auto attr = getInfeedConfigAttr(); + return attr.getValue(); +} + +::std::optional< ::mlir::ArrayAttr > InfeedOpGenericAdaptorBase::getLayout() { + auto attr = getLayoutAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +} // namespace detail +InfeedOpAdaptor::InfeedOpAdaptor(InfeedOp op) : InfeedOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult InfeedOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_infeed_config = getProperties().infeed_config; (void)tblgen_infeed_config; + auto tblgen_layout = getProperties().layout; (void)tblgen_layout; + + if (tblgen_infeed_config && !((::llvm::isa<::mlir::StringAttr>(tblgen_infeed_config)))) + return emitError(loc, "'stablehlo.infeed' op ""attribute 'infeed_config' failed to satisfy constraint: string attribute"); + + if (tblgen_layout && !((::llvm::isa<::mlir::ArrayAttr>(tblgen_layout)))) + return emitError(loc, "'stablehlo.infeed' op ""attribute 'layout' failed to satisfy constraint: array attribute"); + return ::mlir::success(); +} + +std::pair InfeedOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult InfeedOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.infeed_config; + auto attr = dict.get("infeed_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `infeed_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.layout; + auto attr = dict.get("layout"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `layout` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute InfeedOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.infeed_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("infeed_config", + propStorage)); + } + + { + const auto &propStorage = prop.layout; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("layout", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code InfeedOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.infeed_config.getAsOpaquePointer()), + llvm::hash_value(prop.layout.getAsOpaquePointer())); +} + +std::optional InfeedOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "infeed_config") + return prop.infeed_config; + + if (name == "layout") + return prop.layout; + return std::nullopt; +} + +void InfeedOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "infeed_config") { + prop.infeed_config = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "layout") { + prop.layout = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void InfeedOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.infeed_config) attrs.append("infeed_config", prop.infeed_config); + + if (prop.layout) attrs.append("layout", prop.layout); +} + +::llvm::LogicalResult InfeedOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getInfeedConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps12(attr, "infeed_config", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLayoutAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps30(attr, "layout", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult InfeedOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.infeed_config))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.layout))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void InfeedOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.infeed_config); + + writer.writeOptionalAttribute(prop.layout); +} + +::llvm::StringRef InfeedOp::getInfeedConfig() { + auto attr = getInfeedConfigAttr(); + return attr.getValue(); +} + +::std::optional< ::mlir::ArrayAttr > InfeedOp::getLayout() { + auto attr = getLayoutAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +void InfeedOp::setInfeedConfig(::llvm::StringRef attrValue) { + getProperties().infeed_config = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); +} + +void InfeedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::Value token, ::mlir::StringAttr infeed_config, /*optional*/::mlir::ArrayAttr layout) { + odsState.addOperands(token); + if (infeed_config) { + odsState.getOrAddProperties().infeed_config = infeed_config; + } + if (layout) { + odsState.getOrAddProperties().layout = layout; + } + odsState.addTypes(resultType0); +} + +void InfeedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::Value token, ::llvm::StringRef infeed_config, /*optional*/::mlir::ArrayAttr layout) { + odsState.addOperands(token); + odsState.getOrAddProperties().infeed_config = odsBuilder.getStringAttr(infeed_config); + if (layout) { + odsState.getOrAddProperties().layout = layout; + } + odsState.addTypes(resultType0); +} + +void InfeedOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void InfeedOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +void InfeedOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { + ::mlir::Builder odsBuilder(opName.getContext()); + if (!properties.infeed_config) + properties.infeed_config = odsBuilder.getStringAttr(""); +} + +::llvm::LogicalResult InfeedOp::verifyInvariantsImpl() { + auto tblgen_infeed_config = getProperties().infeed_config; (void)tblgen_infeed_config; + auto tblgen_layout = getProperties().layout; (void)tblgen_layout; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps12(*this, tblgen_infeed_config, "infeed_config"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps30(*this, tblgen_layout, "layout"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps33(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult InfeedOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +void InfeedOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { + effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::stablehlo::side_effects::InfeedResource::get()); + effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::stablehlo::side_effects::InfeedResource::get()); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::InfeedOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::IotaOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IotaOpGenericAdaptorBase::IotaOpGenericAdaptorBase(IotaOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +uint64_t IotaOpGenericAdaptorBase::getIotaDimension() { + auto attr = getIotaDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +IotaOpAdaptor::IotaOpAdaptor(IotaOp op) : IotaOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult IotaOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_iota_dimension = getProperties().iota_dimension; (void)tblgen_iota_dimension; + if (!tblgen_iota_dimension) return emitError(loc, "'stablehlo.iota' op ""requires attribute 'iota_dimension'"); + + if (tblgen_iota_dimension && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_iota_dimension))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_iota_dimension).getType().isSignlessInteger(64)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_iota_dimension).getValue().isNegative())))) + return emitError(loc, "'stablehlo.iota' op ""attribute 'iota_dimension' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative"); + return ::mlir::success(); +} + +::llvm::LogicalResult IotaOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.iota_dimension; + auto attr = dict.get("iota_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `iota_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute IotaOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.iota_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("iota_dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code IotaOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.iota_dimension.getAsOpaquePointer())); +} + +std::optional IotaOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "iota_dimension") + return prop.iota_dimension; + return std::nullopt; +} + +void IotaOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "iota_dimension") { + prop.iota_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void IotaOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.iota_dimension) attrs.append("iota_dimension", prop.iota_dimension); +} + +::llvm::LogicalResult IotaOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getIotaDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(attr, "iota_dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult IotaOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.iota_dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void IotaOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.iota_dimension); +} + +uint64_t IotaOp::getIotaDimension() { + auto attr = getIotaDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +void IotaOp::setIotaDimension(uint64_t attrValue) { + getProperties().iota_dimension = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void IotaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::IntegerAttr iota_dimension) { + odsState.getOrAddProperties().iota_dimension = iota_dimension; + odsState.addTypes(output); +} + +void IotaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr iota_dimension) { + odsState.getOrAddProperties().iota_dimension = iota_dimension; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void IotaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, uint64_t iota_dimension) { + odsState.getOrAddProperties().iota_dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), iota_dimension); + odsState.addTypes(output); +} + +void IotaOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, uint64_t iota_dimension) { + odsState.getOrAddProperties().iota_dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), iota_dimension); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void IotaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void IotaOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult IotaOp::verifyInvariantsImpl() { + auto tblgen_iota_dimension = getProperties().iota_dimension; (void)tblgen_iota_dimension; + if (!tblgen_iota_dimension) return emitOpError("requires attribute 'iota_dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(*this, tblgen_iota_dimension, "iota_dimension"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps34(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult IotaOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult IotaOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::IntegerAttr iota_dimensionAttr; + ::mlir::Type outputRawType{}; + ::llvm::ArrayRef<::mlir::Type> outputTypes(&outputRawType, 1); + if (parser.parseKeyword("dim")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(iota_dimensionAttr, parser.getBuilder().getIntegerType(64))) { + return ::mlir::failure(); + } + if (iota_dimensionAttr) result.getOrAddProperties().iota_dimension = iota_dimensionAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + outputRawType = type; + } + result.addTypes(outputTypes); + return ::mlir::success(); +} + +void IotaOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' ' << "dim"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getIotaDimensionAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("iota_dimension"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOutput().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void IotaOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::IotaOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::IsFiniteOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IsFiniteOpGenericAdaptorBase::IsFiniteOpGenericAdaptorBase(IsFiniteOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +IsFiniteOpAdaptor::IsFiniteOpAdaptor(IsFiniteOp op) : IsFiniteOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult IsFiniteOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult IsFiniteOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute IsFiniteOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code IsFiniteOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional IsFiniteOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void IsFiniteOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void IsFiniteOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult IsFiniteOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void IsFiniteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type y, ::mlir::Value x) { + odsState.addOperands(x); + odsState.addTypes(y); +} + +void IsFiniteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x) { + odsState.addOperands(x); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IsFiniteOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void IsFiniteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x) { + odsState.addOperands(x); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void IsFiniteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void IsFiniteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IsFiniteOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void IsFiniteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void IsFiniteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IsFiniteOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult IsFiniteOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps16(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult IsFiniteOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult IsFiniteOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + [[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(allOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(allOperands, allOperandTypes, allOperandLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void IsFiniteOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperation()->getOperands(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void IsFiniteOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::IsFiniteOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::Log1pOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +Log1pOpGenericAdaptorBase::Log1pOpGenericAdaptorBase(Log1pOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ResultAccuracyAttr Log1pOpGenericAdaptorBase::getResultAccuracyAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + if (!attr) + attr = ::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + return attr; +} + +::mlir::stablehlo::ResultAccuracyAttr Log1pOpGenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +} // namespace detail +Log1pOpAdaptor::Log1pOpAdaptor(Log1pOp op) : Log1pOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult Log1pOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (tblgen_result_accuracy && !((::llvm::isa<::mlir::stablehlo::ResultAccuracyAttr>(tblgen_result_accuracy)))) + return emitError(loc, "'stablehlo.log_plus_one' op ""attribute 'result_accuracy' failed to satisfy constraint: The requested accuracy for transcendental unary ops."); + return ::mlir::success(); +} + +::llvm::LogicalResult Log1pOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute Log1pOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code Log1pOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional Log1pOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void Log1pOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void Log1pOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult Log1pOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult Log1pOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void Log1pOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.result_accuracy); +} + +::mlir::stablehlo::ResultAccuracyAttr Log1pOp::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder((*this)->getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +void Log1pOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + odsState.addTypes(result); +} + +void Log1pOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(Log1pOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void Log1pOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void Log1pOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void Log1pOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(Log1pOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void Log1pOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void Log1pOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(Log1pOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult Log1pOp::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult Log1pOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult Log1pOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void Log1pOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getResultAccuracyAttr(); + if(attr && (attr == ::mlir::stablehlo::ResultAccuracyAttr::get(odsBuilder.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(odsBuilder.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)))) + elidedAttrs.push_back("result_accuracy"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void Log1pOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::Log1pOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::LogOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +LogOpGenericAdaptorBase::LogOpGenericAdaptorBase(LogOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ResultAccuracyAttr LogOpGenericAdaptorBase::getResultAccuracyAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + if (!attr) + attr = ::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + return attr; +} + +::mlir::stablehlo::ResultAccuracyAttr LogOpGenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +} // namespace detail +LogOpAdaptor::LogOpAdaptor(LogOp op) : LogOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult LogOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (tblgen_result_accuracy && !((::llvm::isa<::mlir::stablehlo::ResultAccuracyAttr>(tblgen_result_accuracy)))) + return emitError(loc, "'stablehlo.log' op ""attribute 'result_accuracy' failed to satisfy constraint: The requested accuracy for transcendental unary ops."); + return ::mlir::success(); +} + +::llvm::LogicalResult LogOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute LogOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code LogOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional LogOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void LogOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void LogOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult LogOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult LogOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void LogOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.result_accuracy); +} + +::mlir::stablehlo::ResultAccuracyAttr LogOp::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder((*this)->getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +void LogOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + odsState.addTypes(result); +} + +void LogOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(LogOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void LogOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void LogOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void LogOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(LogOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void LogOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void LogOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(LogOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult LogOp::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult LogOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult LogOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void LogOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getResultAccuracyAttr(); + if(attr && (attr == ::mlir::stablehlo::ResultAccuracyAttr::get(odsBuilder.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(odsBuilder.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)))) + elidedAttrs.push_back("result_accuracy"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void LogOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::LogOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::LogisticOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +LogisticOpGenericAdaptorBase::LogisticOpGenericAdaptorBase(LogisticOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ResultAccuracyAttr LogisticOpGenericAdaptorBase::getResultAccuracyAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + if (!attr) + attr = ::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + return attr; +} + +::mlir::stablehlo::ResultAccuracyAttr LogisticOpGenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +} // namespace detail +LogisticOpAdaptor::LogisticOpAdaptor(LogisticOp op) : LogisticOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult LogisticOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (tblgen_result_accuracy && !((::llvm::isa<::mlir::stablehlo::ResultAccuracyAttr>(tblgen_result_accuracy)))) + return emitError(loc, "'stablehlo.logistic' op ""attribute 'result_accuracy' failed to satisfy constraint: The requested accuracy for transcendental unary ops."); + return ::mlir::success(); +} + +::llvm::LogicalResult LogisticOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute LogisticOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code LogisticOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional LogisticOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void LogisticOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void LogisticOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult LogisticOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult LogisticOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void LogisticOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.result_accuracy); +} + +::mlir::stablehlo::ResultAccuracyAttr LogisticOp::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder((*this)->getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +void LogisticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + odsState.addTypes(result); +} + +void LogisticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(LogisticOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void LogisticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void LogisticOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void LogisticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(LogisticOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void LogisticOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void LogisticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(LogisticOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult LogisticOp::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult LogisticOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult LogisticOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void LogisticOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getResultAccuracyAttr(); + if(attr && (attr == ::mlir::stablehlo::ResultAccuracyAttr::get(odsBuilder.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(odsBuilder.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)))) + elidedAttrs.push_back("result_accuracy"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void LogisticOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::LogisticOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::MapOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MapOpGenericAdaptorBase::MapOpGenericAdaptorBase(MapOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair MapOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::ArrayRef MapOpGenericAdaptorBase::getDimensions() { + auto attr = getDimensionsAttr(); + return attr; +} + +} // namespace detail +MapOpAdaptor::MapOpAdaptor(MapOp op) : MapOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult MapOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_dimensions = getProperties().dimensions; (void)tblgen_dimensions; + if (!tblgen_dimensions) return emitError(loc, "'stablehlo.map' op ""requires attribute 'dimensions'"); + + if (tblgen_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_dimensions)))) + return emitError(loc, "'stablehlo.map' op ""attribute 'dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +std::pair MapOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange MapOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult MapOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimensions; + auto attr = dict.get("dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute MapOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MapOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimensions.getAsOpaquePointer())); +} + +std::optional MapOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimensions") + return prop.dimensions; + return std::nullopt; +} + +void MapOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimensions") { + prop.dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void MapOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimensions) attrs.append("dimensions", prop.dimensions); +} + +::llvm::LogicalResult MapOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult MapOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MapOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimensions); +} + +::llvm::ArrayRef MapOp::getDimensions() { + auto attr = getDimensionsAttr(); + return attr; +} + +void MapOp::setDimensions(::llvm::ArrayRef attrValue) { + getProperties().dimensions = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void MapOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::mlir::DenseI64ArrayAttr dimensions) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimensions = dimensions; + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void MapOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::DenseI64ArrayAttr dimensions) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimensions = dimensions; + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MapOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void MapOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::DenseI64ArrayAttr dimensions) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimensions = dimensions; + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MapOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::llvm::ArrayRef dimensions) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimensions = odsBuilder.getDenseI64ArrayAttr(dimensions); + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void MapOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::llvm::ArrayRef dimensions) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimensions = odsBuilder.getDenseI64ArrayAttr(dimensions); + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MapOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void MapOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::llvm::ArrayRef dimensions) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimensions = odsBuilder.getDenseI64ArrayAttr(dimensions); + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MapOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void MapOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MapOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void MapOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MapOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MapOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult MapOp::verifyInvariantsImpl() { + auto tblgen_dimensions = getProperties().dimensions; (void)tblgen_dimensions; + if (!tblgen_dimensions) return emitOpError("requires attribute 'dimensions'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_dimensions, "dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "computation", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult MapOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::llvm::LogicalResult +MapOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(MapOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::MapOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::MaxOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaxOpGenericAdaptorBase::MaxOpGenericAdaptorBase(MaxOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +MaxOpAdaptor::MaxOpAdaptor(MaxOp op) : MaxOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult MaxOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult MaxOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute MaxOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MaxOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional MaxOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void MaxOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void MaxOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult MaxOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void MaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void MaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaxOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void MaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MaxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaxOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void MaxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaxOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult MaxOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult MaxOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult MaxOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MaxOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void MaxOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::MaxOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::MinOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MinOpGenericAdaptorBase::MinOpGenericAdaptorBase(MinOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +MinOpAdaptor::MinOpAdaptor(MinOp op) : MinOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult MinOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult MinOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute MinOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MinOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional MinOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void MinOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void MinOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult MinOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void MinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void MinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MinOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void MinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MinOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MinOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void MinOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MinOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult MinOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult MinOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult MinOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MinOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void MinOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::MinOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::MulOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MulOpGenericAdaptorBase::MulOpGenericAdaptorBase(MulOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +MulOpAdaptor::MulOpAdaptor(MulOp op) : MulOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult MulOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult MulOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute MulOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MulOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional MulOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void MulOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void MulOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult MulOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void MulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void MulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MulOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void MulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MulOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MulOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void MulOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MulOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult MulOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult MulOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult MulOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MulOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void MulOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::MulOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::NegOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +NegOpGenericAdaptorBase::NegOpGenericAdaptorBase(NegOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +NegOpAdaptor::NegOpAdaptor(NegOp op) : NegOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult NegOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult NegOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute NegOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code NegOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional NegOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void NegOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void NegOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult NegOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void NegOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void NegOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(NegOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void NegOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void NegOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void NegOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(NegOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void NegOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void NegOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(NegOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult NegOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult NegOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult NegOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void NegOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void NegOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::NegOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::NotOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +NotOpGenericAdaptorBase::NotOpGenericAdaptorBase(NotOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +NotOpAdaptor::NotOpAdaptor(NotOp op) : NotOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult NotOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult NotOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute NotOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code NotOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional NotOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void NotOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void NotOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult NotOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void NotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void NotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(NotOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void NotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void NotOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void NotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(NotOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void NotOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void NotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(NotOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult NotOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult NotOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult NotOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void NotOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void NotOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::NotOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::OptimizationBarrierOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +OptimizationBarrierOpGenericAdaptorBase::OptimizationBarrierOpGenericAdaptorBase(OptimizationBarrierOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair OptimizationBarrierOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +} // namespace detail +OptimizationBarrierOpAdaptor::OptimizationBarrierOpAdaptor(OptimizationBarrierOp op) : OptimizationBarrierOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult OptimizationBarrierOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair OptimizationBarrierOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange OptimizationBarrierOp::getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair OptimizationBarrierOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult OptimizationBarrierOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute OptimizationBarrierOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code OptimizationBarrierOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional OptimizationBarrierOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void OptimizationBarrierOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void OptimizationBarrierOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult OptimizationBarrierOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void OptimizationBarrierOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); +} + +void OptimizationBarrierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(OptimizationBarrierOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void OptimizationBarrierOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +void OptimizationBarrierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(OptimizationBarrierOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult OptimizationBarrierOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps35(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps35(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult OptimizationBarrierOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult OptimizationBarrierOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> operandOperands; + ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> operandTypes; + ::llvm::SmallVector<::mlir::Type, 1> resultTypes; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(operandOperands)) + return ::mlir::failure(); + if (!operandOperands.empty()) { + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parsePairwiseOpType(parser, operandTypes, resultTypes); + if (odsResult) return ::mlir::failure(); + } + } else { + if (parser.parseLParen()) + return ::mlir::failure(); + if (parser.parseRParen()) + return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void OptimizationBarrierOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (!getOperand().empty()) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printPairwiseOpType(_odsPrinter, *this, getOperand().getTypes(), getResult().getTypes()); + } else { + _odsPrinter << "("; + _odsPrinter << ")"; + } +} + +void OptimizationBarrierOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::OptimizationBarrierOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::OrOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +OrOpGenericAdaptorBase::OrOpGenericAdaptorBase(OrOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +OrOpAdaptor::OrOpAdaptor(OrOp op) : OrOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult OrOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult OrOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute OrOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code OrOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional OrOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void OrOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void OrOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult OrOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void OrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void OrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(OrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void OrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void OrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void OrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(OrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void OrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void OrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(OrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult OrOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult OrOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult OrOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void OrOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void OrOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::OrOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::OutfeedOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +OutfeedOpGenericAdaptorBase::OutfeedOpGenericAdaptorBase(OutfeedOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair OutfeedOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::StringAttr OutfeedOpGenericAdaptorBase::getOutfeedConfigAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().outfeed_config); + return attr; +} + +::llvm::StringRef OutfeedOpGenericAdaptorBase::getOutfeedConfig() { + auto attr = getOutfeedConfigAttr(); + return attr.getValue(); +} + +} // namespace detail +OutfeedOpAdaptor::OutfeedOpAdaptor(OutfeedOp op) : OutfeedOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult OutfeedOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_outfeed_config = getProperties().outfeed_config; (void)tblgen_outfeed_config; + + if (tblgen_outfeed_config && !((::llvm::isa<::mlir::StringAttr>(tblgen_outfeed_config)))) + return emitError(loc, "'stablehlo.outfeed' op ""attribute 'outfeed_config' failed to satisfy constraint: string attribute"); + return ::mlir::success(); +} + +std::pair OutfeedOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange OutfeedOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult OutfeedOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.outfeed_config; + auto attr = dict.get("outfeed_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `outfeed_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute OutfeedOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.outfeed_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("outfeed_config", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code OutfeedOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.outfeed_config.getAsOpaquePointer())); +} + +std::optional OutfeedOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "outfeed_config") + return prop.outfeed_config; + return std::nullopt; +} + +void OutfeedOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "outfeed_config") { + prop.outfeed_config = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void OutfeedOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.outfeed_config) attrs.append("outfeed_config", prop.outfeed_config); +} + +::llvm::LogicalResult OutfeedOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getOutfeedConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps12(attr, "outfeed_config", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult OutfeedOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.outfeed_config))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void OutfeedOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.outfeed_config); +} + +::llvm::StringRef OutfeedOp::getOutfeedConfig() { + auto attr = getOutfeedConfigAttr(); + return attr.getValue(); +} + +void OutfeedOp::setOutfeedConfig(::llvm::StringRef attrValue) { + getProperties().outfeed_config = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); +} + +void OutfeedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::StringAttr outfeed_config) { + odsState.addOperands(inputs); + odsState.addOperands(token); + if (outfeed_config) { + odsState.getOrAddProperties().outfeed_config = outfeed_config; + } + odsState.addTypes(resultType0); +} + +void OutfeedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::StringAttr outfeed_config) { + odsState.addOperands(inputs); + odsState.addOperands(token); + if (outfeed_config) { + odsState.getOrAddProperties().outfeed_config = outfeed_config; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(OutfeedOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void OutfeedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::StringAttr outfeed_config) { + odsState.addOperands(inputs); + odsState.addOperands(token); + if (outfeed_config) { + odsState.getOrAddProperties().outfeed_config = outfeed_config; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void OutfeedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::mlir::Value token, ::llvm::StringRef outfeed_config) { + odsState.addOperands(inputs); + odsState.addOperands(token); + odsState.getOrAddProperties().outfeed_config = odsBuilder.getStringAttr(outfeed_config); + odsState.addTypes(resultType0); +} + +void OutfeedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::Value token, ::llvm::StringRef outfeed_config) { + odsState.addOperands(inputs); + odsState.addOperands(token); + odsState.getOrAddProperties().outfeed_config = odsBuilder.getStringAttr(outfeed_config); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(OutfeedOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void OutfeedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Value token, ::llvm::StringRef outfeed_config) { + odsState.addOperands(inputs); + odsState.addOperands(token); + odsState.getOrAddProperties().outfeed_config = odsBuilder.getStringAttr(outfeed_config); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void OutfeedOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void OutfeedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(OutfeedOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void OutfeedOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void OutfeedOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(OutfeedOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void OutfeedOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { + ::mlir::Builder odsBuilder(opName.getContext()); + if (!properties.outfeed_config) + properties.outfeed_config = odsBuilder.getStringAttr(""); +} + +::llvm::LogicalResult OutfeedOp::verifyInvariantsImpl() { + auto tblgen_outfeed_config = getProperties().outfeed_config; (void)tblgen_outfeed_config; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps12(*this, tblgen_outfeed_config, "outfeed_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps36(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult OutfeedOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void OutfeedOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { + effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::stablehlo::side_effects::OutfeedResource::get()); + effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::stablehlo::side_effects::OutfeedResource::get()); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::OutfeedOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::PadOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PadOpGenericAdaptorBase::PadOpGenericAdaptorBase(PadOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::llvm::ArrayRef PadOpGenericAdaptorBase::getEdgePaddingLow() { + auto attr = getEdgePaddingLowAttr(); + return attr; +} + +::llvm::ArrayRef PadOpGenericAdaptorBase::getEdgePaddingHigh() { + auto attr = getEdgePaddingHighAttr(); + return attr; +} + +::llvm::ArrayRef PadOpGenericAdaptorBase::getInteriorPadding() { + auto attr = getInteriorPaddingAttr(); + return attr; +} + +} // namespace detail +PadOpAdaptor::PadOpAdaptor(PadOp op) : PadOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult PadOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_edge_padding_high = getProperties().edge_padding_high; (void)tblgen_edge_padding_high; + if (!tblgen_edge_padding_high) return emitError(loc, "'stablehlo.pad' op ""requires attribute 'edge_padding_high'"); + auto tblgen_edge_padding_low = getProperties().edge_padding_low; (void)tblgen_edge_padding_low; + if (!tblgen_edge_padding_low) return emitError(loc, "'stablehlo.pad' op ""requires attribute 'edge_padding_low'"); + auto tblgen_interior_padding = getProperties().interior_padding; (void)tblgen_interior_padding; + if (!tblgen_interior_padding) return emitError(loc, "'stablehlo.pad' op ""requires attribute 'interior_padding'"); + + if (tblgen_edge_padding_low && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_edge_padding_low)))) + return emitError(loc, "'stablehlo.pad' op ""attribute 'edge_padding_low' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_edge_padding_high && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_edge_padding_high)))) + return emitError(loc, "'stablehlo.pad' op ""attribute 'edge_padding_high' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_interior_padding && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_interior_padding)))) + return emitError(loc, "'stablehlo.pad' op ""attribute 'interior_padding' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult PadOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.edge_padding_high; + auto attr = dict.get("edge_padding_high"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `edge_padding_high` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.edge_padding_low; + auto attr = dict.get("edge_padding_low"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `edge_padding_low` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.interior_padding; + auto attr = dict.get("interior_padding"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `interior_padding` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute PadOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.edge_padding_high; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("edge_padding_high", + propStorage)); + } + + { + const auto &propStorage = prop.edge_padding_low; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("edge_padding_low", + propStorage)); + } + + { + const auto &propStorage = prop.interior_padding; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("interior_padding", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PadOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.edge_padding_high.getAsOpaquePointer()), + llvm::hash_value(prop.edge_padding_low.getAsOpaquePointer()), + llvm::hash_value(prop.interior_padding.getAsOpaquePointer())); +} + +std::optional PadOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "edge_padding_high") + return prop.edge_padding_high; + + if (name == "edge_padding_low") + return prop.edge_padding_low; + + if (name == "interior_padding") + return prop.interior_padding; + return std::nullopt; +} + +void PadOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "edge_padding_high") { + prop.edge_padding_high = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "edge_padding_low") { + prop.edge_padding_low = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "interior_padding") { + prop.interior_padding = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void PadOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.edge_padding_high) attrs.append("edge_padding_high", prop.edge_padding_high); + + if (prop.edge_padding_low) attrs.append("edge_padding_low", prop.edge_padding_low); + + if (prop.interior_padding) attrs.append("interior_padding", prop.interior_padding); +} + +::llvm::LogicalResult PadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getEdgePaddingHighAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "edge_padding_high", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getEdgePaddingLowAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "edge_padding_low", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInteriorPaddingAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "interior_padding", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult PadOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.edge_padding_high))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.edge_padding_low))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.interior_padding))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PadOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.edge_padding_high); + writer.writeAttribute(prop.edge_padding_low); + writer.writeAttribute(prop.interior_padding); +} + +::llvm::ArrayRef PadOp::getEdgePaddingLow() { + auto attr = getEdgePaddingLowAttr(); + return attr; +} + +::llvm::ArrayRef PadOp::getEdgePaddingHigh() { + auto attr = getEdgePaddingHighAttr(); + return attr; +} + +::llvm::ArrayRef PadOp::getInteriorPadding() { + auto attr = getInteriorPaddingAttr(); + return attr; +} + +void PadOp::setEdgePaddingLow(::llvm::ArrayRef attrValue) { + getProperties().edge_padding_low = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void PadOp::setEdgePaddingHigh(::llvm::ArrayRef attrValue) { + getProperties().edge_padding_high = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void PadOp::setInteriorPadding(::llvm::ArrayRef attrValue) { + getProperties().interior_padding = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::DenseI64ArrayAttr edge_padding_low, ::mlir::DenseI64ArrayAttr edge_padding_high, ::mlir::DenseI64ArrayAttr interior_padding) { + odsState.addOperands(operand); + odsState.addOperands(padding_value); + odsState.getOrAddProperties().edge_padding_low = edge_padding_low; + odsState.getOrAddProperties().edge_padding_high = edge_padding_high; + odsState.getOrAddProperties().interior_padding = interior_padding; + odsState.addTypes(resultType0); +} + +void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::DenseI64ArrayAttr edge_padding_low, ::mlir::DenseI64ArrayAttr edge_padding_high, ::mlir::DenseI64ArrayAttr interior_padding) { + odsState.addOperands(operand); + odsState.addOperands(padding_value); + odsState.getOrAddProperties().edge_padding_low = edge_padding_low; + odsState.getOrAddProperties().edge_padding_high = edge_padding_high; + odsState.getOrAddProperties().interior_padding = interior_padding; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PadOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::DenseI64ArrayAttr edge_padding_low, ::mlir::DenseI64ArrayAttr edge_padding_high, ::mlir::DenseI64ArrayAttr interior_padding) { + odsState.addOperands(operand); + odsState.addOperands(padding_value); + odsState.getOrAddProperties().edge_padding_low = edge_padding_low; + odsState.getOrAddProperties().edge_padding_high = edge_padding_high; + odsState.getOrAddProperties().interior_padding = interior_padding; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value padding_value, ::llvm::ArrayRef edge_padding_low, ::llvm::ArrayRef edge_padding_high, ::llvm::ArrayRef interior_padding) { + odsState.addOperands(operand); + odsState.addOperands(padding_value); + odsState.getOrAddProperties().edge_padding_low = odsBuilder.getDenseI64ArrayAttr(edge_padding_low); + odsState.getOrAddProperties().edge_padding_high = odsBuilder.getDenseI64ArrayAttr(edge_padding_high); + odsState.getOrAddProperties().interior_padding = odsBuilder.getDenseI64ArrayAttr(interior_padding); + odsState.addTypes(resultType0); +} + +void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value padding_value, ::llvm::ArrayRef edge_padding_low, ::llvm::ArrayRef edge_padding_high, ::llvm::ArrayRef interior_padding) { + odsState.addOperands(operand); + odsState.addOperands(padding_value); + odsState.getOrAddProperties().edge_padding_low = odsBuilder.getDenseI64ArrayAttr(edge_padding_low); + odsState.getOrAddProperties().edge_padding_high = odsBuilder.getDenseI64ArrayAttr(edge_padding_high); + odsState.getOrAddProperties().interior_padding = odsBuilder.getDenseI64ArrayAttr(interior_padding); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PadOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value padding_value, ::llvm::ArrayRef edge_padding_low, ::llvm::ArrayRef edge_padding_high, ::llvm::ArrayRef interior_padding) { + odsState.addOperands(operand); + odsState.addOperands(padding_value); + odsState.getOrAddProperties().edge_padding_low = odsBuilder.getDenseI64ArrayAttr(edge_padding_low); + odsState.getOrAddProperties().edge_padding_high = odsBuilder.getDenseI64ArrayAttr(edge_padding_high); + odsState.getOrAddProperties().interior_padding = odsBuilder.getDenseI64ArrayAttr(interior_padding); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PadOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void PadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PadOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult PadOp::verifyInvariantsImpl() { + auto tblgen_edge_padding_high = getProperties().edge_padding_high; (void)tblgen_edge_padding_high; + if (!tblgen_edge_padding_high) return emitOpError("requires attribute 'edge_padding_high'"); + auto tblgen_edge_padding_low = getProperties().edge_padding_low; (void)tblgen_edge_padding_low; + if (!tblgen_edge_padding_low) return emitOpError("requires attribute 'edge_padding_low'"); + auto tblgen_interior_padding = getProperties().interior_padding; (void)tblgen_interior_padding; + if (!tblgen_interior_padding) return emitOpError("requires attribute 'interior_padding'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_edge_padding_low, "edge_padding_low"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_edge_padding_high, "edge_padding_high"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_interior_padding, "interior_padding"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps27(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!(((getEdgePaddingLow().size()) == (getEdgePaddingHigh().size()) && (getEdgePaddingHigh().size()) == (getInteriorPadding().size()) && (getInteriorPadding().size()) == (getEdgePaddingLow().size())))) + return emitOpError("failed to verify that all of {edge_padding_low, edge_padding_high, interior_padding} have same size"); + return ::mlir::success(); +} + +::llvm::LogicalResult PadOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult PadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand padding_valueRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> padding_valueOperands(&padding_valueRawOperand, 1); ::llvm::SMLoc padding_valueOperandsLoc; + (void)padding_valueOperandsLoc; + ::mlir::DenseI64ArrayAttr edge_padding_lowAttr; + ::mlir::DenseI64ArrayAttr edge_padding_highAttr; + ::mlir::DenseI64ArrayAttr interior_paddingAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + padding_valueOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(padding_valueRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("low")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(edge_padding_lowAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (edge_padding_lowAttr) result.getOrAddProperties().edge_padding_low = edge_padding_lowAttr; + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("high")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(edge_padding_highAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (edge_padding_highAttr) result.getOrAddProperties().edge_padding_high = edge_padding_highAttr; + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("interior")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(interior_paddingAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (interior_paddingAttr) result.getOrAddProperties().interior_padding = interior_paddingAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(::llvm::concat(operandOperands, padding_valueOperands), allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PadOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getPaddingValue(); + _odsPrinter << ","; + _odsPrinter << ' ' << "low"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getEdgePaddingLowAttr()); + _odsPrinter << ","; + _odsPrinter << ' ' << "high"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getEdgePaddingHighAttr()); + _odsPrinter << ","; + _odsPrinter << ' ' << "interior"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getInteriorPaddingAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("edge_padding_low"); + elidedAttrs.push_back("edge_padding_high"); + elidedAttrs.push_back("interior_padding"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void PadOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::PadOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::PartitionIdOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PartitionIdOpGenericAdaptorBase::PartitionIdOpGenericAdaptorBase(PartitionIdOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +PartitionIdOpAdaptor::PartitionIdOpAdaptor(PartitionIdOp op) : PartitionIdOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult PartitionIdOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult PartitionIdOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute PartitionIdOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PartitionIdOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional PartitionIdOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void PartitionIdOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void PartitionIdOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult PartitionIdOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void PartitionIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0) { + odsState.addTypes(resultType0); +} + +void PartitionIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PartitionIdOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void PartitionIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PartitionIdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PartitionIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PartitionIdOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void PartitionIdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PartitionIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PartitionIdOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult PartitionIdOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps37(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult PartitionIdOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult PartitionIdOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + return ::mlir::success(); +} + +void PartitionIdOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void PartitionIdOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::PartitionIdOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::PopulationCountOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PopulationCountOpGenericAdaptorBase::PopulationCountOpGenericAdaptorBase(PopulationCountOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +PopulationCountOpAdaptor::PopulationCountOpAdaptor(PopulationCountOp op) : PopulationCountOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult PopulationCountOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult PopulationCountOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute PopulationCountOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PopulationCountOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional PopulationCountOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void PopulationCountOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void PopulationCountOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult PopulationCountOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void PopulationCountOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void PopulationCountOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PopulationCountOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void PopulationCountOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PopulationCountOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PopulationCountOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PopulationCountOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void PopulationCountOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PopulationCountOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PopulationCountOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult PopulationCountOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult PopulationCountOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult PopulationCountOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PopulationCountOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void PopulationCountOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::PopulationCountOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::PowOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PowOpGenericAdaptorBase::PowOpGenericAdaptorBase(PowOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +PowOpAdaptor::PowOpAdaptor(PowOp op) : PowOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult PowOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult PowOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute PowOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PowOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional PowOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void PowOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void PowOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult PowOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void PowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void PowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PowOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void PowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PowOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PowOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void PowOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PowOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult PowOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult PowOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult PowOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PowOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void PowOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::PowOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RealDynamicSliceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RealDynamicSliceOpGenericAdaptorBase::RealDynamicSliceOpGenericAdaptorBase(RealDynamicSliceOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +RealDynamicSliceOpAdaptor::RealDynamicSliceOpAdaptor(RealDynamicSliceOp op) : RealDynamicSliceOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RealDynamicSliceOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult RealDynamicSliceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute RealDynamicSliceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RealDynamicSliceOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional RealDynamicSliceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void RealDynamicSliceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void RealDynamicSliceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult RealDynamicSliceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void RealDynamicSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value limit_indices, ::mlir::Value strides) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(limit_indices); + odsState.addOperands(strides); + odsState.addTypes(result); +} + +void RealDynamicSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value limit_indices, ::mlir::Value strides) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(limit_indices); + odsState.addOperands(strides); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RealDynamicSliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 4u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RealDynamicSliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 4u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RealDynamicSliceOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps38(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps38(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps38(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!(((getElementTypeOrSelf((*this->getODSOperands(0).begin()))) == (getElementTypeOrSelf((*this->getODSResults(0).begin()))) && (getElementTypeOrSelf((*this->getODSResults(0).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(0).begin())))))) + return emitOpError("failed to verify that all of {operand, result} have same element type"); + if (!((((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSOperands(2).begin()).getType()) && ((*this->getODSOperands(2).begin()).getType()) == ((*this->getODSOperands(3).begin()).getType()) && ((*this->getODSOperands(3).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType())))) + return emitOpError("failed to verify that all of {start_indices, limit_indices, strides} have same type"); + return ::mlir::success(); +} + +::llvm::LogicalResult RealDynamicSliceOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult RealDynamicSliceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + [[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(allOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(allOperands, allOperandTypes, allOperandLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RealDynamicSliceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperation()->getOperands(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void RealDynamicSliceOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RealDynamicSliceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RealOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RealOpGenericAdaptorBase::RealOpGenericAdaptorBase(RealOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +RealOpAdaptor::RealOpAdaptor(RealOp op) : RealOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RealOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult RealOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute RealOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RealOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional RealOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void RealOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void RealOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult RealOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void RealOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void RealOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RealOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void RealOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RealOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RealOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RealOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void RealOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RealOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RealOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult RealOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps29(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps32(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RealOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult RealOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RealOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void RealOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RealOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RecvOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RecvOpGenericAdaptorBase::RecvOpGenericAdaptorBase(RecvOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ChannelHandleAttr RecvOpGenericAdaptorBase::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return ::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr); +} + +::mlir::BoolAttr RecvOpGenericAdaptorBase::getIsHostTransferAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().is_host_transfer); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false); + return attr; +} + +bool RecvOpGenericAdaptorBase::getIsHostTransfer() { + auto attr = getIsHostTransferAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +} // namespace detail +RecvOpAdaptor::RecvOpAdaptor(RecvOp op) : RecvOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RecvOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + if (!tblgen_channel_handle) return emitError(loc, "'stablehlo.recv' op ""requires attribute 'channel_handle'"); + auto tblgen_is_host_transfer = getProperties().is_host_transfer; (void)tblgen_is_host_transfer; + + if (tblgen_channel_handle && !((::llvm::isa<::mlir::stablehlo::ChannelHandleAttr>(tblgen_channel_handle)))) + return emitError(loc, "'stablehlo.recv' op ""attribute 'channel_handle' failed to satisfy constraint: two 64-bit integers 'handle' and 'type'"); + + if (tblgen_is_host_transfer && !((::llvm::isa<::mlir::BoolAttr>(tblgen_is_host_transfer)))) + return emitError(loc, "'stablehlo.recv' op ""attribute 'is_host_transfer' failed to satisfy constraint: bool attribute"); + return ::mlir::success(); +} + +std::pair RecvOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult RecvOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_handle; + auto attr = dict.get("channel_handle"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_handle` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.is_host_transfer; + auto attr = dict.get("is_host_transfer"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `is_host_transfer` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute RecvOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_handle; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_handle", + propStorage)); + } + + { + const auto &propStorage = prop.is_host_transfer; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("is_host_transfer", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RecvOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_handle.getAsOpaquePointer()), + llvm::hash_value(prop.is_host_transfer.getAsOpaquePointer())); +} + +std::optional RecvOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_handle") + return prop.channel_handle; + + if (name == "is_host_transfer") + return prop.is_host_transfer; + return std::nullopt; +} + +void RecvOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_handle") { + prop.channel_handle = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "is_host_transfer") { + prop.is_host_transfer = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void RecvOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_handle) attrs.append("channel_handle", prop.channel_handle); + + if (prop.is_host_transfer) attrs.append("is_host_transfer", prop.is_host_transfer); +} + +::llvm::LogicalResult RecvOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelHandleAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(attr, "channel_handle", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIsHostTransferAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(attr, "is_host_transfer", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult RecvOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.channel_handle))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.is_host_transfer))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RecvOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.channel_handle); + + writer.writeOptionalAttribute(prop.is_host_transfer); +} + +::mlir::stablehlo::ChannelHandleAttr RecvOp::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return ::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr); +} + +bool RecvOp::getIsHostTransfer() { + auto attr = getIsHostTransferAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +void RecvOp::setIsHostTransfer(::std::optional attrValue) { + auto &odsProp = getProperties().is_host_transfer; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue); + else + odsProp = nullptr; +} + +void RecvOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::BoolAttr is_host_transfer) { + odsState.addOperands(token); + odsState.getOrAddProperties().channel_handle = channel_handle; + if (is_host_transfer) { + odsState.getOrAddProperties().is_host_transfer = is_host_transfer; + } + odsState.addTypes(resultType0); +} + +void RecvOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool is_host_transfer) { + odsState.addOperands(token); + odsState.getOrAddProperties().channel_handle = channel_handle; + odsState.getOrAddProperties().is_host_transfer = odsBuilder.getBoolAttr(is_host_transfer); + odsState.addTypes(resultType0); +} + +void RecvOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void RecvOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RecvOp::verifyInvariantsImpl() { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + if (!tblgen_channel_handle) return emitOpError("requires attribute 'channel_handle'"); + auto tblgen_is_host_transfer = getProperties().is_host_transfer; (void)tblgen_is_host_transfer; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(*this, tblgen_channel_handle, "channel_handle"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(*this, tblgen_is_host_transfer, "is_host_transfer"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps33(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RecvOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +void RecvOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { + effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::stablehlo::side_effects::RecvResource::get()); + effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::stablehlo::side_effects::RecvResource::get()); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RecvOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReduceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReduceOpGenericAdaptorBase::ReduceOpGenericAdaptorBase(ReduceOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair ReduceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::ArrayRef ReduceOpGenericAdaptorBase::getDimensions() { + auto attr = getDimensionsAttr(); + return attr; +} + +} // namespace detail +ReduceOpAdaptor::ReduceOpAdaptor(ReduceOp op) : ReduceOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReduceOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_dimensions = getProperties().dimensions; (void)tblgen_dimensions; + if (!tblgen_dimensions) return emitError(loc, "'stablehlo.reduce' op ""requires attribute 'dimensions'"); + + if (tblgen_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_dimensions)))) + return emitError(loc, "'stablehlo.reduce' op ""attribute 'dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +std::pair ReduceOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange ReduceOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::mlir::MutableOperandRange ReduceOp::getInitValuesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ReduceOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult ReduceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimensions; + auto attr = dict.get("dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ReduceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReduceOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimensions.getAsOpaquePointer())); +} + +std::optional ReduceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimensions") + return prop.dimensions; + return std::nullopt; +} + +void ReduceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimensions") { + prop.dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ReduceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimensions) attrs.append("dimensions", prop.dimensions); +} + +::llvm::LogicalResult ReduceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReduceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimensions); +} + +::llvm::ArrayRef ReduceOp::getDimensions() { + auto attr = getDimensionsAttr(); + return attr; +} + +void ReduceOp::setDimensions(::llvm::ArrayRef attrValue) { + getProperties().dimensions = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void ReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::mlir::DenseI64ArrayAttr dimensions) { + odsState.addOperands(inputs); + odsState.addOperands(init_values); + odsState.getOrAddProperties().dimensions = dimensions; + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void ReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::mlir::DenseI64ArrayAttr dimensions) { + odsState.addOperands(inputs); + odsState.addOperands(init_values); + odsState.getOrAddProperties().dimensions = dimensions; + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReduceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::llvm::ArrayRef dimensions) { + odsState.addOperands(inputs); + odsState.addOperands(init_values); + odsState.getOrAddProperties().dimensions = odsBuilder.getDenseI64ArrayAttr(dimensions); + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void ReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::llvm::ArrayRef dimensions) { + odsState.addOperands(inputs); + odsState.addOperands(init_values); + odsState.getOrAddProperties().dimensions = odsBuilder.getDenseI64ArrayAttr(dimensions); + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReduceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ReduceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReduceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ReduceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void ReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReduceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ReduceOp::verifyInvariantsImpl() { + auto tblgen_dimensions = getProperties().dimensions; (void)tblgen_dimensions; + if (!tblgen_dimensions) return emitOpError("requires attribute 'dimensions'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_dimensions, "dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "body", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::llvm::LogicalResult +ReduceOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(ReduceOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReduceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReducePrecisionOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReducePrecisionOpGenericAdaptorBase::ReducePrecisionOpGenericAdaptorBase(ReducePrecisionOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +uint32_t ReducePrecisionOpGenericAdaptorBase::getExponentBits() { + auto attr = getExponentBitsAttr(); + return attr.getValue().getZExtValue(); +} + +uint32_t ReducePrecisionOpGenericAdaptorBase::getMantissaBits() { + auto attr = getMantissaBitsAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +ReducePrecisionOpAdaptor::ReducePrecisionOpAdaptor(ReducePrecisionOp op) : ReducePrecisionOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReducePrecisionOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_exponent_bits = getProperties().exponent_bits; (void)tblgen_exponent_bits; + if (!tblgen_exponent_bits) return emitError(loc, "'stablehlo.reduce_precision' op ""requires attribute 'exponent_bits'"); + auto tblgen_mantissa_bits = getProperties().mantissa_bits; (void)tblgen_mantissa_bits; + if (!tblgen_mantissa_bits) return emitError(loc, "'stablehlo.reduce_precision' op ""requires attribute 'mantissa_bits'"); + + if (tblgen_exponent_bits && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_exponent_bits))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_exponent_bits).getType().isSignlessInteger(32)))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_exponent_bits).getValue().isStrictlyPositive())))) + return emitError(loc, "'stablehlo.reduce_precision' op ""attribute 'exponent_bits' failed to satisfy constraint: 32-bit signless integer attribute whose value is positive"); + + if (tblgen_mantissa_bits && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_mantissa_bits))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_mantissa_bits).getType().isSignlessInteger(32)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_mantissa_bits).getValue().isNegative())))) + return emitError(loc, "'stablehlo.reduce_precision' op ""attribute 'mantissa_bits' failed to satisfy constraint: 32-bit signless integer attribute whose value is non-negative"); + return ::mlir::success(); +} + +::llvm::LogicalResult ReducePrecisionOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.exponent_bits; + auto attr = dict.get("exponent_bits"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `exponent_bits` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.mantissa_bits; + auto attr = dict.get("mantissa_bits"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `mantissa_bits` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ReducePrecisionOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.exponent_bits; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("exponent_bits", + propStorage)); + } + + { + const auto &propStorage = prop.mantissa_bits; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("mantissa_bits", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReducePrecisionOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.exponent_bits.getAsOpaquePointer()), + llvm::hash_value(prop.mantissa_bits.getAsOpaquePointer())); +} + +std::optional ReducePrecisionOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "exponent_bits") + return prop.exponent_bits; + + if (name == "mantissa_bits") + return prop.mantissa_bits; + return std::nullopt; +} + +void ReducePrecisionOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "exponent_bits") { + prop.exponent_bits = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "mantissa_bits") { + prop.mantissa_bits = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ReducePrecisionOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.exponent_bits) attrs.append("exponent_bits", prop.exponent_bits); + + if (prop.mantissa_bits) attrs.append("mantissa_bits", prop.mantissa_bits); +} + +::llvm::LogicalResult ReducePrecisionOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getExponentBitsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps31(attr, "exponent_bits", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getMantissaBitsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps29(attr, "mantissa_bits", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReducePrecisionOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.exponent_bits))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.mantissa_bits))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReducePrecisionOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.exponent_bits); + writer.writeAttribute(prop.mantissa_bits); +} + +uint32_t ReducePrecisionOp::getExponentBits() { + auto attr = getExponentBitsAttr(); + return attr.getValue().getZExtValue(); +} + +uint32_t ReducePrecisionOp::getMantissaBits() { + auto attr = getMantissaBitsAttr(); + return attr.getValue().getZExtValue(); +} + +void ReducePrecisionOp::setExponentBits(uint32_t attrValue) { + getProperties().exponent_bits = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); +} + +void ReducePrecisionOp::setMantissaBits(uint32_t attrValue) { + getProperties().mantissa_bits = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue); +} + +void ReducePrecisionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value operand, ::mlir::IntegerAttr exponent_bits, ::mlir::IntegerAttr mantissa_bits) { + odsState.addOperands(operand); + odsState.getOrAddProperties().exponent_bits = exponent_bits; + odsState.getOrAddProperties().mantissa_bits = mantissa_bits; + odsState.addTypes(output); +} + +void ReducePrecisionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::IntegerAttr exponent_bits, ::mlir::IntegerAttr mantissa_bits) { + odsState.addOperands(operand); + odsState.getOrAddProperties().exponent_bits = exponent_bits; + odsState.getOrAddProperties().mantissa_bits = mantissa_bits; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReducePrecisionOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ReducePrecisionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::IntegerAttr exponent_bits, ::mlir::IntegerAttr mantissa_bits) { + odsState.addOperands(operand); + odsState.getOrAddProperties().exponent_bits = exponent_bits; + odsState.getOrAddProperties().mantissa_bits = mantissa_bits; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReducePrecisionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value operand, uint32_t exponent_bits, uint32_t mantissa_bits) { + odsState.addOperands(operand); + odsState.getOrAddProperties().exponent_bits = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), exponent_bits); + odsState.getOrAddProperties().mantissa_bits = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), mantissa_bits); + odsState.addTypes(output); +} + +void ReducePrecisionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, uint32_t exponent_bits, uint32_t mantissa_bits) { + odsState.addOperands(operand); + odsState.getOrAddProperties().exponent_bits = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), exponent_bits); + odsState.getOrAddProperties().mantissa_bits = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), mantissa_bits); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReducePrecisionOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ReducePrecisionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, uint32_t exponent_bits, uint32_t mantissa_bits) { + odsState.addOperands(operand); + odsState.getOrAddProperties().exponent_bits = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), exponent_bits); + odsState.getOrAddProperties().mantissa_bits = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), mantissa_bits); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReducePrecisionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ReducePrecisionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReducePrecisionOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ReducePrecisionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ReducePrecisionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReducePrecisionOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ReducePrecisionOp::verifyInvariantsImpl() { + auto tblgen_exponent_bits = getProperties().exponent_bits; (void)tblgen_exponent_bits; + if (!tblgen_exponent_bits) return emitOpError("requires attribute 'exponent_bits'"); + auto tblgen_mantissa_bits = getProperties().mantissa_bits; (void)tblgen_mantissa_bits; + if (!tblgen_mantissa_bits) return emitOpError("requires attribute 'mantissa_bits'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps31(*this, tblgen_exponent_bits, "exponent_bits"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps29(*this, tblgen_mantissa_bits, "mantissa_bits"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReducePrecisionOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ReducePrecisionOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::IntegerAttr exponent_bitsAttr; + ::mlir::IntegerAttr mantissa_bitsAttr; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type outputRawType{}; + ::llvm::ArrayRef<::mlir::Type> outputTypes(&outputRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("format")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + { + auto odsResult = parseExponentMantissa(parser, exponent_bitsAttr, mantissa_bitsAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().exponent_bits = exponent_bitsAttr; + result.getOrAddProperties().mantissa_bits = mantissa_bitsAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, outputRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(outputTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReducePrecisionOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' ' << "format"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + printExponentMantissa(_odsPrinter, *this, getExponentBitsAttr(), getMantissaBitsAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("exponent_bits"); + elidedAttrs.push_back("mantissa_bits"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getOutput().getType()); +} + +void ReducePrecisionOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReducePrecisionOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReduceScatterOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReduceScatterOpGenericAdaptorBase::ReduceScatterOpGenericAdaptorBase(ReduceScatterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +uint64_t ReduceScatterOpGenericAdaptorBase::getScatterDimension() { + auto attr = getScatterDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::DenseIntElementsAttr ReduceScatterOpGenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::std::optional<::mlir::stablehlo::ChannelHandleAttr> ReduceScatterOpGenericAdaptorBase::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ChannelHandleAttr>(::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr)) : (::std::nullopt); +} + +::mlir::UnitAttr ReduceScatterOpGenericAdaptorBase::getUseGlobalDeviceIdsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().use_global_device_ids); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool ReduceScatterOpGenericAdaptorBase::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +} // namespace detail +ReduceScatterOpAdaptor::ReduceScatterOpAdaptor(ReduceScatterOp op) : ReduceScatterOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReduceScatterOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'stablehlo.reduce_scatter' op ""requires attribute 'replica_groups'"); + auto tblgen_scatter_dimension = getProperties().scatter_dimension; (void)tblgen_scatter_dimension; + if (!tblgen_scatter_dimension) return emitError(loc, "'stablehlo.reduce_scatter' op ""requires attribute 'scatter_dimension'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + + if (tblgen_scatter_dimension && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_scatter_dimension))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_scatter_dimension).getType().isSignlessInteger(64)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_scatter_dimension).getValue().isNegative())))) + return emitError(loc, "'stablehlo.reduce_scatter' op ""attribute 'scatter_dimension' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative"); + + if (tblgen_replica_groups && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(tblgen_replica_groups))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(tblgen_replica_groups).getType().getElementType().isSignlessInteger(64))))) + return emitError(loc, "'stablehlo.reduce_scatter' op ""attribute 'replica_groups' failed to satisfy constraint: 64-bit signless integer elements attribute"); + + if (tblgen_channel_handle && !((::llvm::isa<::mlir::stablehlo::ChannelHandleAttr>(tblgen_channel_handle)))) + return emitError(loc, "'stablehlo.reduce_scatter' op ""attribute 'channel_handle' failed to satisfy constraint: two 64-bit integers 'handle' and 'type'"); + + if (tblgen_use_global_device_ids && !((::llvm::isa<::mlir::UnitAttr>(tblgen_use_global_device_ids)))) + return emitError(loc, "'stablehlo.reduce_scatter' op ""attribute 'use_global_device_ids' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceScatterOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_handle; + auto attr = dict.get("channel_handle"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_handle` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.scatter_dimension; + auto attr = dict.get("scatter_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `scatter_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.use_global_device_ids; + auto attr = dict.get("use_global_device_ids"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `use_global_device_ids` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ReduceScatterOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_handle; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_handle", + propStorage)); + } + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + { + const auto &propStorage = prop.scatter_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("scatter_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.use_global_device_ids; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("use_global_device_ids", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReduceScatterOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_handle.getAsOpaquePointer()), + llvm::hash_value(prop.replica_groups.getAsOpaquePointer()), + llvm::hash_value(prop.scatter_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.use_global_device_ids.getAsOpaquePointer())); +} + +std::optional ReduceScatterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_handle") + return prop.channel_handle; + + if (name == "replica_groups") + return prop.replica_groups; + + if (name == "scatter_dimension") + return prop.scatter_dimension; + + if (name == "use_global_device_ids") + return prop.use_global_device_ids; + return std::nullopt; +} + +void ReduceScatterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_handle") { + prop.channel_handle = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "scatter_dimension") { + prop.scatter_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "use_global_device_ids") { + prop.use_global_device_ids = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ReduceScatterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_handle) attrs.append("channel_handle", prop.channel_handle); + + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); + + if (prop.scatter_dimension) attrs.append("scatter_dimension", prop.scatter_dimension); + + if (prop.use_global_device_ids) attrs.append("use_global_device_ids", prop.use_global_device_ids); +} + +::llvm::LogicalResult ReduceScatterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelHandleAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(attr, "channel_handle", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getScatterDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(attr, "scatter_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUseGlobalDeviceIdsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps4(attr, "use_global_device_ids", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceScatterOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.channel_handle))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.scatter_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.use_global_device_ids))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReduceScatterOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.channel_handle); + writer.writeAttribute(prop.replica_groups); + writer.writeAttribute(prop.scatter_dimension); + + writer.writeOptionalAttribute(prop.use_global_device_ids); +} + +uint64_t ReduceScatterOp::getScatterDimension() { + auto attr = getScatterDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::DenseIntElementsAttr ReduceScatterOp::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::std::optional<::mlir::stablehlo::ChannelHandleAttr> ReduceScatterOp::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return attr ? ::std::optional<::mlir::stablehlo::ChannelHandleAttr>(::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr)) : (::std::nullopt); +} + +bool ReduceScatterOp::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void ReduceScatterOp::setScatterDimension(uint64_t attrValue) { + getProperties().scatter_dimension = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void ReduceScatterOp::setUseGlobalDeviceIds(bool attrValue) { + auto &odsProp = getProperties().use_global_device_ids; + if (attrValue) + odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr); + else + odsProp = nullptr; +} + +void ReduceScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::IntegerAttr scatter_dimension, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::UnitAttr use_global_device_ids) { + odsState.addOperands(operand); + odsState.getOrAddProperties().scatter_dimension = scatter_dimension; + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + if (use_global_device_ids) { + odsState.getOrAddProperties().use_global_device_ids = use_global_device_ids; + } + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void ReduceScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::IntegerAttr scatter_dimension, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::UnitAttr use_global_device_ids) { + odsState.addOperands(operand); + odsState.getOrAddProperties().scatter_dimension = scatter_dimension; + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + if (use_global_device_ids) { + odsState.getOrAddProperties().use_global_device_ids = use_global_device_ids; + } + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReduceScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, uint64_t scatter_dimension, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool use_global_device_ids) { + odsState.addOperands(operand); + odsState.getOrAddProperties().scatter_dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), scatter_dimension); + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + if (use_global_device_ids) { + odsState.getOrAddProperties().use_global_device_ids = ((use_global_device_ids) ? odsBuilder.getUnitAttr() : nullptr); + } + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void ReduceScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, uint64_t scatter_dimension, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool use_global_device_ids) { + odsState.addOperands(operand); + odsState.getOrAddProperties().scatter_dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), scatter_dimension); + odsState.getOrAddProperties().replica_groups = replica_groups; + if (channel_handle) { + odsState.getOrAddProperties().channel_handle = channel_handle; + } + if (use_global_device_ids) { + odsState.getOrAddProperties().use_global_device_ids = ((use_global_device_ids) ? odsBuilder.getUnitAttr() : nullptr); + } + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReduceScatterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ReduceScatterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ReduceScatterOp::verifyInvariantsImpl() { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + auto tblgen_scatter_dimension = getProperties().scatter_dimension; (void)tblgen_scatter_dimension; + if (!tblgen_scatter_dimension) return emitOpError("requires attribute 'scatter_dimension'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(*this, tblgen_scatter_dimension, "scatter_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(*this, tblgen_channel_handle, "channel_handle"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps4(*this, tblgen_use_global_device_ids, "use_global_device_ids"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "computation", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceScatterOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReduceScatterOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReduceWindowOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReduceWindowOpGenericAdaptorBase::ReduceWindowOpGenericAdaptorBase(ReduceWindowOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair ReduceWindowOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::ArrayRef ReduceWindowOpGenericAdaptorBase::getWindowDimensions() { + auto attr = getWindowDimensionsAttr(); + return attr; +} + +::std::optional<::llvm::ArrayRef> ReduceWindowOpGenericAdaptorBase::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> ReduceWindowOpGenericAdaptorBase::getBaseDilations() { + auto attr = getBaseDilationsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> ReduceWindowOpGenericAdaptorBase::getWindowDilations() { + auto attr = getWindowDilationsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional< ::mlir::DenseIntElementsAttr > ReduceWindowOpGenericAdaptorBase::getPadding() { + auto attr = getPaddingAttr(); + return attr ? ::std::optional< ::mlir::DenseIntElementsAttr >(attr) : (::std::nullopt); +} + +} // namespace detail +ReduceWindowOpAdaptor::ReduceWindowOpAdaptor(ReduceWindowOp op) : ReduceWindowOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReduceWindowOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_base_dilations = getProperties().base_dilations; (void)tblgen_base_dilations; + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + auto tblgen_window_dilations = getProperties().window_dilations; (void)tblgen_window_dilations; + auto tblgen_window_dimensions = getProperties().window_dimensions; (void)tblgen_window_dimensions; + if (!tblgen_window_dimensions) return emitError(loc, "'stablehlo.reduce_window' op ""requires attribute 'window_dimensions'"); + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + + if (tblgen_window_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_window_dimensions)))) + return emitError(loc, "'stablehlo.reduce_window' op ""attribute 'window_dimensions' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_window_strides && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_window_strides)))) + return emitError(loc, "'stablehlo.reduce_window' op ""attribute 'window_strides' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_base_dilations && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_base_dilations)))) + return emitError(loc, "'stablehlo.reduce_window' op ""attribute 'base_dilations' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_window_dilations && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_window_dilations)))) + return emitError(loc, "'stablehlo.reduce_window' op ""attribute 'window_dilations' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_padding && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(tblgen_padding))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(tblgen_padding).getType().getElementType().isSignlessInteger(64))))) + return emitError(loc, "'stablehlo.reduce_window' op ""attribute 'padding' failed to satisfy constraint: 64-bit signless integer elements attribute"); + return ::mlir::success(); +} + +std::pair ReduceWindowOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange ReduceWindowOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::mlir::MutableOperandRange ReduceWindowOp::getInitValuesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ReduceWindowOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult ReduceWindowOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.base_dilations; + auto attr = dict.get("base_dilations"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `base_dilations` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.padding; + auto attr = dict.get("padding"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `padding` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_dilations; + auto attr = dict.get("window_dilations"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_dilations` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_dimensions; + auto attr = dict.get("window_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_strides; + auto attr = dict.get("window_strides"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ReduceWindowOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.base_dilations; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("base_dilations", + propStorage)); + } + + { + const auto &propStorage = prop.padding; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("padding", + propStorage)); + } + + { + const auto &propStorage = prop.window_dilations; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_dilations", + propStorage)); + } + + { + const auto &propStorage = prop.window_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.window_strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_strides", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReduceWindowOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.base_dilations.getAsOpaquePointer()), + llvm::hash_value(prop.padding.getAsOpaquePointer()), + llvm::hash_value(prop.window_dilations.getAsOpaquePointer()), + llvm::hash_value(prop.window_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.window_strides.getAsOpaquePointer())); +} + +std::optional ReduceWindowOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "base_dilations") + return prop.base_dilations; + + if (name == "padding") + return prop.padding; + + if (name == "window_dilations") + return prop.window_dilations; + + if (name == "window_dimensions") + return prop.window_dimensions; + + if (name == "window_strides") + return prop.window_strides; + return std::nullopt; +} + +void ReduceWindowOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "base_dilations") { + prop.base_dilations = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "padding") { + prop.padding = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_dilations") { + prop.window_dilations = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_dimensions") { + prop.window_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_strides") { + prop.window_strides = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ReduceWindowOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.base_dilations) attrs.append("base_dilations", prop.base_dilations); + + if (prop.padding) attrs.append("padding", prop.padding); + + if (prop.window_dilations) attrs.append("window_dilations", prop.window_dilations); + + if (prop.window_dimensions) attrs.append("window_dimensions", prop.window_dimensions); + + if (prop.window_strides) attrs.append("window_strides", prop.window_strides); +} + +::llvm::LogicalResult ReduceWindowOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBaseDilationsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "base_dilations", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPaddingAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(attr, "padding", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowDilationsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "window_dilations", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "window_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "window_strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceWindowOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.base_dilations))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.padding))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.window_dilations))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.window_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.window_strides))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReduceWindowOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.base_dilations); + + writer.writeOptionalAttribute(prop.padding); + + writer.writeOptionalAttribute(prop.window_dilations); + writer.writeAttribute(prop.window_dimensions); + + writer.writeOptionalAttribute(prop.window_strides); +} + +::llvm::ArrayRef ReduceWindowOp::getWindowDimensions() { + auto attr = getWindowDimensionsAttr(); + return attr; +} + +::std::optional<::llvm::ArrayRef> ReduceWindowOp::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> ReduceWindowOp::getBaseDilations() { + auto attr = getBaseDilationsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> ReduceWindowOp::getWindowDilations() { + auto attr = getWindowDilationsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional< ::mlir::DenseIntElementsAttr > ReduceWindowOp::getPadding() { + auto attr = getPaddingAttr(); + return attr ? ::std::optional< ::mlir::DenseIntElementsAttr >(attr) : (::std::nullopt); +} + +void ReduceWindowOp::setWindowDimensions(::llvm::ArrayRef attrValue) { + getProperties().window_dimensions = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void ReduceWindowOp::setWindowStrides(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().window_strides; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void ReduceWindowOp::setBaseDilations(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().base_dilations; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void ReduceWindowOp::setWindowDilations(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().window_dilations; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void ReduceWindowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type result_type, Value operand, Value init_value, DenseI64ArrayAttr window_dimensions, DenseI64ArrayAttr window_strides, DenseI64ArrayAttr base_dilations, DenseI64ArrayAttr window_dilations, DenseIntElementsAttr padding) { + build(odsBuilder, odsState, TypeRange(result_type), ValueRange(operand), + ValueRange(init_value), window_dimensions, window_strides, + base_dilations, window_dilations, padding); + +} + +void ReduceWindowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::mlir::DenseI64ArrayAttr window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr base_dilations, /*optional*/::mlir::DenseI64ArrayAttr window_dilations, /*optional*/::mlir::DenseIntElementsAttr padding) { + odsState.addOperands(inputs); + odsState.addOperands(init_values); + odsState.getOrAddProperties().window_dimensions = window_dimensions; + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (base_dilations) { + odsState.getOrAddProperties().base_dilations = base_dilations; + } + if (window_dilations) { + odsState.getOrAddProperties().window_dilations = window_dilations; + } + if (padding) { + odsState.getOrAddProperties().padding = padding; + } + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void ReduceWindowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::mlir::DenseI64ArrayAttr window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr base_dilations, /*optional*/::mlir::DenseI64ArrayAttr window_dilations, /*optional*/::mlir::DenseIntElementsAttr padding) { + odsState.addOperands(inputs); + odsState.addOperands(init_values); + odsState.getOrAddProperties().window_dimensions = window_dimensions; + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (base_dilations) { + odsState.getOrAddProperties().base_dilations = base_dilations; + } + if (window_dilations) { + odsState.getOrAddProperties().window_dilations = window_dilations; + } + if (padding) { + odsState.getOrAddProperties().padding = padding; + } + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReduceWindowOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ReduceWindowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::llvm::ArrayRef window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr base_dilations, /*optional*/::mlir::DenseI64ArrayAttr window_dilations, /*optional*/::mlir::DenseIntElementsAttr padding) { + odsState.addOperands(inputs); + odsState.addOperands(init_values); + odsState.getOrAddProperties().window_dimensions = odsBuilder.getDenseI64ArrayAttr(window_dimensions); + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (base_dilations) { + odsState.getOrAddProperties().base_dilations = base_dilations; + } + if (window_dilations) { + odsState.getOrAddProperties().window_dilations = window_dilations; + } + if (padding) { + odsState.getOrAddProperties().padding = padding; + } + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void ReduceWindowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::llvm::ArrayRef window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr base_dilations, /*optional*/::mlir::DenseI64ArrayAttr window_dilations, /*optional*/::mlir::DenseIntElementsAttr padding) { + odsState.addOperands(inputs); + odsState.addOperands(init_values); + odsState.getOrAddProperties().window_dimensions = odsBuilder.getDenseI64ArrayAttr(window_dimensions); + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (base_dilations) { + odsState.getOrAddProperties().base_dilations = base_dilations; + } + if (window_dilations) { + odsState.getOrAddProperties().window_dilations = window_dilations; + } + if (padding) { + odsState.getOrAddProperties().padding = padding; + } + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReduceWindowOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ReduceWindowOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ReduceWindowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReduceWindowOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ReduceWindowOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void ReduceWindowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReduceWindowOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ReduceWindowOp::verifyInvariantsImpl() { + auto tblgen_base_dilations = getProperties().base_dilations; (void)tblgen_base_dilations; + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + auto tblgen_window_dilations = getProperties().window_dilations; (void)tblgen_window_dilations; + auto tblgen_window_dimensions = getProperties().window_dimensions; (void)tblgen_window_dimensions; + if (!tblgen_window_dimensions) return emitOpError("requires attribute 'window_dimensions'"); + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_window_dimensions, "window_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_window_strides, "window_strides"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_base_dilations, "base_dilations"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_window_dilations, "window_dilations"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(*this, tblgen_padding, "padding"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "body", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceWindowOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::llvm::LogicalResult +ReduceWindowOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(ReduceWindowOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReduceWindowOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RemOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RemOpGenericAdaptorBase::RemOpGenericAdaptorBase(RemOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +RemOpAdaptor::RemOpAdaptor(RemOp op) : RemOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RemOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult RemOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute RemOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RemOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional RemOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void RemOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void RemOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult RemOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void RemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void RemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RemOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void RemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RemOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RemOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void RemOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RemOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RemOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult RemOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RemOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult RemOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RemOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void RemOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RemOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReplicaIdOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReplicaIdOpGenericAdaptorBase::ReplicaIdOpGenericAdaptorBase(ReplicaIdOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ReplicaIdOpAdaptor::ReplicaIdOpAdaptor(ReplicaIdOp op) : ReplicaIdOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReplicaIdOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ReplicaIdOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ReplicaIdOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReplicaIdOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ReplicaIdOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ReplicaIdOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ReplicaIdOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ReplicaIdOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ReplicaIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0) { + odsState.addTypes(resultType0); +} + +void ReplicaIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReplicaIdOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ReplicaIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReplicaIdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ReplicaIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReplicaIdOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ReplicaIdOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ReplicaIdOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReplicaIdOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ReplicaIdOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps37(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReplicaIdOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ReplicaIdOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + return ::mlir::success(); +} + +void ReplicaIdOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void ReplicaIdOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReplicaIdOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReshapeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReshapeOpGenericAdaptorBase::ReshapeOpGenericAdaptorBase(ReshapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ReshapeOpAdaptor::ReshapeOpAdaptor(ReshapeOp op) : ReshapeOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReshapeOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ReshapeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ReshapeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReshapeOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ReshapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ReshapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ReshapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ReshapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(resultType0); +} + +void ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReshapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ReshapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ReshapeOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps12(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReshapeOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ReshapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + [[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(allOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(allOperands, allOperandTypes, allOperandLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReshapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperation()->getOperands(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void ReshapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReshapeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReturnOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReturnOpGenericAdaptorBase::ReturnOpGenericAdaptorBase(ReturnOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair ReturnOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +} // namespace detail +ReturnOpAdaptor::ReturnOpAdaptor(ReturnOp op) : ReturnOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReturnOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ReturnOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange ReturnOp::getResultsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult ReturnOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ReturnOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReturnOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ReturnOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ReturnOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ReturnOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ReturnOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ReturnOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange results) { + odsState.addOperands(results); +} + +void ReturnOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ReturnOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ReturnOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps14(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReturnOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ReturnOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> resultsOperands; + ::llvm::SMLoc resultsOperandsLoc; + (void)resultsOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> resultsTypes; + + resultsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(resultsOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (::mlir::succeeded(parser.parseOptionalColon())) { + + if (parser.parseTypeList(resultsTypes)) + return ::mlir::failure(); + } + if (parser.resolveOperands(resultsOperands, resultsTypes, resultsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReturnOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getResults(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (!getResults().empty()) { + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getResults().getTypes(); + } +} + +void ReturnOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReturnOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReverseOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReverseOpGenericAdaptorBase::ReverseOpGenericAdaptorBase(ReverseOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::llvm::ArrayRef ReverseOpGenericAdaptorBase::getDimensions() { + auto attr = getDimensionsAttr(); + return attr; +} + +} // namespace detail +ReverseOpAdaptor::ReverseOpAdaptor(ReverseOp op) : ReverseOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReverseOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_dimensions = getProperties().dimensions; (void)tblgen_dimensions; + if (!tblgen_dimensions) return emitError(loc, "'stablehlo.reverse' op ""requires attribute 'dimensions'"); + + if (tblgen_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_dimensions)))) + return emitError(loc, "'stablehlo.reverse' op ""attribute 'dimensions' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult ReverseOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimensions; + auto attr = dict.get("dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ReverseOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReverseOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimensions.getAsOpaquePointer())); +} + +std::optional ReverseOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimensions") + return prop.dimensions; + return std::nullopt; +} + +void ReverseOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimensions") { + prop.dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ReverseOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimensions) attrs.append("dimensions", prop.dimensions); +} + +::llvm::LogicalResult ReverseOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReverseOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReverseOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimensions); +} + +::llvm::ArrayRef ReverseOp::getDimensions() { + auto attr = getDimensionsAttr(); + return attr; +} + +void ReverseOp::setDimensions(::llvm::ArrayRef attrValue) { + getProperties().dimensions = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void ReverseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimensions = dimensions; + odsState.addTypes(result); +} + +void ReverseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimensions = dimensions; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReverseOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ReverseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimensions = dimensions; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReverseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::llvm::ArrayRef dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimensions = odsBuilder.getDenseI64ArrayAttr(dimensions); + odsState.addTypes(result); +} + +void ReverseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::llvm::ArrayRef dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimensions = odsBuilder.getDenseI64ArrayAttr(dimensions); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReverseOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ReverseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::llvm::ArrayRef dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimensions = odsBuilder.getDenseI64ArrayAttr(dimensions); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReverseOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ReverseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReverseOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ReverseOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ReverseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReverseOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ReverseOp::verifyInvariantsImpl() { + auto tblgen_dimensions = getProperties().dimensions; (void)tblgen_dimensions; + if (!tblgen_dimensions) return emitOpError("requires attribute 'dimensions'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_dimensions, "dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReverseOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ReverseOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::DenseI64ArrayAttr dimensionsAttr; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("dims")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(dimensionsAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (dimensionsAttr) result.getOrAddProperties().dimensions = dimensionsAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReverseOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' ' << "dims"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getDimensionsAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("dimensions"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void ReverseOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReverseOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RngBitGeneratorOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RngBitGeneratorOpGenericAdaptorBase::RngBitGeneratorOpGenericAdaptorBase(RngBitGeneratorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::RngAlgorithm RngBitGeneratorOpGenericAdaptorBase::getRngAlgorithm() { + auto attr = getRngAlgorithmAttr(); + return attr.getValue(); +} + +} // namespace detail +RngBitGeneratorOpAdaptor::RngBitGeneratorOpAdaptor(RngBitGeneratorOp op) : RngBitGeneratorOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RngBitGeneratorOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_rng_algorithm = getProperties().rng_algorithm; (void)tblgen_rng_algorithm; + if (!tblgen_rng_algorithm) return emitError(loc, "'stablehlo.rng_bit_generator' op ""requires attribute 'rng_algorithm'"); + + if (tblgen_rng_algorithm && !((::llvm::isa<::mlir::stablehlo::RngAlgorithmAttr>(tblgen_rng_algorithm)))) + return emitError(loc, "'stablehlo.rng_bit_generator' op ""attribute 'rng_algorithm' failed to satisfy constraint: XLA PRNG algorithm to be used."); + return ::mlir::success(); +} + +void RngBitGeneratorOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { + auto resultGroup0 = getODSResults(0); + if (!resultGroup0.empty()) + setNameFn(*resultGroup0.begin(), "output_state"); + auto resultGroup1 = getODSResults(1); + if (!resultGroup1.empty()) + setNameFn(*resultGroup1.begin(), "output"); +} + +::llvm::LogicalResult RngBitGeneratorOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.rng_algorithm; + auto attr = dict.get("rng_algorithm"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rng_algorithm` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute RngBitGeneratorOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.rng_algorithm; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rng_algorithm", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RngBitGeneratorOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.rng_algorithm.getAsOpaquePointer())); +} + +std::optional RngBitGeneratorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "rng_algorithm") + return prop.rng_algorithm; + return std::nullopt; +} + +void RngBitGeneratorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "rng_algorithm") { + prop.rng_algorithm = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void RngBitGeneratorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.rng_algorithm) attrs.append("rng_algorithm", prop.rng_algorithm); +} + +::llvm::LogicalResult RngBitGeneratorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getRngAlgorithmAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps32(attr, "rng_algorithm", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult RngBitGeneratorOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.rng_algorithm))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RngBitGeneratorOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.rng_algorithm); +} + +::mlir::stablehlo::RngAlgorithm RngBitGeneratorOp::getRngAlgorithm() { + auto attr = getRngAlgorithmAttr(); + return attr.getValue(); +} + +void RngBitGeneratorOp::setRngAlgorithm(::mlir::stablehlo::RngAlgorithm attrValue) { + getProperties().rng_algorithm = ::mlir::stablehlo::RngAlgorithmAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); +} + +void RngBitGeneratorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_state, ::mlir::Type output, ::mlir::stablehlo::RngAlgorithmAttr rng_algorithm, ::mlir::Value initial_state) { + odsState.addOperands(initial_state); + odsState.getOrAddProperties().rng_algorithm = rng_algorithm; + odsState.addTypes(output_state); + odsState.addTypes(output); +} + +void RngBitGeneratorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::stablehlo::RngAlgorithmAttr rng_algorithm, ::mlir::Value initial_state) { + odsState.addOperands(initial_state); + odsState.getOrAddProperties().rng_algorithm = rng_algorithm; + assert(resultTypes.size() == 2u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RngBitGeneratorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_state, ::mlir::Type output, ::mlir::stablehlo::RngAlgorithm rng_algorithm, ::mlir::Value initial_state) { + odsState.addOperands(initial_state); + odsState.getOrAddProperties().rng_algorithm = ::mlir::stablehlo::RngAlgorithmAttr::get(odsBuilder.getContext(), rng_algorithm); + odsState.addTypes(output_state); + odsState.addTypes(output); +} + +void RngBitGeneratorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::stablehlo::RngAlgorithm rng_algorithm, ::mlir::Value initial_state) { + odsState.addOperands(initial_state); + odsState.getOrAddProperties().rng_algorithm = ::mlir::stablehlo::RngAlgorithmAttr::get(odsBuilder.getContext(), rng_algorithm); + assert(resultTypes.size() == 2u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RngBitGeneratorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void RngBitGeneratorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RngBitGeneratorOp::verifyInvariantsImpl() { + auto tblgen_rng_algorithm = getProperties().rng_algorithm; (void)tblgen_rng_algorithm; + if (!tblgen_rng_algorithm) return emitOpError("requires attribute 'rng_algorithm'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps32(*this, tblgen_rng_algorithm, "rng_algorithm"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps39(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps39(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSResults(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps40(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RngBitGeneratorOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult RngBitGeneratorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand initial_stateRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> initial_stateOperands(&initial_stateRawOperand, 1); ::llvm::SMLoc initial_stateOperandsLoc; + (void)initial_stateOperandsLoc; + ::mlir::stablehlo::RngAlgorithmAttr rng_algorithmAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + initial_stateOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(initial_stateRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("algorithm")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(rng_algorithmAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (rng_algorithmAttr) result.getOrAddProperties().rng_algorithm = rng_algorithmAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(initial_stateOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RngBitGeneratorOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getInitialState(); + _odsPrinter << ","; + _odsPrinter << ' ' << "algorithm"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getRngAlgorithmAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("rng_algorithm"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void RngBitGeneratorOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RngBitGeneratorOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RngOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RngOpGenericAdaptorBase::RngOpGenericAdaptorBase(RngOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::RngDistribution RngOpGenericAdaptorBase::getRngDistribution() { + auto attr = getRngDistributionAttr(); + return attr.getValue(); +} + +} // namespace detail +RngOpAdaptor::RngOpAdaptor(RngOp op) : RngOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RngOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_rng_distribution = getProperties().rng_distribution; (void)tblgen_rng_distribution; + if (!tblgen_rng_distribution) return emitError(loc, "'stablehlo.rng' op ""requires attribute 'rng_distribution'"); + + if (tblgen_rng_distribution && !((::llvm::isa<::mlir::stablehlo::RngDistributionAttr>(tblgen_rng_distribution)))) + return emitError(loc, "'stablehlo.rng' op ""attribute 'rng_distribution' failed to satisfy constraint: XLA PRNG distribution to be used."); + return ::mlir::success(); +} + +::llvm::LogicalResult RngOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.rng_distribution; + auto attr = dict.get("rng_distribution"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rng_distribution` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute RngOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.rng_distribution; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rng_distribution", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RngOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.rng_distribution.getAsOpaquePointer())); +} + +std::optional RngOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "rng_distribution") + return prop.rng_distribution; + return std::nullopt; +} + +void RngOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "rng_distribution") { + prop.rng_distribution = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void RngOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.rng_distribution) attrs.append("rng_distribution", prop.rng_distribution); +} + +::llvm::LogicalResult RngOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getRngDistributionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps33(attr, "rng_distribution", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult RngOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.rng_distribution))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RngOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.rng_distribution); +} + +::mlir::stablehlo::RngDistribution RngOp::getRngDistribution() { + auto attr = getRngDistributionAttr(); + return attr.getValue(); +} + +void RngOp::setRngDistribution(::mlir::stablehlo::RngDistribution attrValue) { + getProperties().rng_distribution = ::mlir::stablehlo::RngDistributionAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); +} + +void RngOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::stablehlo::RngDistributionAttr rng_distribution) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(shape); + odsState.getOrAddProperties().rng_distribution = rng_distribution; + odsState.addTypes(result); +} + +void RngOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::stablehlo::RngDistributionAttr rng_distribution) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(shape); + odsState.getOrAddProperties().rng_distribution = rng_distribution; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RngOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void RngOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::stablehlo::RngDistributionAttr rng_distribution) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(shape); + odsState.getOrAddProperties().rng_distribution = rng_distribution; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RngOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::stablehlo::RngDistribution rng_distribution) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(shape); + odsState.getOrAddProperties().rng_distribution = ::mlir::stablehlo::RngDistributionAttr::get(odsBuilder.getContext(), rng_distribution); + odsState.addTypes(result); +} + +void RngOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::stablehlo::RngDistribution rng_distribution) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(shape); + odsState.getOrAddProperties().rng_distribution = ::mlir::stablehlo::RngDistributionAttr::get(odsBuilder.getContext(), rng_distribution); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RngOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void RngOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::stablehlo::RngDistribution rng_distribution) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(shape); + odsState.getOrAddProperties().rng_distribution = ::mlir::stablehlo::RngDistributionAttr::get(odsBuilder.getContext(), rng_distribution); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RngOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void RngOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RngOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void RngOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RngOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RngOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult RngOp::verifyInvariantsImpl() { + auto tblgen_rng_distribution = getProperties().rng_distribution; (void)tblgen_rng_distribution; + if (!tblgen_rng_distribution) return emitOpError("requires attribute 'rng_distribution'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps33(*this, tblgen_rng_distribution, "rng_distribution"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps41(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps41(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps24(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps42(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!(((getElementTypeOrSelf((*this->getODSOperands(0).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(1).begin()))) && (getElementTypeOrSelf((*this->getODSOperands(1).begin()))) == (getElementTypeOrSelf((*this->getODSResults(0).begin()))) && (getElementTypeOrSelf((*this->getODSResults(0).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(0).begin())))))) + return emitOpError("failed to verify that all of {a, b, result} have same element type"); + return ::mlir::success(); +} + +::llvm::LogicalResult RngOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult RngOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand aRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(&aRawOperand, 1); ::llvm::SMLoc aOperandsLoc; + (void)aOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand bRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bOperands(&bRawOperand, 1); ::llvm::SMLoc bOperandsLoc; + (void)bOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand shapeRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> shapeOperands(&shapeRawOperand, 1); ::llvm::SMLoc shapeOperandsLoc; + (void)shapeOperandsLoc; + ::mlir::stablehlo::RngDistributionAttr rng_distributionAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + aOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(aRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + bOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(bRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + shapeOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(shapeRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("distribution")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(rng_distributionAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (rng_distributionAttr) result.getOrAddProperties().rng_distribution = rng_distributionAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(::llvm::concat(aOperands, bOperands, shapeOperands), allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RngOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getA(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getB(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getShape(); + _odsPrinter << ","; + _odsPrinter << ' ' << "distribution"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getRngDistributionAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("rng_distribution"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +::llvm::LogicalResult +RngOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(RngOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RngOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RoundNearestEvenOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RoundNearestEvenOpGenericAdaptorBase::RoundNearestEvenOpGenericAdaptorBase(RoundNearestEvenOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +RoundNearestEvenOpAdaptor::RoundNearestEvenOpAdaptor(RoundNearestEvenOp op) : RoundNearestEvenOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RoundNearestEvenOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult RoundNearestEvenOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute RoundNearestEvenOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RoundNearestEvenOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional RoundNearestEvenOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void RoundNearestEvenOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void RoundNearestEvenOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult RoundNearestEvenOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void RoundNearestEvenOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void RoundNearestEvenOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RoundNearestEvenOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void RoundNearestEvenOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RoundNearestEvenOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RoundNearestEvenOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RoundNearestEvenOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void RoundNearestEvenOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RoundNearestEvenOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RoundNearestEvenOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult RoundNearestEvenOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RoundNearestEvenOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult RoundNearestEvenOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RoundNearestEvenOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void RoundNearestEvenOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RoundNearestEvenOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RoundOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RoundOpGenericAdaptorBase::RoundOpGenericAdaptorBase(RoundOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +RoundOpAdaptor::RoundOpAdaptor(RoundOp op) : RoundOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RoundOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult RoundOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute RoundOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RoundOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional RoundOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void RoundOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void RoundOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult RoundOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void RoundOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void RoundOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RoundOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void RoundOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RoundOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RoundOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RoundOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void RoundOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RoundOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RoundOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult RoundOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps10(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RoundOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult RoundOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RoundOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void RoundOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RoundOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RsqrtOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RsqrtOpGenericAdaptorBase::RsqrtOpGenericAdaptorBase(RsqrtOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ResultAccuracyAttr RsqrtOpGenericAdaptorBase::getResultAccuracyAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + if (!attr) + attr = ::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + return attr; +} + +::mlir::stablehlo::ResultAccuracyAttr RsqrtOpGenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +} // namespace detail +RsqrtOpAdaptor::RsqrtOpAdaptor(RsqrtOp op) : RsqrtOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RsqrtOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (tblgen_result_accuracy && !((::llvm::isa<::mlir::stablehlo::ResultAccuracyAttr>(tblgen_result_accuracy)))) + return emitError(loc, "'stablehlo.rsqrt' op ""attribute 'result_accuracy' failed to satisfy constraint: The requested accuracy for transcendental unary ops."); + return ::mlir::success(); +} + +::llvm::LogicalResult RsqrtOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute RsqrtOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RsqrtOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional RsqrtOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void RsqrtOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void RsqrtOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult RsqrtOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult RsqrtOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RsqrtOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.result_accuracy); +} + +::mlir::stablehlo::ResultAccuracyAttr RsqrtOp::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder((*this)->getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + odsState.addTypes(result); +} + +void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RsqrtOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RsqrtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RsqrtOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void RsqrtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RsqrtOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult RsqrtOp::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RsqrtOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult RsqrtOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RsqrtOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getResultAccuracyAttr(); + if(attr && (attr == ::mlir::stablehlo::ResultAccuracyAttr::get(odsBuilder.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(odsBuilder.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)))) + elidedAttrs.push_back("result_accuracy"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void RsqrtOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RsqrtOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ScatterOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ScatterOpGenericAdaptorBase::ScatterOpGenericAdaptorBase(ScatterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair ScatterOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::stablehlo::ScatterDimensionNumbersAttr ScatterOpGenericAdaptorBase::getScatterDimensionNumbers() { + auto attr = getScatterDimensionNumbersAttr(); + return ::llvm::cast<::mlir::stablehlo::ScatterDimensionNumbersAttr>(attr); +} + +::mlir::BoolAttr ScatterOpGenericAdaptorBase::getIndicesAreSortedAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().indices_are_sorted); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false); + return attr; +} + +bool ScatterOpGenericAdaptorBase::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +::mlir::BoolAttr ScatterOpGenericAdaptorBase::getUniqueIndicesAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().unique_indices); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false); + return attr; +} + +bool ScatterOpGenericAdaptorBase::getUniqueIndices() { + auto attr = getUniqueIndicesAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +} // namespace detail +ScatterOpAdaptor::ScatterOpAdaptor(ScatterOp op) : ScatterOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ScatterOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + auto tblgen_scatter_dimension_numbers = getProperties().scatter_dimension_numbers; (void)tblgen_scatter_dimension_numbers; + if (!tblgen_scatter_dimension_numbers) return emitError(loc, "'stablehlo.scatter' op ""requires attribute 'scatter_dimension_numbers'"); + auto tblgen_unique_indices = getProperties().unique_indices; (void)tblgen_unique_indices; + + if (tblgen_scatter_dimension_numbers && !((::llvm::isa<::mlir::stablehlo::ScatterDimensionNumbersAttr>(tblgen_scatter_dimension_numbers)))) + return emitError(loc, "'stablehlo.scatter' op ""attribute 'scatter_dimension_numbers' failed to satisfy constraint: Attribute that models the dimension information for scatter"); + + if (tblgen_indices_are_sorted && !((::llvm::isa<::mlir::BoolAttr>(tblgen_indices_are_sorted)))) + return emitError(loc, "'stablehlo.scatter' op ""attribute 'indices_are_sorted' failed to satisfy constraint: bool attribute"); + + if (tblgen_unique_indices && !((::llvm::isa<::mlir::BoolAttr>(tblgen_unique_indices)))) + return emitError(loc, "'stablehlo.scatter' op ""attribute 'unique_indices' failed to satisfy constraint: bool attribute"); + return ::mlir::success(); +} + +std::pair ScatterOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange ScatterOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::mlir::MutableOperandRange ScatterOp::getUpdatesMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ScatterOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult ScatterOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.indices_are_sorted; + auto attr = dict.get("indices_are_sorted"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `indices_are_sorted` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.scatter_dimension_numbers; + auto attr = dict.get("scatter_dimension_numbers"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `scatter_dimension_numbers` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.unique_indices; + auto attr = dict.get("unique_indices"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `unique_indices` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ScatterOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.indices_are_sorted; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("indices_are_sorted", + propStorage)); + } + + { + const auto &propStorage = prop.scatter_dimension_numbers; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("scatter_dimension_numbers", + propStorage)); + } + + { + const auto &propStorage = prop.unique_indices; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("unique_indices", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ScatterOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.indices_are_sorted.getAsOpaquePointer()), + llvm::hash_value(prop.scatter_dimension_numbers.getAsOpaquePointer()), + llvm::hash_value(prop.unique_indices.getAsOpaquePointer())); +} + +std::optional ScatterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "indices_are_sorted") + return prop.indices_are_sorted; + + if (name == "scatter_dimension_numbers") + return prop.scatter_dimension_numbers; + + if (name == "unique_indices") + return prop.unique_indices; + return std::nullopt; +} + +void ScatterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "indices_are_sorted") { + prop.indices_are_sorted = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "scatter_dimension_numbers") { + prop.scatter_dimension_numbers = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "unique_indices") { + prop.unique_indices = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ScatterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.indices_are_sorted) attrs.append("indices_are_sorted", prop.indices_are_sorted); + + if (prop.scatter_dimension_numbers) attrs.append("scatter_dimension_numbers", prop.scatter_dimension_numbers); + + if (prop.unique_indices) attrs.append("unique_indices", prop.unique_indices); +} + +::llvm::LogicalResult ScatterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getIndicesAreSortedAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(attr, "indices_are_sorted", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getScatterDimensionNumbersAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps34(attr, "scatter_dimension_numbers", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUniqueIndicesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(attr, "unique_indices", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ScatterOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.indices_are_sorted))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.scatter_dimension_numbers))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.unique_indices))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ScatterOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.indices_are_sorted); + writer.writeAttribute(prop.scatter_dimension_numbers); + + writer.writeOptionalAttribute(prop.unique_indices); +} + +::mlir::stablehlo::ScatterDimensionNumbersAttr ScatterOp::getScatterDimensionNumbers() { + auto attr = getScatterDimensionNumbersAttr(); + return ::llvm::cast<::mlir::stablehlo::ScatterDimensionNumbersAttr>(attr); +} + +bool ScatterOp::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +bool ScatterOp::getUniqueIndices() { + auto attr = getUniqueIndicesAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +void ScatterOp::setIndicesAreSorted(::std::optional attrValue) { + auto &odsProp = getProperties().indices_are_sorted; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue); + else + odsProp = nullptr; +} + +void ScatterOp::setUniqueIndices(::std::optional attrValue) { + auto &odsProp = getProperties().unique_indices; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue); + else + odsProp = nullptr; +} + +void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::Value scatter_indices, ::mlir::ValueRange updates, ::mlir::stablehlo::ScatterDimensionNumbersAttr scatter_dimension_numbers, /*optional*/::mlir::BoolAttr indices_are_sorted, /*optional*/::mlir::BoolAttr unique_indices) { + odsState.addOperands(inputs); + odsState.addOperands(scatter_indices); + odsState.addOperands(updates); + odsState.getOrAddProperties().scatter_dimension_numbers = scatter_dimension_numbers; + if (indices_are_sorted) { + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + } + if (unique_indices) { + odsState.getOrAddProperties().unique_indices = unique_indices; + } + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::Value scatter_indices, ::mlir::ValueRange updates, ::mlir::stablehlo::ScatterDimensionNumbersAttr scatter_dimension_numbers, /*optional*/::mlir::BoolAttr indices_are_sorted, /*optional*/::mlir::BoolAttr unique_indices) { + odsState.addOperands(inputs); + odsState.addOperands(scatter_indices); + odsState.addOperands(updates); + odsState.getOrAddProperties().scatter_dimension_numbers = scatter_dimension_numbers; + if (indices_are_sorted) { + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + } + if (unique_indices) { + odsState.getOrAddProperties().unique_indices = unique_indices; + } + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ScatterOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::Value scatter_indices, ::mlir::ValueRange updates, ::mlir::stablehlo::ScatterDimensionNumbersAttr scatter_dimension_numbers, /*optional*/bool indices_are_sorted, /*optional*/bool unique_indices) { + odsState.addOperands(inputs); + odsState.addOperands(scatter_indices); + odsState.addOperands(updates); + odsState.getOrAddProperties().scatter_dimension_numbers = scatter_dimension_numbers; + odsState.getOrAddProperties().indices_are_sorted = odsBuilder.getBoolAttr(indices_are_sorted); + odsState.getOrAddProperties().unique_indices = odsBuilder.getBoolAttr(unique_indices); + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::Value scatter_indices, ::mlir::ValueRange updates, ::mlir::stablehlo::ScatterDimensionNumbersAttr scatter_dimension_numbers, /*optional*/bool indices_are_sorted, /*optional*/bool unique_indices) { + odsState.addOperands(inputs); + odsState.addOperands(scatter_indices); + odsState.addOperands(updates); + odsState.getOrAddProperties().scatter_dimension_numbers = scatter_dimension_numbers; + odsState.getOrAddProperties().indices_are_sorted = odsBuilder.getBoolAttr(indices_are_sorted); + odsState.getOrAddProperties().unique_indices = odsBuilder.getBoolAttr(unique_indices); + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ScatterOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ScatterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ScatterOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ScatterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ScatterOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ScatterOp::verifyInvariantsImpl() { + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + auto tblgen_scatter_dimension_numbers = getProperties().scatter_dimension_numbers; (void)tblgen_scatter_dimension_numbers; + if (!tblgen_scatter_dimension_numbers) return emitOpError("requires attribute 'scatter_dimension_numbers'"); + auto tblgen_unique_indices = getProperties().unique_indices; (void)tblgen_unique_indices; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps34(*this, tblgen_scatter_dimension_numbers, "scatter_dimension_numbers"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(*this, tblgen_indices_are_sorted, "indices_are_sorted"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(*this, tblgen_unique_indices, "unique_indices"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps43(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "update_computation", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ScatterOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ScatterOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SelectAndScatterOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SelectAndScatterOpGenericAdaptorBase::SelectAndScatterOpGenericAdaptorBase(SelectAndScatterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::std::optional<::llvm::ArrayRef> SelectAndScatterOpGenericAdaptorBase::getWindowDimensions() { + auto attr = getWindowDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> SelectAndScatterOpGenericAdaptorBase::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional< ::mlir::DenseIntElementsAttr > SelectAndScatterOpGenericAdaptorBase::getPadding() { + auto attr = getPaddingAttr(); + return attr ? ::std::optional< ::mlir::DenseIntElementsAttr >(attr) : (::std::nullopt); +} + +} // namespace detail +SelectAndScatterOpAdaptor::SelectAndScatterOpAdaptor(SelectAndScatterOp op) : SelectAndScatterOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SelectAndScatterOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + auto tblgen_window_dimensions = getProperties().window_dimensions; (void)tblgen_window_dimensions; + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + + if (tblgen_window_dimensions && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_window_dimensions)))) + return emitError(loc, "'stablehlo.select_and_scatter' op ""attribute 'window_dimensions' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_window_strides && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_window_strides)))) + return emitError(loc, "'stablehlo.select_and_scatter' op ""attribute 'window_strides' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_padding && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(tblgen_padding))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(tblgen_padding).getType().getElementType().isSignlessInteger(64))))) + return emitError(loc, "'stablehlo.select_and_scatter' op ""attribute 'padding' failed to satisfy constraint: 64-bit signless integer elements attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult SelectAndScatterOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.padding; + auto attr = dict.get("padding"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `padding` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_dimensions; + auto attr = dict.get("window_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_strides; + auto attr = dict.get("window_strides"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SelectAndScatterOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.padding; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("padding", + propStorage)); + } + + { + const auto &propStorage = prop.window_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.window_strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_strides", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SelectAndScatterOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.padding.getAsOpaquePointer()), + llvm::hash_value(prop.window_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.window_strides.getAsOpaquePointer())); +} + +std::optional SelectAndScatterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "padding") + return prop.padding; + + if (name == "window_dimensions") + return prop.window_dimensions; + + if (name == "window_strides") + return prop.window_strides; + return std::nullopt; +} + +void SelectAndScatterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "padding") { + prop.padding = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_dimensions") { + prop.window_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_strides") { + prop.window_strides = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SelectAndScatterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.padding) attrs.append("padding", prop.padding); + + if (prop.window_dimensions) attrs.append("window_dimensions", prop.window_dimensions); + + if (prop.window_strides) attrs.append("window_strides", prop.window_strides); +} + +::llvm::LogicalResult SelectAndScatterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getPaddingAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(attr, "padding", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "window_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "window_strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SelectAndScatterOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.padding))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.window_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.window_strides))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SelectAndScatterOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.padding); + + writer.writeOptionalAttribute(prop.window_dimensions); + + writer.writeOptionalAttribute(prop.window_strides); +} + +::std::optional<::llvm::ArrayRef> SelectAndScatterOp::getWindowDimensions() { + auto attr = getWindowDimensionsAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional<::llvm::ArrayRef> SelectAndScatterOp::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr ? ::std::optional<::llvm::ArrayRef>(attr) : (::std::nullopt); +} + +::std::optional< ::mlir::DenseIntElementsAttr > SelectAndScatterOp::getPadding() { + auto attr = getPaddingAttr(); + return attr ? ::std::optional< ::mlir::DenseIntElementsAttr >(attr) : (::std::nullopt); +} + +void SelectAndScatterOp::setWindowDimensions(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().window_dimensions; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void SelectAndScatterOp::setWindowStrides(::std::optional<::llvm::ArrayRef> attrValue) { + auto &odsProp = getProperties().window_strides; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue); + else + odsProp = nullptr; +} + +void SelectAndScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value source, ::mlir::Value init_value, /*optional*/::mlir::DenseI64ArrayAttr window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding) { + odsState.addOperands(operand); + odsState.addOperands(source); + odsState.addOperands(init_value); + if (window_dimensions) { + odsState.getOrAddProperties().window_dimensions = window_dimensions; + } + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (padding) { + odsState.getOrAddProperties().padding = padding; + } + (void)odsState.addRegion(); + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void SelectAndScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value source, ::mlir::Value init_value, /*optional*/::mlir::DenseI64ArrayAttr window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding) { + odsState.addOperands(operand); + odsState.addOperands(source); + odsState.addOperands(init_value); + if (window_dimensions) { + odsState.getOrAddProperties().window_dimensions = window_dimensions; + } + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (padding) { + odsState.getOrAddProperties().padding = padding; + } + (void)odsState.addRegion(); + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SelectAndScatterOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SelectAndScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value source, ::mlir::Value init_value, /*optional*/::mlir::DenseI64ArrayAttr window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding) { + odsState.addOperands(operand); + odsState.addOperands(source); + odsState.addOperands(init_value); + if (window_dimensions) { + odsState.getOrAddProperties().window_dimensions = window_dimensions; + } + if (window_strides) { + odsState.getOrAddProperties().window_strides = window_strides; + } + if (padding) { + odsState.getOrAddProperties().padding = padding; + } + (void)odsState.addRegion(); + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SelectAndScatterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SelectAndScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SelectAndScatterOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void SelectAndScatterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SelectAndScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SelectAndScatterOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult SelectAndScatterOp::verifyInvariantsImpl() { + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + auto tblgen_window_dimensions = getProperties().window_dimensions; (void)tblgen_window_dimensions; + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_window_dimensions, "window_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_window_strides, "window_strides"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps2(*this, tblgen_padding, "padding"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "select", index++))) + return ::mlir::failure(); + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "scatter", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SelectAndScatterOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SelectAndScatterOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SelectOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SelectOpGenericAdaptorBase::SelectOpGenericAdaptorBase(SelectOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +SelectOpAdaptor::SelectOpAdaptor(SelectOp op) : SelectOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SelectOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult SelectOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute SelectOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SelectOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional SelectOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void SelectOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void SelectOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult SelectOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false) { + odsState.addOperands(pred); + odsState.addOperands(on_true); + odsState.addOperands(on_false); + odsState.addTypes(result); +} + +void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false) { + odsState.addOperands(pred); + odsState.addOperands(on_true); + odsState.addOperands(on_false); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SelectOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false) { + odsState.addOperands(pred); + odsState.addOperands(on_true); + odsState.addOperands(on_false); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SelectOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SelectOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void SelectOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SelectOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult SelectOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps16(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SelectOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult SelectOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; + ::mlir::Type predRawType{}; + ::llvm::ArrayRef<::mlir::Type> predTypes(&predRawType, 1); + ::mlir::Type on_trueRawType{}; + ::llvm::ArrayRef<::mlir::Type> on_trueTypes(&on_trueRawType, 1); + ::mlir::Type on_falseRawType{}; + ::llvm::ArrayRef<::mlir::Type> on_falseTypes(&on_falseRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + [[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(allOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSelectOpType(parser, predRawType, on_trueRawType, on_falseRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(allOperands, ::llvm::concat(::llvm::ArrayRef<::mlir::Type>(predTypes), ::llvm::ArrayRef<::mlir::Type>(on_trueTypes), ::llvm::ArrayRef<::mlir::Type>(on_falseTypes)), allOperandLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SelectOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperation()->getOperands(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSelectOpType(_odsPrinter, *this, getPred().getType(), getOnTrue().getType(), getOnFalse().getType(), getResult().getType()); +} + +void SelectOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +SelectOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(SelectOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SelectOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SendOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SendOpGenericAdaptorBase::SendOpGenericAdaptorBase(SendOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair SendOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::stablehlo::ChannelHandleAttr SendOpGenericAdaptorBase::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return ::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr); +} + +::mlir::BoolAttr SendOpGenericAdaptorBase::getIsHostTransferAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().is_host_transfer); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false); + return attr; +} + +bool SendOpGenericAdaptorBase::getIsHostTransfer() { + auto attr = getIsHostTransferAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +} // namespace detail +SendOpAdaptor::SendOpAdaptor(SendOp op) : SendOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SendOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + if (!tblgen_channel_handle) return emitError(loc, "'stablehlo.send' op ""requires attribute 'channel_handle'"); + auto tblgen_is_host_transfer = getProperties().is_host_transfer; (void)tblgen_is_host_transfer; + + if (tblgen_channel_handle && !((::llvm::isa<::mlir::stablehlo::ChannelHandleAttr>(tblgen_channel_handle)))) + return emitError(loc, "'stablehlo.send' op ""attribute 'channel_handle' failed to satisfy constraint: two 64-bit integers 'handle' and 'type'"); + + if (tblgen_is_host_transfer && !((::llvm::isa<::mlir::BoolAttr>(tblgen_is_host_transfer)))) + return emitError(loc, "'stablehlo.send' op ""attribute 'is_host_transfer' failed to satisfy constraint: bool attribute"); + return ::mlir::success(); +} + +std::pair SendOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange SendOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult SendOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_handle; + auto attr = dict.get("channel_handle"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_handle` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.is_host_transfer; + auto attr = dict.get("is_host_transfer"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `is_host_transfer` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SendOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_handle; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_handle", + propStorage)); + } + + { + const auto &propStorage = prop.is_host_transfer; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("is_host_transfer", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SendOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_handle.getAsOpaquePointer()), + llvm::hash_value(prop.is_host_transfer.getAsOpaquePointer())); +} + +std::optional SendOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_handle") + return prop.channel_handle; + + if (name == "is_host_transfer") + return prop.is_host_transfer; + return std::nullopt; +} + +void SendOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_handle") { + prop.channel_handle = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "is_host_transfer") { + prop.is_host_transfer = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SendOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_handle) attrs.append("channel_handle", prop.channel_handle); + + if (prop.is_host_transfer) attrs.append("is_host_transfer", prop.is_host_transfer); +} + +::llvm::LogicalResult SendOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelHandleAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(attr, "channel_handle", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIsHostTransferAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(attr, "is_host_transfer", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SendOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.channel_handle))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.is_host_transfer))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SendOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.channel_handle); + + writer.writeOptionalAttribute(prop.is_host_transfer); +} + +::mlir::stablehlo::ChannelHandleAttr SendOp::getChannelHandle() { + auto attr = getChannelHandleAttr(); + return ::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(attr); +} + +bool SendOp::getIsHostTransfer() { + auto attr = getIsHostTransferAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +void SendOp::setIsHostTransfer(::std::optional attrValue) { + auto &odsProp = getProperties().is_host_transfer; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue); + else + odsProp = nullptr; +} + +void SendOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::BoolAttr is_host_transfer) { + odsState.addOperands(inputs); + odsState.addOperands(token); + odsState.getOrAddProperties().channel_handle = channel_handle; + if (is_host_transfer) { + odsState.getOrAddProperties().is_host_transfer = is_host_transfer; + } + odsState.addTypes(resultType0); +} + +void SendOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::BoolAttr is_host_transfer) { + odsState.addOperands(inputs); + odsState.addOperands(token); + odsState.getOrAddProperties().channel_handle = channel_handle; + if (is_host_transfer) { + odsState.getOrAddProperties().is_host_transfer = is_host_transfer; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SendOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SendOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::BoolAttr is_host_transfer) { + odsState.addOperands(inputs); + odsState.addOperands(token); + odsState.getOrAddProperties().channel_handle = channel_handle; + if (is_host_transfer) { + odsState.getOrAddProperties().is_host_transfer = is_host_transfer; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SendOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool is_host_transfer) { + odsState.addOperands(inputs); + odsState.addOperands(token); + odsState.getOrAddProperties().channel_handle = channel_handle; + odsState.getOrAddProperties().is_host_transfer = odsBuilder.getBoolAttr(is_host_transfer); + odsState.addTypes(resultType0); +} + +void SendOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool is_host_transfer) { + odsState.addOperands(inputs); + odsState.addOperands(token); + odsState.getOrAddProperties().channel_handle = channel_handle; + odsState.getOrAddProperties().is_host_transfer = odsBuilder.getBoolAttr(is_host_transfer); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SendOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SendOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool is_host_transfer) { + odsState.addOperands(inputs); + odsState.addOperands(token); + odsState.getOrAddProperties().channel_handle = channel_handle; + odsState.getOrAddProperties().is_host_transfer = odsBuilder.getBoolAttr(is_host_transfer); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SendOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SendOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SendOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void SendOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SendOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SendOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult SendOp::verifyInvariantsImpl() { + auto tblgen_channel_handle = getProperties().channel_handle; (void)tblgen_channel_handle; + if (!tblgen_channel_handle) return emitOpError("requires attribute 'channel_handle'"); + auto tblgen_is_host_transfer = getProperties().is_host_transfer; (void)tblgen_is_host_transfer; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps3(*this, tblgen_channel_handle, "channel_handle"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(*this, tblgen_is_host_transfer, "is_host_transfer"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps36(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SendOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void SendOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { + effects.emplace_back(::mlir::MemoryEffects::Read::get(), 0, false, ::mlir::stablehlo::side_effects::SendResource::get()); + effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, ::mlir::stablehlo::side_effects::SendResource::get()); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SendOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SetDimensionSizeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SetDimensionSizeOpGenericAdaptorBase::SetDimensionSizeOpGenericAdaptorBase(SetDimensionSizeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +uint64_t SetDimensionSizeOpGenericAdaptorBase::getDimension() { + auto attr = getDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +SetDimensionSizeOpAdaptor::SetDimensionSizeOpAdaptor(SetDimensionSizeOp op) : SetDimensionSizeOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SetDimensionSizeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitError(loc, "'stablehlo.set_dimension_size' op ""requires attribute 'dimension'"); + + if (tblgen_dimension && !((((::llvm::isa<::mlir::IntegerAttr>(tblgen_dimension))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_dimension).getType().isSignlessInteger(64)))) && ((!::llvm::cast<::mlir::IntegerAttr>(tblgen_dimension).getValue().isNegative())))) + return emitError(loc, "'stablehlo.set_dimension_size' op ""attribute 'dimension' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative"); + return ::mlir::success(); +} + +::llvm::LogicalResult SetDimensionSizeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimension; + auto attr = dict.get("dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SetDimensionSizeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SetDimensionSizeOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimension.getAsOpaquePointer())); +} + +std::optional SetDimensionSizeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimension") + return prop.dimension; + return std::nullopt; +} + +void SetDimensionSizeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimension") { + prop.dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SetDimensionSizeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimension) attrs.append("dimension", prop.dimension); +} + +::llvm::LogicalResult SetDimensionSizeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(attr, "dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SetDimensionSizeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SetDimensionSizeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimension); +} + +uint64_t SetDimensionSizeOp::getDimension() { + auto attr = getDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +void SetDimensionSizeOp::setDimension(uint64_t attrValue) { + getProperties().dimension = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void SetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value size, ::mlir::IntegerAttr dimension) { + odsState.addOperands(operand); + odsState.addOperands(size); + odsState.getOrAddProperties().dimension = dimension; + odsState.addTypes(resultType0); +} + +void SetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value size, ::mlir::IntegerAttr dimension) { + odsState.addOperands(operand); + odsState.addOperands(size); + odsState.getOrAddProperties().dimension = dimension; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SetDimensionSizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value size, ::mlir::IntegerAttr dimension) { + odsState.addOperands(operand); + odsState.addOperands(size); + odsState.getOrAddProperties().dimension = dimension; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value size, uint64_t dimension) { + odsState.addOperands(operand); + odsState.addOperands(size); + odsState.getOrAddProperties().dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), dimension); + odsState.addTypes(resultType0); +} + +void SetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value size, uint64_t dimension) { + odsState.addOperands(operand); + odsState.addOperands(size); + odsState.getOrAddProperties().dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), dimension); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SetDimensionSizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value size, uint64_t dimension) { + odsState.addOperands(operand); + odsState.addOperands(size); + odsState.getOrAddProperties().dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), dimension); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SetDimensionSizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SetDimensionSizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void SetDimensionSizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SetDimensionSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SetDimensionSizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult SetDimensionSizeOp::verifyInvariantsImpl() { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitOpError("requires attribute 'dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps1(*this, tblgen_dimension, "dimension"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps13(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SetDimensionSizeOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult SetDimensionSizeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand sizeRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sizeOperands(&sizeRawOperand, 1); ::llvm::SMLoc sizeOperandsLoc; + (void)sizeOperandsLoc; + ::mlir::IntegerAttr dimensionAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + sizeOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sizeRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("dim")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(dimensionAttr, parser.getBuilder().getIntegerType(64))) { + return ::mlir::failure(); + } + if (dimensionAttr) result.getOrAddProperties().dimension = dimensionAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(::llvm::concat(operandOperands, sizeOperands), allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SetDimensionSizeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getSize(); + _odsPrinter << ","; + _odsPrinter << ' ' << "dim"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getDimensionAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("dimension"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void SetDimensionSizeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +SetDimensionSizeOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(SetDimensionSizeOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SetDimensionSizeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ShiftLeftOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ShiftLeftOpGenericAdaptorBase::ShiftLeftOpGenericAdaptorBase(ShiftLeftOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ShiftLeftOpAdaptor::ShiftLeftOpAdaptor(ShiftLeftOp op) : ShiftLeftOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ShiftLeftOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ShiftLeftOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ShiftLeftOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ShiftLeftOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ShiftLeftOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ShiftLeftOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ShiftLeftOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ShiftLeftOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ShiftLeftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void ShiftLeftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShiftLeftOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ShiftLeftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ShiftLeftOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ShiftLeftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShiftLeftOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ShiftLeftOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ShiftLeftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShiftLeftOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ShiftLeftOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ShiftLeftOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ShiftLeftOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ShiftLeftOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void ShiftLeftOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ShiftLeftOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ShiftRightArithmeticOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ShiftRightArithmeticOpGenericAdaptorBase::ShiftRightArithmeticOpGenericAdaptorBase(ShiftRightArithmeticOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ShiftRightArithmeticOpAdaptor::ShiftRightArithmeticOpAdaptor(ShiftRightArithmeticOp op) : ShiftRightArithmeticOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ShiftRightArithmeticOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ShiftRightArithmeticOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ShiftRightArithmeticOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ShiftRightArithmeticOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ShiftRightArithmeticOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ShiftRightArithmeticOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ShiftRightArithmeticOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ShiftRightArithmeticOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ShiftRightArithmeticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void ShiftRightArithmeticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShiftRightArithmeticOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ShiftRightArithmeticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ShiftRightArithmeticOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ShiftRightArithmeticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShiftRightArithmeticOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ShiftRightArithmeticOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ShiftRightArithmeticOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShiftRightArithmeticOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ShiftRightArithmeticOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ShiftRightArithmeticOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ShiftRightArithmeticOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ShiftRightArithmeticOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void ShiftRightArithmeticOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ShiftRightArithmeticOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ShiftRightLogicalOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ShiftRightLogicalOpGenericAdaptorBase::ShiftRightLogicalOpGenericAdaptorBase(ShiftRightLogicalOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ShiftRightLogicalOpAdaptor::ShiftRightLogicalOpAdaptor(ShiftRightLogicalOp op) : ShiftRightLogicalOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ShiftRightLogicalOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ShiftRightLogicalOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ShiftRightLogicalOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ShiftRightLogicalOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ShiftRightLogicalOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ShiftRightLogicalOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ShiftRightLogicalOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ShiftRightLogicalOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ShiftRightLogicalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void ShiftRightLogicalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShiftRightLogicalOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void ShiftRightLogicalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ShiftRightLogicalOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ShiftRightLogicalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShiftRightLogicalOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void ShiftRightLogicalOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ShiftRightLogicalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShiftRightLogicalOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult ShiftRightLogicalOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps15(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ShiftRightLogicalOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ShiftRightLogicalOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ShiftRightLogicalOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void ShiftRightLogicalOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ShiftRightLogicalOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SignOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SignOpGenericAdaptorBase::SignOpGenericAdaptorBase(SignOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +SignOpAdaptor::SignOpAdaptor(SignOp op) : SignOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SignOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult SignOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute SignOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SignOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional SignOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void SignOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void SignOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult SignOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void SignOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void SignOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SignOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SignOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SignOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SignOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SignOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void SignOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SignOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SignOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult SignOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SignOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult SignOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SignOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void SignOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SignOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SineOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SineOpGenericAdaptorBase::SineOpGenericAdaptorBase(SineOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ResultAccuracyAttr SineOpGenericAdaptorBase::getResultAccuracyAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + if (!attr) + attr = ::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + return attr; +} + +::mlir::stablehlo::ResultAccuracyAttr SineOpGenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +} // namespace detail +SineOpAdaptor::SineOpAdaptor(SineOp op) : SineOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SineOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (tblgen_result_accuracy && !((::llvm::isa<::mlir::stablehlo::ResultAccuracyAttr>(tblgen_result_accuracy)))) + return emitError(loc, "'stablehlo.sine' op ""attribute 'result_accuracy' failed to satisfy constraint: The requested accuracy for transcendental unary ops."); + return ::mlir::success(); +} + +::llvm::LogicalResult SineOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SineOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SineOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional SineOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void SineOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SineOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult SineOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SineOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SineOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.result_accuracy); +} + +::mlir::stablehlo::ResultAccuracyAttr SineOp::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder((*this)->getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +void SineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + odsState.addTypes(result); +} + +void SineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SineOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SineOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SineOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void SineOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SineOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SineOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult SineOp::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SineOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult SineOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SineOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getResultAccuracyAttr(); + if(attr && (attr == ::mlir::stablehlo::ResultAccuracyAttr::get(odsBuilder.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(odsBuilder.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)))) + elidedAttrs.push_back("result_accuracy"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void SineOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SineOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SliceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SliceOpGenericAdaptorBase::SliceOpGenericAdaptorBase(SliceOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::llvm::ArrayRef SliceOpGenericAdaptorBase::getStartIndices() { + auto attr = getStartIndicesAttr(); + return attr; +} + +::llvm::ArrayRef SliceOpGenericAdaptorBase::getLimitIndices() { + auto attr = getLimitIndicesAttr(); + return attr; +} + +::llvm::ArrayRef SliceOpGenericAdaptorBase::getStrides() { + auto attr = getStridesAttr(); + return attr; +} + +} // namespace detail +SliceOpAdaptor::SliceOpAdaptor(SliceOp op) : SliceOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SliceOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_limit_indices = getProperties().limit_indices; (void)tblgen_limit_indices; + if (!tblgen_limit_indices) return emitError(loc, "'stablehlo.slice' op ""requires attribute 'limit_indices'"); + auto tblgen_start_indices = getProperties().start_indices; (void)tblgen_start_indices; + if (!tblgen_start_indices) return emitError(loc, "'stablehlo.slice' op ""requires attribute 'start_indices'"); + auto tblgen_strides = getProperties().strides; (void)tblgen_strides; + if (!tblgen_strides) return emitError(loc, "'stablehlo.slice' op ""requires attribute 'strides'"); + + if (tblgen_start_indices && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_start_indices)))) + return emitError(loc, "'stablehlo.slice' op ""attribute 'start_indices' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_limit_indices && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_limit_indices)))) + return emitError(loc, "'stablehlo.slice' op ""attribute 'limit_indices' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_strides && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_strides)))) + return emitError(loc, "'stablehlo.slice' op ""attribute 'strides' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult SliceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.limit_indices; + auto attr = dict.get("limit_indices"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `limit_indices` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.start_indices; + auto attr = dict.get("start_indices"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `start_indices` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.strides; + auto attr = dict.get("strides"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SliceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.limit_indices; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("limit_indices", + propStorage)); + } + + { + const auto &propStorage = prop.start_indices; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("start_indices", + propStorage)); + } + + { + const auto &propStorage = prop.strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("strides", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SliceOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.limit_indices.getAsOpaquePointer()), + llvm::hash_value(prop.start_indices.getAsOpaquePointer()), + llvm::hash_value(prop.strides.getAsOpaquePointer())); +} + +std::optional SliceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "limit_indices") + return prop.limit_indices; + + if (name == "start_indices") + return prop.start_indices; + + if (name == "strides") + return prop.strides; + return std::nullopt; +} + +void SliceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "limit_indices") { + prop.limit_indices = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "start_indices") { + prop.start_indices = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "strides") { + prop.strides = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SliceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.limit_indices) attrs.append("limit_indices", prop.limit_indices); + + if (prop.start_indices) attrs.append("start_indices", prop.start_indices); + + if (prop.strides) attrs.append("strides", prop.strides); +} + +::llvm::LogicalResult SliceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getLimitIndicesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "limit_indices", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStartIndicesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "start_indices", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SliceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.limit_indices))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.start_indices))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.strides))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SliceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.limit_indices); + writer.writeAttribute(prop.start_indices); + writer.writeAttribute(prop.strides); +} + +::llvm::ArrayRef SliceOp::getStartIndices() { + auto attr = getStartIndicesAttr(); + return attr; +} + +::llvm::ArrayRef SliceOp::getLimitIndices() { + auto attr = getLimitIndicesAttr(); + return attr; +} + +::llvm::ArrayRef SliceOp::getStrides() { + auto attr = getStridesAttr(); + return attr; +} + +void SliceOp::setStartIndices(::llvm::ArrayRef attrValue) { + getProperties().start_indices = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void SliceOp::setLimitIndices(::llvm::ArrayRef attrValue) { + getProperties().limit_indices = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void SliceOp::setStrides(::llvm::ArrayRef attrValue) { + getProperties().strides = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void SliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr start_indices, ::mlir::DenseI64ArrayAttr limit_indices, ::mlir::DenseI64ArrayAttr strides) { + odsState.addOperands(operand); + odsState.getOrAddProperties().start_indices = start_indices; + odsState.getOrAddProperties().limit_indices = limit_indices; + odsState.getOrAddProperties().strides = strides; + odsState.addTypes(resultType0); +} + +void SliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr start_indices, ::mlir::DenseI64ArrayAttr limit_indices, ::mlir::DenseI64ArrayAttr strides) { + odsState.addOperands(operand); + odsState.getOrAddProperties().start_indices = start_indices; + odsState.getOrAddProperties().limit_indices = limit_indices; + odsState.getOrAddProperties().strides = strides; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr start_indices, ::mlir::DenseI64ArrayAttr limit_indices, ::mlir::DenseI64ArrayAttr strides) { + odsState.addOperands(operand); + odsState.getOrAddProperties().start_indices = start_indices; + odsState.getOrAddProperties().limit_indices = limit_indices; + odsState.getOrAddProperties().strides = strides; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::llvm::ArrayRef start_indices, ::llvm::ArrayRef limit_indices, ::llvm::ArrayRef strides) { + odsState.addOperands(operand); + odsState.getOrAddProperties().start_indices = odsBuilder.getDenseI64ArrayAttr(start_indices); + odsState.getOrAddProperties().limit_indices = odsBuilder.getDenseI64ArrayAttr(limit_indices); + odsState.getOrAddProperties().strides = odsBuilder.getDenseI64ArrayAttr(strides); + odsState.addTypes(resultType0); +} + +void SliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::llvm::ArrayRef start_indices, ::llvm::ArrayRef limit_indices, ::llvm::ArrayRef strides) { + odsState.addOperands(operand); + odsState.getOrAddProperties().start_indices = odsBuilder.getDenseI64ArrayAttr(start_indices); + odsState.getOrAddProperties().limit_indices = odsBuilder.getDenseI64ArrayAttr(limit_indices); + odsState.getOrAddProperties().strides = odsBuilder.getDenseI64ArrayAttr(strides); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::llvm::ArrayRef start_indices, ::llvm::ArrayRef limit_indices, ::llvm::ArrayRef strides) { + odsState.addOperands(operand); + odsState.getOrAddProperties().start_indices = odsBuilder.getDenseI64ArrayAttr(start_indices); + odsState.getOrAddProperties().limit_indices = odsBuilder.getDenseI64ArrayAttr(limit_indices); + odsState.getOrAddProperties().strides = odsBuilder.getDenseI64ArrayAttr(strides); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void SliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult SliceOp::verifyInvariantsImpl() { + auto tblgen_limit_indices = getProperties().limit_indices; (void)tblgen_limit_indices; + if (!tblgen_limit_indices) return emitOpError("requires attribute 'limit_indices'"); + auto tblgen_start_indices = getProperties().start_indices; (void)tblgen_start_indices; + if (!tblgen_start_indices) return emitOpError("requires attribute 'start_indices'"); + auto tblgen_strides = getProperties().strides; (void)tblgen_strides; + if (!tblgen_strides) return emitOpError("requires attribute 'strides'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_start_indices, "start_indices"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_limit_indices, "limit_indices"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_strides, "strides"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!(((getStartIndices().size()) == (getLimitIndices().size()) && (getLimitIndices().size()) == (getStrides().size()) && (getStrides().size()) == (getStartIndices().size())))) + return emitOpError("failed to verify that all of {start_indices, limit_indices, strides} have same size"); + return ::mlir::success(); +} + +::llvm::LogicalResult SliceOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult SliceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::DenseI64ArrayAttr start_indicesAttr; + ::mlir::DenseI64ArrayAttr limit_indicesAttr; + ::mlir::DenseI64ArrayAttr stridesAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto odsResult = parseSliceRanges(parser, start_indicesAttr, limit_indicesAttr, stridesAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().start_indices = start_indicesAttr; + result.getOrAddProperties().limit_indices = limit_indicesAttr; + result.getOrAddProperties().strides = stridesAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(operandOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SliceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ' '; + printSliceRanges(_odsPrinter, *this, getStartIndicesAttr(), getLimitIndicesAttr(), getStridesAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("start_indices"); + elidedAttrs.push_back("limit_indices"); + elidedAttrs.push_back("strides"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void SliceOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SliceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SortOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SortOpGenericAdaptorBase::SortOpGenericAdaptorBase(SortOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair SortOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::IntegerAttr SortOpGenericAdaptorBase::getDimensionAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().dimension); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), -1); + return attr; +} + +uint64_t SortOpGenericAdaptorBase::getDimension() { + auto attr = getDimensionAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getIntegerAttr(::mlir::Builder(odsAttrs.getContext()).getIntegerType(64), -1).getValue().getZExtValue(); + return attr.getValue().getZExtValue(); +} + +::mlir::BoolAttr SortOpGenericAdaptorBase::getIsStableAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().is_stable); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false); + return attr; +} + +bool SortOpGenericAdaptorBase::getIsStable() { + auto attr = getIsStableAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +} // namespace detail +SortOpAdaptor::SortOpAdaptor(SortOp op) : SortOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SortOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + auto tblgen_is_stable = getProperties().is_stable; (void)tblgen_is_stable; + + if (tblgen_dimension && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_dimension))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_dimension).getType().isSignlessInteger(64))))) + return emitError(loc, "'stablehlo.sort' op ""attribute 'dimension' failed to satisfy constraint: 64-bit signless integer attribute"); + + if (tblgen_is_stable && !((::llvm::isa<::mlir::BoolAttr>(tblgen_is_stable)))) + return emitError(loc, "'stablehlo.sort' op ""attribute 'is_stable' failed to satisfy constraint: bool attribute"); + return ::mlir::success(); +} + +std::pair SortOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange SortOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair SortOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult SortOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimension; + auto attr = dict.get("dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.is_stable; + auto attr = dict.get("is_stable"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `is_stable` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SortOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimension", + propStorage)); + } + + { + const auto &propStorage = prop.is_stable; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("is_stable", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SortOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimension.getAsOpaquePointer()), + llvm::hash_value(prop.is_stable.getAsOpaquePointer())); +} + +std::optional SortOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimension") + return prop.dimension; + + if (name == "is_stable") + return prop.is_stable; + return std::nullopt; +} + +void SortOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimension") { + prop.dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "is_stable") { + prop.is_stable = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SortOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimension) attrs.append("dimension", prop.dimension); + + if (prop.is_stable) attrs.append("is_stable", prop.is_stable); +} + +::llvm::LogicalResult SortOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps35(attr, "dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIsStableAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(attr, "is_stable", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SortOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.is_stable))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SortOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.dimension); + + writer.writeOptionalAttribute(prop.is_stable); +} + +uint64_t SortOp::getDimension() { + auto attr = getDimensionAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), -1).getValue().getZExtValue(); + return attr.getValue().getZExtValue(); +} + +bool SortOp::getIsStable() { + auto attr = getIsStableAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue(); + return attr.getValue(); +} + +void SortOp::setDimension(::std::optional attrValue) { + auto &odsProp = getProperties().dimension; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue); + else + odsProp = nullptr; +} + +void SortOp::setIsStable(::std::optional attrValue) { + auto &odsProp = getProperties().is_stable; + if (attrValue) + odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue); + else + odsProp = nullptr; +} + +void SortOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, /*optional*/::mlir::IntegerAttr dimension, /*optional*/::mlir::BoolAttr is_stable) { + odsState.addOperands(inputs); + if (dimension) { + odsState.getOrAddProperties().dimension = dimension; + } + if (is_stable) { + odsState.getOrAddProperties().is_stable = is_stable; + } + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void SortOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, /*optional*/::mlir::IntegerAttr dimension, /*optional*/::mlir::BoolAttr is_stable) { + odsState.addOperands(inputs); + if (dimension) { + odsState.getOrAddProperties().dimension = dimension; + } + if (is_stable) { + odsState.getOrAddProperties().is_stable = is_stable; + } + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SortOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SortOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, /*optional*/uint64_t dimension, /*optional*/bool is_stable) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), dimension); + odsState.getOrAddProperties().is_stable = odsBuilder.getBoolAttr(is_stable); + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void SortOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, /*optional*/uint64_t dimension, /*optional*/bool is_stable) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), dimension); + odsState.getOrAddProperties().is_stable = odsBuilder.getBoolAttr(is_stable); + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SortOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SortOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SortOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SortOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void SortOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void SortOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SortOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult SortOp::verifyInvariantsImpl() { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + auto tblgen_is_stable = getProperties().is_stable; (void)tblgen_is_stable; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps35(*this, tblgen_dimension, "dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(*this, tblgen_is_stable, "is_stable"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "comparator", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SortOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::llvm::LogicalResult +SortOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(SortOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SortOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SqrtOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SqrtOpGenericAdaptorBase::SqrtOpGenericAdaptorBase(SqrtOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ResultAccuracyAttr SqrtOpGenericAdaptorBase::getResultAccuracyAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + if (!attr) + attr = ::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + return attr; +} + +::mlir::stablehlo::ResultAccuracyAttr SqrtOpGenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +} // namespace detail +SqrtOpAdaptor::SqrtOpAdaptor(SqrtOp op) : SqrtOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SqrtOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (tblgen_result_accuracy && !((::llvm::isa<::mlir::stablehlo::ResultAccuracyAttr>(tblgen_result_accuracy)))) + return emitError(loc, "'stablehlo.sqrt' op ""attribute 'result_accuracy' failed to satisfy constraint: The requested accuracy for transcendental unary ops."); + return ::mlir::success(); +} + +::llvm::LogicalResult SqrtOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SqrtOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SqrtOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional SqrtOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void SqrtOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SqrtOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult SqrtOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SqrtOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SqrtOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.result_accuracy); +} + +::mlir::stablehlo::ResultAccuracyAttr SqrtOp::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder((*this)->getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +void SqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + odsState.addTypes(result); +} + +void SqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SqrtOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SqrtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SqrtOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void SqrtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SqrtOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult SqrtOp::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SqrtOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult SqrtOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SqrtOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getResultAccuracyAttr(); + if(attr && (attr == ::mlir::stablehlo::ResultAccuracyAttr::get(odsBuilder.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(odsBuilder.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)))) + elidedAttrs.push_back("result_accuracy"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void SqrtOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SqrtOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SubtractOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SubtractOpGenericAdaptorBase::SubtractOpGenericAdaptorBase(SubtractOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +SubtractOpAdaptor::SubtractOpAdaptor(SubtractOp op) : SubtractOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SubtractOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult SubtractOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute SubtractOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SubtractOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional SubtractOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void SubtractOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void SubtractOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult SubtractOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void SubtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void SubtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SubtractOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void SubtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SubtractOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SubtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SubtractOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void SubtractOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SubtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SubtractOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult SubtractOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps23(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SubtractOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult SubtractOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SubtractOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void SubtractOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SubtractOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::TanOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TanOpGenericAdaptorBase::TanOpGenericAdaptorBase(TanOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ResultAccuracyAttr TanOpGenericAdaptorBase::getResultAccuracyAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + if (!attr) + attr = ::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + return attr; +} + +::mlir::stablehlo::ResultAccuracyAttr TanOpGenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +} // namespace detail +TanOpAdaptor::TanOpAdaptor(TanOp op) : TanOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TanOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (tblgen_result_accuracy && !((::llvm::isa<::mlir::stablehlo::ResultAccuracyAttr>(tblgen_result_accuracy)))) + return emitError(loc, "'stablehlo.tan' op ""attribute 'result_accuracy' failed to satisfy constraint: The requested accuracy for transcendental unary ops."); + return ::mlir::success(); +} + +::llvm::LogicalResult TanOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute TanOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TanOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional TanOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void TanOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void TanOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult TanOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult TanOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TanOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.result_accuracy); +} + +::mlir::stablehlo::ResultAccuracyAttr TanOp::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder((*this)->getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +void TanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + odsState.addTypes(result); +} + +void TanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TanOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void TanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TanOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void TanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TanOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void TanOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void TanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TanOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult TanOp::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TanOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult TanOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TanOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getResultAccuracyAttr(); + if(attr && (attr == ::mlir::stablehlo::ResultAccuracyAttr::get(odsBuilder.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(odsBuilder.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)))) + elidedAttrs.push_back("result_accuracy"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void TanOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TanOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::TanhOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TanhOpGenericAdaptorBase::TanhOpGenericAdaptorBase(TanhOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::stablehlo::ResultAccuracyAttr TanhOpGenericAdaptorBase::getResultAccuracyAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + if (!attr) + attr = ::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + return attr; +} + +::mlir::stablehlo::ResultAccuracyAttr TanhOpGenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder(odsAttrs.getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +} // namespace detail +TanhOpAdaptor::TanhOpAdaptor(TanhOp op) : TanhOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TanhOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (tblgen_result_accuracy && !((::llvm::isa<::mlir::stablehlo::ResultAccuracyAttr>(tblgen_result_accuracy)))) + return emitError(loc, "'stablehlo.tanh' op ""attribute 'result_accuracy' failed to satisfy constraint: The requested accuracy for transcendental unary ops."); + return ::mlir::success(); +} + +::llvm::LogicalResult TanhOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute TanhOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TanhOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional TanhOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void TanhOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void TanhOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult TanhOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult TanhOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TanhOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.result_accuracy); +} + +::mlir::stablehlo::ResultAccuracyAttr TanhOp::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + if (!attr) + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(::mlir::stablehlo::ResultAccuracyAttr::get(::mlir::Builder((*this)->getContext()).getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + return ::llvm::cast<::mlir::stablehlo::ResultAccuracyAttr>(attr); +} + +void TanhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + odsState.addTypes(result); +} + +void TanhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TanhOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void TanhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy) { + odsState.addOperands(operand); + if (result_accuracy) { + odsState.getOrAddProperties().result_accuracy = result_accuracy; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TanhOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void TanhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TanhOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void TanhOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void TanhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TanhOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult TanhOp::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps8(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TanhOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult TanhOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TanhOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getResultAccuracyAttr(); + if(attr && (attr == ::mlir::stablehlo::ResultAccuracyAttr::get(odsBuilder.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(odsBuilder.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)))) + elidedAttrs.push_back("result_accuracy"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void TanhOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TanhOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::TorchIndexSelectOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TorchIndexSelectOpGenericAdaptorBase::TorchIndexSelectOpGenericAdaptorBase(TorchIndexSelectOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +uint64_t TorchIndexSelectOpGenericAdaptorBase::getDim() { + auto attr = getDimAttr(); + return attr.getValue().getZExtValue(); +} + +uint64_t TorchIndexSelectOpGenericAdaptorBase::getBatchDims() { + auto attr = getBatchDimsAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +TorchIndexSelectOpAdaptor::TorchIndexSelectOpAdaptor(TorchIndexSelectOp op) : TorchIndexSelectOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TorchIndexSelectOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_batch_dims = getProperties().batch_dims; (void)tblgen_batch_dims; + if (!tblgen_batch_dims) return emitError(loc, "'stablehlo.torch_index_select' op ""requires attribute 'batch_dims'"); + auto tblgen_dim = getProperties().dim; (void)tblgen_dim; + if (!tblgen_dim) return emitError(loc, "'stablehlo.torch_index_select' op ""requires attribute 'dim'"); + + if (tblgen_dim && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_dim))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_dim).getType().isSignlessInteger(64))))) + return emitError(loc, "'stablehlo.torch_index_select' op ""attribute 'dim' failed to satisfy constraint: 64-bit signless integer attribute"); + + if (tblgen_batch_dims && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_batch_dims))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_batch_dims).getType().isSignlessInteger(64))))) + return emitError(loc, "'stablehlo.torch_index_select' op ""attribute 'batch_dims' failed to satisfy constraint: 64-bit signless integer attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult TorchIndexSelectOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.batch_dims; + auto attr = dict.get("batch_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `batch_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.dim; + auto attr = dict.get("dim"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute TorchIndexSelectOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.batch_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("batch_dims", + propStorage)); + } + + { + const auto &propStorage = prop.dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dim", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TorchIndexSelectOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.batch_dims.getAsOpaquePointer()), + llvm::hash_value(prop.dim.getAsOpaquePointer())); +} + +std::optional TorchIndexSelectOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "batch_dims") + return prop.batch_dims; + + if (name == "dim") + return prop.dim; + return std::nullopt; +} + +void TorchIndexSelectOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "batch_dims") { + prop.batch_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "dim") { + prop.dim = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void TorchIndexSelectOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.batch_dims) attrs.append("batch_dims", prop.batch_dims); + + if (prop.dim) attrs.append("dim", prop.dim); +} + +::llvm::LogicalResult TorchIndexSelectOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBatchDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps35(attr, "batch_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps35(attr, "dim", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult TorchIndexSelectOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.batch_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.dim))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TorchIndexSelectOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.batch_dims); + writer.writeAttribute(prop.dim); +} + +uint64_t TorchIndexSelectOp::getDim() { + auto attr = getDimAttr(); + return attr.getValue().getZExtValue(); +} + +uint64_t TorchIndexSelectOp::getBatchDims() { + auto attr = getBatchDimsAttr(); + return attr.getValue().getZExtValue(); +} + +void TorchIndexSelectOp::setDim(uint64_t attrValue) { + getProperties().dim = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void TorchIndexSelectOp::setBatchDims(uint64_t attrValue) { + getProperties().batch_dims = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue); +} + +void TorchIndexSelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value index, ::mlir::IntegerAttr dim, ::mlir::IntegerAttr batch_dims) { + odsState.addOperands(operand); + odsState.addOperands(index); + odsState.getOrAddProperties().dim = dim; + odsState.getOrAddProperties().batch_dims = batch_dims; + odsState.addTypes(resultType0); +} + +void TorchIndexSelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value index, ::mlir::IntegerAttr dim, ::mlir::IntegerAttr batch_dims) { + odsState.addOperands(operand); + odsState.addOperands(index); + odsState.getOrAddProperties().dim = dim; + odsState.getOrAddProperties().batch_dims = batch_dims; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TorchIndexSelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value index, uint64_t dim, uint64_t batch_dims) { + odsState.addOperands(operand); + odsState.addOperands(index); + odsState.getOrAddProperties().dim = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), dim); + odsState.getOrAddProperties().batch_dims = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), batch_dims); + odsState.addTypes(resultType0); +} + +void TorchIndexSelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value index, uint64_t dim, uint64_t batch_dims) { + odsState.addOperands(operand); + odsState.addOperands(index); + odsState.getOrAddProperties().dim = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), dim); + odsState.getOrAddProperties().batch_dims = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), batch_dims); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TorchIndexSelectOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void TorchIndexSelectOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult TorchIndexSelectOp::verifyInvariantsImpl() { + auto tblgen_batch_dims = getProperties().batch_dims; (void)tblgen_batch_dims; + if (!tblgen_batch_dims) return emitOpError("requires attribute 'batch_dims'"); + auto tblgen_dim = getProperties().dim; (void)tblgen_dim; + if (!tblgen_dim) return emitOpError("requires attribute 'dim'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps35(*this, tblgen_dim, "dim"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps35(*this, tblgen_batch_dims, "batch_dims"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TorchIndexSelectOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void TorchIndexSelectOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TorchIndexSelectOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::TransposeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TransposeOpGenericAdaptorBase::TransposeOpGenericAdaptorBase(TransposeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::llvm::ArrayRef TransposeOpGenericAdaptorBase::getPermutation() { + auto attr = getPermutationAttr(); + return attr; +} + +} // namespace detail +TransposeOpAdaptor::TransposeOpAdaptor(TransposeOp op) : TransposeOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TransposeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_permutation = getProperties().permutation; (void)tblgen_permutation; + if (!tblgen_permutation) return emitError(loc, "'stablehlo.transpose' op ""requires attribute 'permutation'"); + + if (tblgen_permutation && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_permutation)))) + return emitError(loc, "'stablehlo.transpose' op ""attribute 'permutation' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult TransposeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.permutation; + auto attr = dict.get("permutation"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `permutation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute TransposeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.permutation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("permutation", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TransposeOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.permutation.getAsOpaquePointer())); +} + +std::optional TransposeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "permutation") + return prop.permutation; + return std::nullopt; +} + +void TransposeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "permutation") { + prop.permutation = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void TransposeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.permutation) attrs.append("permutation", prop.permutation); +} + +::llvm::LogicalResult TransposeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getPermutationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(attr, "permutation", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult TransposeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.permutation))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TransposeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.permutation); +} + +::llvm::ArrayRef TransposeOp::getPermutation() { + auto attr = getPermutationAttr(); + return attr; +} + +void TransposeOp::setPermutation(::llvm::ArrayRef attrValue) { + getProperties().permutation = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue); +} + +void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr permutation) { + odsState.addOperands(operand); + odsState.getOrAddProperties().permutation = permutation; + odsState.addTypes(result); +} + +void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr permutation) { + odsState.addOperands(operand); + odsState.getOrAddProperties().permutation = permutation; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TransposeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr permutation) { + odsState.addOperands(operand); + odsState.getOrAddProperties().permutation = permutation; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::llvm::ArrayRef permutation) { + odsState.addOperands(operand); + odsState.getOrAddProperties().permutation = odsBuilder.getDenseI64ArrayAttr(permutation); + odsState.addTypes(result); +} + +void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::llvm::ArrayRef permutation) { + odsState.addOperands(operand); + odsState.getOrAddProperties().permutation = odsBuilder.getDenseI64ArrayAttr(permutation); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TransposeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::llvm::ArrayRef permutation) { + odsState.addOperands(operand); + odsState.getOrAddProperties().permutation = odsBuilder.getDenseI64ArrayAttr(permutation); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TransposeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TransposeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void TransposeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TransposeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult TransposeOp::verifyInvariantsImpl() { + auto tblgen_permutation = getProperties().permutation; (void)tblgen_permutation; + if (!tblgen_permutation) return emitOpError("requires attribute 'permutation'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps7(*this, tblgen_permutation, "permutation"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TransposeOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult TransposeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::DenseI64ArrayAttr permutationAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("dims")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(permutationAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (permutationAttr) result.getOrAddProperties().permutation = permutationAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(operandOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TransposeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' ' << "dims"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getPermutationAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("permutation"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void TransposeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TransposeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::TriangularSolveOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TriangularSolveOpGenericAdaptorBase::TriangularSolveOpGenericAdaptorBase(TriangularSolveOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +bool TriangularSolveOpGenericAdaptorBase::getLeftSide() { + auto attr = getLeftSideAttr(); + return attr.getValue(); +} + +bool TriangularSolveOpGenericAdaptorBase::getLower() { + auto attr = getLowerAttr(); + return attr.getValue(); +} + +bool TriangularSolveOpGenericAdaptorBase::getUnitDiagonal() { + auto attr = getUnitDiagonalAttr(); + return attr.getValue(); +} + +::mlir::stablehlo::Transpose TriangularSolveOpGenericAdaptorBase::getTransposeA() { + auto attr = getTransposeAAttr(); + return attr.getValue(); +} + +} // namespace detail +TriangularSolveOpAdaptor::TriangularSolveOpAdaptor(TriangularSolveOp op) : TriangularSolveOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TriangularSolveOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_left_side = getProperties().left_side; (void)tblgen_left_side; + if (!tblgen_left_side) return emitError(loc, "'stablehlo.triangular_solve' op ""requires attribute 'left_side'"); + auto tblgen_lower = getProperties().lower; (void)tblgen_lower; + if (!tblgen_lower) return emitError(loc, "'stablehlo.triangular_solve' op ""requires attribute 'lower'"); + auto tblgen_transpose_a = getProperties().transpose_a; (void)tblgen_transpose_a; + if (!tblgen_transpose_a) return emitError(loc, "'stablehlo.triangular_solve' op ""requires attribute 'transpose_a'"); + auto tblgen_unit_diagonal = getProperties().unit_diagonal; (void)tblgen_unit_diagonal; + if (!tblgen_unit_diagonal) return emitError(loc, "'stablehlo.triangular_solve' op ""requires attribute 'unit_diagonal'"); + + if (tblgen_left_side && !((::llvm::isa<::mlir::BoolAttr>(tblgen_left_side)))) + return emitError(loc, "'stablehlo.triangular_solve' op ""attribute 'left_side' failed to satisfy constraint: bool attribute"); + + if (tblgen_lower && !((::llvm::isa<::mlir::BoolAttr>(tblgen_lower)))) + return emitError(loc, "'stablehlo.triangular_solve' op ""attribute 'lower' failed to satisfy constraint: bool attribute"); + + if (tblgen_unit_diagonal && !((::llvm::isa<::mlir::BoolAttr>(tblgen_unit_diagonal)))) + return emitError(loc, "'stablehlo.triangular_solve' op ""attribute 'unit_diagonal' failed to satisfy constraint: bool attribute"); + + if (tblgen_transpose_a && !((::llvm::isa<::mlir::stablehlo::TransposeAttr>(tblgen_transpose_a)))) + return emitError(loc, "'stablehlo.triangular_solve' op ""attribute 'transpose_a' failed to satisfy constraint: Transpose options"); + return ::mlir::success(); +} + +::llvm::LogicalResult TriangularSolveOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.left_side; + auto attr = dict.get("left_side"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `left_side` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.lower; + auto attr = dict.get("lower"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lower` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.transpose_a; + auto attr = dict.get("transpose_a"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `transpose_a` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.unit_diagonal; + auto attr = dict.get("unit_diagonal"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `unit_diagonal` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute TriangularSolveOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.left_side; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("left_side", + propStorage)); + } + + { + const auto &propStorage = prop.lower; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lower", + propStorage)); + } + + { + const auto &propStorage = prop.transpose_a; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("transpose_a", + propStorage)); + } + + { + const auto &propStorage = prop.unit_diagonal; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("unit_diagonal", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TriangularSolveOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.left_side.getAsOpaquePointer()), + llvm::hash_value(prop.lower.getAsOpaquePointer()), + llvm::hash_value(prop.transpose_a.getAsOpaquePointer()), + llvm::hash_value(prop.unit_diagonal.getAsOpaquePointer())); +} + +std::optional TriangularSolveOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "left_side") + return prop.left_side; + + if (name == "lower") + return prop.lower; + + if (name == "transpose_a") + return prop.transpose_a; + + if (name == "unit_diagonal") + return prop.unit_diagonal; + return std::nullopt; +} + +void TriangularSolveOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "left_side") { + prop.left_side = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "lower") { + prop.lower = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "transpose_a") { + prop.transpose_a = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "unit_diagonal") { + prop.unit_diagonal = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void TriangularSolveOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.left_side) attrs.append("left_side", prop.left_side); + + if (prop.lower) attrs.append("lower", prop.lower); + + if (prop.transpose_a) attrs.append("transpose_a", prop.transpose_a); + + if (prop.unit_diagonal) attrs.append("unit_diagonal", prop.unit_diagonal); +} + +::llvm::LogicalResult TriangularSolveOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getLeftSideAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(attr, "left_side", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLowerAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(attr, "lower", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getTransposeAAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps36(attr, "transpose_a", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUnitDiagonalAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(attr, "unit_diagonal", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult TriangularSolveOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.left_side))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.lower))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.transpose_a))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.unit_diagonal))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TriangularSolveOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.left_side); + writer.writeAttribute(prop.lower); + writer.writeAttribute(prop.transpose_a); + writer.writeAttribute(prop.unit_diagonal); +} + +bool TriangularSolveOp::getLeftSide() { + auto attr = getLeftSideAttr(); + return attr.getValue(); +} + +bool TriangularSolveOp::getLower() { + auto attr = getLowerAttr(); + return attr.getValue(); +} + +bool TriangularSolveOp::getUnitDiagonal() { + auto attr = getUnitDiagonalAttr(); + return attr.getValue(); +} + +::mlir::stablehlo::Transpose TriangularSolveOp::getTransposeA() { + auto attr = getTransposeAAttr(); + return attr.getValue(); +} + +void TriangularSolveOp::setLeftSide(bool attrValue) { + getProperties().left_side = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); +} + +void TriangularSolveOp::setLower(bool attrValue) { + getProperties().lower = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); +} + +void TriangularSolveOp::setUnitDiagonal(bool attrValue) { + getProperties().unit_diagonal = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue); +} + +void TriangularSolveOp::setTransposeA(::mlir::stablehlo::Transpose attrValue) { + getProperties().transpose_a = ::mlir::stablehlo::TransposeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue); +} + +void TriangularSolveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr left_side, ::mlir::BoolAttr lower, ::mlir::BoolAttr unit_diagonal, ::mlir::stablehlo::TransposeAttr transpose_a) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.getOrAddProperties().left_side = left_side; + odsState.getOrAddProperties().lower = lower; + odsState.getOrAddProperties().unit_diagonal = unit_diagonal; + odsState.getOrAddProperties().transpose_a = transpose_a; + odsState.addTypes(resultType0); +} + +void TriangularSolveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr left_side, ::mlir::BoolAttr lower, ::mlir::BoolAttr unit_diagonal, ::mlir::stablehlo::TransposeAttr transpose_a) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.getOrAddProperties().left_side = left_side; + odsState.getOrAddProperties().lower = lower; + odsState.getOrAddProperties().unit_diagonal = unit_diagonal; + odsState.getOrAddProperties().transpose_a = transpose_a; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TriangularSolveOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void TriangularSolveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr left_side, ::mlir::BoolAttr lower, ::mlir::BoolAttr unit_diagonal, ::mlir::stablehlo::TransposeAttr transpose_a) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.getOrAddProperties().left_side = left_side; + odsState.getOrAddProperties().lower = lower; + odsState.getOrAddProperties().unit_diagonal = unit_diagonal; + odsState.getOrAddProperties().transpose_a = transpose_a; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TriangularSolveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value a, ::mlir::Value b, bool left_side, bool lower, bool unit_diagonal, ::mlir::stablehlo::Transpose transpose_a) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.getOrAddProperties().left_side = odsBuilder.getBoolAttr(left_side); + odsState.getOrAddProperties().lower = odsBuilder.getBoolAttr(lower); + odsState.getOrAddProperties().unit_diagonal = odsBuilder.getBoolAttr(unit_diagonal); + odsState.getOrAddProperties().transpose_a = ::mlir::stablehlo::TransposeAttr::get(odsBuilder.getContext(), transpose_a); + odsState.addTypes(resultType0); +} + +void TriangularSolveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, bool left_side, bool lower, bool unit_diagonal, ::mlir::stablehlo::Transpose transpose_a) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.getOrAddProperties().left_side = odsBuilder.getBoolAttr(left_side); + odsState.getOrAddProperties().lower = odsBuilder.getBoolAttr(lower); + odsState.getOrAddProperties().unit_diagonal = odsBuilder.getBoolAttr(unit_diagonal); + odsState.getOrAddProperties().transpose_a = ::mlir::stablehlo::TransposeAttr::get(odsBuilder.getContext(), transpose_a); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TriangularSolveOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void TriangularSolveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, bool left_side, bool lower, bool unit_diagonal, ::mlir::stablehlo::Transpose transpose_a) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.getOrAddProperties().left_side = odsBuilder.getBoolAttr(left_side); + odsState.getOrAddProperties().lower = odsBuilder.getBoolAttr(lower); + odsState.getOrAddProperties().unit_diagonal = odsBuilder.getBoolAttr(unit_diagonal); + odsState.getOrAddProperties().transpose_a = ::mlir::stablehlo::TransposeAttr::get(odsBuilder.getContext(), transpose_a); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TriangularSolveOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void TriangularSolveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TriangularSolveOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void TriangularSolveOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void TriangularSolveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TriangularSolveOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult TriangularSolveOp::verifyInvariantsImpl() { + auto tblgen_left_side = getProperties().left_side; (void)tblgen_left_side; + if (!tblgen_left_side) return emitOpError("requires attribute 'left_side'"); + auto tblgen_lower = getProperties().lower; (void)tblgen_lower; + if (!tblgen_lower) return emitOpError("requires attribute 'lower'"); + auto tblgen_transpose_a = getProperties().transpose_a; (void)tblgen_transpose_a; + if (!tblgen_transpose_a) return emitOpError("requires attribute 'transpose_a'"); + auto tblgen_unit_diagonal = getProperties().unit_diagonal; (void)tblgen_unit_diagonal; + if (!tblgen_unit_diagonal) return emitOpError("requires attribute 'unit_diagonal'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(*this, tblgen_left_side, "left_side"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(*this, tblgen_lower, "lower"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps9(*this, tblgen_unit_diagonal, "unit_diagonal"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps36(*this, tblgen_transpose_a, "transpose_a"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps29(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps29(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps29(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TriangularSolveOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void TriangularSolveOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +TriangularSolveOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(TriangularSolveOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TriangularSolveOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::TupleOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TupleOpGenericAdaptorBase::TupleOpGenericAdaptorBase(TupleOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair TupleOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +} // namespace detail +TupleOpAdaptor::TupleOpAdaptor(TupleOp op) : TupleOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TupleOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair TupleOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange TupleOp::getValMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult TupleOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute TupleOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TupleOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional TupleOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void TupleOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void TupleOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult TupleOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void TupleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange val) { + odsState.addOperands(val); + odsState.addTypes(result); +} + +void TupleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void TupleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TupleOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void TupleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void TupleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(TupleOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult TupleOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps19(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps30(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TupleOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult TupleOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> valOperands; + ::llvm::SMLoc valOperandsLoc; + (void)valOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> valTypes; + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + valOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(valOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseTupleOpType(parser, valTypes, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(valOperands, valTypes, valOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TupleOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getVal(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printTupleOpType(_odsPrinter, *this, getVal().getTypes(), getResult().getType()); +} + +void TupleOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TupleOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::UnaryEinsumOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +UnaryEinsumOpGenericAdaptorBase::UnaryEinsumOpGenericAdaptorBase(UnaryEinsumOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::llvm::StringRef UnaryEinsumOpGenericAdaptorBase::getEinsumConfig() { + auto attr = getEinsumConfigAttr(); + return attr.getValue(); +} + +} // namespace detail +UnaryEinsumOpAdaptor::UnaryEinsumOpAdaptor(UnaryEinsumOp op) : UnaryEinsumOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult UnaryEinsumOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_einsum_config = getProperties().einsum_config; (void)tblgen_einsum_config; + if (!tblgen_einsum_config) return emitError(loc, "'stablehlo.unary_einsum' op ""requires attribute 'einsum_config'"); + + if (tblgen_einsum_config && !((::llvm::isa<::mlir::StringAttr>(tblgen_einsum_config)))) + return emitError(loc, "'stablehlo.unary_einsum' op ""attribute 'einsum_config' failed to satisfy constraint: string attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult UnaryEinsumOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.einsum_config; + auto attr = dict.get("einsum_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `einsum_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute UnaryEinsumOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.einsum_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("einsum_config", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code UnaryEinsumOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.einsum_config.getAsOpaquePointer())); +} + +std::optional UnaryEinsumOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "einsum_config") + return prop.einsum_config; + return std::nullopt; +} + +void UnaryEinsumOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "einsum_config") { + prop.einsum_config = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void UnaryEinsumOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.einsum_config) attrs.append("einsum_config", prop.einsum_config); +} + +::llvm::LogicalResult UnaryEinsumOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getEinsumConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps12(attr, "einsum_config", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult UnaryEinsumOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.einsum_config))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void UnaryEinsumOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.einsum_config); +} + +::llvm::StringRef UnaryEinsumOp::getEinsumConfig() { + auto attr = getEinsumConfigAttr(); + return attr.getValue(); +} + +void UnaryEinsumOp::setEinsumConfig(::llvm::StringRef attrValue) { + getProperties().einsum_config = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue); +} + +void UnaryEinsumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::StringAttr einsum_config) { + odsState.addOperands(operand); + odsState.getOrAddProperties().einsum_config = einsum_config; + odsState.addTypes(resultType0); +} + +void UnaryEinsumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::StringAttr einsum_config) { + odsState.addOperands(operand); + odsState.getOrAddProperties().einsum_config = einsum_config; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void UnaryEinsumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::llvm::StringRef einsum_config) { + odsState.addOperands(operand); + odsState.getOrAddProperties().einsum_config = odsBuilder.getStringAttr(einsum_config); + odsState.addTypes(resultType0); +} + +void UnaryEinsumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::llvm::StringRef einsum_config) { + odsState.addOperands(operand); + odsState.getOrAddProperties().einsum_config = odsBuilder.getStringAttr(einsum_config); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void UnaryEinsumOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void UnaryEinsumOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult UnaryEinsumOp::verifyInvariantsImpl() { + auto tblgen_einsum_config = getProperties().einsum_config; (void)tblgen_einsum_config; + if (!tblgen_einsum_config) return emitOpError("requires attribute 'einsum_config'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_StablehloOps12(*this, tblgen_einsum_config, "einsum_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult UnaryEinsumOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult UnaryEinsumOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::StringAttr einsum_configAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseKeyword("config")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(einsum_configAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (einsum_configAttr) result.getOrAddProperties().einsum_config = einsum_configAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(operandOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void UnaryEinsumOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + _odsPrinter << ","; + _odsPrinter << ' ' << "config"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getEinsumConfigAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("einsum_config"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void UnaryEinsumOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::UnaryEinsumOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::UniformDequantizeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +UniformDequantizeOpGenericAdaptorBase::UniformDequantizeOpGenericAdaptorBase(UniformDequantizeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +UniformDequantizeOpAdaptor::UniformDequantizeOpAdaptor(UniformDequantizeOp op) : UniformDequantizeOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult UniformDequantizeOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult UniformDequantizeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute UniformDequantizeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code UniformDequantizeOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional UniformDequantizeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void UniformDequantizeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void UniformDequantizeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult UniformDequantizeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void UniformDequantizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void UniformDequantizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand) { + odsState.addOperands(operand); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(UniformDequantizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void UniformDequantizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void UniformDequantizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void UniformDequantizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(UniformDequantizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void UniformDequantizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void UniformDequantizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(UniformDequantizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult UniformDequantizeOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps44(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps32(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult UniformDequantizeOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult UniformDequantizeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void UniformDequantizeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void UniformDequantizeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::llvm::LogicalResult +UniformDequantizeOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents; + if (failed(UniformDequantizeOp::inferReturnTypeComponents(context, location, + operands, attributes, properties, regions, + retComponents))) + return failure(); + return ::mlir::detail::inferReturnTensorTypes(retComponents, + inferredReturnTypes); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::UniformDequantizeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::UniformQuantizeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +UniformQuantizeOpGenericAdaptorBase::UniformQuantizeOpGenericAdaptorBase(UniformQuantizeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +UniformQuantizeOpAdaptor::UniformQuantizeOpAdaptor(UniformQuantizeOp op) : UniformQuantizeOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult UniformQuantizeOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult UniformQuantizeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute UniformQuantizeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code UniformQuantizeOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional UniformQuantizeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void UniformQuantizeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void UniformQuantizeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult UniformQuantizeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void UniformQuantizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void UniformQuantizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void UniformQuantizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void UniformQuantizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult UniformQuantizeOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps45(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps44(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult UniformQuantizeOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult UniformQuantizeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operandRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operandOperands(&operandRawOperand, 1); ::llvm::SMLoc operandOperandsLoc; + (void)operandOperandsLoc; + ::mlir::Type operandRawType{}; + ::llvm::ArrayRef<::mlir::Type> operandTypes(&operandRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + operandOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operandRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, operandRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(operandOperands, operandTypes, operandOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void UniformQuantizeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperand(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getOperand().getType(), getResult().getType()); +} + +void UniformQuantizeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::UniformQuantizeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::WhileOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +WhileOpGenericAdaptorBase::WhileOpGenericAdaptorBase(WhileOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair WhileOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +} // namespace detail +WhileOpAdaptor::WhileOpAdaptor(WhileOp op) : WhileOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult WhileOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair WhileOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange WhileOp::getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair WhileOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult WhileOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute WhileOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code WhileOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional WhileOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void WhileOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void WhileOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult WhileOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void WhileOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void WhileOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(WhileOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void WhileOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void WhileOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(WhileOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult WhileOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps14(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps14(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "cond", index++))) + return ::mlir::failure(); + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) + if (::mlir::failed(__mlir_ods_local_region_constraint_StablehloOps1(*this, region, "body", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult WhileOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::WhileOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::XorOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +XorOpGenericAdaptorBase::XorOpGenericAdaptorBase(XorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +XorOpAdaptor::XorOpAdaptor(XorOp op) : XorOpGenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult XorOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult XorOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute XorOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code XorOp::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional XorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void XorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void XorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult XorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void XorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void XorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(XorOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::mlir::detail::reportFatalInferReturnTypesError(odsState); + +} + +void XorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void XorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void XorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(XorOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +void XorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void XorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(XorOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::llvm::LogicalResult XorOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_StablehloOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult XorOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult XorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperand{}; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(&rhsRawOperand, 1); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); + ::mlir::Type rhsRawType{}; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(&rhsRawType, 1); + ::mlir::Type resultRawType{}; + ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperand)) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperand)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + { + auto odsResult = parseSameOperandsAndResultType(parser, lhsRawType, rhsRawType, resultRawType); + if (odsResult) return ::mlir::failure(); + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void XorOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + printSameOperandsAndResultType(_odsPrinter, *this, getLhs().getType(), getRhs().getType(), getResult().getType()); +} + +void XorOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::XorOp) + + +#endif // GET_OP_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloOps.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloOps.h new file mode 100644 index 0000000000000000000000000000000000000000..fe99aee4bd5690fdb08c59a191bfca392b2bb111 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloOps.h @@ -0,0 +1,197 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + Copyright 2022 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_STABLEHLO_OPS_H +#define STABLEHLO_DIALECT_STABLEHLO_OPS_H + +#include +#include + +#include "llvm/ADT/StringRef.h" +#include "mlir/Dialect/Quant/IR/QuantTypes.h" +#include "mlir/Dialect/Shape/IR/Shape.h" +#include "mlir/IR/Attributes.h" +#include "mlir/IR/Block.h" +#include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinAttributes.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/Dialect.h" +#include "mlir/IR/DialectImplementation.h" +#include "mlir/IR/Location.h" +#include "mlir/IR/MLIRContext.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/Operation.h" +#include "mlir/IR/Region.h" +#include "mlir/IR/TensorEncoding.h" +#include "mlir/IR/TypeUtilities.h" +#include "mlir/IR/Types.h" +#include "mlir/Interfaces/InferTypeOpInterface.h" +#include "mlir/Interfaces/SideEffectInterfaces.h" +#include "mlir/Support/LogicalResult.h" +#include "stablehlo/dialect/Base.h" +#include "stablehlo/dialect/Version.h" + +#define GET_TYPEDEF_CLASSES +#include "stablehlo/dialect/StablehloTypeDefs.h.inc" + +// Include order matters. +#include "stablehlo/dialect/StablehloEnums.h.inc" +#define GET_ATTRDEF_CLASSES +#include "stablehlo/dialect/StablehloAttrs.h.inc" + +namespace mlir { +namespace stablehlo { + +struct StablehloDialectVersion : public mlir::DialectVersion { + StablehloDialectVersion(int64_t major, int64_t minor, int64_t patch) + : dialectVersion(major, minor, patch) {} + + int64_t getMajor() const { return dialectVersion.getMajor(); } + int64_t getMinor() const { return dialectVersion.getMinor(); } + int64_t getPatch() const { return dialectVersion.getPatch(); } + + static StablehloDialectVersion getCurrentVersion() { + // The same version as VHLO as this is serialization related only. + auto vhloVer = vhlo::Version::getCurrentVersion(); + return {vhloVer.getMajor(), vhloVer.getMinor(), vhloVer.getPatch()}; + } + + bool operator<(const StablehloDialectVersion &other) const { + return this->dialectVersion < other.dialectVersion; + } + + private: + // The dialect version read from bytecode. + vhlo::Version dialectVersion; +}; + +class StablehloDialect : public Dialect { + public: + explicit StablehloDialect(MLIRContext *context); + static StringRef getDialectNamespace() { return "stablehlo"; } + + // Registered hook to materialize a constant operation from a given attribute + // value with the desired resultant type. + Operation *materializeConstant(OpBuilder &builder, Attribute value, Type type, + Location loc) override; + + // Parses a type registered to this dialect. + Type parseType(DialectAsmParser &parser) const override; + + // Prints a type registered to this dialect. + void printType(Type type, DialectAsmPrinter &os) const override; + + // Parses an attribute registered to this dialect. + Attribute parseAttribute(DialectAsmParser &parser, Type type) const override; + + // Prints an attribute registered to this dialect. + void printAttribute(Attribute attr, DialectAsmPrinter &os) const override; + + // Get the set dialect version. + std::optional getVersion() const; + + // Set dialect version. + // Note: there is currently no validation. + void setVersion(std::optional version); + + private: + std::optional version; +}; + +// Verifies the source target pairs attached to collective permute. +LogicalResult verifyCollectivePermuteSourceTargetPairs( + Operation *op, DenseIntElementsAttr attr); + +void printConvolutionDimensions(AsmPrinter &p, + ConvDimensionNumbersAttr dimNums); +void printConvolutionDimensions(AsmPrinter &p, Operation *, + ConvDimensionNumbersAttr dimNums); +ParseResult parseConvolutionDimensions(AsmParser &parser, + ConvDimensionNumbersAttr &dimNums); + +void printWindowAttributes(OpAsmPrinter &p, Operation *op, + std::optional windowStrides, + std::optional padding, + std::optional lhsDilation, + std::optional rhsDilation, + std::optional windowReversal); + +ParseResult parseWindowAttributes(OpAsmParser &parser, + DenseI64ArrayAttr &windowStrides, + DenseIntElementsAttr &padding, + DenseI64ArrayAttr &lhsDilation, + DenseI64ArrayAttr &rhsDilation, + DenseBoolArrayAttr &windowReversal); + +namespace side_effects { + +struct SendResource : ::mlir::SideEffects::Resource::Base { + StringRef getName() final { return "SendResource"; } +}; +struct RecvResource : ::mlir::SideEffects::Resource::Base { + StringRef getName() final { return "RecvResource"; } +}; +struct InfeedResource : ::mlir::SideEffects::Resource::Base { + StringRef getName() final { return "InfeedResource"; } +}; +struct OutfeedResource : ::mlir::SideEffects::Resource::Base { + StringRef getName() final { return "OutfeedResource"; } +}; + +} // end namespace side_effects + +} // end namespace stablehlo +} // end namespace mlir + +#define GET_OP_CLASSES +#include "stablehlo/dialect/StablehloOps.h.inc" + +namespace mlir { +namespace stablehlo { + +// Returns the broadcast_dimensions for a BroadcastInDimOp from the +// result_type and broadcast_sizes from a BroadcastOp. +DenseI64ArrayAttr getBroadcastDimensionsFromBroadcastSizes( + RankedTensorType resultType, DenseI64ArrayAttr broadcastSizes); + +// Returns the dimension numbers for a DotGeneral op that can be expressed as +// a DotOp, given the LHS of such an operation. +DotDimensionNumbersAttr getDefaultDotDimensionNumbers(mlir::Value lhs); + +SortOp createSortOp(PatternRewriter *rewriter, const Location &loc, + const llvm::ArrayRef &operands, + const llvm::ArrayRef &elementTypes, int64_t dimension, + bool isStable, ComparisonDirection direction); + +template +void buildReduceBody(Type elementType, Region &body, OpBuilder &builder) { + OpBuilder::InsertionGuard guard(builder); + Block *block = builder.createBlock(&body); + + // Block arguments are scalars of the given element type. + Type type = RankedTensorType::get(/*shape=*/{}, elementType); + Location loc = body.getLoc(); + block->addArguments({type, type}, {loc, loc}); + + auto reducer = + builder.create(loc, block->getArgument(0), block->getArgument(1)); + builder.create(loc, reducer.getResult()); +} + +} // end namespace stablehlo +} // end namespace mlir + +#endif // STABLEHLO_DIALECT_STABLEHLO_OPS_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloOps.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloOps.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..9c420e1aae38185f81e812a7bbaf99bc194f44d4 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloOps.h.inc @@ -0,0 +1,28284 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: StablehloOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace stablehlo { +/// Abs operation +/// Performs element-wise abs operation on `operand` tensor and produces a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#abs +/// +/// Example: +/// ```mlir +/// %result = stablehlo.abs %operand : tensor<3xi32> +/// ``` +class AbsOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Add operation +/// Performs element-wise addition of two tensors `lhs` and `rhs` and produces a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#add +/// +/// Example: +/// ```mlir +/// %result = stablehlo.add %lhs, %rhs : tensor<2x2xi32> +/// ``` +class AddOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// AfterAll operation +/// Ensures that the operations producing the `inputs` are executed before any +/// operations that depend on `result`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#after_all +/// +/// Example: +/// ```mlir +/// %result = stablehlo.after_all %input0, %input1 : !stablehlo.token +/// ``` +class AfterAllOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// AllGather operation +/// Within each process group in the process grid, concatenates the values of the +/// `operand` tensor from each process along `all_gather_dim` and produces a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#all_gather +/// +/// Example: +/// ```mlir +/// %result:2 = "stablehlo.all_gather"(%operand0, %operand1) { +/// all_gather_dim = 1 : i64, +/// replica_groups = dense<[[0, 1]]> : tensor<1x2xi64>, +/// channel_handle = #stablehlo.channel_handle +/// } : (tensor<2x2xi64>, tensor<2x2xi64>) -> (tensor<2x4xi64>, tensor<2x4xi64>) +/// ``` +class AllGatherOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// AllReduce operation +/// Within each process group in the process grid, applies a reduction function +/// `computation` to the values of the `operand` tensor from each process and +/// produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#all_reduce +/// +/// Example: +/// ```mlir +/// %result:2 = "stablehlo.all_reduce"(%operand0, %operand0) ({ +/// ^bb0(%arg0: tensor, %arg1: tensor): +/// %0 = "stablehlo.add"(%arg0, %arg1) : (tensor, tensor) -> tensor +/// "stablehlo.return"(%0) : (tensor) -> () +/// }) { +/// replica_groups = dense<[[0, 1]]> : tensor<1x2xi64>, +/// channel_handle = #stablehlo.channel_handle +/// } : (tensor<4xi64>, tensor<4xi64>) -> (tensor<4xi64>, tensor<4xi64>) +/// ``` +class AllReduceOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// AllToAll operation +/// Within each process group in the process grid, splits the values of the +/// `operand` tensor along `split_dimension` into parts, scatters the split parts +/// between the processes, concatenates the scattered parts along `concat_dimension` +/// and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#all_to_all +/// +/// Example: +/// ```mlir +/// %result:2 = "stablehlo.all_to_all"(%operand1, %operand2) { +/// split_dimension = 1 : i64, +/// concat_dimension = 0 : i64, +/// split_count = 2 : i64, +/// replica_groups = dense<[[0, 1]]> : tensor<1x2xi64> +/// } : (tensor<2x4xi64>, tensor<2x4xi64>) -> (tensor<4x2xi64>, tensor<4x2xi64>) +/// ``` +class AllToAllOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// And operation +/// Performs element-wise AND of two tensors `lhs` and `rhs` and produces a +/// `result` tensor +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#and +/// +/// Example: +/// ```mlir +/// %result = stablehlo.and %lhs, %rhs : tensor<2x2xi32> +/// ``` +class AndOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Atan2 operation +/// Performs element-wise atan2 operation on `lhs` and `rhs` tensor and produces +/// a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#atan2 +/// +/// Example: +/// ```mlir +/// %result = stablehlo.atan2 %lhs, %rhs : tensor<3xf64> +/// ``` +class Atan2Op; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// BatchNormGrad operation +/// Computes gradients of several inputs of BatchNormTrainingOp backpropagating +/// from `grad_output`, and produces `grad_operand`, `grad_scale` and +/// `grad_offset` tensors. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#batch_norm_grad +/// +/// Example: +/// ```mlir +/// %grad_operand, %grad_scale, %grad_offset = +/// "stablehlo.batch_norm_grad"(%operand, %scale, %mean, %variance, %grad_output) { +/// epsilon = 0.0 : f32, +/// feature_index = 2 : i64 +/// } : (tensor<2x2x2xf64>, tensor<2xf64>, tensor<2xf64>, tensor<2xf64>, +/// tensor<2x2x2xf64>) -> (tensor<2x2x2xf64>, tensor<2xf64>, tensor<2xf64>) +/// ``` +class BatchNormGradOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// BatchNormInference operation +/// Normalizes the `operand` tensor across all dimensions except for the +/// `feature_index` dimension and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#batch_norm_inference +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.batch_norm_inference"(%operand, %scale, %offset, %mean, %variance) { +/// epsilon = 0.0 : f32, +/// feature_index = 2 : i64 +/// } : (tensor<2x2x2xf64>, tensor<2xf64>, tensor<2xf64>, tensor<2xf64>, tensor<2xf64>) -> tensor<2x2x2xf64> +/// ``` +class BatchNormInferenceOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// BatchNormTraining operation +/// Computes mean and variance across batch and spatial dimensions and +/// normalizes the `operand` tensor, for each feature in the `feature_index` +/// dimension and produces `output`, `batch_mean` and `batch_var` tensors. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#batch_norm_training +/// +/// Example: +/// ```mlir +/// %output, %batch_mean, %batch_var = "stablehlo.batch_norm_training"(%operand, %scale, %offset) { +/// epsilon = 0.0 : f32, +/// feature_index = 2 : i64 +/// } : (tensor<2x2x2xf64>, tensor<2xf64>, tensor<2xf64>) -> +/// (tensor<2x2x2xf64>, tensor<2xf64>, tensor<2xf64>) +/// ``` +class BatchNormTrainingOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// BitcastConvert operation +/// Performs a bitcast operation on `operand` tensor and produces a `result` +/// tensor where the bits of the entire `operand` tensor are reinterpreted using +/// the type of the `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#bitcast_convert +/// +/// Example: +/// ```mlir +/// %result = stablehlo.bitcast_convert %operand : (tensor) -> tensor<4xf16> +/// ``` +class BitcastConvertOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// BroadcastInDim operation +/// Expands the dimensions and/or rank of an input tensor by duplicating the +/// data in the `operand` tensor and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#broadcast_in_dim +/// +/// Example: +/// ```mlir +/// %result = stablehlo.broadcast_in_dim %operand, dims = [2, 1] : (tensor<1x3xi32>) -> tensor<2x3x2xi32> +/// ``` +class BroadcastInDimOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Broadcast operation +/// This operation is on its way out of StableHLO, so it is not included in +/// the StableHLO specification: https://github.com/openxla/stablehlo/issues/3. +/// +/// Informally, this operation does the same thing as XLA's Broadcast: +/// https://www.tensorflow.org/xla/operation_semantics#broadcast +/// +/// Example: +/// ```mlir +/// %result = stablehlo.broadcast %operand, sizes = [1, 2] : (tensor<3xi32>) -> tensor<1x2x3xi32> +/// ``` +class BroadcastOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Case operation +/// Produces the output from executing exactly one `function` from `branches` +/// depending on the value of `index`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#case +/// +/// Example: +/// ```mlir +/// %result0, %result1 = "stablehlo.case"(%index) ({ +/// stablehlo.return %result_branch0, %result_branch0 : tensor<2xi64>, tensor<2xi64> +/// }, { +/// stablehlo.return %result_branch1, %result_branch1 : tensor<2xi64>, tensor<2xi64> +/// }) : (tensor) -> (tensor<2xi64>, tensor<2xi64>) +/// ``` +class CaseOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Cbrt operation +/// Performs element-wise cubic root operation on `operand` tensor and produces +/// a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#cbrt +/// +/// Example: +/// ```mlir +/// %result = stablehlo.cbrt %operand : tensor<4xf64> +/// ``` +class CbrtOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Ceil operation +/// Performs element-wise ceil of `operand` tensor and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#ceil +/// +/// Example: +/// ```mlir +/// %result = stablehlo.ceil %operand : tensor<5xf32> +/// ``` +class CeilOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Cholesky operation +/// Computes the Cholesky decomposition of a batch of matrices. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#cholesky +/// +/// Example: +/// ```mlir +/// %result = stablehlo.cholesky %a, lower = true : tensor<3x3xf64> +/// ``` +class CholeskyOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Clamp operation +/// Clamps every element of the `operand` tensor between a minimum and maximum +/// value and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#clamp +/// +/// Example: +/// ```mlir +/// %result = stablehlo.clamp %min, %operand, %max : tensor<3xi32> +/// ``` +class ClampOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Clz operation +/// Performs element-wise count of the number of leading zero bits in the +/// `operand` tensor and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#count_leading_zeros +/// +/// Example: +/// ```mlir +/// %result = stablehlo.count_leading_zeros %operand : tensor<2x2xi64> +/// ``` +class ClzOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// CollectiveBroadcast operation +/// Within each process group in the process grid, send the value of the +/// `operand` tensor from the source process to the target processes and produce a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#collective_broadcast +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.collective_broadcast"(%operand) { +/// replica_groups = dense<[[0, 1]]> : tensor<1x2xi64>, +/// channel_handle = #stablehlo.channel_handle +/// } : (tensor<1x2xi64>) -> tensor<1x2xi64> +/// ``` +class CollectiveBroadcastOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// CollectivePermute operation +/// Within each process group in the process grid, sends the value of the +/// `operand` tensor from the source process to the target process and produces +/// a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#collective_permute +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.collective_permute"(%operand) { +/// source_target_pairs = dense<[[0, 1], [1, 2]]> : tensor<2x2xi64>, +/// channel_handle = #stablehlo.channel_handle +/// } : (tensor<2x2xi64>) -> tensor<2x2xi64> +/// ``` +class CollectivePermuteOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Compare operation +/// Performs element-wise comparison of `lhs` and `rhs` tensors according to +/// `comparison_direction` and `compare_type`, and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#compare +/// +/// Example: +/// ```mlir +/// %result = stablehlo.compare LT, %lhs, %rhs, FLOAT : (tensor<2xf32>, tensor<2xf32>) -> tensor<2xi1> +/// ``` +class CompareOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Complex operation +/// Performs element-wise conversion to a complex value from a pair of real and +/// imaginary values, `lhs` and `rhs`, and produces a `result` tensor. +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#complex +/// Example: +/// ```mlir +/// %result = stablehlo.complex %lhs, %rhs : tensor<2xcomplex> +/// ``` +class ComplexOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Composite operation +/// Encapsulates an operation made up (composed) of other StableHLO operations, +/// taking `inputs` and `composite_attributes` and producing `results`. The +/// semantics of the op are implemented by the `decomposition` attribute. The +/// `composite` op can be replaced with its decomposition without changing program +/// semantics. In cases where inlining the decomposition does not provide the same +/// op semantics, prefer using `custom_call`. +/// +/// The `version` field (defaults to `0`) is used to denote when a composite's +/// semantics change. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#composite +/// +/// Example: +/// ```mlir +/// %results = stablehlo.composite "my.op" %input0, %input1 { +/// composite_attributes = { +/// my_attribute = "my_value" +/// }, +/// decomposition = @my_op, +/// version = 1 : i32 +/// } : (tensor, tensor) -> tensor +/// ``` +class CompositeOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Concatenate operation +/// Concatenates a variadic number of tensors in `inputs` along `dimension` +/// dimension in the same order as the given arguments and produces a `result` +/// tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#concatenate +/// +/// Example: +/// ```mlir +/// %result = stablehlo.concatenate %input0, %input1, dim = 0 : (tensor<3x2xi64>, tensor<1x2xi64>) -> tensor<4x2xi64> +/// ``` +class ConcatenateOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Constant operation +/// Produces an `output` tensor from a constant `value`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#constant +/// +/// Example: +/// ```mlir +/// %output = stablehlo.constant dense<[[0.0, 1.0], [2.0, 3.0]]> : tensor<2x2xf32> +/// ``` +class ConstantOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Convert operation +/// Performs an element-wise conversion from one element type to another on +/// `operand` tensor and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#convert +/// +/// Example: +/// ```mlir +/// %result = stablehlo.convert %operand : (tensor<3xi64>) -> tensor<3xcomplex> +/// ``` +class ConvertOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Convolution operation +/// Computes dot products between windows of `lhs` and slices of `rhs` and +/// produces `result`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#convolution +/// +/// Example: +/// ```mlir +/// %result = stablehlo.convolution(%lhs, %rhs) +/// dim_numbers = [b, 0, 1, f]x[0, 1, i, o]->[b, 0, 1, f], +/// window = { +/// stride = [4, 4], +/// pad = [[0, 0], [0, 0]], +/// lhs_dilate = [2, 2], +/// rhs_dilate = [1, 1], +/// reverse = [0, 0] +/// } { +/// feature_group_count = 1 : i64, +/// batch_group_count = 1 : i64, +/// precision_config = [#stablehlo, #stablehlo] +/// } : +/// (tensor<1x4x4x1xi64>, tensor<3x3x1x1xi64>) -> tensor<1x2x2x1xi64> +/// ``` +class ConvolutionOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Cosine operation +/// Performs element-wise cosine operation on `operand` tensor and produces a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#cosine +/// +/// Example: +/// ```mlir +/// %result = stablehlo.cosine %operand : tensor<2xf32> +/// ``` +class CosineOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// CreateToken operation +/// This operation is on its way out of StableHLO, so it is not included in +/// the StableHLO specification: https://github.com/openxla/stablehlo/issues/3. +/// +/// Informally, this operation does the same thing as AfterAllOp with 0 inputs: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#after_all +/// +/// Example: +/// ```mlir +/// %output = stablehlo.create_token : !stablehlo.token +/// ``` +class CreateTokenOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// CrossReplicaSum operation +/// This operation is on its way out of StableHLO, so it is not included in +/// the StableHLO specification: https://github.com/openxla/stablehlo/issues/3. +/// +/// Informally, this operation does the same thing as AllReduceOp with +/// `channel_id = 0`, `use_global_device_ids = false` and `computation` +/// implementing addition: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#all_reduce +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.cross-replica-sum"(%operand) { +/// replica_groups = dense<[[0, 1]]> : tensor<1x2xi64> +/// } : (tensor<4xf32>) -> tensor<4xf32> +/// ``` +class CrossReplicaSumOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// CustomCall operation +/// Encapsulates an implementation-defined operation `call_target_name` that +/// takes `inputs` and `called_computations` and produces `results`. +/// +/// Depending on the API version there are two ways to pass extra bits of static +/// information to the external function: +/// 1. Use `API_VERSION_TYPED_FFI` which allows passing a dictionary attribute. +/// 2. Use a previous API version with a StringAttr to encode backend config. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#custom_call +/// +/// Example: +/// ```mlir +/// %results = stablehlo.custom_call @foo(%input0) { +/// backend_config = {bar = 42 : i32}, +/// api_version = 4 : i32, +/// called_computations = [@foo] +/// } : (tensor) -> tensor +/// ``` +class CustomCallOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Div operation +/// Performs element-wise division of dividend `lhs` and divisor `rhs` tensors +/// and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#divide +/// +/// Example: +/// ```mlir +/// %result = stablehlo.divide %lhs, %rhs : tensor<4xf32> +/// ``` +class DivOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// DotGeneral operation +/// Computes dot products between slices of `lhs` and slices of `rhs` and +/// produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#dot_general +/// +/// Example: +/// ```mlir +/// %result = stablehlo.dot_general %lhs, %rhs, +/// batching_dims = [0] x [0], +/// contracting_dims = [2] x [1], +/// precision = [DEFAULT, DEFAULT], +/// algorithm = +/// : (tensor<2x2x2xi64>, tensor<2x2x2xi64>) -> tensor<2x2x2xi64> +/// ``` +class DotGeneralOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Dot operation +/// This operation is on its way out of StableHLO, so it is not included in +/// the StableHLO specification: https://github.com/openxla/stablehlo/issues/3. +/// +/// Informally, this operation does the same thing as XLA's Dot: +/// https://www.tensorflow.org/xla/operation_semantics#dot +/// +/// Example: +/// ```mlir +/// %0 = stablehlo.dot %arg0, %arg1 : (tensor<1x2xi32>, tensor<2x1xi32>) -> tensor<1x1xi32> +/// ``` +class DotOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// DynamicBroadcastInDim operation +/// This operation is functionally identical to +/// [broadcast_in_dim](https://github.com/openxla/stablehlo/blob/main/docs/spec.md#broadcast_in_dim) +/// op, but the result shape is specified dynamically via `output_dimensions`. +/// +/// It also accepts optional attributes to express static knowledge about the +/// expanding behavior of dimensions. If not specified, all dimensions are +/// assumed to be possibly expanding. The sets of dimensions that are known to +/// be expanding and the set of dimensions that are known to be non-expanding +/// must be disjoint and they must be a subset of the operand's dimensions. +/// +/// See: https://github.com/openxla/stablehlo/blob/main/docs/spec.md#dynamic_broadcast_in_dim +/// +/// Example: +/// ```mlir +/// %operand = stablehlo.constant dense<[[1, 2, 3]]> : tensor<1x3xi64> +/// %output_dimensions = stablehlo.constant dense<[2, 3, 2]> : tensor<3xi64> +/// %result = "stablehlo.dynamic_broadcast_in_dim"(%operand, %output_dimensions) { +/// broadcast_dimensions = array, +/// known_expanding_dimensions = array, +/// known_nonexpanding_dimensions = array +/// } : (tensor<1x3xi64>, tensor<3xi64>) -> tensor<2x3x2xi64> +/// ``` +class DynamicBroadcastInDimOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// DynamicConv operation +/// This operation is functionally identical to +/// [convolution](https://github.com/openxla/stablehlo/blob/main/docs/spec.md#convolution) +/// op, but the padding is specified dynamically via `padding`. +/// +/// Example: +/// ```mlir +/// %padding = stablehlo.constant dense<2> : tensor<2x2xi64> +/// %result = "stablehlo.dynamic_conv"(%lhs, %rhs, %padding) { +/// window_strides = array, +/// lhs_dilation = array, +/// rhs_dilation = array, +/// window_reversal = array, +/// dimension_numbers = #stablehlo.conv<[b, 0, 1, f]x[0, 1, i, o]->[b, 0, 1, f]>, +/// batch_group_count = 1 : i64, +/// feature_group_count = 1 : i64, +/// precision_config = [#stablehlo, #stablehlo] +/// } : (tensor<1x4x4x1xi64>, tensor<3x3x1x1xi64>, tensor<2x2xi64>) -> tensor<1x2x2x1xi64> +/// ``` +class DynamicConvOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// DynamicGather operation +/// This operation is functionally identical to +/// [gather](https://github.com/openxla/stablehlo/blob/main/docs/spec.md#gather) +/// op, with the `slice_sizes` specified dynamically as an operand. +/// +/// Example: +/// ```mlir +/// %slice_sizes = stablehlo.constant dense<[1, 2, 2]> : tensor<3xi64> +/// %result = "stablehlo.dynamic_gather"(%operand, %start_indices, %slice_sizes) { +/// dimension_numbers = #stablehlo.gather< +/// offset_dims = [2, 3], +/// collapsed_slice_dims = [0], +/// start_index_map = [0, 2], +/// index_vector_dim = 2>, +/// indices_are_sorted = false +/// } : (tensor<3x4x2xi64>, tensor<2x3x2xi64>, tensor<3xi64>) -> tensor<2x3x2x2xi64> +/// ``` +class DynamicGatherOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// DynamicIota operation +/// This operation is functionally identical to +/// [iota](https://github.com/openxla/stablehlo/blob/main/docs/spec.md#iota) +/// op, but the result shape is specified dynamically via `output_shape`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#dynamic_iota +/// +/// Example: +/// ```mlir +/// %output_shape = stablehlo.constant dense<[4, 5]> : tensor<2xi64> +/// %0 = stablehlo.dynamic_iota %output_shape, dim = 0 : (tensor<2xi64>) -> tensor<4x5xi64> +/// ``` +class DynamicIotaOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// DynamicPad operation +/// This operation is functionally identical to +/// [pad](https://github.com/openxla/stablehlo/blob/main/docs/spec.md#pad) +/// https://github.com/openxla/stablehlo/pull/2306#discussion_r1595669709 +/// op, but with `edge_padding_low`, `edge_padding_high` and `interior_padding` +/// specified dynamically as values. +/// +/// See: https://github.com/openxla/stablehlo/blob/main/docs/spec.md#dynamic_pad +/// +/// Example: +/// ```mlir +/// %edge_padding_low = stablehlo.constant dense<[0, 1]> : tensor<2xi32> +/// %edge_padding_high = stablehlo.constant dense<[2, 1]> : tensor<2xi32> +/// %interior_padding = stablehlo.constant dense<[1, 2]> : tensor<2xi32> +/// %result = stablehlo.dynamic_pad %operand, %padding_value, +/// %edge_padding_low, %edge_padding_high, %interior_padding +/// : (tensor<2x3xi64>, tensor, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>) -> tensor<5x9xi64> +/// ``` +class DynamicPadOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// DynamicReshape operation +/// This operation is functionally identical to +/// [reshape](https://github.com/openxla/stablehlo/blob/main/docs/spec.md#reshape) +/// op, but the result shape is specified dynamically via `output_shape`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#dynamic_reshape +/// +/// Example: +/// ```mlir +/// %output_shape = stablehlo.constant dense<[3, 2]> : tensor<2xi64> +/// %result = stablehlo.dynamic_reshape %operand, %output_shape : (tensor<2x3xi64>, tensor<2xi64>) -> tensor<3x2xi64> +/// ``` +class DynamicReshapeOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// DynamicSlice operation +/// Extracts a slice from the `operand` using dynamically-computed starting +/// indices and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#dynamic_slice +/// +/// Example: +/// ```mlir +/// %result = stablehlo.dynamic_slice %operand, %start_indices0, %start_indices1, sizes = [2, 2] +/// : (tensor<4x4xi32>, tensor, tensor) -> tensor<2x2xi32> +/// ``` +class DynamicSliceOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// DynamicUpdateSlice operation +/// Produces a `result` tensor which is equal to the `operand` tensor except +/// that the slice starting at `start_indices` is updated with the values in +/// `update`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#dynamic_update_slice +/// +/// Example: +/// ```mlir +/// %result = stablehlo.dynamic_update_slice %operand, %update, %start_indices0, %start_indices1 +/// : (tensor<4x4xi32>, tensor<2x2xi32>, tensor, tensor) -> tensor<4x4xi32> +/// ``` +class DynamicUpdateSliceOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Einsum operation +/// This operation is on its way out of StableHLO, so it is not included in +/// the StableHLO specification: https://github.com/openxla/stablehlo/issues/3. +/// +/// Informally, this operation does the same thing as TF's einsum: +/// https://www.tensorflow.org/api_docs/python/tf/einsum +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.einsum"(%lhs, %rhs) { +/// einsum_config = "ab,bc->ac" +/// } : (tensor<4x16xf32>, tensor<16x4xf32>) -> tensor<4x4xf32> +/// ``` +class EinsumOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Exp operation +/// Performs element-wise exponential operation on `operand` tensor and produces +/// a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#exponential +/// +/// Example: +/// ```mlir +/// %result = stablehlo.exponential %operand : tensor<2x2xf64> +/// ``` +class ExpOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Expm1 operation +/// Performs element-wise exponential minus one operation on `operand` tensor +/// and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#exponential_minus_one +/// +/// Example: +/// ```mlir +/// %result = stablehlo.exponential_minus_one %operand : tensor<2xf64> +/// ``` +class Expm1Op; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Fft operation +/// Performs the forward and inverse Fourier transforms for real and complex +/// inputs/outputs. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#fft +/// +/// Example: +/// ```mlir +/// %result = stablehlo.fft %operand, type = FFT, length = [4] : (tensor<4xcomplex>) -> tensor<4xcomplex> +/// ``` +class FftOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Floor operation +/// Performs element-wise floor of `operand` tensor and produces a `result` +/// tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#floor +/// +/// Example: +/// ```mlir +/// %result = stablehlo.floor %operand : tensor<2xf32> +/// ``` +class FloorOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Gather operation +/// Gathers slices from `operand` tensor from offsets specified in +/// `start_indices` and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#gather +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.gather"(%operand, %start_indices) { +/// dimension_numbers = #stablehlo.gather< +/// offset_dims = [3, 4], +/// collapsed_slice_dims = [1], +/// operand_batching_dims = [0], +/// start_indices_batching_dims = [1], +/// start_index_map = [2, 1], +/// index_vector_dim = 3>, +/// slice_sizes = array, +/// indices_are_sorted = false +/// } : (tensor<2x3x4x2xi64>, tensor<2x2x3x2xi64>) -> tensor<2x2x3x2x2xi64> +/// ``` +class GatherOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// GetDimensionSize operation +/// Produces the size of the given `dimension` of the `operand`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#get_dimension_size +/// +/// Example: +/// ```mlir +/// %result = stablehlo.get_dimension_size %operand, dim = 1 : (tensor<2x3xi64>) -> tensor +/// ``` +class GetDimensionSizeOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// GetTupleElement operation +/// Extracts element at `index` position of the `operand` tuple and produces a +/// `result`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#get_tuple_element +/// +/// Example: +/// ```mlir +/// %result = stablehlo.get_tuple_element %operand[0] : (tuple, tuple>>) -> tensor<2xf64> +/// ``` +class GetTupleElementOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// If operation +/// Produces the output from executing exactly one branch from `true_branch` or +/// `false_branch` depending on the value of `pred`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#if +/// +/// Example: +/// %result = "stablehlo.if"(%pred) ({ +/// "stablehlo.return"(%result_true_branch) : (tensor) -> () +/// }, { +/// "stablehlo.return"(%result_false_branch) : (tensor) -> () +/// }) : (tensor) -> tensor +class IfOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Imag operation +/// Extracts the imaginary part, element-wise, from the `operand` and produces a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#imag +/// +/// Example: +/// ```mlir +/// %result = stablehlo.imag %operand : (tensor<2xcomplex>) -> tensor<2xf32> +/// ``` +class ImagOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Infeed operation +/// Reads data from the infeed and produces `results`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#infeed +/// +/// Example: +/// ```mlir +/// %results0:2 = "stablehlo.infeed"(%token) : +/// (!stablehlo.token) -> (tensor<2x2xi64>, !stablehlo.token) +/// ``` +class InfeedOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Iota operation +/// Fills an `output` tensor with values in increasing order starting from zero +/// along the `iota_dimension` dimension. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#iota +/// +/// Example: +/// ```mlir +/// %output = stablehlo.iota dim = 0 : tensor<4x5xi32> +/// ``` +class IotaOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// IsFinite operation +/// Performs element-wise check whether the value in `x` is finite (i.e. is +/// neither +Inf, -Inf, nor NaN) and produces a `y` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#is_finite +/// +/// Example: +/// ```mlir +/// %y = stablehlo.is_finite %x : (tensor<7xf64>) -> tensor<7xi1> +/// ``` +class IsFiniteOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Log1p operation +/// Performs element-wise logarithm plus one operation on `operand` tensor and +/// produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#log_plus_one +/// +/// Example: +/// ```mlir +/// %result = stablehlo.log_plus_one %operand : tensor<5xf64> +/// ``` +class Log1pOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Log operation +/// Performs element-wise logarithm operation on `operand` tensor and produces a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#log +/// +/// Example: +/// ```mlir +/// %result = stablehlo.log %operand : tensor<2x2xf64> +/// ``` +class LogOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Logistic operation +/// Performs element-wise logistic operation on `operand` tensor and produces a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#logistic +/// +/// Example: +/// ```mlir +/// %result = stablehlo.logistic %operand : tensor<2x2xf64> +/// ``` +class LogisticOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Map operation +/// Applies a map function `computation` to `inputs` along the `dimensions` and +/// produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#map +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.map"(%input0, %input1) ({ +/// ^bb0(%arg0: tensor, %arg1: tensor): +/// %0 = stablehlo.multiply %arg0, %arg1 : tensor +/// stablehlo.return %0 : tensor +/// }) { +/// dimensions = array +/// } : (tensor<2x2xi64>, tensor<2x2xi64>) -> tensor<2x2xi64> +/// ``` +class MapOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Max operation +/// Performs element-wise max operation on tensors `lhs` and `rhs` and produces +/// a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#maximum +/// +/// Example: +/// ```mlir +/// %result = stablehlo.maximum %lhs, %rhs : tensor<4xf32> +/// ``` +class MaxOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Min operation +/// Performs element-wise min operation on tensors `lhs` and `rhs` and produces a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#minimum +/// +/// Example: +/// ```mlir +/// %result = stablehlo.minimum %lhs, %rhs : tensor<4xf32> +/// ``` +class MinOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Mul operation +/// Performs element-wise product of two tensors `lhs` and `rhs` and produces a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#multiply +/// +/// Example: +/// ```mlir +/// %result = stablehlo.multiply %lhs, %rhs : tensor<2xi32> +/// ``` +class MulOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Neg operation +/// Performs element-wise negation of `operand` tensor and produces a `result` +/// tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#negate +/// +/// Example: +/// ```mlir +/// %result = stablehlo.negate %operand : tensor<2x3xi32> +/// ``` +class NegOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Not operation +/// Performs element-wise NOT of tensor `operand` of type integer and produces +/// a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#not +/// +/// Example: +/// ```mlir +/// %result = stablehlo.not %operand : tensor<5x3x1xi1> +/// ``` +class NotOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// OptimizationBarrier operation +/// Ensures that the operations that produce the `operand` are executed before any +/// operations that depend on the `result` and prevents compiler transformations +/// from moving operations across the barrier. Other than that, the operation is +/// an identity, i.e. `result` = `operand`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#optimization_barrier +/// +/// Example: +/// ```mlir +/// %result0, %result1 = stablehlo.optimization_barrier %operand0, %operand1 : tensor, tensor +/// ``` +class OptimizationBarrierOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Or operation +/// Performs element-wise OR of two tensors `lhs` and `rhs` and produces a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#or +/// +/// Example: +/// ```mlir +/// %result = stablehlo.or %lhs, %rhs : tensor<2xi1> +/// ``` +class OrOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Outfeed operation +/// Writes `inputs` to the outfeed and produces a `result` token. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#outfeed +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.outfeed"(%input0, %token) : +/// (tensor<2x2x2xi64>, !stablehlo.token) -> !stablehlo.token +/// ``` +class OutfeedOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Pad operation +/// Expands `operand` by padding around the tensor as well as between the +/// elements of the tensor with the given `padding_value`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#pad +/// +/// Example: +/// ```mlir +/// %0 = stablehlo.pad %arg0, %arg1, low = [0, 1], high = [2, 1], interior = [1, 2] +/// : (tensor<2x3xi32>, tensor) -> tensor<5x9xi32> +/// ``` +class PadOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// PartitionId operation +/// Produces `partition_id` of the current process. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#partition_id +/// +/// Example: +/// ```mlir +/// %result = stablehlo.partition_id : tensor +/// ``` +class PartitionIdOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// PopulationCount operation +/// Performs element-wise count of the number of bits set in the `operand` +/// tensor and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#popcnt +/// +/// Example: +/// ```mlir +/// %result = stablehlo.popcnt %operand : tensor<4xi64> +/// ``` +class PopulationCountOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Power operation +/// Performs element-wise exponentiation of `lhs` tensor by `rhs` tensor and +/// produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#power +/// +/// Example: +/// ```mlir +/// %result = stablehlo.power %lhs, %rhs : tensor<6xf64> +/// ``` +class PowOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// RealDynamicSlice operation +/// This operation is a work in progress, so it is not yet included in +/// the StableHLO specification: https://github.com/openxla/stablehlo/issues/8. +/// +/// Informally, this operation does the same thing as SliceOp except +/// that `start_indices`, `limit_indices` and `strides` are specified dynamically: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#slice +/// +/// Example: +/// ```mlir +/// %result = stablehlo.real_dynamic_slice %operand, +/// %start_indices, %limit_indices, %strides +/// : (tensor<256x?xf32>, tensor<2xindex>, tensor<2xindex>, tensor<2xindex>) -> tensor<256x?xf32> +/// ``` +class RealDynamicSliceOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Real operation +/// Extracts the real part, element-wise, from the `operand` and produces a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#real +/// +/// Example: +/// ```mlir +/// %result = stablehlo.real %operand : (tensor<2xcomplex>) -> tensor<2xf32> +/// ``` +class RealOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Recv operation +/// Receives data from a channel with `channel_id` and produces `results`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#recv +/// +/// Example: +/// ```mlir +/// %results:2 = "stablehlo.recv"(%token) { +/// channel_handle = #stablehlo.channel_handle, +/// is_host_transfer = true +/// } : (!stablehlo.token) -> (tensor<2x2xi64>, !stablehlo.token) +/// ``` +class RecvOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Reduce operation +/// Applies a reduction function `body` to `inputs` and `init_values` along the +/// `dimensions` and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#reduce +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.reduce"(%input, %init_value) ({ +/// ^bb0(%arg0: tensor, %arg1: tensor): +/// %0 = stablehlo.add %arg0, %arg1 : tensor +/// stablehlo.return %0 : tensor +/// }) { +/// dimensions = array +/// } : (tensor<1x6xi64>, tensor) -> tensor<1xi64> +/// ``` +class ReduceOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// ReducePrecision operation +/// Performs element-wise conversion of `operand` to another floating-point type +/// that uses `exponent_bits` and `mantissa_bits` and back to the original +/// floating-point type and produces an `output` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#reduce_precision +/// +/// Example: +/// ```mlir +/// %output = stablehlo.reduce_precision %operand, format = e5m10 : tensor<6xf64> +/// ``` +class ReducePrecisionOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// ReduceScatter operation +/// Within each process group in the process grid, performs reduction, using +/// `computations`, over the values of the `operand` tensor from each process, +/// splits the reduction result along `scatter_dimension` into parts, and +/// scatters the split parts between the processes to produce the `result`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#reduce_scatter +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.reduce_scatter"(%operand) ({ +/// ^bb0(%arg0: tensor, %arg1: tensor): +/// %0 = stablehlo.add %arg0, %arg1 : tensor +/// stablehlo.return %0 : tensor +/// }) { +/// scatter_dimension = 1 : i64, +/// replica_groups = dense<[[0, 1]]> : tensor<1x2xi64>, +/// channel_handle = #stablehlo.channel_handle +/// } : (tensor<2x4xi64>) -> tensor<2x2xi64> +/// ``` +class ReduceScatterOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// ReduceWindow operation +/// Applies a reduction function `body` to windows of `inputs` and `init_values` +/// and produces `results`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#reduce_window +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.reduce_window"(%input, %init_value) ({ +/// ^bb0(%arg0: tensor, %arg1: tensor): +/// %0 = stablehlo.add %arg0, %arg1 : tensor +/// stablehlo.return %0 : tensor +/// }) { +/// window_dimensions = array, +/// window_strides = array, +/// base_dilations = array, +/// window_dilations = array, +/// padding = dense<[[2, 1], [0, 0]]> : tensor<2x2xi64> +/// } : (tensor<3x2xi64>, tensor) -> tensor<2x2xi64> +/// ``` +class ReduceWindowOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Rem operation +/// Performs element-wise remainder of dividend `lhs` and divisor `rhs` tensors +/// and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#remainder +/// +/// Example: +/// ```mlir +/// %result = stablehlo.remainder %lhs, %rhs : tensor<4xi64> +/// ``` +class RemOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// ReplicaId operation +/// Produces `replica_id` of the current process. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#replica_id +/// +/// Example: +/// ```mlir +/// %result = stablehlo.replica_id : tensor +/// ``` +class ReplicaIdOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Reshape operation +/// Performs reshape of `operand` tensor to a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#reshape +/// +/// Example: +/// ```mlir +/// %result = stablehlo.reshape %operand : (tensor<2xf32>) -> tensor<1x2xf32> +/// ``` +class ReshapeOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// This operation is a work in progress, so it is not yet included in +/// the StableHLO specification: https://github.com/openxla/stablehlo/issues/425. +/// +/// Informally, this operation serves as a terminator for regions defined by +/// the StableHLO ops. Non-StableHLO ops, e.g. `func.func`, have their own +/// terminators, e.g. `func.return`. +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.reduce"(%input, %init_value) ({ +/// ^bb0(%arg0: tensor, %arg1: tensor): +/// %0 = "stablehlo.add"(%arg0, %arg1) : (tensor, tensor) -> tensor +/// "stablehlo.return"(%0) : (tensor) -> () +/// }) { +/// dimensions = array +/// } : (tensor<1x6xi32>, tensor) -> tensor<1xi32> +/// ``` +class ReturnOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Reverse operation +/// Reverses the order of elements in the `operand` along the specified +/// `dimensions` and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#reverse +/// +/// Example: +/// ```mlir +/// %result = stablehlo.reverse %operand, dims = [1] : tensor<3x2xi32> +/// ``` +class ReverseOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// RngBitGenerator operation +/// Returns an `output` filled with uniform random data and an updated output +/// state `output_state` given an initial state `initial_state` using the +/// pseudorandom number generator algorithm `rng_algorithm`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#rng_bit_generator +/// +/// Example: +/// ```mlir +/// %output_state, %output = stablehlo.rng_bit_generator %initial_state, algorithm = THREE_FRY : (tensor<2xui64>) -> (tensor<2xui64>, tensor<2x2xui64>) +/// ``` +class RngBitGeneratorOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Rng operation +/// Generates random numbers using the `rng_distribution` algorithm and produces +/// a `result` tensor of a given shape `shape`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#rng +/// +/// Example: +/// ```mlir +/// %result = stablehlo.rng %a, %b, %shape, distribution = NORMAL : (tensor, tensor, tensor<2xi64>) -> tensor<3x3xi32> +/// ``` +class RngOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// RoundNearestEven operation +/// Performs element-wise rounding towards the nearest integer, breaking ties +/// towards the even integer, on the `operand` tensor and produces a `result` +/// tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#round_nearest_even +/// +/// Example: +/// ```mlir +/// %result = stablehlo.round_nearest_even %operand : tensor<5xf64> +/// ``` +class RoundNearestEvenOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Round operation +/// Performs element-wise rounding towards the nearest integer, breaking ties +/// away from zero, on the `operand` tensor and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#round_nearest_afz +/// +/// Example: +/// ```mlir +/// %result = stablehlo.round_nearest_afz %operand : tensor<5xf64> +/// ``` +class RoundOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Rsqrt operation +/// Performs element-wise reciprocal square root operation on `operand` tensor +/// and produces a `result` tensor, implementing the `rSqrt` operation from the +/// IEEE-754 specification. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#rsqrt +/// +/// Example: +/// ```mlir +/// %result = stablehlo.rsqrt %operand : tensor<2x2xf32> +/// ``` +class RsqrtOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Scatter operation +/// Produces `results` tensors which are equal to `inputs` tensors except that +/// several slices specified by `scatter_indices` are updated with the values +/// `updates` using `update_computation`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#scatter +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.scatter"(%input, %scatter_indices, %update) ({ +/// ^bb0(%arg0: tensor, %arg1: tensor): +/// %0 = stablehlo.add %arg0, %arg1 : tensor +/// stablehlo.return %0 : tensor +/// }) { +/// scatter_dimension_numbers = #stablehlo.scatter< +/// update_window_dims = [3, 4], +/// inserted_window_dims = [1], +/// input_batching_dims = [0], +/// scatter_indices_batching_dims = [1], +/// scatter_dims_to_operand_dims = [2, 1], +/// index_vector_dim = 3>, +/// indices_are_sorted = false, +/// unique_indices = false +/// } : (tensor<2x3x4x2xi64>, tensor<2x2x3x2xi64>, tensor<2x2x3x2x2xi64>) -> tensor<2x3x4x2xi64> +/// ``` +class ScatterOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// SelectAndScatter operation +/// Scatters the values from the `source` tensor using `scatter` based on the +/// outcome of `reduce_window` of the `input` tensor using `select` and produces +/// a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#select_and_scatter +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.select_and_scatter"(%operand, %source, %init_value) ({ +/// ^bb0(%arg0: tensor, %arg1: tensor): +/// %0 = stablehlo.compare GE, %arg0, %arg1 : (tensor, tensor) -> tensor +/// stablehlo.return %0 : tensor +/// }, { +/// ^bb0(%arg0: tensor, %arg1: tensor): +/// %0 = stablehlo.add %arg0, %arg1 : tensor +/// stablehlo.return %0 : tensor +/// }) { +/// window_dimensions = array, +/// window_strides = array, +/// padding = dense<[[0, 1], [0, 0]]> : tensor<2x2xi64> +/// } : (tensor<4x2xi64>, tensor<2x2xi64>, tensor) -> tensor<4x2xi64> +/// ``` +class SelectAndScatterOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Select operation +/// Produces a `result` tensor where each element is selected from `on_true` or +/// `on_false` tensor based on the value of the corresponding element of `pred`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#select +/// +/// Example: +/// ```mlir +/// %result = stablehlo.select %pred, %on_true, %on_false : tensor<2x2xi1>, tensor<2x2xi32> +/// ``` +class SelectOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Send operation +/// Sends `inputs` to a channel `channel_id` and produces a `result` token. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#send +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.send"(%operand, %token) { +/// channel_handle = #stablehlo.channel_handle, +/// is_host_transfer = true +/// } : (tensor<2x2xi64>, !stablehlo.token) -> !stablehlo.token +/// ``` +class SendOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// SetDimensionSize operation +/// This operation is a work in progress, so it is not yet included in +/// the StableHLO specification: https://github.com/openxla/stablehlo/issues/8. +/// +/// Informally, this operation does the same thing as XLA's SetDimensionSize: +/// https://www.tensorflow.org/xla/operation_semantics#setdimensionsize +/// +/// Example: +/// ```mlir +/// %0 = stablehlo.set_dimension_size %arg0, %arg1, dim = 1 : (tensor<4x2xf32>, tensor) -> tensor<4x2xf32> +/// ``` +class SetDimensionSizeOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// ShiftLeft operation +/// Performs element-wise left-shift operation on the `lhs` tensor by `rhs` +/// number of bits and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#shift_left +/// +/// Example: +/// ```mlir +/// %result = stablehlo.shift_left %lhs, %rhs : tensor<3xi64> +/// ``` +class ShiftLeftOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// ShiftRightArithmetic operation +/// Performs element-wise arithmetic right-shift operation on the `lhs` tensor +/// by `rhs` number of bits and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#shift_right_arithmetic +/// +/// Example: +/// ```mlir +/// %result = stablehlo.shift_right_arithmetic %lhs, %rhs : tensor<3xi64> +/// ``` +class ShiftRightArithmeticOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// ShiftRightLogical operation +/// Performs element-wise logical right-shift operation on the `lhs` tensor by +/// `rhs` number of bits and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#shift_right_logical +/// +/// Example: +/// ```mlir +/// %result = stablehlo.shift_right_logical %lhs, %rhs : tensor<3xi64> +/// ``` +class ShiftRightLogicalOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Sign operation +/// Returns the sign of the `operand` element-wise and produces a `result` +/// tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#sign +/// +/// Example: +/// ```mlir +/// %result = stablehlo.sign %operand : tensor<5xf64> +/// ``` +class SignOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Sine operation +/// Performs element-wise sine operation on `operand` tensor and produces a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#sine +/// +/// Example: +/// ```mlir +/// %result = stablehlo.sine %operand : tensor<2xf32> +/// ``` +class SineOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Slice operation +/// Extracts a slice from the `operand` using statically-computed starting +/// indices and produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#slice +/// +/// Example: +/// ```mlir +/// %result = stablehlo.slice %operand [1:3, 4:8:2] +/// : (tensor<3x8xi64>) -> tensor<2x2xi64> +/// +/// // Same in generic form: the `1:3` above is mapped to the first entry in +/// // `start_indices` and `limit_indices`, while `strides` is implicitly 1. +/// // The `4:8:2` above is parsed into the second entry of `start_indices`, +/// // `limit_indices` and `strides` respectively. +/// %result = "stablehlo.slice" (%operand) { +/// start_indices = array, +/// limit_indices = array, +/// strides = array +/// } : (tensor<3x8xi64>) -> tensor<2x2xi64> +/// ``` +class SliceOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Sort operation +/// Sorts a variadic number of tensors in `inputs` together, according to a +/// custom `comparator`, along the given `dimension` and produces a variadic +/// number of tensors as `results`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#sort +/// +/// Example: +/// ```mlir +/// %result0, %result1 = "stablehlo.sort"(%input0, %input1) ({ +/// ^bb0(%arg0: tensor, %arg1: tensor, %arg2: tensor, %arg3: tensor): +/// %predicate = stablehlo.compare GT, %arg0, %arg1 : (tensor, tensor) -> tensor +/// stablehlo.return %predicate : tensor +/// }) { +/// dimension = 0 : i64, +/// is_stable = true +/// } : (tensor<2x3xi64>, tensor<2x3xi64>) -> (tensor<2x3xi64>, tensor<2x3xi64>) +class SortOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Sqrt operation +/// Performs element-wise square root operation on `operand` tensor and produces +/// a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#sqrt +/// +/// Example: +/// ```mlir +/// %result = stablehlo.sqrt %operand : tensor<2x2xf32> +/// ``` +class SqrtOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Subtract operation +/// Performs element-wise subtraction of two tensors `lhs` and `rhs` and +/// produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#subtract +/// +/// Example: +/// ```mlir +/// %result = stablehlo.subtract %lhs, %rhs : tensor<2xi32> +/// ``` +class SubtractOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Tan operation +/// Performs element-wise tangent operation on `operand` tensor and +/// produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#tan +/// +/// Example: +/// ```mlir +/// %result = stablehlo.tan %operand : tensor<2x2xf64> +/// ``` +class TanOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Tanh operation +/// Performs element-wise hyperbolic tangent operation on `operand` tensor and +/// produces a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#tanh +/// +/// Example: +/// ```mlir +/// %result = stablehlo.tanh %operand : tensor<2xf32> +/// ``` +class TanhOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// TorchIndexSelect operation +/// This operation is on its way out of StableHLO, so it is not included in +/// the StableHLO specification: https://github.com/openxla/stablehlo/issues/3. +/// +/// Informally, this operation does the same thing as PyTorch's index_select, +/// augmented with support for batch dimensions: +/// https://pytorch.org/docs/stable/generated/torch.index_select.html. +/// +/// The `batch_dims` attribute specifies the number of major batch dimensions +/// (0 or more) that act like a multidimensional loop over both the operand and +/// the index. +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.torch_index_select"(%operand, %index) { +/// dim = 2 : i64, +/// batch_dims = 1 : i64 +/// } : (tensor<8x128x3072x64xf32>, tensor<8x16x1024xi32>) -> tensor<8x128x16x1024x64xf32> +/// ``` +class TorchIndexSelectOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Transpose operation +/// Permutes the dimensions of `operand` tensor using `permutation` and produces +/// a `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#transpose +/// +/// Example: +/// ```mlir +/// %0 = stablehlo.transpose %arg0, dims = [2, 1, 0] : (tensor<1x2x3xi32>) -> tensor<3x2x1xi32> +/// ``` +class TransposeOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// TriangularSolve operation +/// Solves batches of systems of linear equations with lower or upper triangular +/// coefficient matrices. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#triangular_solve +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.triangular_solve"(%a, %b) { +/// left_side = true, +/// lower = true, +/// unit_diagonal = false, +/// transpose_a = #stablehlo +/// } : (tensor<3x3xf32>, tensor<3x3xf32>) -> tensor<3x3xf32> +/// ``` +class TriangularSolveOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Tuple operation +/// Produces a `result` tuple from values `val`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#tuple +/// +/// Example: +/// ```mlir +/// %result = stablehlo.tuple %val0, %val1 : tuple, tuple>> +/// ``` +class TupleOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// UnaryEinsum operation +/// This operation is on its way out of StableHLO, so it is not included in +/// the StableHLO specification: https://github.com/openxla/stablehlo/issues/3. +/// +/// Informally, this operation does the same thing as TF's einsum: +/// https://www.tensorflow.org/api_docs/python/tf/einsum +/// +/// Example: +/// ```mlir +/// %result = "stablehlo.unary_einsum"(%operand) { +/// einsum_config = "ab->a" +/// } : (tensor<4x16xf32>) -> tensor<4xf32> +/// ``` +class UnaryEinsumOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// UniformDequantize operation +/// Performs element-wise conversion of quantized tensor `operand` to a +/// floating-point tensor `result` according to the quantization parameters +/// defined by the `operand` type. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#uniform_dequantize +/// +/// Example: +/// ```mlir +/// %result = stablehlo.uniform_dequantize %operand : (tensor<2x!quant.uniform>) -> tensor<2xf32> +/// ``` +class UniformDequantizeOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// UniformQuantize operation +/// Performs element-wise conversion of floating-point tensor or quantized +/// tensor `operand` to a quantized tensor `result` according to the +/// quantization parameters defined by the `result` type. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#uniform_quantize +/// +/// Example: +/// ```mlir +/// %result = stablehlo.uniform_quantize %operand : (tensor<2xf32>) -> tensor<2x!quant.uniform> +/// ``` +class UniformQuantizeOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// While operation +/// Produces the output from executing `body` function 0 or more times while the +/// `cond` function outputs `true`. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#while +/// +/// Example: +/// ```mlir +/// %results0, %results1 = stablehlo.while(%arg0 = %init_i, %arg1 = %init_sum) : tensor, tensor +/// cond { +/// %cond = stablehlo.compare LT, %arg0, %ten : (tensor, tensor) -> tensor +/// stablehlo.return %cond : tensor +/// } do { +/// %new_sum = stablehlo.add %arg1, %one : tensor +/// %new_i = stablehlo.add %arg0, %one : tensor +/// stablehlo.return %new_i, %new_sum : tensor, tensor +/// } +/// ``` +class WhileOp; +} // namespace stablehlo +} // namespace mlir +namespace mlir { +namespace stablehlo { +/// Xor operation +/// Performs element-wise XOR of two tensors `lhs` and `rhs` and produces a +/// `result` tensor. +/// +/// See: +/// https://github.com/openxla/stablehlo/blob/main/docs/spec.md#xor +/// +/// Example: +/// ```mlir +/// %result = stablehlo.xor %lhs, %rhs : tensor<2xi32> +/// ``` +class XorOp; +} // namespace stablehlo +} // namespace mlir +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AbsOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AbsOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AbsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.abs", odsAttrs.getContext()); + } + + AbsOpGenericAdaptorBase(AbsOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AbsOpGenericAdaptor : public detail::AbsOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AbsOpGenericAdaptorBase; +public: + AbsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AbsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AbsOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AbsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AbsOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AbsOpGenericAdaptor(RangeT values, const AbsOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AbsOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AbsOpAdaptor : public AbsOpGenericAdaptor<::mlir::ValueRange> { +public: + using AbsOpGenericAdaptor::AbsOpGenericAdaptor; + AbsOpAdaptor(AbsOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AbsOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AbsOpAdaptor; + template + using GenericAdaptor = AbsOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.abs"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AbsOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AddOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AddOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AddOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.add", odsAttrs.getContext()); + } + + AddOpGenericAdaptorBase(AddOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AddOpGenericAdaptor : public detail::AddOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AddOpGenericAdaptorBase; +public: + AddOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AddOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AddOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AddOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AddOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AddOpGenericAdaptor(RangeT values, const AddOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AddOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AddOpAdaptor : public AddOpGenericAdaptor<::mlir::ValueRange> { +public: + using AddOpGenericAdaptor::AddOpGenericAdaptor; + AddOpAdaptor(AddOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AddOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::hlo::OpTrait::IsCommutative, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AddOpAdaptor; + template + using GenericAdaptor = AddOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.add"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } + + static LogicalResult inferReturnTypes( + MLIRContext * /*context*/, std::optional location, + ValueRange operands, DictionaryAttr /*attributes*/, + OpaqueProperties /*properties*/, RegionRange /*regions*/, + SmallVectorImpl &inferredReturnTypes) { + if (operands.empty()) + return emitOptionalError( + location, + "Expected non-empty operands for AddOp::inferReturnTypes"); + + auto inferredTypeOrErr = + mlir::hlo::inferMostSpecificType(location, operands.getTypes()); + if (failed(inferredTypeOrErr)) return failure(); + inferredReturnTypes.emplace_back(*inferredTypeOrErr); + return success(); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AddOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AfterAllOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AfterAllOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AfterAllOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.after_all", odsAttrs.getContext()); + } + + AfterAllOpGenericAdaptorBase(AfterAllOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AfterAllOpGenericAdaptor : public detail::AfterAllOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AfterAllOpGenericAdaptorBase; +public: + AfterAllOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AfterAllOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AfterAllOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AfterAllOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AfterAllOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AfterAllOpGenericAdaptor(RangeT values, const AfterAllOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AfterAllOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AfterAllOpAdaptor : public AfterAllOpGenericAdaptor<::mlir::ValueRange> { +public: + using AfterAllOpGenericAdaptor::AfterAllOpGenericAdaptor; + AfterAllOpAdaptor(AfterAllOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AfterAllOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AfterAllOpAdaptor; + template + using GenericAdaptor = AfterAllOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.after_all"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AfterAllOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AllGatherOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AllGatherOpGenericAdaptorBase { +public: + struct Properties { + using all_gather_dimTy = ::mlir::IntegerAttr; + all_gather_dimTy all_gather_dim; + + auto getAllGatherDim() const { + auto &propStorage = this->all_gather_dim; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setAllGatherDim(const ::mlir::IntegerAttr &propValue) { + this->all_gather_dim = propValue; + } + using channel_handleTy = ::mlir::stablehlo::ChannelHandleAttr; + channel_handleTy channel_handle; + + auto getChannelHandle() const { + auto &propStorage = this->channel_handle; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(propStorage); + } + void setChannelHandle(const ::mlir::stablehlo::ChannelHandleAttr &propValue) { + this->channel_handle = propValue; + } + using replica_groupsTy = ::mlir::DenseIntElementsAttr; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::DenseIntElementsAttr>(propStorage); + } + void setReplicaGroups(const ::mlir::DenseIntElementsAttr &propValue) { + this->replica_groups = propValue; + } + using use_global_device_idsTy = ::mlir::UnitAttr; + use_global_device_idsTy use_global_device_ids; + + auto getUseGlobalDeviceIds() const { + auto &propStorage = this->use_global_device_ids; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setUseGlobalDeviceIds(const ::mlir::UnitAttr &propValue) { + this->use_global_device_ids = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.all_gather_dim == this->all_gather_dim && + rhs.channel_handle == this->channel_handle && + rhs.replica_groups == this->replica_groups && + rhs.use_global_device_ids == this->use_global_device_ids && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AllGatherOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.all_gather", odsAttrs.getContext()); + } + + AllGatherOpGenericAdaptorBase(AllGatherOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::IntegerAttr getAllGatherDimAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().all_gather_dim); + return attr; + } + + uint64_t getAllGatherDim(); + ::mlir::DenseIntElementsAttr getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().replica_groups); + return attr; + } + + ::mlir::DenseIntElementsAttr getReplicaGroups(); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + return attr; + } + + ::std::optional<::mlir::stablehlo::ChannelHandleAttr> getChannelHandle(); + ::mlir::UnitAttr getUseGlobalDeviceIdsAttr(); + bool getUseGlobalDeviceIds(); +}; +} // namespace detail +template +class AllGatherOpGenericAdaptor : public detail::AllGatherOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AllGatherOpGenericAdaptorBase; +public: + AllGatherOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AllGatherOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AllGatherOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AllGatherOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AllGatherOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AllGatherOpGenericAdaptor(RangeT values, const AllGatherOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AllGatherOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class AllGatherOpAdaptor : public AllGatherOpGenericAdaptor<::mlir::ValueRange> { +public: + using AllGatherOpGenericAdaptor::AllGatherOpGenericAdaptor; + AllGatherOpAdaptor(AllGatherOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AllGatherOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = AllGatherOpAdaptor; + template + using GenericAdaptor = AllGatherOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("all_gather_dim"), ::llvm::StringRef("channel_handle"), ::llvm::StringRef("replica_groups"), ::llvm::StringRef("use_global_device_ids")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getAllGatherDimAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getAllGatherDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getChannelHandleAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getChannelHandleAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getUseGlobalDeviceIdsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getUseGlobalDeviceIdsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.all_gather"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getOperands() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getAllGatherDimAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().all_gather_dim); + } + + uint64_t getAllGatherDim(); + ::mlir::DenseIntElementsAttr getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().replica_groups); + } + + ::mlir::DenseIntElementsAttr getReplicaGroups(); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + } + + ::std::optional<::mlir::stablehlo::ChannelHandleAttr> getChannelHandle(); + ::mlir::UnitAttr getUseGlobalDeviceIdsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().use_global_device_ids); + } + + bool getUseGlobalDeviceIds(); + void setAllGatherDimAttr(::mlir::IntegerAttr attr) { + getProperties().all_gather_dim = attr; + } + + void setAllGatherDim(uint64_t attrValue); + void setReplicaGroupsAttr(::mlir::DenseIntElementsAttr attr) { + getProperties().replica_groups = attr; + } + + void setChannelHandleAttr(::mlir::stablehlo::ChannelHandleAttr attr) { + getProperties().channel_handle = attr; + } + + void setUseGlobalDeviceIdsAttr(::mlir::UnitAttr attr) { + getProperties().use_global_device_ids = attr; + } + + void setUseGlobalDeviceIds(bool attrValue); + ::mlir::Attribute removeChannelHandleAttr() { + auto attr = getProperties().channel_handle; + getProperties().channel_handle = {}; + return attr; + } + + ::mlir::Attribute removeUseGlobalDeviceIdsAttr() { + auto attr = getProperties().use_global_device_ids; + getProperties().use_global_device_ids = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange operands, ::mlir::IntegerAttr all_gather_dim, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::UnitAttr use_global_device_ids = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange operands, uint64_t all_gather_dim, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool use_global_device_ids = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 4 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AllGatherOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AllReduceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AllReduceOpGenericAdaptorBase { +public: + struct Properties { + using channel_handleTy = ::mlir::stablehlo::ChannelHandleAttr; + channel_handleTy channel_handle; + + auto getChannelHandle() const { + auto &propStorage = this->channel_handle; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(propStorage); + } + void setChannelHandle(const ::mlir::stablehlo::ChannelHandleAttr &propValue) { + this->channel_handle = propValue; + } + using replica_groupsTy = ::mlir::DenseIntElementsAttr; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::DenseIntElementsAttr>(propStorage); + } + void setReplicaGroups(const ::mlir::DenseIntElementsAttr &propValue) { + this->replica_groups = propValue; + } + using use_global_device_idsTy = ::mlir::UnitAttr; + use_global_device_idsTy use_global_device_ids; + + auto getUseGlobalDeviceIds() const { + auto &propStorage = this->use_global_device_ids; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setUseGlobalDeviceIds(const ::mlir::UnitAttr &propValue) { + this->use_global_device_ids = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_handle == this->channel_handle && + rhs.replica_groups == this->replica_groups && + rhs.use_global_device_ids == this->use_global_device_ids && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AllReduceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.all_reduce", odsAttrs.getContext()); + } + + AllReduceOpGenericAdaptorBase(AllReduceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseIntElementsAttr getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().replica_groups); + return attr; + } + + ::mlir::DenseIntElementsAttr getReplicaGroups(); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + return attr; + } + + ::std::optional<::mlir::stablehlo::ChannelHandleAttr> getChannelHandle(); + ::mlir::UnitAttr getUseGlobalDeviceIdsAttr(); + bool getUseGlobalDeviceIds(); + ::mlir::Region &getComputation() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class AllReduceOpGenericAdaptor : public detail::AllReduceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AllReduceOpGenericAdaptorBase; +public: + AllReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AllReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AllReduceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AllReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AllReduceOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AllReduceOpGenericAdaptor(RangeT values, const AllReduceOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AllReduceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class AllReduceOpAdaptor : public AllReduceOpGenericAdaptor<::mlir::ValueRange> { +public: + using AllReduceOpGenericAdaptor::AllReduceOpGenericAdaptor; + AllReduceOpAdaptor(AllReduceOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AllReduceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = AllReduceOpAdaptor; + template + using GenericAdaptor = AllReduceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_handle"), ::llvm::StringRef("replica_groups"), ::llvm::StringRef("use_global_device_ids")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelHandleAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelHandleAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getUseGlobalDeviceIdsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getUseGlobalDeviceIdsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.all_reduce"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getOperands() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Region &getComputation() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseIntElementsAttr getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().replica_groups); + } + + ::mlir::DenseIntElementsAttr getReplicaGroups(); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + } + + ::std::optional<::mlir::stablehlo::ChannelHandleAttr> getChannelHandle(); + ::mlir::UnitAttr getUseGlobalDeviceIdsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().use_global_device_ids); + } + + bool getUseGlobalDeviceIds(); + void setReplicaGroupsAttr(::mlir::DenseIntElementsAttr attr) { + getProperties().replica_groups = attr; + } + + void setChannelHandleAttr(::mlir::stablehlo::ChannelHandleAttr attr) { + getProperties().channel_handle = attr; + } + + void setUseGlobalDeviceIdsAttr(::mlir::UnitAttr attr) { + getProperties().use_global_device_ids = attr; + } + + void setUseGlobalDeviceIds(bool attrValue); + ::mlir::Attribute removeChannelHandleAttr() { + auto attr = getProperties().channel_handle; + getProperties().channel_handle = {}; + return attr; + } + + ::mlir::Attribute removeUseGlobalDeviceIdsAttr() { + auto attr = getProperties().use_global_device_ids; + getProperties().use_global_device_ids = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result_type, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups, ::mlir::stablehlo::ChannelHandleAttr channel_handle, bool use_global_device_ids = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange operands, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::UnitAttr use_global_device_ids); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::UnitAttr use_global_device_ids); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange operands, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool use_global_device_ids = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool use_global_device_ids = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AllReduceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AllToAllOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AllToAllOpGenericAdaptorBase { +public: + struct Properties { + using channel_handleTy = ::mlir::stablehlo::ChannelHandleAttr; + channel_handleTy channel_handle; + + auto getChannelHandle() const { + auto &propStorage = this->channel_handle; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(propStorage); + } + void setChannelHandle(const ::mlir::stablehlo::ChannelHandleAttr &propValue) { + this->channel_handle = propValue; + } + using concat_dimensionTy = ::mlir::IntegerAttr; + concat_dimensionTy concat_dimension; + + auto getConcatDimension() const { + auto &propStorage = this->concat_dimension; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setConcatDimension(const ::mlir::IntegerAttr &propValue) { + this->concat_dimension = propValue; + } + using replica_groupsTy = ::mlir::DenseIntElementsAttr; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::DenseIntElementsAttr>(propStorage); + } + void setReplicaGroups(const ::mlir::DenseIntElementsAttr &propValue) { + this->replica_groups = propValue; + } + using split_countTy = ::mlir::IntegerAttr; + split_countTy split_count; + + auto getSplitCount() const { + auto &propStorage = this->split_count; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setSplitCount(const ::mlir::IntegerAttr &propValue) { + this->split_count = propValue; + } + using split_dimensionTy = ::mlir::IntegerAttr; + split_dimensionTy split_dimension; + + auto getSplitDimension() const { + auto &propStorage = this->split_dimension; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setSplitDimension(const ::mlir::IntegerAttr &propValue) { + this->split_dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_handle == this->channel_handle && + rhs.concat_dimension == this->concat_dimension && + rhs.replica_groups == this->replica_groups && + rhs.split_count == this->split_count && + rhs.split_dimension == this->split_dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AllToAllOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.all_to_all", odsAttrs.getContext()); + } + + AllToAllOpGenericAdaptorBase(AllToAllOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::IntegerAttr getSplitDimensionAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().split_dimension); + return attr; + } + + uint64_t getSplitDimension(); + ::mlir::IntegerAttr getConcatDimensionAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().concat_dimension); + return attr; + } + + uint64_t getConcatDimension(); + ::mlir::IntegerAttr getSplitCountAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().split_count); + return attr; + } + + uint64_t getSplitCount(); + ::mlir::DenseIntElementsAttr getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().replica_groups); + return attr; + } + + ::mlir::DenseIntElementsAttr getReplicaGroups(); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + return attr; + } + + ::std::optional<::mlir::stablehlo::ChannelHandleAttr> getChannelHandle(); +}; +} // namespace detail +template +class AllToAllOpGenericAdaptor : public detail::AllToAllOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AllToAllOpGenericAdaptorBase; +public: + AllToAllOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AllToAllOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AllToAllOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AllToAllOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AllToAllOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AllToAllOpGenericAdaptor(RangeT values, const AllToAllOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AllToAllOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class AllToAllOpAdaptor : public AllToAllOpGenericAdaptor<::mlir::ValueRange> { +public: + using AllToAllOpGenericAdaptor::AllToAllOpGenericAdaptor; + AllToAllOpAdaptor(AllToAllOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AllToAllOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = AllToAllOpAdaptor; + template + using GenericAdaptor = AllToAllOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_handle"), ::llvm::StringRef("concat_dimension"), ::llvm::StringRef("replica_groups"), ::llvm::StringRef("split_count"), ::llvm::StringRef("split_dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelHandleAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelHandleAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getConcatDimensionAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getConcatDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getSplitCountAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getSplitCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getSplitDimensionAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getSplitDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.all_to_all"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getOperands() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getSplitDimensionAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().split_dimension); + } + + uint64_t getSplitDimension(); + ::mlir::IntegerAttr getConcatDimensionAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().concat_dimension); + } + + uint64_t getConcatDimension(); + ::mlir::IntegerAttr getSplitCountAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().split_count); + } + + uint64_t getSplitCount(); + ::mlir::DenseIntElementsAttr getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().replica_groups); + } + + ::mlir::DenseIntElementsAttr getReplicaGroups(); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + } + + ::std::optional<::mlir::stablehlo::ChannelHandleAttr> getChannelHandle(); + void setSplitDimensionAttr(::mlir::IntegerAttr attr) { + getProperties().split_dimension = attr; + } + + void setSplitDimension(uint64_t attrValue); + void setConcatDimensionAttr(::mlir::IntegerAttr attr) { + getProperties().concat_dimension = attr; + } + + void setConcatDimension(uint64_t attrValue); + void setSplitCountAttr(::mlir::IntegerAttr attr) { + getProperties().split_count = attr; + } + + void setSplitCount(uint64_t attrValue); + void setReplicaGroupsAttr(::mlir::DenseIntElementsAttr attr) { + getProperties().replica_groups = attr; + } + + void setChannelHandleAttr(::mlir::stablehlo::ChannelHandleAttr attr) { + getProperties().channel_handle = attr; + } + + ::mlir::Attribute removeChannelHandleAttr() { + auto attr = getProperties().channel_handle; + getProperties().channel_handle = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result_type, ::mlir::Value operand, ::mlir::IntegerAttr split_dimension, ::mlir::IntegerAttr concat_dimension, ::mlir::IntegerAttr split_count, ::mlir::DenseIntElementsAttr replica_groups); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange operands, ::mlir::IntegerAttr split_dimension, ::mlir::IntegerAttr concat_dimension, ::mlir::IntegerAttr split_count, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::mlir::IntegerAttr split_dimension, ::mlir::IntegerAttr concat_dimension, ::mlir::IntegerAttr split_count, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange operands, uint64_t split_dimension, uint64_t concat_dimension, uint64_t split_count, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, uint64_t split_dimension, uint64_t concat_dimension, uint64_t split_count, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 5 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AllToAllOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::AndOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AndOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AndOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.and", odsAttrs.getContext()); + } + + AndOpGenericAdaptorBase(AndOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AndOpGenericAdaptor : public detail::AndOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AndOpGenericAdaptorBase; +public: + AndOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AndOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AndOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AndOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AndOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + AndOpGenericAdaptor(RangeT values, const AndOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AndOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AndOpAdaptor : public AndOpGenericAdaptor<::mlir::ValueRange> { +public: + using AndOpGenericAdaptor::AndOpGenericAdaptor; + AndOpAdaptor(AndOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AndOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::hlo::OpTrait::IsCommutative, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise> { +public: + using Op::Op; + using Op::print; + using Adaptor = AndOpAdaptor; + template + using GenericAdaptor = AndOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.and"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::AndOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::Atan2Op declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class Atan2OpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + Atan2OpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.atan2", odsAttrs.getContext()); + } + + Atan2OpGenericAdaptorBase(Atan2Op op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class Atan2OpGenericAdaptor : public detail::Atan2OpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::Atan2OpGenericAdaptorBase; +public: + Atan2OpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + Atan2OpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : Atan2OpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + Atan2OpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : Atan2OpGenericAdaptor(values, attrs, Properties{}, {}) {} + + Atan2OpGenericAdaptor(RangeT values, const Atan2OpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + Atan2OpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class Atan2OpAdaptor : public Atan2OpGenericAdaptor<::mlir::ValueRange> { +public: + using Atan2OpGenericAdaptor::Atan2OpGenericAdaptor; + Atan2OpAdaptor(Atan2Op op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class Atan2Op : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = Atan2OpAdaptor; + template + using GenericAdaptor = Atan2OpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.atan2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::Atan2Op) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::BatchNormGradOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BatchNormGradOpGenericAdaptorBase { +public: + struct Properties { + using epsilonTy = ::mlir::FloatAttr; + epsilonTy epsilon; + + auto getEpsilon() const { + auto &propStorage = this->epsilon; + return ::llvm::cast<::mlir::FloatAttr>(propStorage); + } + void setEpsilon(const ::mlir::FloatAttr &propValue) { + this->epsilon = propValue; + } + using feature_indexTy = ::mlir::IntegerAttr; + feature_indexTy feature_index; + + auto getFeatureIndex() const { + auto &propStorage = this->feature_index; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setFeatureIndex(const ::mlir::IntegerAttr &propValue) { + this->feature_index = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.epsilon == this->epsilon && + rhs.feature_index == this->feature_index && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BatchNormGradOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.batch_norm_grad", odsAttrs.getContext()); + } + + BatchNormGradOpGenericAdaptorBase(BatchNormGradOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::FloatAttr getEpsilonAttr() { + auto attr = ::llvm::cast<::mlir::FloatAttr>(getProperties().epsilon); + return attr; + } + + ::llvm::APFloat getEpsilon(); + ::mlir::IntegerAttr getFeatureIndexAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().feature_index); + return attr; + } + + uint64_t getFeatureIndex(); +}; +} // namespace detail +template +class BatchNormGradOpGenericAdaptor : public detail::BatchNormGradOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BatchNormGradOpGenericAdaptorBase; +public: + BatchNormGradOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BatchNormGradOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BatchNormGradOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BatchNormGradOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BatchNormGradOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BatchNormGradOpGenericAdaptor(RangeT values, const BatchNormGradOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BatchNormGradOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getScale() { + return (*getODSOperands(1).begin()); + } + + ValueT getMean() { + return (*getODSOperands(2).begin()); + } + + ValueT getVariance() { + return (*getODSOperands(3).begin()); + } + + ValueT getGradOutput() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BatchNormGradOpAdaptor : public BatchNormGradOpGenericAdaptor<::mlir::ValueRange> { +public: + using BatchNormGradOpGenericAdaptor::BatchNormGradOpGenericAdaptor; + BatchNormGradOpAdaptor(BatchNormGradOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BatchNormGradOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<5>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultElementType, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BatchNormGradOpAdaptor; + template + using GenericAdaptor = BatchNormGradOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("epsilon"), ::llvm::StringRef("feature_index")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getEpsilonAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getEpsilonAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFeatureIndexAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFeatureIndexAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.batch_norm_grad"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getScale() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getMean() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(2).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getVariance() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(3).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getGradOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(4).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getScaleMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getMeanMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getVarianceMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getGradOutputMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getGradOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getGradScale() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getGradOffset() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(2).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::FloatAttr getEpsilonAttr() { + return ::llvm::cast<::mlir::FloatAttr>(getProperties().epsilon); + } + + ::llvm::APFloat getEpsilon(); + ::mlir::IntegerAttr getFeatureIndexAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().feature_index); + } + + uint64_t getFeatureIndex(); + void setEpsilonAttr(::mlir::FloatAttr attr) { + getProperties().epsilon = attr; + } + + void setEpsilon(::llvm::APFloat attrValue); + void setFeatureIndexAttr(::mlir::IntegerAttr attr) { + getProperties().feature_index = attr; + } + + void setFeatureIndex(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type grad_operand, ::mlir::Type grad_scale, ::mlir::Type grad_offset, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type grad_operand, ::mlir::Type grad_scale, ::mlir::Type grad_offset, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::llvm::APFloat epsilon, uint64_t feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::llvm::APFloat epsilon, uint64_t feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::llvm::APFloat epsilon, uint64_t feature_index); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::BatchNormGradOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::BatchNormInferenceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BatchNormInferenceOpGenericAdaptorBase { +public: + struct Properties { + using epsilonTy = ::mlir::FloatAttr; + epsilonTy epsilon; + + auto getEpsilon() const { + auto &propStorage = this->epsilon; + return ::llvm::cast<::mlir::FloatAttr>(propStorage); + } + void setEpsilon(const ::mlir::FloatAttr &propValue) { + this->epsilon = propValue; + } + using feature_indexTy = ::mlir::IntegerAttr; + feature_indexTy feature_index; + + auto getFeatureIndex() const { + auto &propStorage = this->feature_index; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setFeatureIndex(const ::mlir::IntegerAttr &propValue) { + this->feature_index = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.epsilon == this->epsilon && + rhs.feature_index == this->feature_index && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BatchNormInferenceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.batch_norm_inference", odsAttrs.getContext()); + } + + BatchNormInferenceOpGenericAdaptorBase(BatchNormInferenceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::FloatAttr getEpsilonAttr() { + auto attr = ::llvm::cast<::mlir::FloatAttr>(getProperties().epsilon); + return attr; + } + + ::llvm::APFloat getEpsilon(); + ::mlir::IntegerAttr getFeatureIndexAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().feature_index); + return attr; + } + + uint64_t getFeatureIndex(); +}; +} // namespace detail +template +class BatchNormInferenceOpGenericAdaptor : public detail::BatchNormInferenceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BatchNormInferenceOpGenericAdaptorBase; +public: + BatchNormInferenceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BatchNormInferenceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BatchNormInferenceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BatchNormInferenceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BatchNormInferenceOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BatchNormInferenceOpGenericAdaptor(RangeT values, const BatchNormInferenceOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BatchNormInferenceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getScale() { + return (*getODSOperands(1).begin()); + } + + ValueT getOffset() { + return (*getODSOperands(2).begin()); + } + + ValueT getMean() { + return (*getODSOperands(3).begin()); + } + + ValueT getVariance() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BatchNormInferenceOpAdaptor : public BatchNormInferenceOpGenericAdaptor<::mlir::ValueRange> { +public: + using BatchNormInferenceOpGenericAdaptor::BatchNormInferenceOpGenericAdaptor; + BatchNormInferenceOpAdaptor(BatchNormInferenceOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BatchNormInferenceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<5>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultElementType, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BatchNormInferenceOpAdaptor; + template + using GenericAdaptor = BatchNormInferenceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("epsilon"), ::llvm::StringRef("feature_index")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getEpsilonAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getEpsilonAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFeatureIndexAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFeatureIndexAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.batch_norm_inference"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getScale() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOffset() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(2).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getMean() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(3).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getVariance() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(4).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getScaleMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOffsetMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getMeanMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getVarianceMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::FloatAttr getEpsilonAttr() { + return ::llvm::cast<::mlir::FloatAttr>(getProperties().epsilon); + } + + ::llvm::APFloat getEpsilon(); + ::mlir::IntegerAttr getFeatureIndexAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().feature_index); + } + + uint64_t getFeatureIndex(); + void setEpsilonAttr(::mlir::FloatAttr attr) { + getProperties().epsilon = attr; + } + + void setEpsilon(::llvm::APFloat attrValue); + void setFeatureIndexAttr(::mlir::IntegerAttr attr) { + getProperties().feature_index = attr; + } + + void setFeatureIndex(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::llvm::APFloat epsilon, uint64_t feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::llvm::APFloat epsilon, uint64_t feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::llvm::APFloat epsilon, uint64_t feature_index); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::BatchNormInferenceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::BatchNormTrainingOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BatchNormTrainingOpGenericAdaptorBase { +public: + struct Properties { + using epsilonTy = ::mlir::FloatAttr; + epsilonTy epsilon; + + auto getEpsilon() const { + auto &propStorage = this->epsilon; + return ::llvm::cast<::mlir::FloatAttr>(propStorage); + } + void setEpsilon(const ::mlir::FloatAttr &propValue) { + this->epsilon = propValue; + } + using feature_indexTy = ::mlir::IntegerAttr; + feature_indexTy feature_index; + + auto getFeatureIndex() const { + auto &propStorage = this->feature_index; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setFeatureIndex(const ::mlir::IntegerAttr &propValue) { + this->feature_index = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.epsilon == this->epsilon && + rhs.feature_index == this->feature_index && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BatchNormTrainingOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.batch_norm_training", odsAttrs.getContext()); + } + + BatchNormTrainingOpGenericAdaptorBase(BatchNormTrainingOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::FloatAttr getEpsilonAttr() { + auto attr = ::llvm::cast<::mlir::FloatAttr>(getProperties().epsilon); + return attr; + } + + ::llvm::APFloat getEpsilon(); + ::mlir::IntegerAttr getFeatureIndexAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().feature_index); + return attr; + } + + uint64_t getFeatureIndex(); +}; +} // namespace detail +template +class BatchNormTrainingOpGenericAdaptor : public detail::BatchNormTrainingOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BatchNormTrainingOpGenericAdaptorBase; +public: + BatchNormTrainingOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BatchNormTrainingOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BatchNormTrainingOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BatchNormTrainingOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BatchNormTrainingOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BatchNormTrainingOpGenericAdaptor(RangeT values, const BatchNormTrainingOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BatchNormTrainingOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getScale() { + return (*getODSOperands(1).begin()); + } + + ValueT getOffset() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BatchNormTrainingOpAdaptor : public BatchNormTrainingOpGenericAdaptor<::mlir::ValueRange> { +public: + using BatchNormTrainingOpGenericAdaptor::BatchNormTrainingOpGenericAdaptor; + BatchNormTrainingOpAdaptor(BatchNormTrainingOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BatchNormTrainingOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultElementType, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BatchNormTrainingOpAdaptor; + template + using GenericAdaptor = BatchNormTrainingOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("epsilon"), ::llvm::StringRef("feature_index")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getEpsilonAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getEpsilonAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFeatureIndexAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFeatureIndexAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.batch_norm_training"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getScale() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOffset() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getScaleMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOffsetMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getBatchMean() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getBatchVar() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(2).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::FloatAttr getEpsilonAttr() { + return ::llvm::cast<::mlir::FloatAttr>(getProperties().epsilon); + } + + ::llvm::APFloat getEpsilon(); + ::mlir::IntegerAttr getFeatureIndexAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().feature_index); + } + + uint64_t getFeatureIndex(); + void setEpsilonAttr(::mlir::FloatAttr attr) { + getProperties().epsilon = attr; + } + + void setEpsilon(::llvm::APFloat attrValue); + void setFeatureIndexAttr(::mlir::IntegerAttr attr) { + getProperties().feature_index = attr; + } + + void setFeatureIndex(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Type batch_mean, ::mlir::Type batch_var, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::FloatAttr epsilon, ::mlir::IntegerAttr feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Type batch_mean, ::mlir::Type batch_var, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::llvm::APFloat epsilon, uint64_t feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::llvm::APFloat epsilon, uint64_t feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::llvm::APFloat epsilon, uint64_t feature_index); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::BatchNormTrainingOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::BitcastConvertOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BitcastConvertOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BitcastConvertOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.bitcast_convert", odsAttrs.getContext()); + } + + BitcastConvertOpGenericAdaptorBase(BitcastConvertOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class BitcastConvertOpGenericAdaptor : public detail::BitcastConvertOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BitcastConvertOpGenericAdaptorBase; +public: + BitcastConvertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BitcastConvertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BitcastConvertOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BitcastConvertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BitcastConvertOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BitcastConvertOpGenericAdaptor(RangeT values, const BitcastConvertOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BitcastConvertOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BitcastConvertOpAdaptor : public BitcastConvertOpGenericAdaptor<::mlir::ValueRange> { +public: + using BitcastConvertOpGenericAdaptor::BitcastConvertOpGenericAdaptor; + BitcastConvertOpAdaptor(BitcastConvertOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BitcastConvertOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BitcastConvertOpAdaptor; + template + using GenericAdaptor = BitcastConvertOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.bitcast_convert"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::BitcastConvertOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::BroadcastInDimOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastInDimOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastInDimOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.broadcast_in_dim", odsAttrs.getContext()); + } + + BroadcastInDimOpGenericAdaptorBase(BroadcastInDimOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::llvm::ArrayRef getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastInDimOpGenericAdaptor : public detail::BroadcastInDimOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastInDimOpGenericAdaptorBase; +public: + BroadcastInDimOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastInDimOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastInDimOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastInDimOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastInDimOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastInDimOpGenericAdaptor(RangeT values, const BroadcastInDimOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastInDimOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastInDimOpAdaptor : public BroadcastInDimOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastInDimOpGenericAdaptor::BroadcastInDimOpGenericAdaptor; + BroadcastInDimOpAdaptor(BroadcastInDimOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastInDimOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultElementType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastInDimOpAdaptor; + template + using GenericAdaptor = BroadcastInDimOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.broadcast_in_dim"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::llvm::ArrayRef getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::llvm::ArrayRef broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::llvm::ArrayRef broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Determines if this BroadcastInDim instance can be expressed as a Broadcast. + bool isSimpleBroadcast(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::BroadcastInDimOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::BroadcastOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_sizesTy = ::mlir::DenseI64ArrayAttr; + broadcast_sizesTy broadcast_sizes; + + auto getBroadcastSizes() const { + auto &propStorage = this->broadcast_sizes; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastSizes(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_sizes = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_sizes == this->broadcast_sizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.broadcast", odsAttrs.getContext()); + } + + BroadcastOpGenericAdaptorBase(BroadcastOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastSizesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_sizes); + return attr; + } + + ::llvm::ArrayRef getBroadcastSizes(); +}; +} // namespace detail +template +class BroadcastOpGenericAdaptor : public detail::BroadcastOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastOpGenericAdaptorBase; +public: + BroadcastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastOpGenericAdaptor(RangeT values, const BroadcastOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastOpAdaptor : public BroadcastOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastOpGenericAdaptor::BroadcastOpGenericAdaptor; + BroadcastOpAdaptor(BroadcastOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastOpAdaptor; + template + using GenericAdaptor = BroadcastOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_sizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastSizesAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastSizesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.broadcast"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastSizesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_sizes); + } + + ::llvm::ArrayRef getBroadcastSizes(); + void setBroadcastSizesAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_sizes = attr; + } + + void setBroadcastSizes(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr broadcast_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr broadcast_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr broadcast_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::llvm::ArrayRef broadcast_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::llvm::ArrayRef broadcast_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::llvm::ArrayRef broadcast_sizes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::BroadcastOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CaseOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CaseOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CaseOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.case", odsAttrs.getContext()); + } + + CaseOpGenericAdaptorBase(CaseOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::RegionRange getBranches() { + return odsRegions.drop_front(0); + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class CaseOpGenericAdaptor : public detail::CaseOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CaseOpGenericAdaptorBase; +public: + CaseOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CaseOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CaseOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CaseOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CaseOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + CaseOpGenericAdaptor(RangeT values, const CaseOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CaseOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getIndex() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CaseOpAdaptor : public CaseOpGenericAdaptor<::mlir::ValueRange> { +public: + using CaseOpGenericAdaptor::CaseOpGenericAdaptor; + CaseOpAdaptor(CaseOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CaseOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::RecursivelySpeculatableImplTrait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CaseOpAdaptor; + template + using GenericAdaptor = CaseOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.case"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getIndex() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getIndexMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::MutableArrayRef<::mlir::Region> getBranches() { + return (*this)->getRegions().drop_front(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::Value index, unsigned branchesCount); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value index, unsigned branchesCount); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CaseOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CbrtOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CbrtOpGenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::stablehlo::ResultAccuracyAttr; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(propStorage); + } + void setResultAccuracy(const ::mlir::stablehlo::ResultAccuracyAttr &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CbrtOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.cbrt", odsAttrs.getContext()); + } + + CbrtOpGenericAdaptorBase(CbrtOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr(); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); +}; +} // namespace detail +template +class CbrtOpGenericAdaptor : public detail::CbrtOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CbrtOpGenericAdaptorBase; +public: + CbrtOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CbrtOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CbrtOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CbrtOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CbrtOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + CbrtOpGenericAdaptor(RangeT values, const CbrtOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CbrtOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CbrtOpAdaptor : public CbrtOpGenericAdaptor<::mlir::ValueRange> { +public: + using CbrtOpGenericAdaptor::CbrtOpGenericAdaptor; + CbrtOpAdaptor(CbrtOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CbrtOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CbrtOpAdaptor; + template + using GenericAdaptor = CbrtOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.cbrt"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); + void setResultAccuracyAttr(::mlir::stablehlo::ResultAccuracyAttr attr) { + getProperties().result_accuracy = attr; + } + + ::mlir::Attribute removeResultAccuracyAttr() { + auto attr = getProperties().result_accuracy; + getProperties().result_accuracy = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CbrtOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CeilOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CeilOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CeilOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.ceil", odsAttrs.getContext()); + } + + CeilOpGenericAdaptorBase(CeilOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class CeilOpGenericAdaptor : public detail::CeilOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CeilOpGenericAdaptorBase; +public: + CeilOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CeilOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CeilOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CeilOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CeilOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + CeilOpGenericAdaptor(RangeT values, const CeilOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CeilOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CeilOpAdaptor : public CeilOpGenericAdaptor<::mlir::ValueRange> { +public: + using CeilOpGenericAdaptor::CeilOpGenericAdaptor; + CeilOpAdaptor(CeilOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CeilOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CeilOpAdaptor; + template + using GenericAdaptor = CeilOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.ceil"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CeilOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CholeskyOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CholeskyOpGenericAdaptorBase { +public: + struct Properties { + using lowerTy = ::mlir::BoolAttr; + lowerTy lower; + + auto getLower() const { + auto &propStorage = this->lower; + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(propStorage); + } + void setLower(const ::mlir::BoolAttr &propValue) { + this->lower = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.lower == this->lower && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CholeskyOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.cholesky", odsAttrs.getContext()); + } + + CholeskyOpGenericAdaptorBase(CholeskyOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::BoolAttr getLowerAttr(); + bool getLower(); +}; +} // namespace detail +template +class CholeskyOpGenericAdaptor : public detail::CholeskyOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CholeskyOpGenericAdaptorBase; +public: + CholeskyOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CholeskyOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CholeskyOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CholeskyOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CholeskyOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + CholeskyOpGenericAdaptor(RangeT values, const CholeskyOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CholeskyOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CholeskyOpAdaptor : public CholeskyOpGenericAdaptor<::mlir::ValueRange> { +public: + using CholeskyOpGenericAdaptor::CholeskyOpGenericAdaptor; + CholeskyOpAdaptor(CholeskyOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CholeskyOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultElementType, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = CholeskyOpAdaptor; + template + using GenericAdaptor = CholeskyOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("lower")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getLowerAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getLowerAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.cholesky"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::BoolAttr getLowerAttr() { + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().lower); + } + + bool getLower(); + void setLowerAttr(::mlir::BoolAttr attr) { + getProperties().lower = attr; + } + + void setLower(::std::optional attrValue); + ::mlir::Attribute removeLowerAttr() { + auto attr = getProperties().lower; + getProperties().lower = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, /*optional*/::mlir::BoolAttr lower); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, /*optional*/::mlir::BoolAttr lower); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, /*optional*/::mlir::BoolAttr lower); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, /*optional*/bool lower = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, /*optional*/bool lower = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, /*optional*/bool lower = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CholeskyOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ClampOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ClampOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ClampOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.clamp", odsAttrs.getContext()); + } + + ClampOpGenericAdaptorBase(ClampOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ClampOpGenericAdaptor : public detail::ClampOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ClampOpGenericAdaptorBase; +public: + ClampOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ClampOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ClampOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ClampOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ClampOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ClampOpGenericAdaptor(RangeT values, const ClampOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ClampOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getMin() { + return (*getODSOperands(0).begin()); + } + + ValueT getOperand() { + return (*getODSOperands(1).begin()); + } + + ValueT getMax() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ClampOpAdaptor : public ClampOpGenericAdaptor<::mlir::ValueRange> { +public: + using ClampOpGenericAdaptor::ClampOpGenericAdaptor; + ClampOpAdaptor(ClampOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ClampOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultElementType, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = ClampOpAdaptor; + template + using GenericAdaptor = ClampOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.clamp"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getMin() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getMax() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getMinMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getMaxMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value min, ::mlir::Value operand, ::mlir::Value max); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value min, ::mlir::Value operand, ::mlir::Value max); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value min, ::mlir::Value operand, ::mlir::Value max); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ClampOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ClzOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ClzOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ClzOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.count_leading_zeros", odsAttrs.getContext()); + } + + ClzOpGenericAdaptorBase(ClzOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ClzOpGenericAdaptor : public detail::ClzOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ClzOpGenericAdaptorBase; +public: + ClzOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ClzOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ClzOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ClzOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ClzOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ClzOpGenericAdaptor(RangeT values, const ClzOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ClzOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ClzOpAdaptor : public ClzOpGenericAdaptor<::mlir::ValueRange> { +public: + using ClzOpGenericAdaptor::ClzOpGenericAdaptor; + ClzOpAdaptor(ClzOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ClzOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ClzOpAdaptor; + template + using GenericAdaptor = ClzOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.count_leading_zeros"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ClzOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CollectiveBroadcastOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CollectiveBroadcastOpGenericAdaptorBase { +public: + struct Properties { + using channel_handleTy = ::mlir::stablehlo::ChannelHandleAttr; + channel_handleTy channel_handle; + + auto getChannelHandle() const { + auto &propStorage = this->channel_handle; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(propStorage); + } + void setChannelHandle(const ::mlir::stablehlo::ChannelHandleAttr &propValue) { + this->channel_handle = propValue; + } + using replica_groupsTy = ::mlir::DenseIntElementsAttr; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::DenseIntElementsAttr>(propStorage); + } + void setReplicaGroups(const ::mlir::DenseIntElementsAttr &propValue) { + this->replica_groups = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_handle == this->channel_handle && + rhs.replica_groups == this->replica_groups && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CollectiveBroadcastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.collective_broadcast", odsAttrs.getContext()); + } + + CollectiveBroadcastOpGenericAdaptorBase(CollectiveBroadcastOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseIntElementsAttr getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().replica_groups); + return attr; + } + + ::mlir::DenseIntElementsAttr getReplicaGroups(); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + return attr; + } + + ::std::optional<::mlir::stablehlo::ChannelHandleAttr> getChannelHandle(); +}; +} // namespace detail +template +class CollectiveBroadcastOpGenericAdaptor : public detail::CollectiveBroadcastOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CollectiveBroadcastOpGenericAdaptorBase; +public: + CollectiveBroadcastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CollectiveBroadcastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CollectiveBroadcastOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CollectiveBroadcastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CollectiveBroadcastOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + CollectiveBroadcastOpGenericAdaptor(RangeT values, const CollectiveBroadcastOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CollectiveBroadcastOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CollectiveBroadcastOpAdaptor : public CollectiveBroadcastOpGenericAdaptor<::mlir::ValueRange> { +public: + using CollectiveBroadcastOpGenericAdaptor::CollectiveBroadcastOpGenericAdaptor; + CollectiveBroadcastOpAdaptor(CollectiveBroadcastOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CollectiveBroadcastOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CollectiveBroadcastOpAdaptor; + template + using GenericAdaptor = CollectiveBroadcastOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_handle"), ::llvm::StringRef("replica_groups")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelHandleAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelHandleAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.collective_broadcast"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseIntElementsAttr getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().replica_groups); + } + + ::mlir::DenseIntElementsAttr getReplicaGroups(); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + } + + ::std::optional<::mlir::stablehlo::ChannelHandleAttr> getChannelHandle(); + void setReplicaGroupsAttr(::mlir::DenseIntElementsAttr attr) { + getProperties().replica_groups = attr; + } + + void setChannelHandleAttr(::mlir::stablehlo::ChannelHandleAttr attr) { + getProperties().channel_handle = attr; + } + + ::mlir::Attribute removeChannelHandleAttr() { + auto attr = getProperties().channel_handle; + getProperties().channel_handle = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result_type, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CollectiveBroadcastOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CollectivePermuteOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CollectivePermuteOpGenericAdaptorBase { +public: + struct Properties { + using channel_handleTy = ::mlir::stablehlo::ChannelHandleAttr; + channel_handleTy channel_handle; + + auto getChannelHandle() const { + auto &propStorage = this->channel_handle; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(propStorage); + } + void setChannelHandle(const ::mlir::stablehlo::ChannelHandleAttr &propValue) { + this->channel_handle = propValue; + } + using source_target_pairsTy = ::mlir::DenseIntElementsAttr; + source_target_pairsTy source_target_pairs; + + auto getSourceTargetPairs() const { + auto &propStorage = this->source_target_pairs; + return ::llvm::cast<::mlir::DenseIntElementsAttr>(propStorage); + } + void setSourceTargetPairs(const ::mlir::DenseIntElementsAttr &propValue) { + this->source_target_pairs = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_handle == this->channel_handle && + rhs.source_target_pairs == this->source_target_pairs && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CollectivePermuteOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.collective_permute", odsAttrs.getContext()); + } + + CollectivePermuteOpGenericAdaptorBase(CollectivePermuteOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseIntElementsAttr getSourceTargetPairsAttr() { + auto attr = ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().source_target_pairs); + return attr; + } + + ::mlir::DenseIntElementsAttr getSourceTargetPairs(); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + return attr; + } + + ::std::optional<::mlir::stablehlo::ChannelHandleAttr> getChannelHandle(); +}; +} // namespace detail +template +class CollectivePermuteOpGenericAdaptor : public detail::CollectivePermuteOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CollectivePermuteOpGenericAdaptorBase; +public: + CollectivePermuteOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CollectivePermuteOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CollectivePermuteOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CollectivePermuteOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CollectivePermuteOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + CollectivePermuteOpGenericAdaptor(RangeT values, const CollectivePermuteOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CollectivePermuteOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CollectivePermuteOpAdaptor : public CollectivePermuteOpGenericAdaptor<::mlir::ValueRange> { +public: + using CollectivePermuteOpGenericAdaptor::CollectivePermuteOpGenericAdaptor; + CollectivePermuteOpAdaptor(CollectivePermuteOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CollectivePermuteOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CollectivePermuteOpAdaptor; + template + using GenericAdaptor = CollectivePermuteOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_handle"), ::llvm::StringRef("source_target_pairs")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelHandleAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelHandleAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getSourceTargetPairsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getSourceTargetPairsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.collective_permute"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseIntElementsAttr getSourceTargetPairsAttr() { + return ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().source_target_pairs); + } + + ::mlir::DenseIntElementsAttr getSourceTargetPairs(); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + } + + ::std::optional<::mlir::stablehlo::ChannelHandleAttr> getChannelHandle(); + void setSourceTargetPairsAttr(::mlir::DenseIntElementsAttr attr) { + getProperties().source_target_pairs = attr; + } + + void setChannelHandleAttr(::mlir::stablehlo::ChannelHandleAttr attr) { + getProperties().channel_handle = attr; + } + + ::mlir::Attribute removeChannelHandleAttr() { + auto attr = getProperties().channel_handle; + getProperties().channel_handle = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result_type, ::mlir::Value operand, ::mlir::DenseIntElementsAttr source_target_pairs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::DenseIntElementsAttr source_target_pairs, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseIntElementsAttr source_target_pairs, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseIntElementsAttr source_target_pairs, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CollectivePermuteOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CompareOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CompareOpGenericAdaptorBase { +public: + struct Properties { + using compare_typeTy = ::mlir::stablehlo::ComparisonTypeAttr; + compare_typeTy compare_type; + + auto getCompareType() const { + auto &propStorage = this->compare_type; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ComparisonTypeAttr>(propStorage); + } + void setCompareType(const ::mlir::stablehlo::ComparisonTypeAttr &propValue) { + this->compare_type = propValue; + } + using comparison_directionTy = ::mlir::stablehlo::ComparisonDirectionAttr; + comparison_directionTy comparison_direction; + + auto getComparisonDirection() const { + auto &propStorage = this->comparison_direction; + return ::llvm::cast<::mlir::stablehlo::ComparisonDirectionAttr>(propStorage); + } + void setComparisonDirection(const ::mlir::stablehlo::ComparisonDirectionAttr &propValue) { + this->comparison_direction = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.compare_type == this->compare_type && + rhs.comparison_direction == this->comparison_direction && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CompareOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.compare", odsAttrs.getContext()); + } + + CompareOpGenericAdaptorBase(CompareOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ComparisonDirectionAttr getComparisonDirectionAttr() { + auto attr = ::llvm::cast<::mlir::stablehlo::ComparisonDirectionAttr>(getProperties().comparison_direction); + return attr; + } + + ::mlir::stablehlo::ComparisonDirection getComparisonDirection(); + ::mlir::stablehlo::ComparisonTypeAttr getCompareTypeAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ComparisonTypeAttr>(getProperties().compare_type); + return attr; + } + + ::std::optional<::mlir::stablehlo::ComparisonType> getCompareType(); +}; +} // namespace detail +template +class CompareOpGenericAdaptor : public detail::CompareOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CompareOpGenericAdaptorBase; +public: + CompareOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CompareOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CompareOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CompareOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CompareOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + CompareOpGenericAdaptor(RangeT values, const CompareOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CompareOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CompareOpAdaptor : public CompareOpGenericAdaptor<::mlir::ValueRange> { +public: + using CompareOpGenericAdaptor::CompareOpGenericAdaptor; + CompareOpAdaptor(CompareOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CompareOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::hlo::OpTrait::CompatibleOperandsElementType, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = CompareOpAdaptor; + template + using GenericAdaptor = CompareOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("compare_type"), ::llvm::StringRef("comparison_direction")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getCompareTypeAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getCompareTypeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getComparisonDirectionAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getComparisonDirectionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.compare"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ComparisonDirectionAttr getComparisonDirectionAttr() { + return ::llvm::cast<::mlir::stablehlo::ComparisonDirectionAttr>(getProperties().comparison_direction); + } + + ::mlir::stablehlo::ComparisonDirection getComparisonDirection(); + ::mlir::stablehlo::ComparisonTypeAttr getCompareTypeAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ComparisonTypeAttr>(getProperties().compare_type); + } + + ::std::optional<::mlir::stablehlo::ComparisonType> getCompareType(); + void setComparisonDirectionAttr(::mlir::stablehlo::ComparisonDirectionAttr attr) { + getProperties().comparison_direction = attr; + } + + void setComparisonDirection(::mlir::stablehlo::ComparisonDirection attrValue); + void setCompareTypeAttr(::mlir::stablehlo::ComparisonTypeAttr attr) { + getProperties().compare_type = attr; + } + + void setCompareType(::std::optional<::mlir::stablehlo::ComparisonType> attrValue); + ::mlir::Attribute removeCompareTypeAttr() { + auto attr = getProperties().compare_type; + getProperties().compare_type = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, ::mlir::stablehlo::ComparisonDirection comparison_direction, ::mlir::stablehlo::ComparisonType compare_type = ::mlir::stablehlo::ComparisonType::NOTYPE); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::ComparisonDirectionAttr comparison_direction, /*optional*/::mlir::stablehlo::ComparisonTypeAttr compare_type); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::ComparisonDirectionAttr comparison_direction, /*optional*/::mlir::stablehlo::ComparisonTypeAttr compare_type); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::ComparisonDirectionAttr comparison_direction, /*optional*/::mlir::stablehlo::ComparisonTypeAttr compare_type); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::ComparisonDirection comparison_direction, /*optional*/::mlir::stablehlo::ComparisonTypeAttr compare_type); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::ComparisonDirection comparison_direction, /*optional*/::mlir::stablehlo::ComparisonTypeAttr compare_type); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::ComparisonDirection comparison_direction, /*optional*/::mlir::stablehlo::ComparisonTypeAttr compare_type); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CompareOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ComplexOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ComplexOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ComplexOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.complex", odsAttrs.getContext()); + } + + ComplexOpGenericAdaptorBase(ComplexOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ComplexOpGenericAdaptor : public detail::ComplexOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ComplexOpGenericAdaptorBase; +public: + ComplexOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ComplexOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ComplexOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ComplexOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ComplexOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ComplexOpGenericAdaptor(RangeT values, const ComplexOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ComplexOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ComplexOpAdaptor : public ComplexOpGenericAdaptor<::mlir::ValueRange> { +public: + using ComplexOpGenericAdaptor::ComplexOpGenericAdaptor; + ComplexOpAdaptor(ComplexOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ComplexOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsElementType, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::Elementwise> { +public: + using Op::Op; + using Op::print; + using Adaptor = ComplexOpAdaptor; + template + using GenericAdaptor = ComplexOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.complex"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ComplexOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CompositeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CompositeOpGenericAdaptorBase { +public: + struct Properties { + using composite_attributesTy = ::mlir::DictionaryAttr; + composite_attributesTy composite_attributes; + + auto getCompositeAttributes() const { + auto &propStorage = this->composite_attributes; + return ::llvm::dyn_cast_or_null<::mlir::DictionaryAttr>(propStorage); + } + void setCompositeAttributes(const ::mlir::DictionaryAttr &propValue) { + this->composite_attributes = propValue; + } + using decompositionTy = ::mlir::FlatSymbolRefAttr; + decompositionTy decomposition; + + auto getDecomposition() const { + auto &propStorage = this->decomposition; + return ::llvm::cast<::mlir::FlatSymbolRefAttr>(propStorage); + } + void setDecomposition(const ::mlir::FlatSymbolRefAttr &propValue) { + this->decomposition = propValue; + } + using nameTy = ::mlir::StringAttr; + nameTy name; + + auto getName() const { + auto &propStorage = this->name; + return ::llvm::cast<::mlir::StringAttr>(propStorage); + } + void setName(const ::mlir::StringAttr &propValue) { + this->name = propValue; + } + using versionTy = ::mlir::IntegerAttr; + versionTy version; + + auto getVersion() const { + auto &propStorage = this->version; + return ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(propStorage); + } + void setVersion(const ::mlir::IntegerAttr &propValue) { + this->version = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.composite_attributes == this->composite_attributes && + rhs.decomposition == this->decomposition && + rhs.name == this->name && + rhs.version == this->version && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CompositeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.composite", odsAttrs.getContext()); + } + + CompositeOpGenericAdaptorBase(CompositeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::StringAttr getNameAttr() { + auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().name); + return attr; + } + + ::llvm::StringRef getName(); + ::mlir::DictionaryAttr getCompositeAttributesAttr(); + ::mlir::DictionaryAttr getCompositeAttributes(); + ::mlir::FlatSymbolRefAttr getDecompositionAttr() { + auto attr = ::llvm::cast<::mlir::FlatSymbolRefAttr>(getProperties().decomposition); + return attr; + } + + ::llvm::StringRef getDecomposition(); + ::mlir::IntegerAttr getVersionAttr(); + uint32_t getVersion(); +}; +} // namespace detail +template +class CompositeOpGenericAdaptor : public detail::CompositeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CompositeOpGenericAdaptorBase; +public: + CompositeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CompositeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CompositeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CompositeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CompositeOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + CompositeOpGenericAdaptor(RangeT values, const CompositeOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CompositeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CompositeOpAdaptor : public CompositeOpGenericAdaptor<::mlir::ValueRange> { +public: + using CompositeOpGenericAdaptor::CompositeOpGenericAdaptor; + CompositeOpAdaptor(CompositeOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CompositeOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = CompositeOpAdaptor; + template + using GenericAdaptor = CompositeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("composite_attributes"), ::llvm::StringRef("decomposition"), ::llvm::StringRef("name"), ::llvm::StringRef("version")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getCompositeAttributesAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getCompositeAttributesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getDecompositionAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getDecompositionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getNameAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getVersionAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getVersionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.composite"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getNameAttr() { + return ::llvm::cast<::mlir::StringAttr>(getProperties().name); + } + + ::llvm::StringRef getName(); + ::mlir::DictionaryAttr getCompositeAttributesAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DictionaryAttr>(getProperties().composite_attributes); + } + + ::mlir::DictionaryAttr getCompositeAttributes(); + ::mlir::FlatSymbolRefAttr getDecompositionAttr() { + return ::llvm::cast<::mlir::FlatSymbolRefAttr>(getProperties().decomposition); + } + + ::llvm::StringRef getDecomposition(); + ::mlir::IntegerAttr getVersionAttr() { + return ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().version); + } + + uint32_t getVersion(); + void setNameAttr(::mlir::StringAttr attr) { + getProperties().name = attr; + } + + void setName(::llvm::StringRef attrValue); + void setCompositeAttributesAttr(::mlir::DictionaryAttr attr) { + getProperties().composite_attributes = attr; + } + + void setDecompositionAttr(::mlir::FlatSymbolRefAttr attr) { + getProperties().decomposition = attr; + } + + void setDecomposition(::llvm::StringRef attrValue); + void setVersionAttr(::mlir::IntegerAttr attr) { + getProperties().version = attr; + } + + void setVersion(::std::optional attrValue); + ::mlir::Attribute removeCompositeAttributesAttr() { + auto attr = getProperties().composite_attributes; + getProperties().composite_attributes = {}; + return attr; + } + + ::mlir::Attribute removeVersionAttr() { + auto attr = getProperties().version; + getProperties().version = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::StringAttr name, /*optional*/::mlir::DictionaryAttr composite_attributes, ::mlir::FlatSymbolRefAttr decomposition, /*optional*/::mlir::IntegerAttr version = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::llvm::StringRef name, /*optional*/::mlir::DictionaryAttr composite_attributes, ::llvm::StringRef decomposition, /*optional*/uint32_t version = 0); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verifySymbolUses(::mlir::SymbolTableCollection &symbolTable); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 4 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CompositeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ConcatenateOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConcatenateOpGenericAdaptorBase { +public: + struct Properties { + using dimensionTy = ::mlir::IntegerAttr; + dimensionTy dimension; + + auto getDimension() const { + auto &propStorage = this->dimension; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setDimension(const ::mlir::IntegerAttr &propValue) { + this->dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimension == this->dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConcatenateOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.concatenate", odsAttrs.getContext()); + } + + ConcatenateOpGenericAdaptorBase(ConcatenateOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::IntegerAttr getDimensionAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().dimension); + return attr; + } + + uint64_t getDimension(); +}; +} // namespace detail +template +class ConcatenateOpGenericAdaptor : public detail::ConcatenateOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConcatenateOpGenericAdaptorBase; +public: + ConcatenateOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConcatenateOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConcatenateOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ConcatenateOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ConcatenateOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ConcatenateOpGenericAdaptor(RangeT values, const ConcatenateOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ConcatenateOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConcatenateOpAdaptor : public ConcatenateOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConcatenateOpGenericAdaptor::ConcatenateOpGenericAdaptor; + ConcatenateOpAdaptor(ConcatenateOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ConcatenateOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConcatenateOpAdaptor; + template + using GenericAdaptor = ConcatenateOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.concatenate"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getDimensionAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().dimension); + } + + uint64_t getDimension(); + void setDimensionAttr(::mlir::IntegerAttr attr) { + getProperties().dimension = attr; + } + + void setDimension(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::mlir::IntegerAttr dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::IntegerAttr dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::IntegerAttr dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, uint64_t dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, uint64_t dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, uint64_t dimension); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ConcatenateOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ConstantOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConstantOpGenericAdaptorBase { +public: + struct Properties { + using valueTy = ::mlir::ElementsAttr; + valueTy value; + + auto getValue() const { + auto &propStorage = this->value; + return ::llvm::cast<::mlir::ElementsAttr>(propStorage); + } + void setValue(const ::mlir::ElementsAttr &propValue) { + this->value = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.value == this->value && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConstantOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.constant", odsAttrs.getContext()); + } + + ConstantOpGenericAdaptorBase(ConstantOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::ElementsAttr getValueAttr() { + auto attr = ::llvm::cast<::mlir::ElementsAttr>(getProperties().value); + return attr; + } + + ::mlir::ElementsAttr getValue(); +}; +} // namespace detail +template +class ConstantOpGenericAdaptor : public detail::ConstantOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConstantOpGenericAdaptorBase; +public: + ConstantOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConstantOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConstantOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ConstantOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ConstantOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ConstantOpGenericAdaptor(RangeT values, const ConstantOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ConstantOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConstantOpAdaptor : public ConstantOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConstantOpGenericAdaptor::ConstantOpGenericAdaptor; + ConstantOpAdaptor(ConstantOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ConstantOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::ConstantLike, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConstantOpAdaptor; + template + using GenericAdaptor = ConstantOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("value")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getValueAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getValueAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.constant"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ElementsAttr getValueAttr() { + return ::llvm::cast<::mlir::ElementsAttr>(getProperties().value); + } + + ::mlir::ElementsAttr getValue(); + void setValueAttr(::mlir::ElementsAttr attr) { + getProperties().value = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Attribute value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::ElementsAttr value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ElementsAttr value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ElementsAttr value); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ConstantOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ConvertOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConvertOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConvertOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.convert", odsAttrs.getContext()); + } + + ConvertOpGenericAdaptorBase(ConvertOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ConvertOpGenericAdaptor : public detail::ConvertOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConvertOpGenericAdaptorBase; +public: + ConvertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConvertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConvertOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ConvertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ConvertOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ConvertOpGenericAdaptor(RangeT values, const ConvertOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ConvertOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConvertOpAdaptor : public ConvertOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConvertOpGenericAdaptor::ConvertOpGenericAdaptor; + ConvertOpAdaptor(ConvertOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ConvertOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConvertOpAdaptor; + template + using GenericAdaptor = ConvertOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.convert"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value operand, Type result_element_ty); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ConvertOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ConvolutionOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConvolutionOpGenericAdaptorBase { +public: + struct Properties { + using batch_group_countTy = ::mlir::IntegerAttr; + batch_group_countTy batch_group_count; + + auto getBatchGroupCount() const { + auto &propStorage = this->batch_group_count; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setBatchGroupCount(const ::mlir::IntegerAttr &propValue) { + this->batch_group_count = propValue; + } + using dimension_numbersTy = ::mlir::stablehlo::ConvDimensionNumbersAttr; + dimension_numbersTy dimension_numbers; + + auto getDimensionNumbers() const { + auto &propStorage = this->dimension_numbers; + return ::llvm::cast<::mlir::stablehlo::ConvDimensionNumbersAttr>(propStorage); + } + void setDimensionNumbers(const ::mlir::stablehlo::ConvDimensionNumbersAttr &propValue) { + this->dimension_numbers = propValue; + } + using feature_group_countTy = ::mlir::IntegerAttr; + feature_group_countTy feature_group_count; + + auto getFeatureGroupCount() const { + auto &propStorage = this->feature_group_count; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setFeatureGroupCount(const ::mlir::IntegerAttr &propValue) { + this->feature_group_count = propValue; + } + using lhs_dilationTy = ::mlir::DenseI64ArrayAttr; + lhs_dilationTy lhs_dilation; + + auto getLhsDilation() const { + auto &propStorage = this->lhs_dilation; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setLhsDilation(const ::mlir::DenseI64ArrayAttr &propValue) { + this->lhs_dilation = propValue; + } + using paddingTy = ::mlir::DenseIntElementsAttr; + paddingTy padding; + + auto getPadding() const { + auto &propStorage = this->padding; + return ::llvm::dyn_cast_or_null<::mlir::DenseIntElementsAttr>(propStorage); + } + void setPadding(const ::mlir::DenseIntElementsAttr &propValue) { + this->padding = propValue; + } + using precision_configTy = ::mlir::ArrayAttr; + precision_configTy precision_config; + + auto getPrecisionConfig() const { + auto &propStorage = this->precision_config; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setPrecisionConfig(const ::mlir::ArrayAttr &propValue) { + this->precision_config = propValue; + } + using rhs_dilationTy = ::mlir::DenseI64ArrayAttr; + rhs_dilationTy rhs_dilation; + + auto getRhsDilation() const { + auto &propStorage = this->rhs_dilation; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setRhsDilation(const ::mlir::DenseI64ArrayAttr &propValue) { + this->rhs_dilation = propValue; + } + using window_reversalTy = ::mlir::DenseBoolArrayAttr; + window_reversalTy window_reversal; + + auto getWindowReversal() const { + auto &propStorage = this->window_reversal; + return ::llvm::dyn_cast_or_null<::mlir::DenseBoolArrayAttr>(propStorage); + } + void setWindowReversal(const ::mlir::DenseBoolArrayAttr &propValue) { + this->window_reversal = propValue; + } + using window_stridesTy = ::mlir::DenseI64ArrayAttr; + window_stridesTy window_strides; + + auto getWindowStrides() const { + auto &propStorage = this->window_strides; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setWindowStrides(const ::mlir::DenseI64ArrayAttr &propValue) { + this->window_strides = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.batch_group_count == this->batch_group_count && + rhs.dimension_numbers == this->dimension_numbers && + rhs.feature_group_count == this->feature_group_count && + rhs.lhs_dilation == this->lhs_dilation && + rhs.padding == this->padding && + rhs.precision_config == this->precision_config && + rhs.rhs_dilation == this->rhs_dilation && + rhs.window_reversal == this->window_reversal && + rhs.window_strides == this->window_strides && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConvolutionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.convolution", odsAttrs.getContext()); + } + + ConvolutionOpGenericAdaptorBase(ConvolutionOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getWindowStridesAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().window_strides); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getWindowStrides(); + ::mlir::DenseIntElementsAttr getPaddingAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseIntElementsAttr>(getProperties().padding); + return attr; + } + + ::std::optional< ::mlir::DenseIntElementsAttr > getPadding(); + ::mlir::DenseI64ArrayAttr getLhsDilationAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().lhs_dilation); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getLhsDilation(); + ::mlir::DenseI64ArrayAttr getRhsDilationAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().rhs_dilation); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getRhsDilation(); + ::mlir::DenseBoolArrayAttr getWindowReversalAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseBoolArrayAttr>(getProperties().window_reversal); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getWindowReversal(); + ::mlir::stablehlo::ConvDimensionNumbersAttr getDimensionNumbersAttr() { + auto attr = ::llvm::cast<::mlir::stablehlo::ConvDimensionNumbersAttr>(getProperties().dimension_numbers); + return attr; + } + + ::mlir::stablehlo::ConvDimensionNumbersAttr getDimensionNumbers(); + ::mlir::IntegerAttr getFeatureGroupCountAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().feature_group_count); + return attr; + } + + uint64_t getFeatureGroupCount(); + ::mlir::IntegerAttr getBatchGroupCountAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().batch_group_count); + return attr; + } + + uint64_t getBatchGroupCount(); + ::mlir::ArrayAttr getPrecisionConfigAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().precision_config); + return attr; + } + + ::std::optional< ::mlir::ArrayAttr > getPrecisionConfig(); +}; +} // namespace detail +template +class ConvolutionOpGenericAdaptor : public detail::ConvolutionOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConvolutionOpGenericAdaptorBase; +public: + ConvolutionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConvolutionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConvolutionOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ConvolutionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ConvolutionOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ConvolutionOpGenericAdaptor(RangeT values, const ConvolutionOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ConvolutionOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConvolutionOpAdaptor : public ConvolutionOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConvolutionOpGenericAdaptor::ConvolutionOpGenericAdaptor; + ConvolutionOpAdaptor(ConvolutionOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ConvolutionOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConvolutionOpAdaptor; + template + using GenericAdaptor = ConvolutionOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("batch_group_count"), ::llvm::StringRef("dimension_numbers"), ::llvm::StringRef("feature_group_count"), ::llvm::StringRef("lhs_dilation"), ::llvm::StringRef("padding"), ::llvm::StringRef("precision_config"), ::llvm::StringRef("rhs_dilation"), ::llvm::StringRef("window_reversal"), ::llvm::StringRef("window_strides")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBatchGroupCountAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBatchGroupCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getDimensionNumbersAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getDimensionNumbersAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getFeatureGroupCountAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getFeatureGroupCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getLhsDilationAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getLhsDilationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getPaddingAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getPaddingAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + ::mlir::StringAttr getPrecisionConfigAttrName() { + return getAttributeNameForIndex(5); + } + + static ::mlir::StringAttr getPrecisionConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 5); + } + + ::mlir::StringAttr getRhsDilationAttrName() { + return getAttributeNameForIndex(6); + } + + static ::mlir::StringAttr getRhsDilationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 6); + } + + ::mlir::StringAttr getWindowReversalAttrName() { + return getAttributeNameForIndex(7); + } + + static ::mlir::StringAttr getWindowReversalAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 7); + } + + ::mlir::StringAttr getWindowStridesAttrName() { + return getAttributeNameForIndex(8); + } + + static ::mlir::StringAttr getWindowStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 8); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.convolution"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getWindowStridesAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().window_strides); + } + + ::std::optional<::llvm::ArrayRef> getWindowStrides(); + ::mlir::DenseIntElementsAttr getPaddingAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseIntElementsAttr>(getProperties().padding); + } + + ::std::optional< ::mlir::DenseIntElementsAttr > getPadding(); + ::mlir::DenseI64ArrayAttr getLhsDilationAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().lhs_dilation); + } + + ::std::optional<::llvm::ArrayRef> getLhsDilation(); + ::mlir::DenseI64ArrayAttr getRhsDilationAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().rhs_dilation); + } + + ::std::optional<::llvm::ArrayRef> getRhsDilation(); + ::mlir::DenseBoolArrayAttr getWindowReversalAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseBoolArrayAttr>(getProperties().window_reversal); + } + + ::std::optional<::llvm::ArrayRef> getWindowReversal(); + ::mlir::stablehlo::ConvDimensionNumbersAttr getDimensionNumbersAttr() { + return ::llvm::cast<::mlir::stablehlo::ConvDimensionNumbersAttr>(getProperties().dimension_numbers); + } + + ::mlir::stablehlo::ConvDimensionNumbersAttr getDimensionNumbers(); + ::mlir::IntegerAttr getFeatureGroupCountAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().feature_group_count); + } + + uint64_t getFeatureGroupCount(); + ::mlir::IntegerAttr getBatchGroupCountAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().batch_group_count); + } + + uint64_t getBatchGroupCount(); + ::mlir::ArrayAttr getPrecisionConfigAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().precision_config); + } + + ::std::optional< ::mlir::ArrayAttr > getPrecisionConfig(); + void setWindowStridesAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().window_strides = attr; + } + + void setWindowStrides(::std::optional<::llvm::ArrayRef> attrValue); + void setPaddingAttr(::mlir::DenseIntElementsAttr attr) { + getProperties().padding = attr; + } + + void setLhsDilationAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().lhs_dilation = attr; + } + + void setLhsDilation(::std::optional<::llvm::ArrayRef> attrValue); + void setRhsDilationAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().rhs_dilation = attr; + } + + void setRhsDilation(::std::optional<::llvm::ArrayRef> attrValue); + void setWindowReversalAttr(::mlir::DenseBoolArrayAttr attr) { + getProperties().window_reversal = attr; + } + + void setWindowReversal(::std::optional<::llvm::ArrayRef> attrValue); + void setDimensionNumbersAttr(::mlir::stablehlo::ConvDimensionNumbersAttr attr) { + getProperties().dimension_numbers = attr; + } + + void setFeatureGroupCountAttr(::mlir::IntegerAttr attr) { + getProperties().feature_group_count = attr; + } + + void setFeatureGroupCount(uint64_t attrValue); + void setBatchGroupCountAttr(::mlir::IntegerAttr attr) { + getProperties().batch_group_count = attr; + } + + void setBatchGroupCount(uint64_t attrValue); + void setPrecisionConfigAttr(::mlir::ArrayAttr attr) { + getProperties().precision_config = attr; + } + + ::mlir::Attribute removeWindowStridesAttr() { + auto attr = getProperties().window_strides; + getProperties().window_strides = {}; + return attr; + } + + ::mlir::Attribute removePaddingAttr() { + auto attr = getProperties().padding; + getProperties().padding = {}; + return attr; + } + + ::mlir::Attribute removeLhsDilationAttr() { + auto attr = getProperties().lhs_dilation; + getProperties().lhs_dilation = {}; + return attr; + } + + ::mlir::Attribute removeRhsDilationAttr() { + auto attr = getProperties().rhs_dilation; + getProperties().rhs_dilation = {}; + return attr; + } + + ::mlir::Attribute removeWindowReversalAttr() { + auto attr = getProperties().window_reversal; + getProperties().window_reversal = {}; + return attr; + } + + ::mlir::Attribute removePrecisionConfigAttr() { + auto attr = getProperties().precision_config; + getProperties().precision_config = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, ::mlir::IntegerAttr feature_group_count, ::mlir::IntegerAttr batch_group_count, /*optional*/::mlir::ArrayAttr precision_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, ::mlir::IntegerAttr feature_group_count, ::mlir::IntegerAttr batch_group_count, /*optional*/::mlir::ArrayAttr precision_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, uint64_t feature_group_count, uint64_t batch_group_count, /*optional*/::mlir::ArrayAttr precision_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, uint64_t feature_group_count, uint64_t batch_group_count, /*optional*/::mlir::ArrayAttr precision_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 9 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ConvolutionOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CosineOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CosineOpGenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::stablehlo::ResultAccuracyAttr; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(propStorage); + } + void setResultAccuracy(const ::mlir::stablehlo::ResultAccuracyAttr &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CosineOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.cosine", odsAttrs.getContext()); + } + + CosineOpGenericAdaptorBase(CosineOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr(); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); +}; +} // namespace detail +template +class CosineOpGenericAdaptor : public detail::CosineOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CosineOpGenericAdaptorBase; +public: + CosineOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CosineOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CosineOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CosineOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CosineOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + CosineOpGenericAdaptor(RangeT values, const CosineOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CosineOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CosineOpAdaptor : public CosineOpGenericAdaptor<::mlir::ValueRange> { +public: + using CosineOpGenericAdaptor::CosineOpGenericAdaptor; + CosineOpAdaptor(CosineOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CosineOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CosineOpAdaptor; + template + using GenericAdaptor = CosineOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.cosine"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); + void setResultAccuracyAttr(::mlir::stablehlo::ResultAccuracyAttr attr) { + getProperties().result_accuracy = attr; + } + + ::mlir::Attribute removeResultAccuracyAttr() { + auto attr = getProperties().result_accuracy; + getProperties().result_accuracy = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CosineOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CreateTokenOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CreateTokenOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CreateTokenOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.create_token", odsAttrs.getContext()); + } + + CreateTokenOpGenericAdaptorBase(CreateTokenOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class CreateTokenOpGenericAdaptor : public detail::CreateTokenOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CreateTokenOpGenericAdaptorBase; +public: + CreateTokenOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CreateTokenOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CreateTokenOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CreateTokenOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CreateTokenOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + CreateTokenOpGenericAdaptor(RangeT values, const CreateTokenOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CreateTokenOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CreateTokenOpAdaptor : public CreateTokenOpGenericAdaptor<::mlir::ValueRange> { +public: + using CreateTokenOpGenericAdaptor::CreateTokenOpGenericAdaptor; + CreateTokenOpAdaptor(CreateTokenOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CreateTokenOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CreateTokenOpAdaptor; + template + using GenericAdaptor = CreateTokenOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.create_token"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CreateTokenOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CrossReplicaSumOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CrossReplicaSumOpGenericAdaptorBase { +public: + struct Properties { + using replica_groupsTy = ::mlir::DenseIntElementsAttr; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::DenseIntElementsAttr>(propStorage); + } + void setReplicaGroups(const ::mlir::DenseIntElementsAttr &propValue) { + this->replica_groups = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.replica_groups == this->replica_groups && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CrossReplicaSumOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.cross-replica-sum", odsAttrs.getContext()); + } + + CrossReplicaSumOpGenericAdaptorBase(CrossReplicaSumOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseIntElementsAttr getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().replica_groups); + return attr; + } + + ::mlir::DenseIntElementsAttr getReplicaGroups(); +}; +} // namespace detail +template +class CrossReplicaSumOpGenericAdaptor : public detail::CrossReplicaSumOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CrossReplicaSumOpGenericAdaptorBase; +public: + CrossReplicaSumOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CrossReplicaSumOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CrossReplicaSumOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CrossReplicaSumOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CrossReplicaSumOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + CrossReplicaSumOpGenericAdaptor(RangeT values, const CrossReplicaSumOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CrossReplicaSumOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CrossReplicaSumOpAdaptor : public CrossReplicaSumOpGenericAdaptor<::mlir::ValueRange> { +public: + using CrossReplicaSumOpGenericAdaptor::CrossReplicaSumOpGenericAdaptor; + CrossReplicaSumOpAdaptor(CrossReplicaSumOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CrossReplicaSumOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType> { +public: + using Op::Op; + using Op::print; + using Adaptor = CrossReplicaSumOpAdaptor; + template + using GenericAdaptor = CrossReplicaSumOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("replica_groups")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.cross-replica-sum"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseIntElementsAttr getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().replica_groups); + } + + ::mlir::DenseIntElementsAttr getReplicaGroups(); + void setReplicaGroupsAttr(::mlir::DenseIntElementsAttr attr) { + getProperties().replica_groups = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseIntElementsAttr replica_groups); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CrossReplicaSumOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::CustomCallOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CustomCallOpGenericAdaptorBase { +public: + struct Properties { + using api_versionTy = ::mlir::stablehlo::CustomCallApiVersionAttr; + api_versionTy api_version; + + auto getApiVersion() const { + auto &propStorage = this->api_version; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::CustomCallApiVersionAttr>(propStorage); + } + void setApiVersion(const ::mlir::stablehlo::CustomCallApiVersionAttr &propValue) { + this->api_version = propValue; + } + using backend_configTy = ::mlir::Attribute; + backend_configTy backend_config; + + auto getBackendConfig() const { + auto &propStorage = this->backend_config; + return ::llvm::dyn_cast_or_null<::mlir::Attribute>(propStorage); + } + void setBackendConfig(const ::mlir::Attribute &propValue) { + this->backend_config = propValue; + } + using call_target_nameTy = ::mlir::StringAttr; + call_target_nameTy call_target_name; + + auto getCallTargetName() const { + auto &propStorage = this->call_target_name; + return ::llvm::cast<::mlir::StringAttr>(propStorage); + } + void setCallTargetName(const ::mlir::StringAttr &propValue) { + this->call_target_name = propValue; + } + using called_computationsTy = ::mlir::ArrayAttr; + called_computationsTy called_computations; + + auto getCalledComputations() const { + auto &propStorage = this->called_computations; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setCalledComputations(const ::mlir::ArrayAttr &propValue) { + this->called_computations = propValue; + } + using has_side_effectTy = ::mlir::BoolAttr; + has_side_effectTy has_side_effect; + + auto getHasSideEffect() const { + auto &propStorage = this->has_side_effect; + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(propStorage); + } + void setHasSideEffect(const ::mlir::BoolAttr &propValue) { + this->has_side_effect = propValue; + } + using operand_layoutsTy = ::mlir::ArrayAttr; + operand_layoutsTy operand_layouts; + + auto getOperandLayouts() const { + auto &propStorage = this->operand_layouts; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setOperandLayouts(const ::mlir::ArrayAttr &propValue) { + this->operand_layouts = propValue; + } + using output_operand_aliasesTy = ::mlir::ArrayAttr; + output_operand_aliasesTy output_operand_aliases; + + auto getOutputOperandAliases() const { + auto &propStorage = this->output_operand_aliases; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setOutputOperandAliases(const ::mlir::ArrayAttr &propValue) { + this->output_operand_aliases = propValue; + } + using result_layoutsTy = ::mlir::ArrayAttr; + result_layoutsTy result_layouts; + + auto getResultLayouts() const { + auto &propStorage = this->result_layouts; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setResultLayouts(const ::mlir::ArrayAttr &propValue) { + this->result_layouts = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.api_version == this->api_version && + rhs.backend_config == this->backend_config && + rhs.call_target_name == this->call_target_name && + rhs.called_computations == this->called_computations && + rhs.has_side_effect == this->has_side_effect && + rhs.operand_layouts == this->operand_layouts && + rhs.output_operand_aliases == this->output_operand_aliases && + rhs.result_layouts == this->result_layouts && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CustomCallOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.custom_call", odsAttrs.getContext()); + } + + CustomCallOpGenericAdaptorBase(CustomCallOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::StringAttr getCallTargetNameAttr() { + auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().call_target_name); + return attr; + } + + ::llvm::StringRef getCallTargetName(); + ::mlir::BoolAttr getHasSideEffectAttr(); + bool getHasSideEffect(); + ::mlir::Attribute getBackendConfigAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::Attribute>(getProperties().backend_config); + return attr; + } + + ::std::optional<::mlir::Attribute> getBackendConfig(); + ::mlir::stablehlo::CustomCallApiVersionAttr getApiVersionAttr(); + ::mlir::stablehlo::CustomCallApiVersion getApiVersion(); + ::mlir::ArrayAttr getCalledComputationsAttr(); + ::mlir::ArrayAttr getCalledComputations(); + ::mlir::ArrayAttr getOperandLayoutsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().operand_layouts); + return attr; + } + + ::std::optional< ::mlir::ArrayAttr > getOperandLayouts(); + ::mlir::ArrayAttr getResultLayoutsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().result_layouts); + return attr; + } + + ::std::optional< ::mlir::ArrayAttr > getResultLayouts(); + ::mlir::ArrayAttr getOutputOperandAliasesAttr(); + ::mlir::ArrayAttr getOutputOperandAliases(); +}; +} // namespace detail +template +class CustomCallOpGenericAdaptor : public detail::CustomCallOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CustomCallOpGenericAdaptorBase; +public: + CustomCallOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CustomCallOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CustomCallOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CustomCallOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CustomCallOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + CustomCallOpGenericAdaptor(RangeT values, const CustomCallOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CustomCallOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CustomCallOpAdaptor : public CustomCallOpGenericAdaptor<::mlir::ValueRange> { +public: + using CustomCallOpGenericAdaptor::CustomCallOpGenericAdaptor; + CustomCallOpAdaptor(CustomCallOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CustomCallOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = CustomCallOpAdaptor; + template + using GenericAdaptor = CustomCallOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("api_version"), ::llvm::StringRef("backend_config"), ::llvm::StringRef("call_target_name"), ::llvm::StringRef("called_computations"), ::llvm::StringRef("has_side_effect"), ::llvm::StringRef("operand_layouts"), ::llvm::StringRef("output_operand_aliases"), ::llvm::StringRef("result_layouts")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getApiVersionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getApiVersionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getBackendConfigAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getBackendConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getCallTargetNameAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getCallTargetNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getCalledComputationsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getCalledComputationsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getHasSideEffectAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getHasSideEffectAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + ::mlir::StringAttr getOperandLayoutsAttrName() { + return getAttributeNameForIndex(5); + } + + static ::mlir::StringAttr getOperandLayoutsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 5); + } + + ::mlir::StringAttr getOutputOperandAliasesAttrName() { + return getAttributeNameForIndex(6); + } + + static ::mlir::StringAttr getOutputOperandAliasesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 6); + } + + ::mlir::StringAttr getResultLayoutsAttrName() { + return getAttributeNameForIndex(7); + } + + static ::mlir::StringAttr getResultLayoutsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 7); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.custom_call"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getCallTargetNameAttr() { + return ::llvm::cast<::mlir::StringAttr>(getProperties().call_target_name); + } + + ::llvm::StringRef getCallTargetName(); + ::mlir::BoolAttr getHasSideEffectAttr() { + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().has_side_effect); + } + + bool getHasSideEffect(); + ::mlir::Attribute getBackendConfigAttr() { + return ::llvm::dyn_cast_or_null<::mlir::Attribute>(getProperties().backend_config); + } + + ::std::optional<::mlir::Attribute> getBackendConfig(); + ::mlir::stablehlo::CustomCallApiVersionAttr getApiVersionAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::CustomCallApiVersionAttr>(getProperties().api_version); + } + + ::mlir::stablehlo::CustomCallApiVersion getApiVersion(); + ::mlir::ArrayAttr getCalledComputationsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().called_computations); + } + + ::mlir::ArrayAttr getCalledComputations(); + ::mlir::ArrayAttr getOperandLayoutsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().operand_layouts); + } + + ::std::optional< ::mlir::ArrayAttr > getOperandLayouts(); + ::mlir::ArrayAttr getResultLayoutsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().result_layouts); + } + + ::std::optional< ::mlir::ArrayAttr > getResultLayouts(); + ::mlir::ArrayAttr getOutputOperandAliasesAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().output_operand_aliases); + } + + ::mlir::ArrayAttr getOutputOperandAliases(); + void setCallTargetNameAttr(::mlir::StringAttr attr) { + getProperties().call_target_name = attr; + } + + void setCallTargetName(::llvm::StringRef attrValue); + void setHasSideEffectAttr(::mlir::BoolAttr attr) { + getProperties().has_side_effect = attr; + } + + void setHasSideEffect(::std::optional attrValue); + void setBackendConfigAttr(::mlir::Attribute attr) { + getProperties().backend_config = attr; + } + + void setApiVersionAttr(::mlir::stablehlo::CustomCallApiVersionAttr attr) { + getProperties().api_version = attr; + } + + void setApiVersion(::std::optional<::mlir::stablehlo::CustomCallApiVersion> attrValue); + void setCalledComputationsAttr(::mlir::ArrayAttr attr) { + getProperties().called_computations = attr; + } + + void setOperandLayoutsAttr(::mlir::ArrayAttr attr) { + getProperties().operand_layouts = attr; + } + + void setResultLayoutsAttr(::mlir::ArrayAttr attr) { + getProperties().result_layouts = attr; + } + + void setOutputOperandAliasesAttr(::mlir::ArrayAttr attr) { + getProperties().output_operand_aliases = attr; + } + + ::mlir::Attribute removeHasSideEffectAttr() { + auto attr = getProperties().has_side_effect; + getProperties().has_side_effect = {}; + return attr; + } + + ::mlir::Attribute removeBackendConfigAttr() { + auto attr = getProperties().backend_config; + getProperties().backend_config = {}; + return attr; + } + + ::mlir::Attribute removeApiVersionAttr() { + auto attr = getProperties().api_version; + getProperties().api_version = {}; + return attr; + } + + ::mlir::Attribute removeCalledComputationsAttr() { + auto attr = getProperties().called_computations; + getProperties().called_computations = {}; + return attr; + } + + ::mlir::Attribute removeOperandLayoutsAttr() { + auto attr = getProperties().operand_layouts; + getProperties().operand_layouts = {}; + return attr; + } + + ::mlir::Attribute removeResultLayoutsAttr() { + auto attr = getProperties().result_layouts; + getProperties().result_layouts = {}; + return attr; + } + + ::mlir::Attribute removeOutputOperandAliasesAttr() { + auto attr = getProperties().output_operand_aliases; + getProperties().output_operand_aliases = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::StringAttr call_target_name, /*optional*/::mlir::BoolAttr has_side_effect, /*optional*/::mlir::Attribute backend_config, /*optional*/::mlir::stablehlo::CustomCallApiVersionAttr api_version, /*optional*/::mlir::ArrayAttr called_computations, /*optional*/::mlir::ArrayAttr operand_layouts, /*optional*/::mlir::ArrayAttr result_layouts, /*optional*/::mlir::ArrayAttr output_operand_aliases = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::llvm::StringRef call_target_name, /*optional*/bool has_side_effect, /*optional*/::mlir::Attribute backend_config, /*optional*/::mlir::stablehlo::CustomCallApiVersion api_version, /*optional*/::mlir::ArrayAttr called_computations, /*optional*/::mlir::ArrayAttr operand_layouts, /*optional*/::mlir::ArrayAttr result_layouts, /*optional*/::mlir::ArrayAttr output_operand_aliases); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 8 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + mlir::Attribute getBackendConfigOrDefault(); + bool hasEmptyBackendConfig(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::CustomCallOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DivOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DivOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DivOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.divide", odsAttrs.getContext()); + } + + DivOpGenericAdaptorBase(DivOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class DivOpGenericAdaptor : public detail::DivOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DivOpGenericAdaptorBase; +public: + DivOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DivOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DivOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DivOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DivOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + DivOpGenericAdaptor(RangeT values, const DivOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DivOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DivOpAdaptor : public DivOpGenericAdaptor<::mlir::ValueRange> { +public: + using DivOpGenericAdaptor::DivOpGenericAdaptor; + DivOpAdaptor(DivOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DivOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DivOpAdaptor; + template + using GenericAdaptor = DivOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.divide"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DivOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DotGeneralOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DotGeneralOpGenericAdaptorBase { +public: + struct Properties { + using algorithmTy = ::mlir::stablehlo::DotAlgorithmAttr; + algorithmTy algorithm; + + auto getAlgorithm() const { + auto &propStorage = this->algorithm; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::DotAlgorithmAttr>(propStorage); + } + void setAlgorithm(const ::mlir::stablehlo::DotAlgorithmAttr &propValue) { + this->algorithm = propValue; + } + using dot_dimension_numbersTy = ::mlir::stablehlo::DotDimensionNumbersAttr; + dot_dimension_numbersTy dot_dimension_numbers; + + auto getDotDimensionNumbers() const { + auto &propStorage = this->dot_dimension_numbers; + return ::llvm::cast<::mlir::stablehlo::DotDimensionNumbersAttr>(propStorage); + } + void setDotDimensionNumbers(const ::mlir::stablehlo::DotDimensionNumbersAttr &propValue) { + this->dot_dimension_numbers = propValue; + } + using precision_configTy = ::mlir::ArrayAttr; + precision_configTy precision_config; + + auto getPrecisionConfig() const { + auto &propStorage = this->precision_config; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setPrecisionConfig(const ::mlir::ArrayAttr &propValue) { + this->precision_config = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.algorithm == this->algorithm && + rhs.dot_dimension_numbers == this->dot_dimension_numbers && + rhs.precision_config == this->precision_config && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DotGeneralOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.dot_general", odsAttrs.getContext()); + } + + DotGeneralOpGenericAdaptorBase(DotGeneralOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::DotDimensionNumbersAttr getDotDimensionNumbersAttr() { + auto attr = ::llvm::cast<::mlir::stablehlo::DotDimensionNumbersAttr>(getProperties().dot_dimension_numbers); + return attr; + } + + ::mlir::stablehlo::DotDimensionNumbersAttr getDotDimensionNumbers(); + ::mlir::ArrayAttr getPrecisionConfigAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().precision_config); + return attr; + } + + ::std::optional< ::mlir::ArrayAttr > getPrecisionConfig(); + ::mlir::stablehlo::DotAlgorithmAttr getAlgorithmAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::DotAlgorithmAttr>(getProperties().algorithm); + return attr; + } + + ::std::optional<::mlir::stablehlo::DotAlgorithmAttr> getAlgorithm(); +}; +} // namespace detail +template +class DotGeneralOpGenericAdaptor : public detail::DotGeneralOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DotGeneralOpGenericAdaptorBase; +public: + DotGeneralOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DotGeneralOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DotGeneralOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DotGeneralOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DotGeneralOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + DotGeneralOpGenericAdaptor(RangeT values, const DotGeneralOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DotGeneralOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DotGeneralOpAdaptor : public DotGeneralOpGenericAdaptor<::mlir::ValueRange> { +public: + using DotGeneralOpGenericAdaptor::DotGeneralOpGenericAdaptor; + DotGeneralOpAdaptor(DotGeneralOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DotGeneralOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DotGeneralOpAdaptor; + template + using GenericAdaptor = DotGeneralOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("algorithm"), ::llvm::StringRef("dot_dimension_numbers"), ::llvm::StringRef("precision_config")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getAlgorithmAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getAlgorithmAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getDotDimensionNumbersAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getDotDimensionNumbersAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getPrecisionConfigAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getPrecisionConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.dot_general"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::DotDimensionNumbersAttr getDotDimensionNumbersAttr() { + return ::llvm::cast<::mlir::stablehlo::DotDimensionNumbersAttr>(getProperties().dot_dimension_numbers); + } + + ::mlir::stablehlo::DotDimensionNumbersAttr getDotDimensionNumbers(); + ::mlir::ArrayAttr getPrecisionConfigAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().precision_config); + } + + ::std::optional< ::mlir::ArrayAttr > getPrecisionConfig(); + ::mlir::stablehlo::DotAlgorithmAttr getAlgorithmAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::DotAlgorithmAttr>(getProperties().algorithm); + } + + ::std::optional<::mlir::stablehlo::DotAlgorithmAttr> getAlgorithm(); + void setDotDimensionNumbersAttr(::mlir::stablehlo::DotDimensionNumbersAttr attr) { + getProperties().dot_dimension_numbers = attr; + } + + void setPrecisionConfigAttr(::mlir::ArrayAttr attr) { + getProperties().precision_config = attr; + } + + void setAlgorithmAttr(::mlir::stablehlo::DotAlgorithmAttr attr) { + getProperties().algorithm = attr; + } + + ::mlir::Attribute removePrecisionConfigAttr() { + auto attr = getProperties().precision_config; + getProperties().precision_config = {}; + return attr; + } + + ::mlir::Attribute removeAlgorithmAttr() { + auto attr = getProperties().algorithm; + getProperties().algorithm = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::DotDimensionNumbersAttr dot_dimension_numbers, /*optional*/::mlir::ArrayAttr precision_config, /*optional*/::mlir::stablehlo::DotAlgorithmAttr algorithm); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::stablehlo::DotDimensionNumbersAttr dot_dimension_numbers, /*optional*/::mlir::ArrayAttr precision_config, /*optional*/::mlir::stablehlo::DotAlgorithmAttr algorithm); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); + + /// Determines if this DotGeneral instance can be expressed as a DotOp. + bool isSimpleDot(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DotGeneralOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DotOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DotOpGenericAdaptorBase { +public: + struct Properties { + using precision_configTy = ::mlir::ArrayAttr; + precision_configTy precision_config; + + auto getPrecisionConfig() const { + auto &propStorage = this->precision_config; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setPrecisionConfig(const ::mlir::ArrayAttr &propValue) { + this->precision_config = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.precision_config == this->precision_config && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DotOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.dot", odsAttrs.getContext()); + } + + DotOpGenericAdaptorBase(DotOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::ArrayAttr getPrecisionConfigAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().precision_config); + return attr; + } + + ::std::optional< ::mlir::ArrayAttr > getPrecisionConfig(); +}; +} // namespace detail +template +class DotOpGenericAdaptor : public detail::DotOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DotOpGenericAdaptorBase; +public: + DotOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DotOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DotOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DotOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DotOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + DotOpGenericAdaptor(RangeT values, const DotOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DotOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DotOpAdaptor : public DotOpGenericAdaptor<::mlir::ValueRange> { +public: + using DotOpGenericAdaptor::DotOpGenericAdaptor; + DotOpAdaptor(DotOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DotOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DotOpAdaptor; + template + using GenericAdaptor = DotOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("precision_config")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getPrecisionConfigAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getPrecisionConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.dot"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ArrayAttr getPrecisionConfigAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().precision_config); + } + + ::std::optional< ::mlir::ArrayAttr > getPrecisionConfig(); + void setPrecisionConfigAttr(::mlir::ArrayAttr attr) { + getProperties().precision_config = attr; + } + + ::mlir::Attribute removePrecisionConfigAttr() { + auto attr = getProperties().precision_config; + getProperties().precision_config = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::ArrayAttr precision_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::ArrayAttr precision_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DotOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicBroadcastInDimOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicBroadcastInDimOpGenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::DenseI64ArrayAttr; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBroadcastDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->broadcast_dimensions = propValue; + } + using known_expanding_dimensionsTy = ::mlir::DenseI64ArrayAttr; + known_expanding_dimensionsTy known_expanding_dimensions; + + auto getKnownExpandingDimensions() const { + auto &propStorage = this->known_expanding_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setKnownExpandingDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->known_expanding_dimensions = propValue; + } + using known_nonexpanding_dimensionsTy = ::mlir::DenseI64ArrayAttr; + known_nonexpanding_dimensionsTy known_nonexpanding_dimensions; + + auto getKnownNonexpandingDimensions() const { + auto &propStorage = this->known_nonexpanding_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setKnownNonexpandingDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->known_nonexpanding_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + rhs.known_expanding_dimensions == this->known_expanding_dimensions && + rhs.known_nonexpanding_dimensions == this->known_nonexpanding_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicBroadcastInDimOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.dynamic_broadcast_in_dim", odsAttrs.getContext()); + } + + DynamicBroadcastInDimOpGenericAdaptorBase(DynamicBroadcastInDimOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + return attr; + } + + ::llvm::ArrayRef getBroadcastDimensions(); + ::mlir::DenseI64ArrayAttr getKnownExpandingDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().known_expanding_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getKnownExpandingDimensions(); + ::mlir::DenseI64ArrayAttr getKnownNonexpandingDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().known_nonexpanding_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getKnownNonexpandingDimensions(); +}; +} // namespace detail +template +class DynamicBroadcastInDimOpGenericAdaptor : public detail::DynamicBroadcastInDimOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicBroadcastInDimOpGenericAdaptorBase; +public: + DynamicBroadcastInDimOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicBroadcastInDimOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicBroadcastInDimOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicBroadcastInDimOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicBroadcastInDimOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicBroadcastInDimOpGenericAdaptor(RangeT values, const DynamicBroadcastInDimOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicBroadcastInDimOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getOutputDimensions() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicBroadcastInDimOpAdaptor : public DynamicBroadcastInDimOpGenericAdaptor<::mlir::ValueRange> { +public: + using DynamicBroadcastInDimOpGenericAdaptor::DynamicBroadcastInDimOpGenericAdaptor; + DynamicBroadcastInDimOpAdaptor(DynamicBroadcastInDimOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicBroadcastInDimOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicBroadcastInDimOpAdaptor; + template + using GenericAdaptor = DynamicBroadcastInDimOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions"), ::llvm::StringRef("known_expanding_dimensions"), ::llvm::StringRef("known_nonexpanding_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getKnownExpandingDimensionsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getKnownExpandingDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getKnownNonexpandingDimensionsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getKnownNonexpandingDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.dynamic_broadcast_in_dim"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOutputDimensions() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOutputDimensionsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getBroadcastDimensionsAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().broadcast_dimensions); + } + + ::llvm::ArrayRef getBroadcastDimensions(); + ::mlir::DenseI64ArrayAttr getKnownExpandingDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().known_expanding_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getKnownExpandingDimensions(); + ::mlir::DenseI64ArrayAttr getKnownNonexpandingDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().known_nonexpanding_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getKnownNonexpandingDimensions(); + void setBroadcastDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().broadcast_dimensions = attr; + } + + void setBroadcastDimensions(::llvm::ArrayRef attrValue); + void setKnownExpandingDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().known_expanding_dimensions = attr; + } + + void setKnownExpandingDimensions(::std::optional<::llvm::ArrayRef> attrValue); + void setKnownNonexpandingDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().known_nonexpanding_dimensions = attr; + } + + void setKnownNonexpandingDimensions(::std::optional<::llvm::ArrayRef> attrValue); + ::mlir::Attribute removeKnownExpandingDimensionsAttr() { + auto attr = getProperties().known_expanding_dimensions; + getProperties().known_expanding_dimensions = {}; + return attr; + } + + ::mlir::Attribute removeKnownNonexpandingDimensionsAttr() { + auto attr = getProperties().known_nonexpanding_dimensions; + getProperties().known_nonexpanding_dimensions = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type result_type, Value operand, Value output_dimensions, DenseI64ArrayAttr broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value output_dimensions, ::mlir::DenseI64ArrayAttr broadcast_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_expanding_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_nonexpanding_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value output_dimensions, ::mlir::DenseI64ArrayAttr broadcast_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_expanding_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_nonexpanding_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value output_dimensions, ::llvm::ArrayRef broadcast_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_expanding_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_nonexpanding_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value output_dimensions, ::llvm::ArrayRef broadcast_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_expanding_dimensions, /*optional*/::mlir::DenseI64ArrayAttr known_nonexpanding_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicBroadcastInDimOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicConvOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicConvOpGenericAdaptorBase { +public: + struct Properties { + using batch_group_countTy = ::mlir::IntegerAttr; + batch_group_countTy batch_group_count; + + auto getBatchGroupCount() const { + auto &propStorage = this->batch_group_count; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setBatchGroupCount(const ::mlir::IntegerAttr &propValue) { + this->batch_group_count = propValue; + } + using dimension_numbersTy = ::mlir::stablehlo::ConvDimensionNumbersAttr; + dimension_numbersTy dimension_numbers; + + auto getDimensionNumbers() const { + auto &propStorage = this->dimension_numbers; + return ::llvm::cast<::mlir::stablehlo::ConvDimensionNumbersAttr>(propStorage); + } + void setDimensionNumbers(const ::mlir::stablehlo::ConvDimensionNumbersAttr &propValue) { + this->dimension_numbers = propValue; + } + using feature_group_countTy = ::mlir::IntegerAttr; + feature_group_countTy feature_group_count; + + auto getFeatureGroupCount() const { + auto &propStorage = this->feature_group_count; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setFeatureGroupCount(const ::mlir::IntegerAttr &propValue) { + this->feature_group_count = propValue; + } + using lhs_dilationTy = ::mlir::DenseI64ArrayAttr; + lhs_dilationTy lhs_dilation; + + auto getLhsDilation() const { + auto &propStorage = this->lhs_dilation; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setLhsDilation(const ::mlir::DenseI64ArrayAttr &propValue) { + this->lhs_dilation = propValue; + } + using precision_configTy = ::mlir::ArrayAttr; + precision_configTy precision_config; + + auto getPrecisionConfig() const { + auto &propStorage = this->precision_config; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setPrecisionConfig(const ::mlir::ArrayAttr &propValue) { + this->precision_config = propValue; + } + using rhs_dilationTy = ::mlir::DenseI64ArrayAttr; + rhs_dilationTy rhs_dilation; + + auto getRhsDilation() const { + auto &propStorage = this->rhs_dilation; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setRhsDilation(const ::mlir::DenseI64ArrayAttr &propValue) { + this->rhs_dilation = propValue; + } + using window_reversalTy = ::mlir::DenseBoolArrayAttr; + window_reversalTy window_reversal; + + auto getWindowReversal() const { + auto &propStorage = this->window_reversal; + return ::llvm::dyn_cast_or_null<::mlir::DenseBoolArrayAttr>(propStorage); + } + void setWindowReversal(const ::mlir::DenseBoolArrayAttr &propValue) { + this->window_reversal = propValue; + } + using window_stridesTy = ::mlir::DenseI64ArrayAttr; + window_stridesTy window_strides; + + auto getWindowStrides() const { + auto &propStorage = this->window_strides; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setWindowStrides(const ::mlir::DenseI64ArrayAttr &propValue) { + this->window_strides = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.batch_group_count == this->batch_group_count && + rhs.dimension_numbers == this->dimension_numbers && + rhs.feature_group_count == this->feature_group_count && + rhs.lhs_dilation == this->lhs_dilation && + rhs.precision_config == this->precision_config && + rhs.rhs_dilation == this->rhs_dilation && + rhs.window_reversal == this->window_reversal && + rhs.window_strides == this->window_strides && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicConvOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.dynamic_conv", odsAttrs.getContext()); + } + + DynamicConvOpGenericAdaptorBase(DynamicConvOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getWindowStridesAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().window_strides); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getWindowStrides(); + ::mlir::DenseI64ArrayAttr getLhsDilationAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().lhs_dilation); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getLhsDilation(); + ::mlir::DenseI64ArrayAttr getRhsDilationAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().rhs_dilation); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getRhsDilation(); + ::mlir::DenseBoolArrayAttr getWindowReversalAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseBoolArrayAttr>(getProperties().window_reversal); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getWindowReversal(); + ::mlir::stablehlo::ConvDimensionNumbersAttr getDimensionNumbersAttr() { + auto attr = ::llvm::cast<::mlir::stablehlo::ConvDimensionNumbersAttr>(getProperties().dimension_numbers); + return attr; + } + + ::mlir::stablehlo::ConvDimensionNumbersAttr getDimensionNumbers(); + ::mlir::IntegerAttr getFeatureGroupCountAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().feature_group_count); + return attr; + } + + uint64_t getFeatureGroupCount(); + ::mlir::IntegerAttr getBatchGroupCountAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().batch_group_count); + return attr; + } + + uint64_t getBatchGroupCount(); + ::mlir::ArrayAttr getPrecisionConfigAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().precision_config); + return attr; + } + + ::std::optional< ::mlir::ArrayAttr > getPrecisionConfig(); +}; +} // namespace detail +template +class DynamicConvOpGenericAdaptor : public detail::DynamicConvOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicConvOpGenericAdaptorBase; +public: + DynamicConvOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicConvOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicConvOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicConvOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicConvOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicConvOpGenericAdaptor(RangeT values, const DynamicConvOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicConvOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + ValueT getPadding() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicConvOpAdaptor : public DynamicConvOpGenericAdaptor<::mlir::ValueRange> { +public: + using DynamicConvOpGenericAdaptor::DynamicConvOpGenericAdaptor; + DynamicConvOpAdaptor(DynamicConvOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicConvOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticAndShapeConstantImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicConvOpAdaptor; + template + using GenericAdaptor = DynamicConvOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("batch_group_count"), ::llvm::StringRef("dimension_numbers"), ::llvm::StringRef("feature_group_count"), ::llvm::StringRef("lhs_dilation"), ::llvm::StringRef("precision_config"), ::llvm::StringRef("rhs_dilation"), ::llvm::StringRef("window_reversal"), ::llvm::StringRef("window_strides")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBatchGroupCountAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBatchGroupCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getDimensionNumbersAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getDimensionNumbersAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getFeatureGroupCountAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getFeatureGroupCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getLhsDilationAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getLhsDilationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getPrecisionConfigAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getPrecisionConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + ::mlir::StringAttr getRhsDilationAttrName() { + return getAttributeNameForIndex(5); + } + + static ::mlir::StringAttr getRhsDilationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 5); + } + + ::mlir::StringAttr getWindowReversalAttrName() { + return getAttributeNameForIndex(6); + } + + static ::mlir::StringAttr getWindowReversalAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 6); + } + + ::mlir::StringAttr getWindowStridesAttrName() { + return getAttributeNameForIndex(7); + } + + static ::mlir::StringAttr getWindowStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 7); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.dynamic_conv"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getPadding() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getPaddingMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getWindowStridesAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().window_strides); + } + + ::std::optional<::llvm::ArrayRef> getWindowStrides(); + ::mlir::DenseI64ArrayAttr getLhsDilationAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().lhs_dilation); + } + + ::std::optional<::llvm::ArrayRef> getLhsDilation(); + ::mlir::DenseI64ArrayAttr getRhsDilationAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().rhs_dilation); + } + + ::std::optional<::llvm::ArrayRef> getRhsDilation(); + ::mlir::DenseBoolArrayAttr getWindowReversalAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseBoolArrayAttr>(getProperties().window_reversal); + } + + ::std::optional<::llvm::ArrayRef> getWindowReversal(); + ::mlir::stablehlo::ConvDimensionNumbersAttr getDimensionNumbersAttr() { + return ::llvm::cast<::mlir::stablehlo::ConvDimensionNumbersAttr>(getProperties().dimension_numbers); + } + + ::mlir::stablehlo::ConvDimensionNumbersAttr getDimensionNumbers(); + ::mlir::IntegerAttr getFeatureGroupCountAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().feature_group_count); + } + + uint64_t getFeatureGroupCount(); + ::mlir::IntegerAttr getBatchGroupCountAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().batch_group_count); + } + + uint64_t getBatchGroupCount(); + ::mlir::ArrayAttr getPrecisionConfigAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().precision_config); + } + + ::std::optional< ::mlir::ArrayAttr > getPrecisionConfig(); + void setWindowStridesAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().window_strides = attr; + } + + void setWindowStrides(::std::optional<::llvm::ArrayRef> attrValue); + void setLhsDilationAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().lhs_dilation = attr; + } + + void setLhsDilation(::std::optional<::llvm::ArrayRef> attrValue); + void setRhsDilationAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().rhs_dilation = attr; + } + + void setRhsDilation(::std::optional<::llvm::ArrayRef> attrValue); + void setWindowReversalAttr(::mlir::DenseBoolArrayAttr attr) { + getProperties().window_reversal = attr; + } + + void setWindowReversal(::std::optional<::llvm::ArrayRef> attrValue); + void setDimensionNumbersAttr(::mlir::stablehlo::ConvDimensionNumbersAttr attr) { + getProperties().dimension_numbers = attr; + } + + void setFeatureGroupCountAttr(::mlir::IntegerAttr attr) { + getProperties().feature_group_count = attr; + } + + void setFeatureGroupCount(uint64_t attrValue); + void setBatchGroupCountAttr(::mlir::IntegerAttr attr) { + getProperties().batch_group_count = attr; + } + + void setBatchGroupCount(uint64_t attrValue); + void setPrecisionConfigAttr(::mlir::ArrayAttr attr) { + getProperties().precision_config = attr; + } + + ::mlir::Attribute removeWindowStridesAttr() { + auto attr = getProperties().window_strides; + getProperties().window_strides = {}; + return attr; + } + + ::mlir::Attribute removeLhsDilationAttr() { + auto attr = getProperties().lhs_dilation; + getProperties().lhs_dilation = {}; + return attr; + } + + ::mlir::Attribute removeRhsDilationAttr() { + auto attr = getProperties().rhs_dilation; + getProperties().rhs_dilation = {}; + return attr; + } + + ::mlir::Attribute removeWindowReversalAttr() { + auto attr = getProperties().window_reversal; + getProperties().window_reversal = {}; + return attr; + } + + ::mlir::Attribute removePrecisionConfigAttr() { + auto attr = getProperties().precision_config; + getProperties().precision_config = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value padding, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, ::mlir::IntegerAttr feature_group_count, ::mlir::IntegerAttr batch_group_count, /*optional*/::mlir::ArrayAttr precision_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value padding, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, ::mlir::IntegerAttr feature_group_count, ::mlir::IntegerAttr batch_group_count, /*optional*/::mlir::ArrayAttr precision_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value padding, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, uint64_t feature_group_count, uint64_t batch_group_count, /*optional*/::mlir::ArrayAttr precision_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value padding, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr lhs_dilation, /*optional*/::mlir::DenseI64ArrayAttr rhs_dilation, /*optional*/::mlir::DenseBoolArrayAttr window_reversal, ::mlir::stablehlo::ConvDimensionNumbersAttr dimension_numbers, uint64_t feature_group_count, uint64_t batch_group_count, /*optional*/::mlir::ArrayAttr precision_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 8 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + bool hasWindowReversal() { + auto reversal = getWindowReversal(); + return reversal.has_value() && llvm::any_of(reversal.value(), [](bool v) { return v; }); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicConvOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicGatherOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicGatherOpGenericAdaptorBase { +public: + struct Properties { + using dimension_numbersTy = ::mlir::stablehlo::GatherDimensionNumbersAttr; + dimension_numbersTy dimension_numbers; + + auto getDimensionNumbers() const { + auto &propStorage = this->dimension_numbers; + return ::llvm::cast<::mlir::stablehlo::GatherDimensionNumbersAttr>(propStorage); + } + void setDimensionNumbers(const ::mlir::stablehlo::GatherDimensionNumbersAttr &propValue) { + this->dimension_numbers = propValue; + } + using indices_are_sortedTy = ::mlir::BoolAttr; + indices_are_sortedTy indices_are_sorted; + + auto getIndicesAreSorted() const { + auto &propStorage = this->indices_are_sorted; + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(propStorage); + } + void setIndicesAreSorted(const ::mlir::BoolAttr &propValue) { + this->indices_are_sorted = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimension_numbers == this->dimension_numbers && + rhs.indices_are_sorted == this->indices_are_sorted && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicGatherOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.dynamic_gather", odsAttrs.getContext()); + } + + DynamicGatherOpGenericAdaptorBase(DynamicGatherOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::GatherDimensionNumbersAttr getDimensionNumbersAttr() { + auto attr = ::llvm::cast<::mlir::stablehlo::GatherDimensionNumbersAttr>(getProperties().dimension_numbers); + return attr; + } + + ::mlir::stablehlo::GatherDimensionNumbersAttr getDimensionNumbers(); + ::mlir::BoolAttr getIndicesAreSortedAttr(); + bool getIndicesAreSorted(); +}; +} // namespace detail +template +class DynamicGatherOpGenericAdaptor : public detail::DynamicGatherOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicGatherOpGenericAdaptorBase; +public: + DynamicGatherOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicGatherOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicGatherOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicGatherOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicGatherOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicGatherOpGenericAdaptor(RangeT values, const DynamicGatherOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicGatherOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getStartIndices() { + return (*getODSOperands(1).begin()); + } + + ValueT getSliceSizes() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicGatherOpAdaptor : public DynamicGatherOpGenericAdaptor<::mlir::ValueRange> { +public: + using DynamicGatherOpGenericAdaptor::DynamicGatherOpGenericAdaptor; + DynamicGatherOpAdaptor(DynamicGatherOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicGatherOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticAndShapeConstantImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicGatherOpAdaptor; + template + using GenericAdaptor = DynamicGatherOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimension_numbers"), ::llvm::StringRef("indices_are_sorted")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionNumbersAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionNumbersAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIndicesAreSortedAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIndicesAreSortedAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.dynamic_gather"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getStartIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getSliceSizes() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getStartIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getSliceSizesMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::GatherDimensionNumbersAttr getDimensionNumbersAttr() { + return ::llvm::cast<::mlir::stablehlo::GatherDimensionNumbersAttr>(getProperties().dimension_numbers); + } + + ::mlir::stablehlo::GatherDimensionNumbersAttr getDimensionNumbers(); + ::mlir::BoolAttr getIndicesAreSortedAttr() { + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().indices_are_sorted); + } + + bool getIndicesAreSorted(); + void setDimensionNumbersAttr(::mlir::stablehlo::GatherDimensionNumbersAttr attr) { + getProperties().dimension_numbers = attr; + } + + void setIndicesAreSortedAttr(::mlir::BoolAttr attr) { + getProperties().indices_are_sorted = attr; + } + + void setIndicesAreSorted(::std::optional attrValue); + ::mlir::Attribute removeIndicesAreSortedAttr() { + auto attr = getProperties().indices_are_sorted; + getProperties().indices_are_sorted = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, /*optional*/::mlir::BoolAttr indices_are_sorted); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, /*optional*/::mlir::BoolAttr indices_are_sorted); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, /*optional*/::mlir::BoolAttr indices_are_sorted); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, /*optional*/bool indices_are_sorted = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, /*optional*/bool indices_are_sorted = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, /*optional*/bool indices_are_sorted = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicGatherOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicIotaOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicIotaOpGenericAdaptorBase { +public: + struct Properties { + using iota_dimensionTy = ::mlir::IntegerAttr; + iota_dimensionTy iota_dimension; + + auto getIotaDimension() const { + auto &propStorage = this->iota_dimension; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setIotaDimension(const ::mlir::IntegerAttr &propValue) { + this->iota_dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.iota_dimension == this->iota_dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicIotaOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.dynamic_iota", odsAttrs.getContext()); + } + + DynamicIotaOpGenericAdaptorBase(DynamicIotaOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::IntegerAttr getIotaDimensionAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().iota_dimension); + return attr; + } + + uint64_t getIotaDimension(); +}; +} // namespace detail +template +class DynamicIotaOpGenericAdaptor : public detail::DynamicIotaOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicIotaOpGenericAdaptorBase; +public: + DynamicIotaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicIotaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicIotaOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicIotaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicIotaOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicIotaOpGenericAdaptor(RangeT values, const DynamicIotaOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicIotaOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOutputShape() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicIotaOpAdaptor : public DynamicIotaOpGenericAdaptor<::mlir::ValueRange> { +public: + using DynamicIotaOpGenericAdaptor::DynamicIotaOpGenericAdaptor; + DynamicIotaOpAdaptor(DynamicIotaOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicIotaOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicIotaOpAdaptor; + template + using GenericAdaptor = DynamicIotaOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("iota_dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getIotaDimensionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getIotaDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.dynamic_iota"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOutputShape() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOutputShapeMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getIotaDimensionAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().iota_dimension); + } + + uint64_t getIotaDimension(); + void setIotaDimensionAttr(::mlir::IntegerAttr attr) { + getProperties().iota_dimension = attr; + } + + void setIotaDimension(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value output_shape, ::mlir::IntegerAttr iota_dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value output_shape, ::mlir::IntegerAttr iota_dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value output_shape, uint64_t iota_dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value output_shape, uint64_t iota_dimension); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicIotaOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicPadOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicPadOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicPadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.dynamic_pad", odsAttrs.getContext()); + } + + DynamicPadOpGenericAdaptorBase(DynamicPadOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class DynamicPadOpGenericAdaptor : public detail::DynamicPadOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicPadOpGenericAdaptorBase; +public: + DynamicPadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicPadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicPadOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicPadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicPadOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicPadOpGenericAdaptor(RangeT values, const DynamicPadOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicPadOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getPaddingValue() { + return (*getODSOperands(1).begin()); + } + + ValueT getEdgePaddingLow() { + return (*getODSOperands(2).begin()); + } + + ValueT getEdgePaddingHigh() { + return (*getODSOperands(3).begin()); + } + + ValueT getInteriorPadding() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicPadOpAdaptor : public DynamicPadOpGenericAdaptor<::mlir::ValueRange> { +public: + using DynamicPadOpGenericAdaptor::DynamicPadOpGenericAdaptor; + DynamicPadOpAdaptor(DynamicPadOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicPadOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<5>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicPadOpAdaptor; + template + using GenericAdaptor = DynamicPadOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.dynamic_pad"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getPaddingValue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getEdgePaddingLow() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(2).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getEdgePaddingHigh() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(3).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getInteriorPadding() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(4).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getPaddingValueMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getEdgePaddingLowMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getEdgePaddingHighMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getInteriorPaddingMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::Value edge_padding_low, ::mlir::Value edge_padding_high, ::mlir::Value interior_padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::Value edge_padding_low, ::mlir::Value edge_padding_high, ::mlir::Value interior_padding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicPadOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicReshapeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicReshapeOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicReshapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.dynamic_reshape", odsAttrs.getContext()); + } + + DynamicReshapeOpGenericAdaptorBase(DynamicReshapeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class DynamicReshapeOpGenericAdaptor : public detail::DynamicReshapeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicReshapeOpGenericAdaptorBase; +public: + DynamicReshapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicReshapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicReshapeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicReshapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicReshapeOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicReshapeOpGenericAdaptor(RangeT values, const DynamicReshapeOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicReshapeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getOutputShape() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicReshapeOpAdaptor : public DynamicReshapeOpGenericAdaptor<::mlir::ValueRange> { +public: + using DynamicReshapeOpGenericAdaptor::DynamicReshapeOpGenericAdaptor; + DynamicReshapeOpAdaptor(DynamicReshapeOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicReshapeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticAndShapeConstantImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicReshapeOpAdaptor; + template + using GenericAdaptor = DynamicReshapeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.dynamic_reshape"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOutputShape() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOutputShapeMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value output_shape); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value output_shape); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicReshapeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicSliceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicSliceOpGenericAdaptorBase { +public: + struct Properties { + using slice_sizesTy = ::mlir::DenseI64ArrayAttr; + slice_sizesTy slice_sizes; + + auto getSliceSizes() const { + auto &propStorage = this->slice_sizes; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setSliceSizes(const ::mlir::DenseI64ArrayAttr &propValue) { + this->slice_sizes = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.slice_sizes == this->slice_sizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicSliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.dynamic_slice", odsAttrs.getContext()); + } + + DynamicSliceOpGenericAdaptorBase(DynamicSliceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getSliceSizesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().slice_sizes); + return attr; + } + + ::llvm::ArrayRef getSliceSizes(); +}; +} // namespace detail +template +class DynamicSliceOpGenericAdaptor : public detail::DynamicSliceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicSliceOpGenericAdaptorBase; +public: + DynamicSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicSliceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicSliceOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicSliceOpGenericAdaptor(RangeT values, const DynamicSliceOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicSliceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getStartIndices() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicSliceOpAdaptor : public DynamicSliceOpGenericAdaptor<::mlir::ValueRange> { +public: + using DynamicSliceOpGenericAdaptor::DynamicSliceOpGenericAdaptor; + DynamicSliceOpAdaptor(DynamicSliceOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicSliceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicSliceOpAdaptor; + template + using GenericAdaptor = DynamicSliceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("slice_sizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getSliceSizesAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getSliceSizesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.dynamic_slice"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::Operation::operand_range getStartIndices() { + return getODSOperands(1); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::MutableOperandRange getStartIndicesMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getSliceSizesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().slice_sizes); + } + + ::llvm::ArrayRef getSliceSizes(); + void setSliceSizesAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().slice_sizes = attr; + } + + void setSliceSizes(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::mlir::DenseI64ArrayAttr slice_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::mlir::DenseI64ArrayAttr slice_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::mlir::DenseI64ArrayAttr slice_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::llvm::ArrayRef slice_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::llvm::ArrayRef slice_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::llvm::ArrayRef slice_sizes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicSliceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::DynamicUpdateSliceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicUpdateSliceOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicUpdateSliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.dynamic_update_slice", odsAttrs.getContext()); + } + + DynamicUpdateSliceOpGenericAdaptorBase(DynamicUpdateSliceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class DynamicUpdateSliceOpGenericAdaptor : public detail::DynamicUpdateSliceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicUpdateSliceOpGenericAdaptorBase; +public: + DynamicUpdateSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicUpdateSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicUpdateSliceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicUpdateSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicUpdateSliceOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicUpdateSliceOpGenericAdaptor(RangeT values, const DynamicUpdateSliceOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicUpdateSliceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getUpdate() { + return (*getODSOperands(1).begin()); + } + + RangeT getStartIndices() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicUpdateSliceOpAdaptor : public DynamicUpdateSliceOpGenericAdaptor<::mlir::ValueRange> { +public: + using DynamicUpdateSliceOpGenericAdaptor::DynamicUpdateSliceOpGenericAdaptor; + DynamicUpdateSliceOpAdaptor(DynamicUpdateSliceOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicUpdateSliceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicUpdateSliceOpAdaptor; + template + using GenericAdaptor = DynamicUpdateSliceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.dynamic_update_slice"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getUpdate() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::Operation::operand_range getStartIndices() { + return getODSOperands(2); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getUpdateMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::MutableOperandRange getStartIndicesMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value update, ::mlir::ValueRange start_indices); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value update, ::mlir::ValueRange start_indices); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value update, ::mlir::ValueRange start_indices); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::DynamicUpdateSliceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::EinsumOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class EinsumOpGenericAdaptorBase { +public: + struct Properties { + using einsum_configTy = ::mlir::StringAttr; + einsum_configTy einsum_config; + + auto getEinsumConfig() const { + auto &propStorage = this->einsum_config; + return ::llvm::cast<::mlir::StringAttr>(propStorage); + } + void setEinsumConfig(const ::mlir::StringAttr &propValue) { + this->einsum_config = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.einsum_config == this->einsum_config && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + EinsumOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.einsum", odsAttrs.getContext()); + } + + EinsumOpGenericAdaptorBase(EinsumOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::StringAttr getEinsumConfigAttr() { + auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().einsum_config); + return attr; + } + + ::llvm::StringRef getEinsumConfig(); +}; +} // namespace detail +template +class EinsumOpGenericAdaptor : public detail::EinsumOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::EinsumOpGenericAdaptorBase; +public: + EinsumOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + EinsumOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : EinsumOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + EinsumOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : EinsumOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + EinsumOpGenericAdaptor(RangeT values, const EinsumOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + EinsumOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class EinsumOpAdaptor : public EinsumOpGenericAdaptor<::mlir::ValueRange> { +public: + using EinsumOpGenericAdaptor::EinsumOpGenericAdaptor; + EinsumOpAdaptor(EinsumOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class EinsumOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = EinsumOpAdaptor; + template + using GenericAdaptor = EinsumOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("einsum_config")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getEinsumConfigAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getEinsumConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.einsum"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getEinsumConfigAttr() { + return ::llvm::cast<::mlir::StringAttr>(getProperties().einsum_config); + } + + ::llvm::StringRef getEinsumConfig(); + void setEinsumConfigAttr(::mlir::StringAttr attr) { + getProperties().einsum_config = attr; + } + + void setEinsumConfig(::llvm::StringRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::StringAttr einsum_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::StringAttr einsum_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::llvm::StringRef einsum_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::llvm::StringRef einsum_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::EinsumOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ExpOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ExpOpGenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::stablehlo::ResultAccuracyAttr; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(propStorage); + } + void setResultAccuracy(const ::mlir::stablehlo::ResultAccuracyAttr &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ExpOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.exponential", odsAttrs.getContext()); + } + + ExpOpGenericAdaptorBase(ExpOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr(); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); +}; +} // namespace detail +template +class ExpOpGenericAdaptor : public detail::ExpOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ExpOpGenericAdaptorBase; +public: + ExpOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ExpOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ExpOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ExpOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ExpOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ExpOpGenericAdaptor(RangeT values, const ExpOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ExpOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ExpOpAdaptor : public ExpOpGenericAdaptor<::mlir::ValueRange> { +public: + using ExpOpGenericAdaptor::ExpOpGenericAdaptor; + ExpOpAdaptor(ExpOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ExpOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ExpOpAdaptor; + template + using GenericAdaptor = ExpOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.exponential"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); + void setResultAccuracyAttr(::mlir::stablehlo::ResultAccuracyAttr attr) { + getProperties().result_accuracy = attr; + } + + ::mlir::Attribute removeResultAccuracyAttr() { + auto attr = getProperties().result_accuracy; + getProperties().result_accuracy = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ExpOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::Expm1Op declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class Expm1OpGenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::stablehlo::ResultAccuracyAttr; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(propStorage); + } + void setResultAccuracy(const ::mlir::stablehlo::ResultAccuracyAttr &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + Expm1OpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.exponential_minus_one", odsAttrs.getContext()); + } + + Expm1OpGenericAdaptorBase(Expm1Op op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr(); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); +}; +} // namespace detail +template +class Expm1OpGenericAdaptor : public detail::Expm1OpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::Expm1OpGenericAdaptorBase; +public: + Expm1OpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + Expm1OpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : Expm1OpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + Expm1OpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : Expm1OpGenericAdaptor(values, attrs, Properties{}, {}) {} + + Expm1OpGenericAdaptor(RangeT values, const Expm1OpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + Expm1OpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class Expm1OpAdaptor : public Expm1OpGenericAdaptor<::mlir::ValueRange> { +public: + using Expm1OpGenericAdaptor::Expm1OpGenericAdaptor; + Expm1OpAdaptor(Expm1Op op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class Expm1Op : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = Expm1OpAdaptor; + template + using GenericAdaptor = Expm1OpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.exponential_minus_one"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); + void setResultAccuracyAttr(::mlir::stablehlo::ResultAccuracyAttr attr) { + getProperties().result_accuracy = attr; + } + + ::mlir::Attribute removeResultAccuracyAttr() { + auto attr = getProperties().result_accuracy; + getProperties().result_accuracy = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::Expm1Op) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::FftOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class FftOpGenericAdaptorBase { +public: + struct Properties { + using fft_lengthTy = ::mlir::DenseI64ArrayAttr; + fft_lengthTy fft_length; + + auto getFftLength() const { + auto &propStorage = this->fft_length; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setFftLength(const ::mlir::DenseI64ArrayAttr &propValue) { + this->fft_length = propValue; + } + using fft_typeTy = ::mlir::stablehlo::FftTypeAttr; + fft_typeTy fft_type; + + auto getFftType() const { + auto &propStorage = this->fft_type; + return ::llvm::cast<::mlir::stablehlo::FftTypeAttr>(propStorage); + } + void setFftType(const ::mlir::stablehlo::FftTypeAttr &propValue) { + this->fft_type = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.fft_length == this->fft_length && + rhs.fft_type == this->fft_type && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + FftOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.fft", odsAttrs.getContext()); + } + + FftOpGenericAdaptorBase(FftOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::FftTypeAttr getFftTypeAttr() { + auto attr = ::llvm::cast<::mlir::stablehlo::FftTypeAttr>(getProperties().fft_type); + return attr; + } + + ::mlir::stablehlo::FftType getFftType(); + ::mlir::DenseI64ArrayAttr getFftLengthAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().fft_length); + return attr; + } + + ::llvm::ArrayRef getFftLength(); +}; +} // namespace detail +template +class FftOpGenericAdaptor : public detail::FftOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::FftOpGenericAdaptorBase; +public: + FftOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + FftOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : FftOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + FftOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : FftOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + FftOpGenericAdaptor(RangeT values, const FftOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + FftOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class FftOpAdaptor : public FftOpGenericAdaptor<::mlir::ValueRange> { +public: + using FftOpGenericAdaptor::FftOpGenericAdaptor; + FftOpAdaptor(FftOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class FftOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = FftOpAdaptor; + template + using GenericAdaptor = FftOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("fft_length"), ::llvm::StringRef("fft_type")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getFftLengthAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getFftLengthAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFftTypeAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFftTypeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.fft"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::FftTypeAttr getFftTypeAttr() { + return ::llvm::cast<::mlir::stablehlo::FftTypeAttr>(getProperties().fft_type); + } + + ::mlir::stablehlo::FftType getFftType(); + ::mlir::DenseI64ArrayAttr getFftLengthAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().fft_length); + } + + ::llvm::ArrayRef getFftLength(); + void setFftTypeAttr(::mlir::stablehlo::FftTypeAttr attr) { + getProperties().fft_type = attr; + } + + void setFftType(::mlir::stablehlo::FftType attrValue); + void setFftLengthAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().fft_length = attr; + } + + void setFftLength(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::stablehlo::FftTypeAttr fft_type, ::mlir::DenseI64ArrayAttr fft_length); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::stablehlo::FftTypeAttr fft_type, ::mlir::DenseI64ArrayAttr fft_length); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::stablehlo::FftTypeAttr fft_type, ::mlir::DenseI64ArrayAttr fft_length); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::stablehlo::FftType fft_type, ::llvm::ArrayRef fft_length); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::stablehlo::FftType fft_type, ::llvm::ArrayRef fft_length); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::stablehlo::FftType fft_type, ::llvm::ArrayRef fft_length); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::FftOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::FloorOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class FloorOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + FloorOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.floor", odsAttrs.getContext()); + } + + FloorOpGenericAdaptorBase(FloorOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class FloorOpGenericAdaptor : public detail::FloorOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::FloorOpGenericAdaptorBase; +public: + FloorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + FloorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : FloorOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + FloorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : FloorOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + FloorOpGenericAdaptor(RangeT values, const FloorOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + FloorOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class FloorOpAdaptor : public FloorOpGenericAdaptor<::mlir::ValueRange> { +public: + using FloorOpGenericAdaptor::FloorOpGenericAdaptor; + FloorOpAdaptor(FloorOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class FloorOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = FloorOpAdaptor; + template + using GenericAdaptor = FloorOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.floor"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::FloorOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::GatherOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GatherOpGenericAdaptorBase { +public: + struct Properties { + using dimension_numbersTy = ::mlir::stablehlo::GatherDimensionNumbersAttr; + dimension_numbersTy dimension_numbers; + + auto getDimensionNumbers() const { + auto &propStorage = this->dimension_numbers; + return ::llvm::cast<::mlir::stablehlo::GatherDimensionNumbersAttr>(propStorage); + } + void setDimensionNumbers(const ::mlir::stablehlo::GatherDimensionNumbersAttr &propValue) { + this->dimension_numbers = propValue; + } + using indices_are_sortedTy = ::mlir::BoolAttr; + indices_are_sortedTy indices_are_sorted; + + auto getIndicesAreSorted() const { + auto &propStorage = this->indices_are_sorted; + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(propStorage); + } + void setIndicesAreSorted(const ::mlir::BoolAttr &propValue) { + this->indices_are_sorted = propValue; + } + using slice_sizesTy = ::mlir::DenseI64ArrayAttr; + slice_sizesTy slice_sizes; + + auto getSliceSizes() const { + auto &propStorage = this->slice_sizes; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setSliceSizes(const ::mlir::DenseI64ArrayAttr &propValue) { + this->slice_sizes = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimension_numbers == this->dimension_numbers && + rhs.indices_are_sorted == this->indices_are_sorted && + rhs.slice_sizes == this->slice_sizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GatherOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.gather", odsAttrs.getContext()); + } + + GatherOpGenericAdaptorBase(GatherOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::GatherDimensionNumbersAttr getDimensionNumbersAttr() { + auto attr = ::llvm::cast<::mlir::stablehlo::GatherDimensionNumbersAttr>(getProperties().dimension_numbers); + return attr; + } + + ::mlir::stablehlo::GatherDimensionNumbersAttr getDimensionNumbers(); + ::mlir::DenseI64ArrayAttr getSliceSizesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().slice_sizes); + return attr; + } + + ::llvm::ArrayRef getSliceSizes(); + ::mlir::BoolAttr getIndicesAreSortedAttr(); + bool getIndicesAreSorted(); +}; +} // namespace detail +template +class GatherOpGenericAdaptor : public detail::GatherOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GatherOpGenericAdaptorBase; +public: + GatherOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GatherOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GatherOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + GatherOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : GatherOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + GatherOpGenericAdaptor(RangeT values, const GatherOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + GatherOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getStartIndices() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GatherOpAdaptor : public GatherOpGenericAdaptor<::mlir::ValueRange> { +public: + using GatherOpGenericAdaptor::GatherOpGenericAdaptor; + GatherOpAdaptor(GatherOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class GatherOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = GatherOpAdaptor; + template + using GenericAdaptor = GatherOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimension_numbers"), ::llvm::StringRef("indices_are_sorted"), ::llvm::StringRef("slice_sizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionNumbersAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionNumbersAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIndicesAreSortedAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIndicesAreSortedAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getSliceSizesAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getSliceSizesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.gather"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getStartIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getStartIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::GatherDimensionNumbersAttr getDimensionNumbersAttr() { + return ::llvm::cast<::mlir::stablehlo::GatherDimensionNumbersAttr>(getProperties().dimension_numbers); + } + + ::mlir::stablehlo::GatherDimensionNumbersAttr getDimensionNumbers(); + ::mlir::DenseI64ArrayAttr getSliceSizesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().slice_sizes); + } + + ::llvm::ArrayRef getSliceSizes(); + ::mlir::BoolAttr getIndicesAreSortedAttr() { + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().indices_are_sorted); + } + + bool getIndicesAreSorted(); + void setDimensionNumbersAttr(::mlir::stablehlo::GatherDimensionNumbersAttr attr) { + getProperties().dimension_numbers = attr; + } + + void setSliceSizesAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().slice_sizes = attr; + } + + void setSliceSizes(::llvm::ArrayRef attrValue); + void setIndicesAreSortedAttr(::mlir::BoolAttr attr) { + getProperties().indices_are_sorted = attr; + } + + void setIndicesAreSorted(::std::optional attrValue); + ::mlir::Attribute removeIndicesAreSortedAttr() { + auto attr = getProperties().indices_are_sorted; + getProperties().indices_are_sorted = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, ::mlir::DenseI64ArrayAttr slice_sizes, /*optional*/::mlir::BoolAttr indices_are_sorted = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, ::mlir::DenseI64ArrayAttr slice_sizes, /*optional*/::mlir::BoolAttr indices_are_sorted = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, ::mlir::DenseI64ArrayAttr slice_sizes, /*optional*/::mlir::BoolAttr indices_are_sorted = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, ::llvm::ArrayRef slice_sizes, /*optional*/bool indices_are_sorted = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, ::llvm::ArrayRef slice_sizes, /*optional*/bool indices_are_sorted = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers, ::llvm::ArrayRef slice_sizes, /*optional*/bool indices_are_sorted = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::GatherOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::GetDimensionSizeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GetDimensionSizeOpGenericAdaptorBase { +public: + struct Properties { + using dimensionTy = ::mlir::IntegerAttr; + dimensionTy dimension; + + auto getDimension() const { + auto &propStorage = this->dimension; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setDimension(const ::mlir::IntegerAttr &propValue) { + this->dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimension == this->dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GetDimensionSizeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.get_dimension_size", odsAttrs.getContext()); + } + + GetDimensionSizeOpGenericAdaptorBase(GetDimensionSizeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::IntegerAttr getDimensionAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().dimension); + return attr; + } + + uint64_t getDimension(); +}; +} // namespace detail +template +class GetDimensionSizeOpGenericAdaptor : public detail::GetDimensionSizeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GetDimensionSizeOpGenericAdaptorBase; +public: + GetDimensionSizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GetDimensionSizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GetDimensionSizeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + GetDimensionSizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : GetDimensionSizeOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + GetDimensionSizeOpGenericAdaptor(RangeT values, const GetDimensionSizeOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + GetDimensionSizeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GetDimensionSizeOpAdaptor : public GetDimensionSizeOpGenericAdaptor<::mlir::ValueRange> { +public: + using GetDimensionSizeOpGenericAdaptor::GetDimensionSizeOpGenericAdaptor; + GetDimensionSizeOpAdaptor(GetDimensionSizeOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class GetDimensionSizeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = GetDimensionSizeOpAdaptor; + template + using GenericAdaptor = GetDimensionSizeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.get_dimension_size"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getDimensionAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().dimension); + } + + uint64_t getDimension(); + void setDimensionAttr(::mlir::IntegerAttr attr) { + getProperties().dimension = attr; + } + + void setDimension(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::IntegerAttr dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::IntegerAttr dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::IntegerAttr dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, uint64_t dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, uint64_t dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, uint64_t dimension); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::GetDimensionSizeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::GetTupleElementOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GetTupleElementOpGenericAdaptorBase { +public: + struct Properties { + using indexTy = ::mlir::IntegerAttr; + indexTy index; + + auto getIndex() const { + auto &propStorage = this->index; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setIndex(const ::mlir::IntegerAttr &propValue) { + this->index = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.index == this->index && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GetTupleElementOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.get_tuple_element", odsAttrs.getContext()); + } + + GetTupleElementOpGenericAdaptorBase(GetTupleElementOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::IntegerAttr getIndexAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().index); + return attr; + } + + uint32_t getIndex(); +}; +} // namespace detail +template +class GetTupleElementOpGenericAdaptor : public detail::GetTupleElementOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GetTupleElementOpGenericAdaptorBase; +public: + GetTupleElementOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GetTupleElementOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GetTupleElementOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + GetTupleElementOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : GetTupleElementOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + GetTupleElementOpGenericAdaptor(RangeT values, const GetTupleElementOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + GetTupleElementOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GetTupleElementOpAdaptor : public GetTupleElementOpGenericAdaptor<::mlir::ValueRange> { +public: + using GetTupleElementOpGenericAdaptor::GetTupleElementOpGenericAdaptor; + GetTupleElementOpAdaptor(GetTupleElementOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class GetTupleElementOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GetTupleElementOpAdaptor; + template + using GenericAdaptor = GetTupleElementOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("index")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getIndexAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getIndexAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.get_tuple_element"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getIndexAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().index); + } + + uint32_t getIndex(); + void setIndexAttr(::mlir::IntegerAttr attr) { + getProperties().index = attr; + } + + void setIndex(uint32_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::IntegerAttr index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::IntegerAttr index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::IntegerAttr index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, uint32_t index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, uint32_t index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, uint32_t index); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::GetTupleElementOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::IfOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IfOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + IfOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.if", odsAttrs.getContext()); + } + + IfOpGenericAdaptorBase(IfOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Region &getTrueBranch() { + return *odsRegions[0]; + } + + ::mlir::Region &getFalseBranch() { + return *odsRegions[1]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class IfOpGenericAdaptor : public detail::IfOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IfOpGenericAdaptorBase; +public: + IfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IfOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + IfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : IfOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + IfOpGenericAdaptor(RangeT values, const IfOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + IfOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getPred() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class IfOpAdaptor : public IfOpGenericAdaptor<::mlir::ValueRange> { +public: + using IfOpGenericAdaptor::IfOpGenericAdaptor; + IfOpAdaptor(IfOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class IfOp : public ::mlir::Op::Impl, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::RecursivelySpeculatableImplTrait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = IfOpAdaptor; + template + using GenericAdaptor = IfOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.if"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getPred() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getPredMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Region &getTrueBranch() { + return (*this)->getRegion(0); + } + + ::mlir::Region &getFalseBranch() { + return (*this)->getRegion(1); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::Value pred); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value pred); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::IfOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ImagOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ImagOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ImagOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.imag", odsAttrs.getContext()); + } + + ImagOpGenericAdaptorBase(ImagOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ImagOpGenericAdaptor : public detail::ImagOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ImagOpGenericAdaptorBase; +public: + ImagOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ImagOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ImagOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ImagOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ImagOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ImagOpGenericAdaptor(RangeT values, const ImagOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ImagOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ImagOpAdaptor : public ImagOpGenericAdaptor<::mlir::ValueRange> { +public: + using ImagOpGenericAdaptor::ImagOpGenericAdaptor; + ImagOpAdaptor(ImagOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ImagOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ImagOpAdaptor; + template + using GenericAdaptor = ImagOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.imag"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ImagOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::InfeedOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class InfeedOpGenericAdaptorBase { +public: + struct Properties { + using infeed_configTy = ::mlir::StringAttr; + infeed_configTy infeed_config; + + auto getInfeedConfig() const { + auto &propStorage = this->infeed_config; + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(propStorage); + } + void setInfeedConfig(const ::mlir::StringAttr &propValue) { + this->infeed_config = propValue; + } + using layoutTy = ::mlir::ArrayAttr; + layoutTy layout; + + auto getLayout() const { + auto &propStorage = this->layout; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setLayout(const ::mlir::ArrayAttr &propValue) { + this->layout = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.infeed_config == this->infeed_config && + rhs.layout == this->layout && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + InfeedOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.infeed", odsAttrs.getContext()); + } + + InfeedOpGenericAdaptorBase(InfeedOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::StringAttr getInfeedConfigAttr(); + ::llvm::StringRef getInfeedConfig(); + ::mlir::ArrayAttr getLayoutAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().layout); + return attr; + } + + ::std::optional< ::mlir::ArrayAttr > getLayout(); +}; +} // namespace detail +template +class InfeedOpGenericAdaptor : public detail::InfeedOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::InfeedOpGenericAdaptorBase; +public: + InfeedOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + InfeedOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : InfeedOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + InfeedOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : InfeedOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + InfeedOpGenericAdaptor(RangeT values, const InfeedOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + InfeedOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getToken() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class InfeedOpAdaptor : public InfeedOpGenericAdaptor<::mlir::ValueRange> { +public: + using InfeedOpGenericAdaptor::InfeedOpGenericAdaptor; + InfeedOpAdaptor(InfeedOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class InfeedOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = InfeedOpAdaptor; + template + using GenericAdaptor = InfeedOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("infeed_config"), ::llvm::StringRef("layout")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getInfeedConfigAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getInfeedConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getLayoutAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getLayoutAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.infeed"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getToken() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getTokenMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getInfeedConfigAttr() { + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().infeed_config); + } + + ::llvm::StringRef getInfeedConfig(); + ::mlir::ArrayAttr getLayoutAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().layout); + } + + ::std::optional< ::mlir::ArrayAttr > getLayout(); + void setInfeedConfigAttr(::mlir::StringAttr attr) { + getProperties().infeed_config = attr; + } + + void setInfeedConfig(::llvm::StringRef attrValue); + void setLayoutAttr(::mlir::ArrayAttr attr) { + getProperties().layout = attr; + } + + ::mlir::Attribute removeLayoutAttr() { + auto attr = getProperties().layout; + getProperties().layout = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::Value token, ::mlir::StringAttr infeed_config, /*optional*/::mlir::ArrayAttr layout); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::Value token, ::llvm::StringRef infeed_config, /*optional*/::mlir::ArrayAttr layout); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::InfeedOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::IotaOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IotaOpGenericAdaptorBase { +public: + struct Properties { + using iota_dimensionTy = ::mlir::IntegerAttr; + iota_dimensionTy iota_dimension; + + auto getIotaDimension() const { + auto &propStorage = this->iota_dimension; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setIotaDimension(const ::mlir::IntegerAttr &propValue) { + this->iota_dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.iota_dimension == this->iota_dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + IotaOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.iota", odsAttrs.getContext()); + } + + IotaOpGenericAdaptorBase(IotaOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::IntegerAttr getIotaDimensionAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().iota_dimension); + return attr; + } + + uint64_t getIotaDimension(); +}; +} // namespace detail +template +class IotaOpGenericAdaptor : public detail::IotaOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IotaOpGenericAdaptorBase; +public: + IotaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IotaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IotaOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + IotaOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : IotaOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + IotaOpGenericAdaptor(RangeT values, const IotaOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + IotaOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class IotaOpAdaptor : public IotaOpGenericAdaptor<::mlir::ValueRange> { +public: + using IotaOpGenericAdaptor::IotaOpGenericAdaptor; + IotaOpAdaptor(IotaOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class IotaOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = IotaOpAdaptor; + template + using GenericAdaptor = IotaOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("iota_dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getIotaDimensionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getIotaDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.iota"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getIotaDimensionAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().iota_dimension); + } + + uint64_t getIotaDimension(); + void setIotaDimensionAttr(::mlir::IntegerAttr attr) { + getProperties().iota_dimension = attr; + } + + void setIotaDimension(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::IntegerAttr iota_dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr iota_dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, uint64_t iota_dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, uint64_t iota_dimension); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::IotaOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::IsFiniteOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IsFiniteOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + IsFiniteOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.is_finite", odsAttrs.getContext()); + } + + IsFiniteOpGenericAdaptorBase(IsFiniteOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class IsFiniteOpGenericAdaptor : public detail::IsFiniteOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IsFiniteOpGenericAdaptorBase; +public: + IsFiniteOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IsFiniteOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IsFiniteOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + IsFiniteOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : IsFiniteOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + IsFiniteOpGenericAdaptor(RangeT values, const IsFiniteOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + IsFiniteOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getX() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class IsFiniteOpAdaptor : public IsFiniteOpGenericAdaptor<::mlir::ValueRange> { +public: + using IsFiniteOpGenericAdaptor::IsFiniteOpGenericAdaptor; + IsFiniteOpAdaptor(IsFiniteOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class IsFiniteOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = IsFiniteOpAdaptor; + template + using GenericAdaptor = IsFiniteOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.is_finite"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getX() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getXMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getY() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type y, ::mlir::Value x); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::IsFiniteOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::Log1pOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class Log1pOpGenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::stablehlo::ResultAccuracyAttr; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(propStorage); + } + void setResultAccuracy(const ::mlir::stablehlo::ResultAccuracyAttr &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + Log1pOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.log_plus_one", odsAttrs.getContext()); + } + + Log1pOpGenericAdaptorBase(Log1pOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr(); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); +}; +} // namespace detail +template +class Log1pOpGenericAdaptor : public detail::Log1pOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::Log1pOpGenericAdaptorBase; +public: + Log1pOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + Log1pOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : Log1pOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + Log1pOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : Log1pOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + Log1pOpGenericAdaptor(RangeT values, const Log1pOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + Log1pOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class Log1pOpAdaptor : public Log1pOpGenericAdaptor<::mlir::ValueRange> { +public: + using Log1pOpGenericAdaptor::Log1pOpGenericAdaptor; + Log1pOpAdaptor(Log1pOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class Log1pOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = Log1pOpAdaptor; + template + using GenericAdaptor = Log1pOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.log_plus_one"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); + void setResultAccuracyAttr(::mlir::stablehlo::ResultAccuracyAttr attr) { + getProperties().result_accuracy = attr; + } + + ::mlir::Attribute removeResultAccuracyAttr() { + auto attr = getProperties().result_accuracy; + getProperties().result_accuracy = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::Log1pOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::LogOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class LogOpGenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::stablehlo::ResultAccuracyAttr; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(propStorage); + } + void setResultAccuracy(const ::mlir::stablehlo::ResultAccuracyAttr &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + LogOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.log", odsAttrs.getContext()); + } + + LogOpGenericAdaptorBase(LogOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr(); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); +}; +} // namespace detail +template +class LogOpGenericAdaptor : public detail::LogOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::LogOpGenericAdaptorBase; +public: + LogOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + LogOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : LogOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + LogOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : LogOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + LogOpGenericAdaptor(RangeT values, const LogOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + LogOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class LogOpAdaptor : public LogOpGenericAdaptor<::mlir::ValueRange> { +public: + using LogOpGenericAdaptor::LogOpGenericAdaptor; + LogOpAdaptor(LogOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class LogOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = LogOpAdaptor; + template + using GenericAdaptor = LogOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.log"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); + void setResultAccuracyAttr(::mlir::stablehlo::ResultAccuracyAttr attr) { + getProperties().result_accuracy = attr; + } + + ::mlir::Attribute removeResultAccuracyAttr() { + auto attr = getProperties().result_accuracy; + getProperties().result_accuracy = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::LogOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::LogisticOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class LogisticOpGenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::stablehlo::ResultAccuracyAttr; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(propStorage); + } + void setResultAccuracy(const ::mlir::stablehlo::ResultAccuracyAttr &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + LogisticOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.logistic", odsAttrs.getContext()); + } + + LogisticOpGenericAdaptorBase(LogisticOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr(); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); +}; +} // namespace detail +template +class LogisticOpGenericAdaptor : public detail::LogisticOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::LogisticOpGenericAdaptorBase; +public: + LogisticOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + LogisticOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : LogisticOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + LogisticOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : LogisticOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + LogisticOpGenericAdaptor(RangeT values, const LogisticOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + LogisticOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class LogisticOpAdaptor : public LogisticOpGenericAdaptor<::mlir::ValueRange> { +public: + using LogisticOpGenericAdaptor::LogisticOpGenericAdaptor; + LogisticOpAdaptor(LogisticOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class LogisticOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = LogisticOpAdaptor; + template + using GenericAdaptor = LogisticOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.logistic"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); + void setResultAccuracyAttr(::mlir::stablehlo::ResultAccuracyAttr attr) { + getProperties().result_accuracy = attr; + } + + ::mlir::Attribute removeResultAccuracyAttr() { + auto attr = getProperties().result_accuracy; + getProperties().result_accuracy = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::LogisticOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::MapOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MapOpGenericAdaptorBase { +public: + struct Properties { + using dimensionsTy = ::mlir::DenseI64ArrayAttr; + dimensionsTy dimensions; + + auto getDimensions() const { + auto &propStorage = this->dimensions; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimensions == this->dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MapOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.map", odsAttrs.getContext()); + } + + MapOpGenericAdaptorBase(MapOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().dimensions); + return attr; + } + + ::llvm::ArrayRef getDimensions(); + ::mlir::Region &getComputation() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class MapOpGenericAdaptor : public detail::MapOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MapOpGenericAdaptorBase; +public: + MapOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MapOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MapOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + MapOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : MapOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + MapOpGenericAdaptor(RangeT values, const MapOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + MapOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MapOpAdaptor : public MapOpGenericAdaptor<::mlir::ValueRange> { +public: + using MapOpGenericAdaptor::MapOpGenericAdaptor; + MapOpAdaptor(MapOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class MapOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::RecursivelySpeculatableIfAllInputsStaticImplTrait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = MapOpAdaptor; + template + using GenericAdaptor = MapOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.map"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Region &getComputation() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getDimensionsAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().dimensions); + } + + ::llvm::ArrayRef getDimensions(); + void setDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().dimensions = attr; + } + + void setDimensions(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::mlir::DenseI64ArrayAttr dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::DenseI64ArrayAttr dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::DenseI64ArrayAttr dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::llvm::ArrayRef dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::llvm::ArrayRef dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::llvm::ArrayRef dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::MapOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::MaxOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaxOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MaxOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.maximum", odsAttrs.getContext()); + } + + MaxOpGenericAdaptorBase(MaxOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class MaxOpGenericAdaptor : public detail::MaxOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaxOpGenericAdaptorBase; +public: + MaxOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaxOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaxOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + MaxOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : MaxOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + MaxOpGenericAdaptor(RangeT values, const MaxOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + MaxOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaxOpAdaptor : public MaxOpGenericAdaptor<::mlir::ValueRange> { +public: + using MaxOpGenericAdaptor::MaxOpGenericAdaptor; + MaxOpAdaptor(MaxOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class MaxOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::hlo::OpTrait::IsCommutative, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaxOpAdaptor; + template + using GenericAdaptor = MaxOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.maximum"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::MaxOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::MinOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MinOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MinOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.minimum", odsAttrs.getContext()); + } + + MinOpGenericAdaptorBase(MinOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class MinOpGenericAdaptor : public detail::MinOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MinOpGenericAdaptorBase; +public: + MinOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MinOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MinOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + MinOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : MinOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + MinOpGenericAdaptor(RangeT values, const MinOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + MinOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MinOpAdaptor : public MinOpGenericAdaptor<::mlir::ValueRange> { +public: + using MinOpGenericAdaptor::MinOpGenericAdaptor; + MinOpAdaptor(MinOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class MinOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::hlo::OpTrait::IsCommutative, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MinOpAdaptor; + template + using GenericAdaptor = MinOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.minimum"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::MinOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::MulOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MulOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MulOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.multiply", odsAttrs.getContext()); + } + + MulOpGenericAdaptorBase(MulOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class MulOpGenericAdaptor : public detail::MulOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MulOpGenericAdaptorBase; +public: + MulOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MulOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MulOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + MulOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : MulOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + MulOpGenericAdaptor(RangeT values, const MulOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + MulOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MulOpAdaptor : public MulOpGenericAdaptor<::mlir::ValueRange> { +public: + using MulOpGenericAdaptor::MulOpGenericAdaptor; + MulOpAdaptor(MulOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class MulOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::hlo::OpTrait::IsCommutative, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MulOpAdaptor; + template + using GenericAdaptor = MulOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.multiply"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::MulOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::NegOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class NegOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + NegOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.negate", odsAttrs.getContext()); + } + + NegOpGenericAdaptorBase(NegOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class NegOpGenericAdaptor : public detail::NegOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::NegOpGenericAdaptorBase; +public: + NegOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + NegOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : NegOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + NegOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : NegOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + NegOpGenericAdaptor(RangeT values, const NegOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + NegOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class NegOpAdaptor : public NegOpGenericAdaptor<::mlir::ValueRange> { +public: + using NegOpGenericAdaptor::NegOpGenericAdaptor; + NegOpAdaptor(NegOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class NegOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = NegOpAdaptor; + template + using GenericAdaptor = NegOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.negate"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::NegOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::NotOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class NotOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + NotOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.not", odsAttrs.getContext()); + } + + NotOpGenericAdaptorBase(NotOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class NotOpGenericAdaptor : public detail::NotOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::NotOpGenericAdaptorBase; +public: + NotOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + NotOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : NotOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + NotOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : NotOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + NotOpGenericAdaptor(RangeT values, const NotOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + NotOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class NotOpAdaptor : public NotOpGenericAdaptor<::mlir::ValueRange> { +public: + using NotOpGenericAdaptor::NotOpGenericAdaptor; + NotOpAdaptor(NotOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class NotOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = NotOpAdaptor; + template + using GenericAdaptor = NotOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.not"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::NotOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::OptimizationBarrierOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class OptimizationBarrierOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + OptimizationBarrierOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.optimization_barrier", odsAttrs.getContext()); + } + + OptimizationBarrierOpGenericAdaptorBase(OptimizationBarrierOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class OptimizationBarrierOpGenericAdaptor : public detail::OptimizationBarrierOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::OptimizationBarrierOpGenericAdaptorBase; +public: + OptimizationBarrierOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + OptimizationBarrierOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : OptimizationBarrierOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + OptimizationBarrierOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : OptimizationBarrierOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + OptimizationBarrierOpGenericAdaptor(RangeT values, const OptimizationBarrierOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + OptimizationBarrierOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperand() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class OptimizationBarrierOpAdaptor : public OptimizationBarrierOpGenericAdaptor<::mlir::ValueRange> { +public: + using OptimizationBarrierOpGenericAdaptor::OptimizationBarrierOpGenericAdaptor; + OptimizationBarrierOpAdaptor(OptimizationBarrierOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class OptimizationBarrierOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = OptimizationBarrierOpAdaptor; + template + using GenericAdaptor = OptimizationBarrierOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.optimization_barrier"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getOperand() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getOperandMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResult() { + return getODSResults(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::OptimizationBarrierOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::OrOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class OrOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + OrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.or", odsAttrs.getContext()); + } + + OrOpGenericAdaptorBase(OrOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class OrOpGenericAdaptor : public detail::OrOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::OrOpGenericAdaptorBase; +public: + OrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + OrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : OrOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + OrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : OrOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + OrOpGenericAdaptor(RangeT values, const OrOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + OrOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class OrOpAdaptor : public OrOpGenericAdaptor<::mlir::ValueRange> { +public: + using OrOpGenericAdaptor::OrOpGenericAdaptor; + OrOpAdaptor(OrOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class OrOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::hlo::OpTrait::IsCommutative, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise> { +public: + using Op::Op; + using Op::print; + using Adaptor = OrOpAdaptor; + template + using GenericAdaptor = OrOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.or"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::OrOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::OutfeedOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class OutfeedOpGenericAdaptorBase { +public: + struct Properties { + using outfeed_configTy = ::mlir::StringAttr; + outfeed_configTy outfeed_config; + + auto getOutfeedConfig() const { + auto &propStorage = this->outfeed_config; + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(propStorage); + } + void setOutfeedConfig(const ::mlir::StringAttr &propValue) { + this->outfeed_config = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.outfeed_config == this->outfeed_config && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + OutfeedOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.outfeed", odsAttrs.getContext()); + } + + OutfeedOpGenericAdaptorBase(OutfeedOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::StringAttr getOutfeedConfigAttr(); + ::llvm::StringRef getOutfeedConfig(); +}; +} // namespace detail +template +class OutfeedOpGenericAdaptor : public detail::OutfeedOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::OutfeedOpGenericAdaptorBase; +public: + OutfeedOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + OutfeedOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : OutfeedOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + OutfeedOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : OutfeedOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + OutfeedOpGenericAdaptor(RangeT values, const OutfeedOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + OutfeedOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + ValueT getToken() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class OutfeedOpAdaptor : public OutfeedOpGenericAdaptor<::mlir::ValueRange> { +public: + using OutfeedOpGenericAdaptor::OutfeedOpGenericAdaptor; + OutfeedOpAdaptor(OutfeedOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class OutfeedOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = OutfeedOpAdaptor; + template + using GenericAdaptor = OutfeedOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("outfeed_config")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getOutfeedConfigAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getOutfeedConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.outfeed"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::TypedValue<::mlir::Type> getToken() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::MutableOperandRange getInputsMutable(); + ::mlir::OpOperand &getTokenMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getOutfeedConfigAttr() { + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().outfeed_config); + } + + ::llvm::StringRef getOutfeedConfig(); + void setOutfeedConfigAttr(::mlir::StringAttr attr) { + getProperties().outfeed_config = attr; + } + + void setOutfeedConfig(::llvm::StringRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::StringAttr outfeed_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::StringAttr outfeed_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::StringAttr outfeed_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::mlir::Value token, ::llvm::StringRef outfeed_config = ""); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::Value token, ::llvm::StringRef outfeed_config = ""); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Value token, ::llvm::StringRef outfeed_config = ""); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::OutfeedOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::PadOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PadOpGenericAdaptorBase { +public: + struct Properties { + using edge_padding_highTy = ::mlir::DenseI64ArrayAttr; + edge_padding_highTy edge_padding_high; + + auto getEdgePaddingHigh() const { + auto &propStorage = this->edge_padding_high; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setEdgePaddingHigh(const ::mlir::DenseI64ArrayAttr &propValue) { + this->edge_padding_high = propValue; + } + using edge_padding_lowTy = ::mlir::DenseI64ArrayAttr; + edge_padding_lowTy edge_padding_low; + + auto getEdgePaddingLow() const { + auto &propStorage = this->edge_padding_low; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setEdgePaddingLow(const ::mlir::DenseI64ArrayAttr &propValue) { + this->edge_padding_low = propValue; + } + using interior_paddingTy = ::mlir::DenseI64ArrayAttr; + interior_paddingTy interior_padding; + + auto getInteriorPadding() const { + auto &propStorage = this->interior_padding; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setInteriorPadding(const ::mlir::DenseI64ArrayAttr &propValue) { + this->interior_padding = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.edge_padding_high == this->edge_padding_high && + rhs.edge_padding_low == this->edge_padding_low && + rhs.interior_padding == this->interior_padding && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.pad", odsAttrs.getContext()); + } + + PadOpGenericAdaptorBase(PadOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getEdgePaddingLowAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().edge_padding_low); + return attr; + } + + ::llvm::ArrayRef getEdgePaddingLow(); + ::mlir::DenseI64ArrayAttr getEdgePaddingHighAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().edge_padding_high); + return attr; + } + + ::llvm::ArrayRef getEdgePaddingHigh(); + ::mlir::DenseI64ArrayAttr getInteriorPaddingAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().interior_padding); + return attr; + } + + ::llvm::ArrayRef getInteriorPadding(); +}; +} // namespace detail +template +class PadOpGenericAdaptor : public detail::PadOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PadOpGenericAdaptorBase; +public: + PadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PadOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + PadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : PadOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + PadOpGenericAdaptor(RangeT values, const PadOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + PadOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getPaddingValue() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PadOpAdaptor : public PadOpGenericAdaptor<::mlir::ValueRange> { +public: + using PadOpGenericAdaptor::PadOpGenericAdaptor; + PadOpAdaptor(PadOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class PadOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = PadOpAdaptor; + template + using GenericAdaptor = PadOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("edge_padding_high"), ::llvm::StringRef("edge_padding_low"), ::llvm::StringRef("interior_padding")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getEdgePaddingHighAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getEdgePaddingHighAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getEdgePaddingLowAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getEdgePaddingLowAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getInteriorPaddingAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getInteriorPaddingAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.pad"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getPaddingValue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getPaddingValueMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getEdgePaddingLowAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().edge_padding_low); + } + + ::llvm::ArrayRef getEdgePaddingLow(); + ::mlir::DenseI64ArrayAttr getEdgePaddingHighAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().edge_padding_high); + } + + ::llvm::ArrayRef getEdgePaddingHigh(); + ::mlir::DenseI64ArrayAttr getInteriorPaddingAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().interior_padding); + } + + ::llvm::ArrayRef getInteriorPadding(); + void setEdgePaddingLowAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().edge_padding_low = attr; + } + + void setEdgePaddingLow(::llvm::ArrayRef attrValue); + void setEdgePaddingHighAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().edge_padding_high = attr; + } + + void setEdgePaddingHigh(::llvm::ArrayRef attrValue); + void setInteriorPaddingAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().interior_padding = attr; + } + + void setInteriorPadding(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::DenseI64ArrayAttr edge_padding_low, ::mlir::DenseI64ArrayAttr edge_padding_high, ::mlir::DenseI64ArrayAttr interior_padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::DenseI64ArrayAttr edge_padding_low, ::mlir::DenseI64ArrayAttr edge_padding_high, ::mlir::DenseI64ArrayAttr interior_padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::DenseI64ArrayAttr edge_padding_low, ::mlir::DenseI64ArrayAttr edge_padding_high, ::mlir::DenseI64ArrayAttr interior_padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value padding_value, ::llvm::ArrayRef edge_padding_low, ::llvm::ArrayRef edge_padding_high, ::llvm::ArrayRef interior_padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value padding_value, ::llvm::ArrayRef edge_padding_low, ::llvm::ArrayRef edge_padding_high, ::llvm::ArrayRef interior_padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value padding_value, ::llvm::ArrayRef edge_padding_low, ::llvm::ArrayRef edge_padding_high, ::llvm::ArrayRef interior_padding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::PadOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::PartitionIdOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PartitionIdOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PartitionIdOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.partition_id", odsAttrs.getContext()); + } + + PartitionIdOpGenericAdaptorBase(PartitionIdOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class PartitionIdOpGenericAdaptor : public detail::PartitionIdOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PartitionIdOpGenericAdaptorBase; +public: + PartitionIdOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PartitionIdOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PartitionIdOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + PartitionIdOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : PartitionIdOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + PartitionIdOpGenericAdaptor(RangeT values, const PartitionIdOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + PartitionIdOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PartitionIdOpAdaptor : public PartitionIdOpGenericAdaptor<::mlir::ValueRange> { +public: + using PartitionIdOpGenericAdaptor::PartitionIdOpGenericAdaptor; + PartitionIdOpAdaptor(PartitionIdOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class PartitionIdOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = PartitionIdOpAdaptor; + template + using GenericAdaptor = PartitionIdOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.partition_id"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::PartitionIdOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::PopulationCountOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PopulationCountOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PopulationCountOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.popcnt", odsAttrs.getContext()); + } + + PopulationCountOpGenericAdaptorBase(PopulationCountOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class PopulationCountOpGenericAdaptor : public detail::PopulationCountOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PopulationCountOpGenericAdaptorBase; +public: + PopulationCountOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PopulationCountOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PopulationCountOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + PopulationCountOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : PopulationCountOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + PopulationCountOpGenericAdaptor(RangeT values, const PopulationCountOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + PopulationCountOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PopulationCountOpAdaptor : public PopulationCountOpGenericAdaptor<::mlir::ValueRange> { +public: + using PopulationCountOpGenericAdaptor::PopulationCountOpGenericAdaptor; + PopulationCountOpAdaptor(PopulationCountOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class PopulationCountOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = PopulationCountOpAdaptor; + template + using GenericAdaptor = PopulationCountOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.popcnt"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::PopulationCountOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::PowOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PowOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PowOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.power", odsAttrs.getContext()); + } + + PowOpGenericAdaptorBase(PowOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class PowOpGenericAdaptor : public detail::PowOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PowOpGenericAdaptorBase; +public: + PowOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PowOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PowOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + PowOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : PowOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + PowOpGenericAdaptor(RangeT values, const PowOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + PowOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PowOpAdaptor : public PowOpGenericAdaptor<::mlir::ValueRange> { +public: + using PowOpGenericAdaptor::PowOpGenericAdaptor; + PowOpAdaptor(PowOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class PowOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = PowOpAdaptor; + template + using GenericAdaptor = PowOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.power"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::PowOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RealDynamicSliceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RealDynamicSliceOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RealDynamicSliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.real_dynamic_slice", odsAttrs.getContext()); + } + + RealDynamicSliceOpGenericAdaptorBase(RealDynamicSliceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class RealDynamicSliceOpGenericAdaptor : public detail::RealDynamicSliceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RealDynamicSliceOpGenericAdaptorBase; +public: + RealDynamicSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RealDynamicSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RealDynamicSliceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RealDynamicSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RealDynamicSliceOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + RealDynamicSliceOpGenericAdaptor(RangeT values, const RealDynamicSliceOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RealDynamicSliceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getStartIndices() { + return (*getODSOperands(1).begin()); + } + + ValueT getLimitIndices() { + return (*getODSOperands(2).begin()); + } + + ValueT getStrides() { + return (*getODSOperands(3).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RealDynamicSliceOpAdaptor : public RealDynamicSliceOpGenericAdaptor<::mlir::ValueRange> { +public: + using RealDynamicSliceOpGenericAdaptor::RealDynamicSliceOpGenericAdaptor; + RealDynamicSliceOpAdaptor(RealDynamicSliceOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RealDynamicSliceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<4>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RealDynamicSliceOpAdaptor; + template + using GenericAdaptor = RealDynamicSliceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.real_dynamic_slice"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getStartIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLimitIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(2).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getStrides() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(3).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getStartIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getLimitIndicesMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getStridesMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value limit_indices, ::mlir::Value strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value limit_indices, ::mlir::Value strides); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RealDynamicSliceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RealOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RealOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RealOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.real", odsAttrs.getContext()); + } + + RealOpGenericAdaptorBase(RealOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class RealOpGenericAdaptor : public detail::RealOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RealOpGenericAdaptorBase; +public: + RealOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RealOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RealOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RealOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RealOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + RealOpGenericAdaptor(RangeT values, const RealOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RealOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RealOpAdaptor : public RealOpGenericAdaptor<::mlir::ValueRange> { +public: + using RealOpGenericAdaptor::RealOpGenericAdaptor; + RealOpAdaptor(RealOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RealOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RealOpAdaptor; + template + using GenericAdaptor = RealOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.real"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RealOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RecvOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RecvOpGenericAdaptorBase { +public: + struct Properties { + using channel_handleTy = ::mlir::stablehlo::ChannelHandleAttr; + channel_handleTy channel_handle; + + auto getChannelHandle() const { + auto &propStorage = this->channel_handle; + return ::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(propStorage); + } + void setChannelHandle(const ::mlir::stablehlo::ChannelHandleAttr &propValue) { + this->channel_handle = propValue; + } + using is_host_transferTy = ::mlir::BoolAttr; + is_host_transferTy is_host_transfer; + + auto getIsHostTransfer() const { + auto &propStorage = this->is_host_transfer; + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(propStorage); + } + void setIsHostTransfer(const ::mlir::BoolAttr &propValue) { + this->is_host_transfer = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_handle == this->channel_handle && + rhs.is_host_transfer == this->is_host_transfer && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RecvOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.recv", odsAttrs.getContext()); + } + + RecvOpGenericAdaptorBase(RecvOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + auto attr = ::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + return attr; + } + + ::mlir::stablehlo::ChannelHandleAttr getChannelHandle(); + ::mlir::BoolAttr getIsHostTransferAttr(); + bool getIsHostTransfer(); +}; +} // namespace detail +template +class RecvOpGenericAdaptor : public detail::RecvOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RecvOpGenericAdaptorBase; +public: + RecvOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RecvOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RecvOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RecvOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RecvOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + RecvOpGenericAdaptor(RangeT values, const RecvOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RecvOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getToken() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RecvOpAdaptor : public RecvOpGenericAdaptor<::mlir::ValueRange> { +public: + using RecvOpGenericAdaptor::RecvOpGenericAdaptor; + RecvOpAdaptor(RecvOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RecvOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = RecvOpAdaptor; + template + using GenericAdaptor = RecvOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_handle"), ::llvm::StringRef("is_host_transfer")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelHandleAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelHandleAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIsHostTransferAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIsHostTransferAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.recv"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getToken() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getTokenMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + return ::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + } + + ::mlir::stablehlo::ChannelHandleAttr getChannelHandle(); + ::mlir::BoolAttr getIsHostTransferAttr() { + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().is_host_transfer); + } + + bool getIsHostTransfer(); + void setChannelHandleAttr(::mlir::stablehlo::ChannelHandleAttr attr) { + getProperties().channel_handle = attr; + } + + void setIsHostTransferAttr(::mlir::BoolAttr attr) { + getProperties().is_host_transfer = attr; + } + + void setIsHostTransfer(::std::optional attrValue); + ::mlir::Attribute removeIsHostTransferAttr() { + auto attr = getProperties().is_host_transfer; + getProperties().is_host_transfer = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::BoolAttr is_host_transfer); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool is_host_transfer = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RecvOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReduceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReduceOpGenericAdaptorBase { +public: + struct Properties { + using dimensionsTy = ::mlir::DenseI64ArrayAttr; + dimensionsTy dimensions; + + auto getDimensions() const { + auto &propStorage = this->dimensions; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimensions == this->dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReduceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.reduce", odsAttrs.getContext()); + } + + ReduceOpGenericAdaptorBase(ReduceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().dimensions); + return attr; + } + + ::llvm::ArrayRef getDimensions(); + ::mlir::Region &getBody() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class ReduceOpGenericAdaptor : public detail::ReduceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReduceOpGenericAdaptorBase; +public: + ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReduceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReduceOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ReduceOpGenericAdaptor(RangeT values, const ReduceOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReduceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getInitValues() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReduceOpAdaptor : public ReduceOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReduceOpGenericAdaptor::ReduceOpGenericAdaptor; + ReduceOpAdaptor(ReduceOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReduceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::RecursivelySpeculatableIfAllInputsStaticImplTrait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReduceOpAdaptor; + template + using GenericAdaptor = ReduceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.reduce"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::Operation::operand_range getInitValues() { + return getODSOperands(1); + } + + ::mlir::MutableOperandRange getInputsMutable(); + ::mlir::MutableOperandRange getInitValuesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Region &getBody() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getDimensionsAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().dimensions); + } + + ::llvm::ArrayRef getDimensions(); + void setDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().dimensions = attr; + } + + void setDimensions(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ValueRange inputs, ValueRange init_values, DenseI64ArrayAttr dimensions, TypeRange element_types); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::mlir::DenseI64ArrayAttr dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::mlir::DenseI64ArrayAttr dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::llvm::ArrayRef dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::llvm::ArrayRef dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReduceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReducePrecisionOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReducePrecisionOpGenericAdaptorBase { +public: + struct Properties { + using exponent_bitsTy = ::mlir::IntegerAttr; + exponent_bitsTy exponent_bits; + + auto getExponentBits() const { + auto &propStorage = this->exponent_bits; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setExponentBits(const ::mlir::IntegerAttr &propValue) { + this->exponent_bits = propValue; + } + using mantissa_bitsTy = ::mlir::IntegerAttr; + mantissa_bitsTy mantissa_bits; + + auto getMantissaBits() const { + auto &propStorage = this->mantissa_bits; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setMantissaBits(const ::mlir::IntegerAttr &propValue) { + this->mantissa_bits = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.exponent_bits == this->exponent_bits && + rhs.mantissa_bits == this->mantissa_bits && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReducePrecisionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.reduce_precision", odsAttrs.getContext()); + } + + ReducePrecisionOpGenericAdaptorBase(ReducePrecisionOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::IntegerAttr getExponentBitsAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().exponent_bits); + return attr; + } + + uint32_t getExponentBits(); + ::mlir::IntegerAttr getMantissaBitsAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().mantissa_bits); + return attr; + } + + uint32_t getMantissaBits(); +}; +} // namespace detail +template +class ReducePrecisionOpGenericAdaptor : public detail::ReducePrecisionOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReducePrecisionOpGenericAdaptorBase; +public: + ReducePrecisionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReducePrecisionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReducePrecisionOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReducePrecisionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReducePrecisionOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ReducePrecisionOpGenericAdaptor(RangeT values, const ReducePrecisionOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReducePrecisionOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReducePrecisionOpAdaptor : public ReducePrecisionOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReducePrecisionOpGenericAdaptor::ReducePrecisionOpGenericAdaptor; + ReducePrecisionOpAdaptor(ReducePrecisionOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReducePrecisionOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReducePrecisionOpAdaptor; + template + using GenericAdaptor = ReducePrecisionOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("exponent_bits"), ::llvm::StringRef("mantissa_bits")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getExponentBitsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getExponentBitsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getMantissaBitsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getMantissaBitsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.reduce_precision"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getExponentBitsAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().exponent_bits); + } + + uint32_t getExponentBits(); + ::mlir::IntegerAttr getMantissaBitsAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().mantissa_bits); + } + + uint32_t getMantissaBits(); + void setExponentBitsAttr(::mlir::IntegerAttr attr) { + getProperties().exponent_bits = attr; + } + + void setExponentBits(uint32_t attrValue); + void setMantissaBitsAttr(::mlir::IntegerAttr attr) { + getProperties().mantissa_bits = attr; + } + + void setMantissaBits(uint32_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value operand, ::mlir::IntegerAttr exponent_bits, ::mlir::IntegerAttr mantissa_bits); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::IntegerAttr exponent_bits, ::mlir::IntegerAttr mantissa_bits); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::IntegerAttr exponent_bits, ::mlir::IntegerAttr mantissa_bits); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value operand, uint32_t exponent_bits, uint32_t mantissa_bits); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, uint32_t exponent_bits, uint32_t mantissa_bits); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, uint32_t exponent_bits, uint32_t mantissa_bits); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReducePrecisionOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReduceScatterOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReduceScatterOpGenericAdaptorBase { +public: + struct Properties { + using channel_handleTy = ::mlir::stablehlo::ChannelHandleAttr; + channel_handleTy channel_handle; + + auto getChannelHandle() const { + auto &propStorage = this->channel_handle; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(propStorage); + } + void setChannelHandle(const ::mlir::stablehlo::ChannelHandleAttr &propValue) { + this->channel_handle = propValue; + } + using replica_groupsTy = ::mlir::DenseIntElementsAttr; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::DenseIntElementsAttr>(propStorage); + } + void setReplicaGroups(const ::mlir::DenseIntElementsAttr &propValue) { + this->replica_groups = propValue; + } + using scatter_dimensionTy = ::mlir::IntegerAttr; + scatter_dimensionTy scatter_dimension; + + auto getScatterDimension() const { + auto &propStorage = this->scatter_dimension; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setScatterDimension(const ::mlir::IntegerAttr &propValue) { + this->scatter_dimension = propValue; + } + using use_global_device_idsTy = ::mlir::UnitAttr; + use_global_device_idsTy use_global_device_ids; + + auto getUseGlobalDeviceIds() const { + auto &propStorage = this->use_global_device_ids; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setUseGlobalDeviceIds(const ::mlir::UnitAttr &propValue) { + this->use_global_device_ids = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_handle == this->channel_handle && + rhs.replica_groups == this->replica_groups && + rhs.scatter_dimension == this->scatter_dimension && + rhs.use_global_device_ids == this->use_global_device_ids && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReduceScatterOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.reduce_scatter", odsAttrs.getContext()); + } + + ReduceScatterOpGenericAdaptorBase(ReduceScatterOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::IntegerAttr getScatterDimensionAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().scatter_dimension); + return attr; + } + + uint64_t getScatterDimension(); + ::mlir::DenseIntElementsAttr getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().replica_groups); + return attr; + } + + ::mlir::DenseIntElementsAttr getReplicaGroups(); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + return attr; + } + + ::std::optional<::mlir::stablehlo::ChannelHandleAttr> getChannelHandle(); + ::mlir::UnitAttr getUseGlobalDeviceIdsAttr(); + bool getUseGlobalDeviceIds(); + ::mlir::Region &getComputation() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class ReduceScatterOpGenericAdaptor : public detail::ReduceScatterOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReduceScatterOpGenericAdaptorBase; +public: + ReduceScatterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReduceScatterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReduceScatterOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReduceScatterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReduceScatterOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ReduceScatterOpGenericAdaptor(RangeT values, const ReduceScatterOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReduceScatterOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReduceScatterOpAdaptor : public ReduceScatterOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReduceScatterOpGenericAdaptor::ReduceScatterOpGenericAdaptor; + ReduceScatterOpAdaptor(ReduceScatterOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReduceScatterOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReduceScatterOpAdaptor; + template + using GenericAdaptor = ReduceScatterOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_handle"), ::llvm::StringRef("replica_groups"), ::llvm::StringRef("scatter_dimension"), ::llvm::StringRef("use_global_device_ids")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelHandleAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelHandleAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getScatterDimensionAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getScatterDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getUseGlobalDeviceIdsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getUseGlobalDeviceIdsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.reduce_scatter"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Region &getComputation() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getScatterDimensionAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().scatter_dimension); + } + + uint64_t getScatterDimension(); + ::mlir::DenseIntElementsAttr getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().replica_groups); + } + + ::mlir::DenseIntElementsAttr getReplicaGroups(); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + } + + ::std::optional<::mlir::stablehlo::ChannelHandleAttr> getChannelHandle(); + ::mlir::UnitAttr getUseGlobalDeviceIdsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().use_global_device_ids); + } + + bool getUseGlobalDeviceIds(); + void setScatterDimensionAttr(::mlir::IntegerAttr attr) { + getProperties().scatter_dimension = attr; + } + + void setScatterDimension(uint64_t attrValue); + void setReplicaGroupsAttr(::mlir::DenseIntElementsAttr attr) { + getProperties().replica_groups = attr; + } + + void setChannelHandleAttr(::mlir::stablehlo::ChannelHandleAttr attr) { + getProperties().channel_handle = attr; + } + + void setUseGlobalDeviceIdsAttr(::mlir::UnitAttr attr) { + getProperties().use_global_device_ids = attr; + } + + void setUseGlobalDeviceIds(bool attrValue); + ::mlir::Attribute removeChannelHandleAttr() { + auto attr = getProperties().channel_handle; + getProperties().channel_handle = {}; + return attr; + } + + ::mlir::Attribute removeUseGlobalDeviceIdsAttr() { + auto attr = getProperties().use_global_device_ids; + getProperties().use_global_device_ids = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::IntegerAttr scatter_dimension, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::UnitAttr use_global_device_ids = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::IntegerAttr scatter_dimension, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::UnitAttr use_global_device_ids = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, uint64_t scatter_dimension, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool use_global_device_ids = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, uint64_t scatter_dimension, ::mlir::DenseIntElementsAttr replica_groups, /*optional*/::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool use_global_device_ids = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 4 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReduceScatterOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReduceWindowOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReduceWindowOpGenericAdaptorBase { +public: + struct Properties { + using base_dilationsTy = ::mlir::DenseI64ArrayAttr; + base_dilationsTy base_dilations; + + auto getBaseDilations() const { + auto &propStorage = this->base_dilations; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setBaseDilations(const ::mlir::DenseI64ArrayAttr &propValue) { + this->base_dilations = propValue; + } + using paddingTy = ::mlir::DenseIntElementsAttr; + paddingTy padding; + + auto getPadding() const { + auto &propStorage = this->padding; + return ::llvm::dyn_cast_or_null<::mlir::DenseIntElementsAttr>(propStorage); + } + void setPadding(const ::mlir::DenseIntElementsAttr &propValue) { + this->padding = propValue; + } + using window_dilationsTy = ::mlir::DenseI64ArrayAttr; + window_dilationsTy window_dilations; + + auto getWindowDilations() const { + auto &propStorage = this->window_dilations; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setWindowDilations(const ::mlir::DenseI64ArrayAttr &propValue) { + this->window_dilations = propValue; + } + using window_dimensionsTy = ::mlir::DenseI64ArrayAttr; + window_dimensionsTy window_dimensions; + + auto getWindowDimensions() const { + auto &propStorage = this->window_dimensions; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setWindowDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->window_dimensions = propValue; + } + using window_stridesTy = ::mlir::DenseI64ArrayAttr; + window_stridesTy window_strides; + + auto getWindowStrides() const { + auto &propStorage = this->window_strides; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setWindowStrides(const ::mlir::DenseI64ArrayAttr &propValue) { + this->window_strides = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.base_dilations == this->base_dilations && + rhs.padding == this->padding && + rhs.window_dilations == this->window_dilations && + rhs.window_dimensions == this->window_dimensions && + rhs.window_strides == this->window_strides && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReduceWindowOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.reduce_window", odsAttrs.getContext()); + } + + ReduceWindowOpGenericAdaptorBase(ReduceWindowOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getWindowDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().window_dimensions); + return attr; + } + + ::llvm::ArrayRef getWindowDimensions(); + ::mlir::DenseI64ArrayAttr getWindowStridesAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().window_strides); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getWindowStrides(); + ::mlir::DenseI64ArrayAttr getBaseDilationsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().base_dilations); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getBaseDilations(); + ::mlir::DenseI64ArrayAttr getWindowDilationsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().window_dilations); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getWindowDilations(); + ::mlir::DenseIntElementsAttr getPaddingAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseIntElementsAttr>(getProperties().padding); + return attr; + } + + ::std::optional< ::mlir::DenseIntElementsAttr > getPadding(); + ::mlir::Region &getBody() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class ReduceWindowOpGenericAdaptor : public detail::ReduceWindowOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReduceWindowOpGenericAdaptorBase; +public: + ReduceWindowOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReduceWindowOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReduceWindowOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReduceWindowOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReduceWindowOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ReduceWindowOpGenericAdaptor(RangeT values, const ReduceWindowOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReduceWindowOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getInitValues() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReduceWindowOpAdaptor : public ReduceWindowOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReduceWindowOpGenericAdaptor::ReduceWindowOpGenericAdaptor; + ReduceWindowOpAdaptor(ReduceWindowOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReduceWindowOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::RecursivelySpeculatableIfAllInputsStaticImplTrait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReduceWindowOpAdaptor; + template + using GenericAdaptor = ReduceWindowOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("base_dilations"), ::llvm::StringRef("padding"), ::llvm::StringRef("window_dilations"), ::llvm::StringRef("window_dimensions"), ::llvm::StringRef("window_strides")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBaseDilationsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBaseDilationsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getPaddingAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getPaddingAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getWindowDilationsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getWindowDilationsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getWindowDimensionsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getWindowDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getWindowStridesAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getWindowStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.reduce_window"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::Operation::operand_range getInitValues() { + return getODSOperands(1); + } + + ::mlir::MutableOperandRange getInputsMutable(); + ::mlir::MutableOperandRange getInitValuesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Region &getBody() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getWindowDimensionsAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().window_dimensions); + } + + ::llvm::ArrayRef getWindowDimensions(); + ::mlir::DenseI64ArrayAttr getWindowStridesAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().window_strides); + } + + ::std::optional<::llvm::ArrayRef> getWindowStrides(); + ::mlir::DenseI64ArrayAttr getBaseDilationsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().base_dilations); + } + + ::std::optional<::llvm::ArrayRef> getBaseDilations(); + ::mlir::DenseI64ArrayAttr getWindowDilationsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().window_dilations); + } + + ::std::optional<::llvm::ArrayRef> getWindowDilations(); + ::mlir::DenseIntElementsAttr getPaddingAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseIntElementsAttr>(getProperties().padding); + } + + ::std::optional< ::mlir::DenseIntElementsAttr > getPadding(); + void setWindowDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().window_dimensions = attr; + } + + void setWindowDimensions(::llvm::ArrayRef attrValue); + void setWindowStridesAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().window_strides = attr; + } + + void setWindowStrides(::std::optional<::llvm::ArrayRef> attrValue); + void setBaseDilationsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().base_dilations = attr; + } + + void setBaseDilations(::std::optional<::llvm::ArrayRef> attrValue); + void setWindowDilationsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().window_dilations = attr; + } + + void setWindowDilations(::std::optional<::llvm::ArrayRef> attrValue); + void setPaddingAttr(::mlir::DenseIntElementsAttr attr) { + getProperties().padding = attr; + } + + ::mlir::Attribute removeWindowStridesAttr() { + auto attr = getProperties().window_strides; + getProperties().window_strides = {}; + return attr; + } + + ::mlir::Attribute removeBaseDilationsAttr() { + auto attr = getProperties().base_dilations; + getProperties().base_dilations = {}; + return attr; + } + + ::mlir::Attribute removeWindowDilationsAttr() { + auto attr = getProperties().window_dilations; + getProperties().window_dilations = {}; + return attr; + } + + ::mlir::Attribute removePaddingAttr() { + auto attr = getProperties().padding; + getProperties().padding = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type result_type, Value operand, Value init_value, DenseI64ArrayAttr window_dimensions, DenseI64ArrayAttr window_strides, DenseI64ArrayAttr base_dilations, DenseI64ArrayAttr window_dilations, DenseIntElementsAttr padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ValueRange operands, ValueRange init_values, DenseI64ArrayAttr window_dimensions, DenseI64ArrayAttr window_strides, DenseI64ArrayAttr base_dilations, DenseI64ArrayAttr window_dilations, DenseIntElementsAttr padding, function_ref bodyBuilder); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::mlir::DenseI64ArrayAttr window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr base_dilations, /*optional*/::mlir::DenseI64ArrayAttr window_dilations, /*optional*/::mlir::DenseIntElementsAttr padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::mlir::DenseI64ArrayAttr window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr base_dilations, /*optional*/::mlir::DenseI64ArrayAttr window_dilations, /*optional*/::mlir::DenseIntElementsAttr padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::llvm::ArrayRef window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr base_dilations, /*optional*/::mlir::DenseI64ArrayAttr window_dilations, /*optional*/::mlir::DenseIntElementsAttr padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::llvm::ArrayRef window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseI64ArrayAttr base_dilations, /*optional*/::mlir::DenseI64ArrayAttr window_dilations, /*optional*/::mlir::DenseIntElementsAttr padding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 5 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReduceWindowOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RemOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RemOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RemOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.remainder", odsAttrs.getContext()); + } + + RemOpGenericAdaptorBase(RemOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class RemOpGenericAdaptor : public detail::RemOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RemOpGenericAdaptorBase; +public: + RemOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RemOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RemOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RemOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RemOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + RemOpGenericAdaptor(RangeT values, const RemOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RemOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RemOpAdaptor : public RemOpGenericAdaptor<::mlir::ValueRange> { +public: + using RemOpGenericAdaptor::RemOpGenericAdaptor; + RemOpAdaptor(RemOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RemOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RemOpAdaptor; + template + using GenericAdaptor = RemOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.remainder"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RemOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReplicaIdOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReplicaIdOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReplicaIdOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.replica_id", odsAttrs.getContext()); + } + + ReplicaIdOpGenericAdaptorBase(ReplicaIdOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ReplicaIdOpGenericAdaptor : public detail::ReplicaIdOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReplicaIdOpGenericAdaptorBase; +public: + ReplicaIdOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReplicaIdOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReplicaIdOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReplicaIdOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReplicaIdOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ReplicaIdOpGenericAdaptor(RangeT values, const ReplicaIdOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReplicaIdOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReplicaIdOpAdaptor : public ReplicaIdOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReplicaIdOpGenericAdaptor::ReplicaIdOpGenericAdaptor; + ReplicaIdOpAdaptor(ReplicaIdOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReplicaIdOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReplicaIdOpAdaptor; + template + using GenericAdaptor = ReplicaIdOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.replica_id"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReplicaIdOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReshapeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReshapeOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReshapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.reshape", odsAttrs.getContext()); + } + + ReshapeOpGenericAdaptorBase(ReshapeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ReshapeOpGenericAdaptor : public detail::ReshapeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReshapeOpGenericAdaptorBase; +public: + ReshapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReshapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReshapeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReshapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReshapeOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ReshapeOpGenericAdaptor(RangeT values, const ReshapeOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReshapeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReshapeOpAdaptor : public ReshapeOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReshapeOpGenericAdaptor::ReshapeOpGenericAdaptor; + ReshapeOpAdaptor(ReshapeOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReshapeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultElementType> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReshapeOpAdaptor; + template + using GenericAdaptor = ReshapeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.reshape"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReshapeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReturnOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReturnOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReturnOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.return", odsAttrs.getContext()); + } + + ReturnOpGenericAdaptorBase(ReturnOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ReturnOpGenericAdaptor : public detail::ReturnOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReturnOpGenericAdaptorBase; +public: + ReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReturnOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReturnOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ReturnOpGenericAdaptor(RangeT values, const ReturnOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReturnOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getResults() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReturnOpAdaptor : public ReturnOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReturnOpGenericAdaptor::ReturnOpGenericAdaptor; + ReturnOpAdaptor(ReturnOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReturnOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = ReturnOpAdaptor; + template + using GenericAdaptor = ReturnOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.return"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getResults() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getResultsMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange results); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReturnOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ReverseOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReverseOpGenericAdaptorBase { +public: + struct Properties { + using dimensionsTy = ::mlir::DenseI64ArrayAttr; + dimensionsTy dimensions; + + auto getDimensions() const { + auto &propStorage = this->dimensions; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimensions == this->dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReverseOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.reverse", odsAttrs.getContext()); + } + + ReverseOpGenericAdaptorBase(ReverseOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().dimensions); + return attr; + } + + ::llvm::ArrayRef getDimensions(); +}; +} // namespace detail +template +class ReverseOpGenericAdaptor : public detail::ReverseOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReverseOpGenericAdaptorBase; +public: + ReverseOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReverseOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReverseOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReverseOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReverseOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ReverseOpGenericAdaptor(RangeT values, const ReverseOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReverseOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReverseOpAdaptor : public ReverseOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReverseOpGenericAdaptor::ReverseOpGenericAdaptor; + ReverseOpAdaptor(ReverseOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReverseOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReverseOpAdaptor; + template + using GenericAdaptor = ReverseOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.reverse"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getDimensionsAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().dimensions); + } + + ::llvm::ArrayRef getDimensions(); + void setDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().dimensions = attr; + } + + void setDimensions(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::llvm::ArrayRef dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::llvm::ArrayRef dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::llvm::ArrayRef dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ReverseOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RngBitGeneratorOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RngBitGeneratorOpGenericAdaptorBase { +public: + struct Properties { + using rng_algorithmTy = ::mlir::stablehlo::RngAlgorithmAttr; + rng_algorithmTy rng_algorithm; + + auto getRngAlgorithm() const { + auto &propStorage = this->rng_algorithm; + return ::llvm::cast<::mlir::stablehlo::RngAlgorithmAttr>(propStorage); + } + void setRngAlgorithm(const ::mlir::stablehlo::RngAlgorithmAttr &propValue) { + this->rng_algorithm = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.rng_algorithm == this->rng_algorithm && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RngBitGeneratorOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.rng_bit_generator", odsAttrs.getContext()); + } + + RngBitGeneratorOpGenericAdaptorBase(RngBitGeneratorOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::RngAlgorithmAttr getRngAlgorithmAttr() { + auto attr = ::llvm::cast<::mlir::stablehlo::RngAlgorithmAttr>(getProperties().rng_algorithm); + return attr; + } + + ::mlir::stablehlo::RngAlgorithm getRngAlgorithm(); +}; +} // namespace detail +template +class RngBitGeneratorOpGenericAdaptor : public detail::RngBitGeneratorOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RngBitGeneratorOpGenericAdaptorBase; +public: + RngBitGeneratorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RngBitGeneratorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RngBitGeneratorOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RngBitGeneratorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RngBitGeneratorOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + RngBitGeneratorOpGenericAdaptor(RangeT values, const RngBitGeneratorOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RngBitGeneratorOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getInitialState() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RngBitGeneratorOpAdaptor : public RngBitGeneratorOpGenericAdaptor<::mlir::ValueRange> { +public: + using RngBitGeneratorOpGenericAdaptor::RngBitGeneratorOpGenericAdaptor; + RngBitGeneratorOpAdaptor(RngBitGeneratorOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RngBitGeneratorOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RngBitGeneratorOpAdaptor; + template + using GenericAdaptor = RngBitGeneratorOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("rng_algorithm")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getRngAlgorithmAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getRngAlgorithmAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.rng_bit_generator"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getInitialState() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getInitialStateMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOutputState() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(1).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::RngAlgorithmAttr getRngAlgorithmAttr() { + return ::llvm::cast<::mlir::stablehlo::RngAlgorithmAttr>(getProperties().rng_algorithm); + } + + ::mlir::stablehlo::RngAlgorithm getRngAlgorithm(); + void setRngAlgorithmAttr(::mlir::stablehlo::RngAlgorithmAttr attr) { + getProperties().rng_algorithm = attr; + } + + void setRngAlgorithm(::mlir::stablehlo::RngAlgorithm attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_state, ::mlir::Type output, ::mlir::stablehlo::RngAlgorithmAttr rng_algorithm, ::mlir::Value initial_state); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::stablehlo::RngAlgorithmAttr rng_algorithm, ::mlir::Value initial_state); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_state, ::mlir::Type output, ::mlir::stablehlo::RngAlgorithm rng_algorithm, ::mlir::Value initial_state); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::stablehlo::RngAlgorithm rng_algorithm, ::mlir::Value initial_state); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RngBitGeneratorOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RngOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RngOpGenericAdaptorBase { +public: + struct Properties { + using rng_distributionTy = ::mlir::stablehlo::RngDistributionAttr; + rng_distributionTy rng_distribution; + + auto getRngDistribution() const { + auto &propStorage = this->rng_distribution; + return ::llvm::cast<::mlir::stablehlo::RngDistributionAttr>(propStorage); + } + void setRngDistribution(const ::mlir::stablehlo::RngDistributionAttr &propValue) { + this->rng_distribution = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.rng_distribution == this->rng_distribution && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RngOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.rng", odsAttrs.getContext()); + } + + RngOpGenericAdaptorBase(RngOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::RngDistributionAttr getRngDistributionAttr() { + auto attr = ::llvm::cast<::mlir::stablehlo::RngDistributionAttr>(getProperties().rng_distribution); + return attr; + } + + ::mlir::stablehlo::RngDistribution getRngDistribution(); +}; +} // namespace detail +template +class RngOpGenericAdaptor : public detail::RngOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RngOpGenericAdaptorBase; +public: + RngOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RngOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RngOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RngOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RngOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + RngOpGenericAdaptor(RangeT values, const RngOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RngOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + ValueT getB() { + return (*getODSOperands(1).begin()); + } + + ValueT getShape() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RngOpAdaptor : public RngOpGenericAdaptor<::mlir::ValueRange> { +public: + using RngOpGenericAdaptor::RngOpGenericAdaptor; + RngOpAdaptor(RngOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RngOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = RngOpAdaptor; + template + using GenericAdaptor = RngOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("rng_distribution")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getRngDistributionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getRngDistributionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.rng"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getB() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getShape() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getBMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getShapeMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::RngDistributionAttr getRngDistributionAttr() { + return ::llvm::cast<::mlir::stablehlo::RngDistributionAttr>(getProperties().rng_distribution); + } + + ::mlir::stablehlo::RngDistribution getRngDistribution(); + void setRngDistributionAttr(::mlir::stablehlo::RngDistributionAttr attr) { + getProperties().rng_distribution = attr; + } + + void setRngDistribution(::mlir::stablehlo::RngDistribution attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::stablehlo::RngDistributionAttr rng_distribution); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::stablehlo::RngDistributionAttr rng_distribution); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::stablehlo::RngDistributionAttr rng_distribution); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::stablehlo::RngDistribution rng_distribution); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::stablehlo::RngDistribution rng_distribution); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::stablehlo::RngDistribution rng_distribution); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RngOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RoundNearestEvenOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RoundNearestEvenOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RoundNearestEvenOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.round_nearest_even", odsAttrs.getContext()); + } + + RoundNearestEvenOpGenericAdaptorBase(RoundNearestEvenOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class RoundNearestEvenOpGenericAdaptor : public detail::RoundNearestEvenOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RoundNearestEvenOpGenericAdaptorBase; +public: + RoundNearestEvenOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RoundNearestEvenOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RoundNearestEvenOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RoundNearestEvenOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RoundNearestEvenOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + RoundNearestEvenOpGenericAdaptor(RangeT values, const RoundNearestEvenOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RoundNearestEvenOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RoundNearestEvenOpAdaptor : public RoundNearestEvenOpGenericAdaptor<::mlir::ValueRange> { +public: + using RoundNearestEvenOpGenericAdaptor::RoundNearestEvenOpGenericAdaptor; + RoundNearestEvenOpAdaptor(RoundNearestEvenOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RoundNearestEvenOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RoundNearestEvenOpAdaptor; + template + using GenericAdaptor = RoundNearestEvenOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.round_nearest_even"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RoundNearestEvenOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RoundOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RoundOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RoundOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.round_nearest_afz", odsAttrs.getContext()); + } + + RoundOpGenericAdaptorBase(RoundOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class RoundOpGenericAdaptor : public detail::RoundOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RoundOpGenericAdaptorBase; +public: + RoundOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RoundOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RoundOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RoundOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RoundOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + RoundOpGenericAdaptor(RangeT values, const RoundOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RoundOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RoundOpAdaptor : public RoundOpGenericAdaptor<::mlir::ValueRange> { +public: + using RoundOpGenericAdaptor::RoundOpGenericAdaptor; + RoundOpAdaptor(RoundOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RoundOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RoundOpAdaptor; + template + using GenericAdaptor = RoundOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.round_nearest_afz"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RoundOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::RsqrtOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RsqrtOpGenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::stablehlo::ResultAccuracyAttr; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(propStorage); + } + void setResultAccuracy(const ::mlir::stablehlo::ResultAccuracyAttr &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RsqrtOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.rsqrt", odsAttrs.getContext()); + } + + RsqrtOpGenericAdaptorBase(RsqrtOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr(); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); +}; +} // namespace detail +template +class RsqrtOpGenericAdaptor : public detail::RsqrtOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RsqrtOpGenericAdaptorBase; +public: + RsqrtOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RsqrtOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RsqrtOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RsqrtOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RsqrtOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + RsqrtOpGenericAdaptor(RangeT values, const RsqrtOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RsqrtOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RsqrtOpAdaptor : public RsqrtOpGenericAdaptor<::mlir::ValueRange> { +public: + using RsqrtOpGenericAdaptor::RsqrtOpGenericAdaptor; + RsqrtOpAdaptor(RsqrtOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RsqrtOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RsqrtOpAdaptor; + template + using GenericAdaptor = RsqrtOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.rsqrt"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); + void setResultAccuracyAttr(::mlir::stablehlo::ResultAccuracyAttr attr) { + getProperties().result_accuracy = attr; + } + + ::mlir::Attribute removeResultAccuracyAttr() { + auto attr = getProperties().result_accuracy; + getProperties().result_accuracy = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::RsqrtOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ScatterOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ScatterOpGenericAdaptorBase { +public: + struct Properties { + using indices_are_sortedTy = ::mlir::BoolAttr; + indices_are_sortedTy indices_are_sorted; + + auto getIndicesAreSorted() const { + auto &propStorage = this->indices_are_sorted; + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(propStorage); + } + void setIndicesAreSorted(const ::mlir::BoolAttr &propValue) { + this->indices_are_sorted = propValue; + } + using scatter_dimension_numbersTy = ::mlir::stablehlo::ScatterDimensionNumbersAttr; + scatter_dimension_numbersTy scatter_dimension_numbers; + + auto getScatterDimensionNumbers() const { + auto &propStorage = this->scatter_dimension_numbers; + return ::llvm::cast<::mlir::stablehlo::ScatterDimensionNumbersAttr>(propStorage); + } + void setScatterDimensionNumbers(const ::mlir::stablehlo::ScatterDimensionNumbersAttr &propValue) { + this->scatter_dimension_numbers = propValue; + } + using unique_indicesTy = ::mlir::BoolAttr; + unique_indicesTy unique_indices; + + auto getUniqueIndices() const { + auto &propStorage = this->unique_indices; + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(propStorage); + } + void setUniqueIndices(const ::mlir::BoolAttr &propValue) { + this->unique_indices = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.indices_are_sorted == this->indices_are_sorted && + rhs.scatter_dimension_numbers == this->scatter_dimension_numbers && + rhs.unique_indices == this->unique_indices && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ScatterOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.scatter", odsAttrs.getContext()); + } + + ScatterOpGenericAdaptorBase(ScatterOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ScatterDimensionNumbersAttr getScatterDimensionNumbersAttr() { + auto attr = ::llvm::cast<::mlir::stablehlo::ScatterDimensionNumbersAttr>(getProperties().scatter_dimension_numbers); + return attr; + } + + ::mlir::stablehlo::ScatterDimensionNumbersAttr getScatterDimensionNumbers(); + ::mlir::BoolAttr getIndicesAreSortedAttr(); + bool getIndicesAreSorted(); + ::mlir::BoolAttr getUniqueIndicesAttr(); + bool getUniqueIndices(); + ::mlir::Region &getUpdateComputation() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class ScatterOpGenericAdaptor : public detail::ScatterOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ScatterOpGenericAdaptorBase; +public: + ScatterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ScatterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ScatterOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ScatterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ScatterOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ScatterOpGenericAdaptor(RangeT values, const ScatterOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ScatterOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + ValueT getScatterIndices() { + return (*getODSOperands(1).begin()); + } + + RangeT getUpdates() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ScatterOpAdaptor : public ScatterOpGenericAdaptor<::mlir::ValueRange> { +public: + using ScatterOpGenericAdaptor::ScatterOpGenericAdaptor; + ScatterOpAdaptor(ScatterOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ScatterOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ScatterOpAdaptor; + template + using GenericAdaptor = ScatterOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("indices_are_sorted"), ::llvm::StringRef("scatter_dimension_numbers"), ::llvm::StringRef("unique_indices")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getIndicesAreSortedAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getIndicesAreSortedAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getScatterDimensionNumbersAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getScatterDimensionNumbersAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getUniqueIndicesAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getUniqueIndicesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.scatter"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getScatterIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::Operation::operand_range getUpdates() { + return getODSOperands(2); + } + + ::mlir::MutableOperandRange getInputsMutable(); + ::mlir::OpOperand &getScatterIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::MutableOperandRange getUpdatesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Region &getUpdateComputation() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ScatterDimensionNumbersAttr getScatterDimensionNumbersAttr() { + return ::llvm::cast<::mlir::stablehlo::ScatterDimensionNumbersAttr>(getProperties().scatter_dimension_numbers); + } + + ::mlir::stablehlo::ScatterDimensionNumbersAttr getScatterDimensionNumbers(); + ::mlir::BoolAttr getIndicesAreSortedAttr() { + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().indices_are_sorted); + } + + bool getIndicesAreSorted(); + ::mlir::BoolAttr getUniqueIndicesAttr() { + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().unique_indices); + } + + bool getUniqueIndices(); + void setScatterDimensionNumbersAttr(::mlir::stablehlo::ScatterDimensionNumbersAttr attr) { + getProperties().scatter_dimension_numbers = attr; + } + + void setIndicesAreSortedAttr(::mlir::BoolAttr attr) { + getProperties().indices_are_sorted = attr; + } + + void setIndicesAreSorted(::std::optional attrValue); + void setUniqueIndicesAttr(::mlir::BoolAttr attr) { + getProperties().unique_indices = attr; + } + + void setUniqueIndices(::std::optional attrValue); + ::mlir::Attribute removeIndicesAreSortedAttr() { + auto attr = getProperties().indices_are_sorted; + getProperties().indices_are_sorted = {}; + return attr; + } + + ::mlir::Attribute removeUniqueIndicesAttr() { + auto attr = getProperties().unique_indices; + getProperties().unique_indices = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::Value scatter_indices, ::mlir::ValueRange updates, ::mlir::stablehlo::ScatterDimensionNumbersAttr scatter_dimension_numbers, /*optional*/::mlir::BoolAttr indices_are_sorted, /*optional*/::mlir::BoolAttr unique_indices = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::Value scatter_indices, ::mlir::ValueRange updates, ::mlir::stablehlo::ScatterDimensionNumbersAttr scatter_dimension_numbers, /*optional*/::mlir::BoolAttr indices_are_sorted, /*optional*/::mlir::BoolAttr unique_indices = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, ::mlir::Value scatter_indices, ::mlir::ValueRange updates, ::mlir::stablehlo::ScatterDimensionNumbersAttr scatter_dimension_numbers, /*optional*/bool indices_are_sorted = false, /*optional*/bool unique_indices = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::Value scatter_indices, ::mlir::ValueRange updates, ::mlir::stablehlo::ScatterDimensionNumbersAttr scatter_dimension_numbers, /*optional*/bool indices_are_sorted = false, /*optional*/bool unique_indices = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ScatterOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SelectAndScatterOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SelectAndScatterOpGenericAdaptorBase { +public: + struct Properties { + using paddingTy = ::mlir::DenseIntElementsAttr; + paddingTy padding; + + auto getPadding() const { + auto &propStorage = this->padding; + return ::llvm::dyn_cast_or_null<::mlir::DenseIntElementsAttr>(propStorage); + } + void setPadding(const ::mlir::DenseIntElementsAttr &propValue) { + this->padding = propValue; + } + using window_dimensionsTy = ::mlir::DenseI64ArrayAttr; + window_dimensionsTy window_dimensions; + + auto getWindowDimensions() const { + auto &propStorage = this->window_dimensions; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setWindowDimensions(const ::mlir::DenseI64ArrayAttr &propValue) { + this->window_dimensions = propValue; + } + using window_stridesTy = ::mlir::DenseI64ArrayAttr; + window_stridesTy window_strides; + + auto getWindowStrides() const { + auto &propStorage = this->window_strides; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setWindowStrides(const ::mlir::DenseI64ArrayAttr &propValue) { + this->window_strides = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.padding == this->padding && + rhs.window_dimensions == this->window_dimensions && + rhs.window_strides == this->window_strides && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SelectAndScatterOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.select_and_scatter", odsAttrs.getContext()); + } + + SelectAndScatterOpGenericAdaptorBase(SelectAndScatterOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getWindowDimensionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().window_dimensions); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getWindowDimensions(); + ::mlir::DenseI64ArrayAttr getWindowStridesAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().window_strides); + return attr; + } + + ::std::optional<::llvm::ArrayRef> getWindowStrides(); + ::mlir::DenseIntElementsAttr getPaddingAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseIntElementsAttr>(getProperties().padding); + return attr; + } + + ::std::optional< ::mlir::DenseIntElementsAttr > getPadding(); + ::mlir::Region &getSelect() { + return *odsRegions[0]; + } + + ::mlir::Region &getScatter() { + return *odsRegions[1]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class SelectAndScatterOpGenericAdaptor : public detail::SelectAndScatterOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SelectAndScatterOpGenericAdaptorBase; +public: + SelectAndScatterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SelectAndScatterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SelectAndScatterOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SelectAndScatterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SelectAndScatterOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + SelectAndScatterOpGenericAdaptor(RangeT values, const SelectAndScatterOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SelectAndScatterOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getSource() { + return (*getODSOperands(1).begin()); + } + + ValueT getInitValue() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SelectAndScatterOpAdaptor : public SelectAndScatterOpGenericAdaptor<::mlir::ValueRange> { +public: + using SelectAndScatterOpGenericAdaptor::SelectAndScatterOpGenericAdaptor; + SelectAndScatterOpAdaptor(SelectAndScatterOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SelectAndScatterOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OneResult, ::mlir::OpTrait::OneTypedResult<::mlir::RankedTensorType>::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::RecursivelySpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects> { +public: + using Op::Op; + using Op::print; + using Adaptor = SelectAndScatterOpAdaptor; + template + using GenericAdaptor = SelectAndScatterOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("padding"), ::llvm::StringRef("window_dimensions"), ::llvm::StringRef("window_strides")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getPaddingAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getPaddingAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getWindowDimensionsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getWindowDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getWindowStridesAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getWindowStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.select_and_scatter"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getInitValue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getSourceMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getInitValueMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Region &getSelect() { + return (*this)->getRegion(0); + } + + ::mlir::Region &getScatter() { + return (*this)->getRegion(1); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getWindowDimensionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().window_dimensions); + } + + ::std::optional<::llvm::ArrayRef> getWindowDimensions(); + ::mlir::DenseI64ArrayAttr getWindowStridesAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().window_strides); + } + + ::std::optional<::llvm::ArrayRef> getWindowStrides(); + ::mlir::DenseIntElementsAttr getPaddingAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseIntElementsAttr>(getProperties().padding); + } + + ::std::optional< ::mlir::DenseIntElementsAttr > getPadding(); + void setWindowDimensionsAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().window_dimensions = attr; + } + + void setWindowDimensions(::std::optional<::llvm::ArrayRef> attrValue); + void setWindowStridesAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().window_strides = attr; + } + + void setWindowStrides(::std::optional<::llvm::ArrayRef> attrValue); + void setPaddingAttr(::mlir::DenseIntElementsAttr attr) { + getProperties().padding = attr; + } + + ::mlir::Attribute removeWindowDimensionsAttr() { + auto attr = getProperties().window_dimensions; + getProperties().window_dimensions = {}; + return attr; + } + + ::mlir::Attribute removeWindowStridesAttr() { + auto attr = getProperties().window_strides; + getProperties().window_strides = {}; + return attr; + } + + ::mlir::Attribute removePaddingAttr() { + auto attr = getProperties().padding; + getProperties().padding = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value source, ::mlir::Value init_value, /*optional*/::mlir::DenseI64ArrayAttr window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value source, ::mlir::Value init_value, /*optional*/::mlir::DenseI64ArrayAttr window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value source, ::mlir::Value init_value, /*optional*/::mlir::DenseI64ArrayAttr window_dimensions, /*optional*/::mlir::DenseI64ArrayAttr window_strides, /*optional*/::mlir::DenseIntElementsAttr padding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SelectAndScatterOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SelectOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SelectOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SelectOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.select", odsAttrs.getContext()); + } + + SelectOpGenericAdaptorBase(SelectOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class SelectOpGenericAdaptor : public detail::SelectOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SelectOpGenericAdaptorBase; +public: + SelectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SelectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SelectOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SelectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SelectOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + SelectOpGenericAdaptor(RangeT values, const SelectOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SelectOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getPred() { + return (*getODSOperands(0).begin()); + } + + ValueT getOnTrue() { + return (*getODSOperands(1).begin()); + } + + ValueT getOnFalse() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SelectOpAdaptor : public SelectOpGenericAdaptor<::mlir::ValueRange> { +public: + using SelectOpGenericAdaptor::SelectOpGenericAdaptor; + SelectOpAdaptor(SelectOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SelectOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::BroadcastingElementwise, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = SelectOpAdaptor; + template + using GenericAdaptor = SelectOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.select"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getPred() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOnTrue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOnFalse() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getPredMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOnTrueMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOnFalseMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SelectOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SendOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SendOpGenericAdaptorBase { +public: + struct Properties { + using channel_handleTy = ::mlir::stablehlo::ChannelHandleAttr; + channel_handleTy channel_handle; + + auto getChannelHandle() const { + auto &propStorage = this->channel_handle; + return ::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(propStorage); + } + void setChannelHandle(const ::mlir::stablehlo::ChannelHandleAttr &propValue) { + this->channel_handle = propValue; + } + using is_host_transferTy = ::mlir::BoolAttr; + is_host_transferTy is_host_transfer; + + auto getIsHostTransfer() const { + auto &propStorage = this->is_host_transfer; + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(propStorage); + } + void setIsHostTransfer(const ::mlir::BoolAttr &propValue) { + this->is_host_transfer = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_handle == this->channel_handle && + rhs.is_host_transfer == this->is_host_transfer && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SendOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.send", odsAttrs.getContext()); + } + + SendOpGenericAdaptorBase(SendOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + auto attr = ::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + return attr; + } + + ::mlir::stablehlo::ChannelHandleAttr getChannelHandle(); + ::mlir::BoolAttr getIsHostTransferAttr(); + bool getIsHostTransfer(); +}; +} // namespace detail +template +class SendOpGenericAdaptor : public detail::SendOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SendOpGenericAdaptorBase; +public: + SendOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SendOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SendOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SendOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SendOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + SendOpGenericAdaptor(RangeT values, const SendOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SendOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + ValueT getToken() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SendOpAdaptor : public SendOpGenericAdaptor<::mlir::ValueRange> { +public: + using SendOpGenericAdaptor::SendOpGenericAdaptor; + SendOpAdaptor(SendOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SendOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SendOpAdaptor; + template + using GenericAdaptor = SendOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_handle"), ::llvm::StringRef("is_host_transfer")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelHandleAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelHandleAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIsHostTransferAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIsHostTransferAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.send"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::TypedValue<::mlir::Type> getToken() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::MutableOperandRange getInputsMutable(); + ::mlir::OpOperand &getTokenMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ChannelHandleAttr getChannelHandleAttr() { + return ::llvm::cast<::mlir::stablehlo::ChannelHandleAttr>(getProperties().channel_handle); + } + + ::mlir::stablehlo::ChannelHandleAttr getChannelHandle(); + ::mlir::BoolAttr getIsHostTransferAttr() { + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().is_host_transfer); + } + + bool getIsHostTransfer(); + void setChannelHandleAttr(::mlir::stablehlo::ChannelHandleAttr attr) { + getProperties().channel_handle = attr; + } + + void setIsHostTransferAttr(::mlir::BoolAttr attr) { + getProperties().is_host_transfer = attr; + } + + void setIsHostTransfer(::std::optional attrValue); + ::mlir::Attribute removeIsHostTransferAttr() { + auto attr = getProperties().is_host_transfer; + getProperties().is_host_transfer = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::BoolAttr is_host_transfer); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::BoolAttr is_host_transfer); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/::mlir::BoolAttr is_host_transfer); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool is_host_transfer = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool is_host_transfer = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::stablehlo::ChannelHandleAttr channel_handle, /*optional*/bool is_host_transfer = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SendOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SetDimensionSizeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SetDimensionSizeOpGenericAdaptorBase { +public: + struct Properties { + using dimensionTy = ::mlir::IntegerAttr; + dimensionTy dimension; + + auto getDimension() const { + auto &propStorage = this->dimension; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setDimension(const ::mlir::IntegerAttr &propValue) { + this->dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimension == this->dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SetDimensionSizeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.set_dimension_size", odsAttrs.getContext()); + } + + SetDimensionSizeOpGenericAdaptorBase(SetDimensionSizeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::IntegerAttr getDimensionAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().dimension); + return attr; + } + + uint64_t getDimension(); +}; +} // namespace detail +template +class SetDimensionSizeOpGenericAdaptor : public detail::SetDimensionSizeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SetDimensionSizeOpGenericAdaptorBase; +public: + SetDimensionSizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SetDimensionSizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SetDimensionSizeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SetDimensionSizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SetDimensionSizeOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + SetDimensionSizeOpGenericAdaptor(RangeT values, const SetDimensionSizeOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SetDimensionSizeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getSize() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SetDimensionSizeOpAdaptor : public SetDimensionSizeOpGenericAdaptor<::mlir::ValueRange> { +public: + using SetDimensionSizeOpGenericAdaptor::SetDimensionSizeOpGenericAdaptor; + SetDimensionSizeOpAdaptor(SetDimensionSizeOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SetDimensionSizeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = SetDimensionSizeOpAdaptor; + template + using GenericAdaptor = SetDimensionSizeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.set_dimension_size"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getSize() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getSizeMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getDimensionAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().dimension); + } + + uint64_t getDimension(); + void setDimensionAttr(::mlir::IntegerAttr attr) { + getProperties().dimension = attr; + } + + void setDimension(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value size, ::mlir::IntegerAttr dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value size, ::mlir::IntegerAttr dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value size, ::mlir::IntegerAttr dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value size, uint64_t dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value size, uint64_t dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value size, uint64_t dimension); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SetDimensionSizeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ShiftLeftOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ShiftLeftOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ShiftLeftOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.shift_left", odsAttrs.getContext()); + } + + ShiftLeftOpGenericAdaptorBase(ShiftLeftOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ShiftLeftOpGenericAdaptor : public detail::ShiftLeftOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ShiftLeftOpGenericAdaptorBase; +public: + ShiftLeftOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ShiftLeftOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ShiftLeftOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ShiftLeftOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ShiftLeftOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ShiftLeftOpGenericAdaptor(RangeT values, const ShiftLeftOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ShiftLeftOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ShiftLeftOpAdaptor : public ShiftLeftOpGenericAdaptor<::mlir::ValueRange> { +public: + using ShiftLeftOpGenericAdaptor::ShiftLeftOpGenericAdaptor; + ShiftLeftOpAdaptor(ShiftLeftOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ShiftLeftOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ShiftLeftOpAdaptor; + template + using GenericAdaptor = ShiftLeftOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.shift_left"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ShiftLeftOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ShiftRightArithmeticOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ShiftRightArithmeticOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ShiftRightArithmeticOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.shift_right_arithmetic", odsAttrs.getContext()); + } + + ShiftRightArithmeticOpGenericAdaptorBase(ShiftRightArithmeticOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ShiftRightArithmeticOpGenericAdaptor : public detail::ShiftRightArithmeticOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ShiftRightArithmeticOpGenericAdaptorBase; +public: + ShiftRightArithmeticOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ShiftRightArithmeticOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ShiftRightArithmeticOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ShiftRightArithmeticOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ShiftRightArithmeticOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ShiftRightArithmeticOpGenericAdaptor(RangeT values, const ShiftRightArithmeticOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ShiftRightArithmeticOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ShiftRightArithmeticOpAdaptor : public ShiftRightArithmeticOpGenericAdaptor<::mlir::ValueRange> { +public: + using ShiftRightArithmeticOpGenericAdaptor::ShiftRightArithmeticOpGenericAdaptor; + ShiftRightArithmeticOpAdaptor(ShiftRightArithmeticOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ShiftRightArithmeticOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ShiftRightArithmeticOpAdaptor; + template + using GenericAdaptor = ShiftRightArithmeticOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.shift_right_arithmetic"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ShiftRightArithmeticOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::ShiftRightLogicalOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ShiftRightLogicalOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ShiftRightLogicalOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.shift_right_logical", odsAttrs.getContext()); + } + + ShiftRightLogicalOpGenericAdaptorBase(ShiftRightLogicalOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ShiftRightLogicalOpGenericAdaptor : public detail::ShiftRightLogicalOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ShiftRightLogicalOpGenericAdaptorBase; +public: + ShiftRightLogicalOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ShiftRightLogicalOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ShiftRightLogicalOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ShiftRightLogicalOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ShiftRightLogicalOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + ShiftRightLogicalOpGenericAdaptor(RangeT values, const ShiftRightLogicalOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ShiftRightLogicalOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ShiftRightLogicalOpAdaptor : public ShiftRightLogicalOpGenericAdaptor<::mlir::ValueRange> { +public: + using ShiftRightLogicalOpGenericAdaptor::ShiftRightLogicalOpGenericAdaptor; + ShiftRightLogicalOpAdaptor(ShiftRightLogicalOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ShiftRightLogicalOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ShiftRightLogicalOpAdaptor; + template + using GenericAdaptor = ShiftRightLogicalOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.shift_right_logical"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::ShiftRightLogicalOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SignOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SignOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SignOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.sign", odsAttrs.getContext()); + } + + SignOpGenericAdaptorBase(SignOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class SignOpGenericAdaptor : public detail::SignOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SignOpGenericAdaptorBase; +public: + SignOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SignOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SignOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SignOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SignOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + SignOpGenericAdaptor(RangeT values, const SignOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SignOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SignOpAdaptor : public SignOpGenericAdaptor<::mlir::ValueRange> { +public: + using SignOpGenericAdaptor::SignOpGenericAdaptor; + SignOpAdaptor(SignOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SignOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SignOpAdaptor; + template + using GenericAdaptor = SignOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.sign"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SignOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SineOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SineOpGenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::stablehlo::ResultAccuracyAttr; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(propStorage); + } + void setResultAccuracy(const ::mlir::stablehlo::ResultAccuracyAttr &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SineOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.sine", odsAttrs.getContext()); + } + + SineOpGenericAdaptorBase(SineOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr(); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); +}; +} // namespace detail +template +class SineOpGenericAdaptor : public detail::SineOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SineOpGenericAdaptorBase; +public: + SineOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SineOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SineOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SineOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SineOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + SineOpGenericAdaptor(RangeT values, const SineOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SineOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SineOpAdaptor : public SineOpGenericAdaptor<::mlir::ValueRange> { +public: + using SineOpGenericAdaptor::SineOpGenericAdaptor; + SineOpAdaptor(SineOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SineOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SineOpAdaptor; + template + using GenericAdaptor = SineOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.sine"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); + void setResultAccuracyAttr(::mlir::stablehlo::ResultAccuracyAttr attr) { + getProperties().result_accuracy = attr; + } + + ::mlir::Attribute removeResultAccuracyAttr() { + auto attr = getProperties().result_accuracy; + getProperties().result_accuracy = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SineOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SliceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SliceOpGenericAdaptorBase { +public: + struct Properties { + using limit_indicesTy = ::mlir::DenseI64ArrayAttr; + limit_indicesTy limit_indices; + + auto getLimitIndices() const { + auto &propStorage = this->limit_indices; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setLimitIndices(const ::mlir::DenseI64ArrayAttr &propValue) { + this->limit_indices = propValue; + } + using start_indicesTy = ::mlir::DenseI64ArrayAttr; + start_indicesTy start_indices; + + auto getStartIndices() const { + auto &propStorage = this->start_indices; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStartIndices(const ::mlir::DenseI64ArrayAttr &propValue) { + this->start_indices = propValue; + } + using stridesTy = ::mlir::DenseI64ArrayAttr; + stridesTy strides; + + auto getStrides() const { + auto &propStorage = this->strides; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStrides(const ::mlir::DenseI64ArrayAttr &propValue) { + this->strides = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.limit_indices == this->limit_indices && + rhs.start_indices == this->start_indices && + rhs.strides == this->strides && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.slice", odsAttrs.getContext()); + } + + SliceOpGenericAdaptorBase(SliceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getStartIndicesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().start_indices); + return attr; + } + + ::llvm::ArrayRef getStartIndices(); + ::mlir::DenseI64ArrayAttr getLimitIndicesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().limit_indices); + return attr; + } + + ::llvm::ArrayRef getLimitIndices(); + ::mlir::DenseI64ArrayAttr getStridesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().strides); + return attr; + } + + ::llvm::ArrayRef getStrides(); +}; +} // namespace detail +template +class SliceOpGenericAdaptor : public detail::SliceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SliceOpGenericAdaptorBase; +public: + SliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SliceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SliceOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + SliceOpGenericAdaptor(RangeT values, const SliceOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SliceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SliceOpAdaptor : public SliceOpGenericAdaptor<::mlir::ValueRange> { +public: + using SliceOpGenericAdaptor::SliceOpGenericAdaptor; + SliceOpAdaptor(SliceOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SliceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultElementType, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SliceOpAdaptor; + template + using GenericAdaptor = SliceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("limit_indices"), ::llvm::StringRef("start_indices"), ::llvm::StringRef("strides")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getLimitIndicesAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getLimitIndicesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getStartIndicesAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getStartIndicesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getStridesAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.slice"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getStartIndicesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().start_indices); + } + + ::llvm::ArrayRef getStartIndices(); + ::mlir::DenseI64ArrayAttr getLimitIndicesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().limit_indices); + } + + ::llvm::ArrayRef getLimitIndices(); + ::mlir::DenseI64ArrayAttr getStridesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().strides); + } + + ::llvm::ArrayRef getStrides(); + void setStartIndicesAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().start_indices = attr; + } + + void setStartIndices(::llvm::ArrayRef attrValue); + void setLimitIndicesAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().limit_indices = attr; + } + + void setLimitIndices(::llvm::ArrayRef attrValue); + void setStridesAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().strides = attr; + } + + void setStrides(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr start_indices, ::mlir::DenseI64ArrayAttr limit_indices, ::mlir::DenseI64ArrayAttr strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr start_indices, ::mlir::DenseI64ArrayAttr limit_indices, ::mlir::DenseI64ArrayAttr strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr start_indices, ::mlir::DenseI64ArrayAttr limit_indices, ::mlir::DenseI64ArrayAttr strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::llvm::ArrayRef start_indices, ::llvm::ArrayRef limit_indices, ::llvm::ArrayRef strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::llvm::ArrayRef start_indices, ::llvm::ArrayRef limit_indices, ::llvm::ArrayRef strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::llvm::ArrayRef start_indices, ::llvm::ArrayRef limit_indices, ::llvm::ArrayRef strides); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SliceOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SortOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SortOpGenericAdaptorBase { +public: + struct Properties { + using dimensionTy = ::mlir::IntegerAttr; + dimensionTy dimension; + + auto getDimension() const { + auto &propStorage = this->dimension; + return ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(propStorage); + } + void setDimension(const ::mlir::IntegerAttr &propValue) { + this->dimension = propValue; + } + using is_stableTy = ::mlir::BoolAttr; + is_stableTy is_stable; + + auto getIsStable() const { + auto &propStorage = this->is_stable; + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(propStorage); + } + void setIsStable(const ::mlir::BoolAttr &propValue) { + this->is_stable = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimension == this->dimension && + rhs.is_stable == this->is_stable && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SortOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.sort", odsAttrs.getContext()); + } + + SortOpGenericAdaptorBase(SortOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::IntegerAttr getDimensionAttr(); + uint64_t getDimension(); + ::mlir::BoolAttr getIsStableAttr(); + bool getIsStable(); + ::mlir::Region &getComparator() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class SortOpGenericAdaptor : public detail::SortOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SortOpGenericAdaptorBase; +public: + SortOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SortOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SortOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SortOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SortOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + SortOpGenericAdaptor(RangeT values, const SortOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SortOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SortOpAdaptor : public SortOpGenericAdaptor<::mlir::ValueRange> { +public: + using SortOpGenericAdaptor::SortOpGenericAdaptor; + SortOpAdaptor(SortOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SortOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = SortOpAdaptor; + template + using GenericAdaptor = SortOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimension"), ::llvm::StringRef("is_stable")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIsStableAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIsStableAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.sort"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Region &getComparator() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getDimensionAttr() { + return ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().dimension); + } + + uint64_t getDimension(); + ::mlir::BoolAttr getIsStableAttr() { + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().is_stable); + } + + bool getIsStable(); + void setDimensionAttr(::mlir::IntegerAttr attr) { + getProperties().dimension = attr; + } + + void setDimension(::std::optional attrValue); + void setIsStableAttr(::mlir::BoolAttr attr) { + getProperties().is_stable = attr; + } + + void setIsStable(::std::optional attrValue); + ::mlir::Attribute removeDimensionAttr() { + auto attr = getProperties().dimension; + getProperties().dimension = {}; + return attr; + } + + ::mlir::Attribute removeIsStableAttr() { + auto attr = getProperties().is_stable; + getProperties().is_stable = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ValueRange inputs, int64_t dimension = -1, bool is_stable = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, /*optional*/::mlir::IntegerAttr dimension, /*optional*/::mlir::BoolAttr is_stable = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, /*optional*/::mlir::IntegerAttr dimension, /*optional*/::mlir::BoolAttr is_stable = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0, ::mlir::ValueRange inputs, /*optional*/uint64_t dimension = -1, /*optional*/bool is_stable = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs, /*optional*/uint64_t dimension = -1, /*optional*/bool is_stable = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SortOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SqrtOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SqrtOpGenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::stablehlo::ResultAccuracyAttr; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(propStorage); + } + void setResultAccuracy(const ::mlir::stablehlo::ResultAccuracyAttr &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SqrtOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.sqrt", odsAttrs.getContext()); + } + + SqrtOpGenericAdaptorBase(SqrtOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr(); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); +}; +} // namespace detail +template +class SqrtOpGenericAdaptor : public detail::SqrtOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SqrtOpGenericAdaptorBase; +public: + SqrtOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SqrtOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SqrtOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SqrtOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SqrtOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + SqrtOpGenericAdaptor(RangeT values, const SqrtOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SqrtOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SqrtOpAdaptor : public SqrtOpGenericAdaptor<::mlir::ValueRange> { +public: + using SqrtOpGenericAdaptor::SqrtOpGenericAdaptor; + SqrtOpAdaptor(SqrtOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SqrtOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SqrtOpAdaptor; + template + using GenericAdaptor = SqrtOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.sqrt"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); + void setResultAccuracyAttr(::mlir::stablehlo::ResultAccuracyAttr attr) { + getProperties().result_accuracy = attr; + } + + ::mlir::Attribute removeResultAccuracyAttr() { + auto attr = getProperties().result_accuracy; + getProperties().result_accuracy = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SqrtOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::SubtractOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SubtractOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SubtractOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.subtract", odsAttrs.getContext()); + } + + SubtractOpGenericAdaptorBase(SubtractOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class SubtractOpGenericAdaptor : public detail::SubtractOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SubtractOpGenericAdaptorBase; +public: + SubtractOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SubtractOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SubtractOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SubtractOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SubtractOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + SubtractOpGenericAdaptor(RangeT values, const SubtractOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SubtractOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SubtractOpAdaptor : public SubtractOpGenericAdaptor<::mlir::ValueRange> { +public: + using SubtractOpGenericAdaptor::SubtractOpGenericAdaptor; + SubtractOpAdaptor(SubtractOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SubtractOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SubtractOpAdaptor; + template + using GenericAdaptor = SubtractOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.subtract"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::SubtractOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::TanOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TanOpGenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::stablehlo::ResultAccuracyAttr; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(propStorage); + } + void setResultAccuracy(const ::mlir::stablehlo::ResultAccuracyAttr &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TanOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.tan", odsAttrs.getContext()); + } + + TanOpGenericAdaptorBase(TanOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr(); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); +}; +} // namespace detail +template +class TanOpGenericAdaptor : public detail::TanOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TanOpGenericAdaptorBase; +public: + TanOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TanOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TanOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TanOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TanOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + TanOpGenericAdaptor(RangeT values, const TanOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TanOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TanOpAdaptor : public TanOpGenericAdaptor<::mlir::ValueRange> { +public: + using TanOpGenericAdaptor::TanOpGenericAdaptor; + TanOpAdaptor(TanOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TanOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TanOpAdaptor; + template + using GenericAdaptor = TanOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.tan"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); + void setResultAccuracyAttr(::mlir::stablehlo::ResultAccuracyAttr attr) { + getProperties().result_accuracy = attr; + } + + ::mlir::Attribute removeResultAccuracyAttr() { + auto attr = getProperties().result_accuracy; + getProperties().result_accuracy = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TanOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::TanhOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TanhOpGenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::stablehlo::ResultAccuracyAttr; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(propStorage); + } + void setResultAccuracy(const ::mlir::stablehlo::ResultAccuracyAttr &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TanhOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.tanh", odsAttrs.getContext()); + } + + TanhOpGenericAdaptorBase(TanhOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr(); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); +}; +} // namespace detail +template +class TanhOpGenericAdaptor : public detail::TanhOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TanhOpGenericAdaptorBase; +public: + TanhOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TanhOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TanhOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TanhOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TanhOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + TanhOpGenericAdaptor(RangeT values, const TanhOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TanhOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TanhOpAdaptor : public TanhOpGenericAdaptor<::mlir::ValueRange> { +public: + using TanhOpGenericAdaptor::TanhOpGenericAdaptor; + TanhOpAdaptor(TanhOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TanhOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TanhOpAdaptor; + template + using GenericAdaptor = TanhOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.tanh"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracyAttr() { + return ::llvm::dyn_cast_or_null<::mlir::stablehlo::ResultAccuracyAttr>(getProperties().result_accuracy); + } + + ::mlir::stablehlo::ResultAccuracyAttr getResultAccuracy(); + void setResultAccuracyAttr(::mlir::stablehlo::ResultAccuracyAttr attr) { + getProperties().result_accuracy = attr; + } + + ::mlir::Attribute removeResultAccuracyAttr() { + auto attr = getProperties().result_accuracy; + getProperties().result_accuracy = {}; + return attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, /*optional*/::mlir::stablehlo::ResultAccuracyAttr result_accuracy = nullptr); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TanhOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::TorchIndexSelectOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TorchIndexSelectOpGenericAdaptorBase { +public: + struct Properties { + using batch_dimsTy = ::mlir::IntegerAttr; + batch_dimsTy batch_dims; + + auto getBatchDims() const { + auto &propStorage = this->batch_dims; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setBatchDims(const ::mlir::IntegerAttr &propValue) { + this->batch_dims = propValue; + } + using dimTy = ::mlir::IntegerAttr; + dimTy dim; + + auto getDim() const { + auto &propStorage = this->dim; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setDim(const ::mlir::IntegerAttr &propValue) { + this->dim = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.batch_dims == this->batch_dims && + rhs.dim == this->dim && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TorchIndexSelectOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.torch_index_select", odsAttrs.getContext()); + } + + TorchIndexSelectOpGenericAdaptorBase(TorchIndexSelectOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::IntegerAttr getDimAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().dim); + return attr; + } + + uint64_t getDim(); + ::mlir::IntegerAttr getBatchDimsAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().batch_dims); + return attr; + } + + uint64_t getBatchDims(); +}; +} // namespace detail +template +class TorchIndexSelectOpGenericAdaptor : public detail::TorchIndexSelectOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TorchIndexSelectOpGenericAdaptorBase; +public: + TorchIndexSelectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TorchIndexSelectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TorchIndexSelectOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TorchIndexSelectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TorchIndexSelectOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + TorchIndexSelectOpGenericAdaptor(RangeT values, const TorchIndexSelectOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TorchIndexSelectOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getIndex() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TorchIndexSelectOpAdaptor : public TorchIndexSelectOpGenericAdaptor<::mlir::ValueRange> { +public: + using TorchIndexSelectOpGenericAdaptor::TorchIndexSelectOpGenericAdaptor; + TorchIndexSelectOpAdaptor(TorchIndexSelectOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TorchIndexSelectOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TorchIndexSelectOpAdaptor; + template + using GenericAdaptor = TorchIndexSelectOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("batch_dims"), ::llvm::StringRef("dim")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBatchDimsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBatchDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getDimAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.torch_index_select"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getIndex() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getIndexMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getDimAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().dim); + } + + uint64_t getDim(); + ::mlir::IntegerAttr getBatchDimsAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().batch_dims); + } + + uint64_t getBatchDims(); + void setDimAttr(::mlir::IntegerAttr attr) { + getProperties().dim = attr; + } + + void setDim(uint64_t attrValue); + void setBatchDimsAttr(::mlir::IntegerAttr attr) { + getProperties().batch_dims = attr; + } + + void setBatchDims(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value index, ::mlir::IntegerAttr dim, ::mlir::IntegerAttr batch_dims); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value index, ::mlir::IntegerAttr dim, ::mlir::IntegerAttr batch_dims); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::Value index, uint64_t dim, uint64_t batch_dims); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value index, uint64_t dim, uint64_t batch_dims); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TorchIndexSelectOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::TransposeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TransposeOpGenericAdaptorBase { +public: + struct Properties { + using permutationTy = ::mlir::DenseI64ArrayAttr; + permutationTy permutation; + + auto getPermutation() const { + auto &propStorage = this->permutation; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setPermutation(const ::mlir::DenseI64ArrayAttr &propValue) { + this->permutation = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.permutation == this->permutation && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TransposeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.transpose", odsAttrs.getContext()); + } + + TransposeOpGenericAdaptorBase(TransposeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::DenseI64ArrayAttr getPermutationAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().permutation); + return attr; + } + + ::llvm::ArrayRef getPermutation(); +}; +} // namespace detail +template +class TransposeOpGenericAdaptor : public detail::TransposeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TransposeOpGenericAdaptorBase; +public: + TransposeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TransposeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TransposeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TransposeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TransposeOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + TransposeOpGenericAdaptor(RangeT values, const TransposeOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TransposeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TransposeOpAdaptor : public TransposeOpGenericAdaptor<::mlir::ValueRange> { +public: + using TransposeOpGenericAdaptor::TransposeOpGenericAdaptor; + TransposeOpAdaptor(TransposeOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TransposeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultElementType, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TransposeOpAdaptor; + template + using GenericAdaptor = TransposeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("permutation")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getPermutationAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getPermutationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.transpose"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getPermutationAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().permutation); + } + + ::llvm::ArrayRef getPermutation(); + void setPermutationAttr(::mlir::DenseI64ArrayAttr attr) { + getProperties().permutation = attr; + } + + void setPermutation(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr permutation); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr permutation); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::DenseI64ArrayAttr permutation); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::llvm::ArrayRef permutation); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::llvm::ArrayRef permutation); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::llvm::ArrayRef permutation); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + ::llvm::LogicalResult reifyReturnTypeShapes(::mlir::OpBuilder&builder, ::mlir::ValueRange operands, ::llvm::SmallVectorImpl<::mlir::Value> &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TransposeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::TriangularSolveOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TriangularSolveOpGenericAdaptorBase { +public: + struct Properties { + using left_sideTy = ::mlir::BoolAttr; + left_sideTy left_side; + + auto getLeftSide() const { + auto &propStorage = this->left_side; + return ::llvm::cast<::mlir::BoolAttr>(propStorage); + } + void setLeftSide(const ::mlir::BoolAttr &propValue) { + this->left_side = propValue; + } + using lowerTy = ::mlir::BoolAttr; + lowerTy lower; + + auto getLower() const { + auto &propStorage = this->lower; + return ::llvm::cast<::mlir::BoolAttr>(propStorage); + } + void setLower(const ::mlir::BoolAttr &propValue) { + this->lower = propValue; + } + using transpose_aTy = ::mlir::stablehlo::TransposeAttr; + transpose_aTy transpose_a; + + auto getTransposeA() const { + auto &propStorage = this->transpose_a; + return ::llvm::cast<::mlir::stablehlo::TransposeAttr>(propStorage); + } + void setTransposeA(const ::mlir::stablehlo::TransposeAttr &propValue) { + this->transpose_a = propValue; + } + using unit_diagonalTy = ::mlir::BoolAttr; + unit_diagonalTy unit_diagonal; + + auto getUnitDiagonal() const { + auto &propStorage = this->unit_diagonal; + return ::llvm::cast<::mlir::BoolAttr>(propStorage); + } + void setUnitDiagonal(const ::mlir::BoolAttr &propValue) { + this->unit_diagonal = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.left_side == this->left_side && + rhs.lower == this->lower && + rhs.transpose_a == this->transpose_a && + rhs.unit_diagonal == this->unit_diagonal && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TriangularSolveOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.triangular_solve", odsAttrs.getContext()); + } + + TriangularSolveOpGenericAdaptorBase(TriangularSolveOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::BoolAttr getLeftSideAttr() { + auto attr = ::llvm::cast<::mlir::BoolAttr>(getProperties().left_side); + return attr; + } + + bool getLeftSide(); + ::mlir::BoolAttr getLowerAttr() { + auto attr = ::llvm::cast<::mlir::BoolAttr>(getProperties().lower); + return attr; + } + + bool getLower(); + ::mlir::BoolAttr getUnitDiagonalAttr() { + auto attr = ::llvm::cast<::mlir::BoolAttr>(getProperties().unit_diagonal); + return attr; + } + + bool getUnitDiagonal(); + ::mlir::stablehlo::TransposeAttr getTransposeAAttr() { + auto attr = ::llvm::cast<::mlir::stablehlo::TransposeAttr>(getProperties().transpose_a); + return attr; + } + + ::mlir::stablehlo::Transpose getTransposeA(); +}; +} // namespace detail +template +class TriangularSolveOpGenericAdaptor : public detail::TriangularSolveOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TriangularSolveOpGenericAdaptorBase; +public: + TriangularSolveOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TriangularSolveOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TriangularSolveOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TriangularSolveOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TriangularSolveOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + TriangularSolveOpGenericAdaptor(RangeT values, const TriangularSolveOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TriangularSolveOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + ValueT getB() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TriangularSolveOpAdaptor : public TriangularSolveOpGenericAdaptor<::mlir::ValueRange> { +public: + using TriangularSolveOpGenericAdaptor::TriangularSolveOpGenericAdaptor; + TriangularSolveOpAdaptor(TriangularSolveOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TriangularSolveOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultElementType, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType> { +public: + using Op::Op; + using Op::print; + using Adaptor = TriangularSolveOpAdaptor; + template + using GenericAdaptor = TriangularSolveOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("left_side"), ::llvm::StringRef("lower"), ::llvm::StringRef("transpose_a"), ::llvm::StringRef("unit_diagonal")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getLeftSideAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getLeftSideAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getLowerAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getLowerAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getTransposeAAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getTransposeAAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getUnitDiagonalAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getUnitDiagonalAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.triangular_solve"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getB() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getBMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::BoolAttr getLeftSideAttr() { + return ::llvm::cast<::mlir::BoolAttr>(getProperties().left_side); + } + + bool getLeftSide(); + ::mlir::BoolAttr getLowerAttr() { + return ::llvm::cast<::mlir::BoolAttr>(getProperties().lower); + } + + bool getLower(); + ::mlir::BoolAttr getUnitDiagonalAttr() { + return ::llvm::cast<::mlir::BoolAttr>(getProperties().unit_diagonal); + } + + bool getUnitDiagonal(); + ::mlir::stablehlo::TransposeAttr getTransposeAAttr() { + return ::llvm::cast<::mlir::stablehlo::TransposeAttr>(getProperties().transpose_a); + } + + ::mlir::stablehlo::Transpose getTransposeA(); + void setLeftSideAttr(::mlir::BoolAttr attr) { + getProperties().left_side = attr; + } + + void setLeftSide(bool attrValue); + void setLowerAttr(::mlir::BoolAttr attr) { + getProperties().lower = attr; + } + + void setLower(bool attrValue); + void setUnitDiagonalAttr(::mlir::BoolAttr attr) { + getProperties().unit_diagonal = attr; + } + + void setUnitDiagonal(bool attrValue); + void setTransposeAAttr(::mlir::stablehlo::TransposeAttr attr) { + getProperties().transpose_a = attr; + } + + void setTransposeA(::mlir::stablehlo::Transpose attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr left_side, ::mlir::BoolAttr lower, ::mlir::BoolAttr unit_diagonal, ::mlir::stablehlo::TransposeAttr transpose_a); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr left_side, ::mlir::BoolAttr lower, ::mlir::BoolAttr unit_diagonal, ::mlir::stablehlo::TransposeAttr transpose_a); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::BoolAttr left_side, ::mlir::BoolAttr lower, ::mlir::BoolAttr unit_diagonal, ::mlir::stablehlo::TransposeAttr transpose_a); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value a, ::mlir::Value b, bool left_side, bool lower, bool unit_diagonal, ::mlir::stablehlo::Transpose transpose_a); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, bool left_side, bool lower, bool unit_diagonal, ::mlir::stablehlo::Transpose transpose_a); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, bool left_side, bool lower, bool unit_diagonal, ::mlir::stablehlo::Transpose transpose_a); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 4 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + /// Interface method for ConditionallySpeculatable. + mlir::Speculation::Speculatability getSpeculatability(); +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TriangularSolveOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::TupleOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TupleOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TupleOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.tuple", odsAttrs.getContext()); + } + + TupleOpGenericAdaptorBase(TupleOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class TupleOpGenericAdaptor : public detail::TupleOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TupleOpGenericAdaptorBase; +public: + TupleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TupleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TupleOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TupleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TupleOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + TupleOpGenericAdaptor(RangeT values, const TupleOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TupleOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getVal() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TupleOpAdaptor : public TupleOpGenericAdaptor<::mlir::ValueRange> { +public: + using TupleOpGenericAdaptor::TupleOpGenericAdaptor; + TupleOpAdaptor(TupleOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TupleOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TupleOpAdaptor; + template + using GenericAdaptor = TupleOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.tuple"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getVal() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getValMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange val); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TupleOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::UnaryEinsumOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class UnaryEinsumOpGenericAdaptorBase { +public: + struct Properties { + using einsum_configTy = ::mlir::StringAttr; + einsum_configTy einsum_config; + + auto getEinsumConfig() const { + auto &propStorage = this->einsum_config; + return ::llvm::cast<::mlir::StringAttr>(propStorage); + } + void setEinsumConfig(const ::mlir::StringAttr &propValue) { + this->einsum_config = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.einsum_config == this->einsum_config && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + UnaryEinsumOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.unary_einsum", odsAttrs.getContext()); + } + + UnaryEinsumOpGenericAdaptorBase(UnaryEinsumOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::StringAttr getEinsumConfigAttr() { + auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().einsum_config); + return attr; + } + + ::llvm::StringRef getEinsumConfig(); +}; +} // namespace detail +template +class UnaryEinsumOpGenericAdaptor : public detail::UnaryEinsumOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::UnaryEinsumOpGenericAdaptorBase; +public: + UnaryEinsumOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + UnaryEinsumOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : UnaryEinsumOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + UnaryEinsumOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : UnaryEinsumOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + UnaryEinsumOpGenericAdaptor(RangeT values, const UnaryEinsumOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + UnaryEinsumOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class UnaryEinsumOpAdaptor : public UnaryEinsumOpGenericAdaptor<::mlir::ValueRange> { +public: + using UnaryEinsumOpGenericAdaptor::UnaryEinsumOpGenericAdaptor; + UnaryEinsumOpAdaptor(UnaryEinsumOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class UnaryEinsumOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = UnaryEinsumOpAdaptor; + template + using GenericAdaptor = UnaryEinsumOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("einsum_config")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getEinsumConfigAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getEinsumConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.unary_einsum"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getEinsumConfigAttr() { + return ::llvm::cast<::mlir::StringAttr>(getProperties().einsum_config); + } + + ::llvm::StringRef getEinsumConfig(); + void setEinsumConfigAttr(::mlir::StringAttr attr) { + getProperties().einsum_config = attr; + } + + void setEinsumConfig(::llvm::StringRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::mlir::StringAttr einsum_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::StringAttr einsum_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value operand, ::llvm::StringRef einsum_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::llvm::StringRef einsum_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::UnaryEinsumOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::UniformDequantizeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class UniformDequantizeOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + UniformDequantizeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.uniform_dequantize", odsAttrs.getContext()); + } + + UniformDequantizeOpGenericAdaptorBase(UniformDequantizeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class UniformDequantizeOpGenericAdaptor : public detail::UniformDequantizeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::UniformDequantizeOpGenericAdaptorBase; +public: + UniformDequantizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + UniformDequantizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : UniformDequantizeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + UniformDequantizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : UniformDequantizeOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + UniformDequantizeOpGenericAdaptor(RangeT values, const UniformDequantizeOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + UniformDequantizeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class UniformDequantizeOpAdaptor : public UniformDequantizeOpGenericAdaptor<::mlir::ValueRange> { +public: + using UniformDequantizeOpGenericAdaptor::UniformDequantizeOpGenericAdaptor; + UniformDequantizeOpAdaptor(UniformDequantizeOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class UniformDequantizeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::InferTensorType, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = UniformDequantizeOpAdaptor; + template + using GenericAdaptor = UniformDequantizeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.uniform_dequantize"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::UniformDequantizeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::UniformQuantizeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class UniformQuantizeOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + UniformQuantizeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.uniform_quantize", odsAttrs.getContext()); + } + + UniformQuantizeOpGenericAdaptorBase(UniformQuantizeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class UniformQuantizeOpGenericAdaptor : public detail::UniformQuantizeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::UniformQuantizeOpGenericAdaptorBase; +public: + UniformQuantizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + UniformQuantizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : UniformQuantizeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + UniformQuantizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : UniformQuantizeOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + UniformQuantizeOpGenericAdaptor(RangeT values, const UniformQuantizeOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + UniformQuantizeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class UniformQuantizeOpAdaptor : public UniformQuantizeOpGenericAdaptor<::mlir::ValueRange> { +public: + using UniformQuantizeOpGenericAdaptor::UniformQuantizeOpGenericAdaptor; + UniformQuantizeOpAdaptor(UniformQuantizeOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class UniformQuantizeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::Elementwise, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfStaticDimInOutputIsStaticInInputImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = UniformQuantizeOpAdaptor; + template + using GenericAdaptor = UniformQuantizeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.uniform_quantize"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::UniformQuantizeOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::WhileOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class WhileOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + WhileOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.while", odsAttrs.getContext()); + } + + WhileOpGenericAdaptorBase(WhileOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Region &getCond() { + return *odsRegions[0]; + } + + ::mlir::Region &getBody() { + return *odsRegions[1]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class WhileOpGenericAdaptor : public detail::WhileOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::WhileOpGenericAdaptorBase; +public: + WhileOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + WhileOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : WhileOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + WhileOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : WhileOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + WhileOpGenericAdaptor(RangeT values, const WhileOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + WhileOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperand() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class WhileOpAdaptor : public WhileOpGenericAdaptor<::mlir::ValueRange> { +public: + using WhileOpGenericAdaptor::WhileOpGenericAdaptor; + WhileOpAdaptor(WhileOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class WhileOp : public ::mlir::Op::Impl, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::RecursivelySpeculatableImplTrait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = WhileOpAdaptor; + template + using GenericAdaptor = WhileOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.while"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getOperand() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getOperandMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Region &getCond() { + return (*this)->getRegion(0); + } + + ::mlir::Region &getBody() { + return (*this)->getRegion(1); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + ::llvm::LogicalResult verify(); + static ::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + // Method of OpAsmOpInterface used during custom printing to name the block + // arguments in the nested regions. We name both the condition and the body + // regions entry arguments the same way, with a `iterArg` prefix. Since the + // two regions are side-by-side they will have the same name, which allows + // us to print them once and share it for the two regions, and still be able + // to parse them back. + void getAsmBlockArgumentNames(Region ®ion, OpAsmSetValueNameFn setNameFn) { + for (BlockArgument arg : region.getArguments()) + setNameFn(arg, "iterArg"); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::WhileOp) + +namespace mlir { +namespace stablehlo { + +//===----------------------------------------------------------------------===// +// ::mlir::stablehlo::XorOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class XorOpGenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + XorOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("stablehlo.xor", odsAttrs.getContext()); + } + + XorOpGenericAdaptorBase(XorOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class XorOpGenericAdaptor : public detail::XorOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::XorOpGenericAdaptorBase; +public: + XorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + XorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : XorOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + XorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : XorOpGenericAdaptor(values, attrs, Properties{}, {}) {} + + XorOpGenericAdaptor(RangeT values, const XorOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + XorOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class XorOpAdaptor : public XorOpGenericAdaptor<::mlir::ValueRange> { +public: + using XorOpGenericAdaptor::XorOpGenericAdaptor; + XorOpAdaptor(XorOp op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class XorOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::hlo::OpTrait::IsCommutative, ::mlir::InferTypeOpInterface::Trait, ::mlir::InferShapedTypeOpInterface::Trait, ::mlir::hlo::OpTrait::CompatibleOperandsAndResultType, ::mlir::ConditionallySpeculatable::Trait, ::mlir::hlo::OpTrait::SpeculatableIfAllInputsStaticImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultShape, ::mlir::OpTrait::Elementwise> { +public: + using Op::Op; + using Op::print; + using Adaptor = XorOpAdaptor; + template + using GenericAdaptor = XorOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("stablehlo.xor"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::RankedTensorType> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + static ::llvm::LogicalResult inferReturnTypeComponents(::mlir::MLIRContext*context, ::std::optional<::mlir::Location> location, ::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents>&inferredReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + // Relax the strict default implementation with one that allows + // for StableHLO-specific differences. + static bool isCompatibleReturnTypes(TypeRange l, TypeRange r) { + return mlir::hlo::isCompatibleForHloTypeInference(l, r); + } + + LogicalResult reifyReturnTypeShapes( + OpBuilder& builder, ValueRange operands, + SmallVectorImpl& reifiedReturnShapes) { + return ::mlir::hlo::deriveShapeFromOperand(&builder, getOperation(), + operands.front(), + &reifiedReturnShapes); + } +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::XorOp) + + +#endif // GET_OP_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloTypeDefs.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloTypeDefs.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..aec3773db5251ded2ba7fdcedfd74024ec093dfd --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloTypeDefs.cpp.inc @@ -0,0 +1,46 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* TypeDef Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_TYPEDEF_LIST +#undef GET_TYPEDEF_LIST + +::mlir::stablehlo::TokenType + +#endif // GET_TYPEDEF_LIST + +#ifdef GET_TYPEDEF_CLASSES +#undef GET_TYPEDEF_CLASSES + +static ::mlir::OptionalParseResult generatedTypeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type &value) { + return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser) + .Case(::mlir::stablehlo::TokenType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::stablehlo::TokenType::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Default([&](llvm::StringRef keyword, llvm::SMLoc) { + *mnemonic = keyword; + return std::nullopt; + }); +} + +static ::llvm::LogicalResult generatedTypePrinter(::mlir::Type def, ::mlir::AsmPrinter &printer) { + return ::llvm::TypeSwitch<::mlir::Type, ::llvm::LogicalResult>(def) .Case<::mlir::stablehlo::TokenType>([&](auto t) { + printer << ::mlir::stablehlo::TokenType::getMnemonic(); + return ::mlir::success(); + }) + .Default([](auto) { return ::mlir::failure(); }); +} + +namespace mlir { +namespace stablehlo { +} // namespace stablehlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TokenType) + +#endif // GET_TYPEDEF_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloTypeDefs.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloTypeDefs.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..646f9d023e9018afee403321372f94c6e8d45e8e --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/StablehloTypeDefs.h.inc @@ -0,0 +1,35 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* TypeDef Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_TYPEDEF_CLASSES +#undef GET_TYPEDEF_CLASSES + + +namespace mlir { +class AsmParser; +class AsmPrinter; +} // namespace mlir +namespace mlir { +namespace stablehlo { +class TokenType; +class TokenType : public ::mlir::Type::TypeBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral name = "stablehlo.token"; + static constexpr ::llvm::StringLiteral dialectName = "stablehlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"token"}; + } + +}; +} // namespace stablehlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::stablehlo::TokenType) + +#endif // GET_TYPEDEF_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/TypeInference.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/TypeInference.h new file mode 100644 index 0000000000000000000000000000000000000000..d34e75ca35737828b1fa052958858e99f845bbff --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/TypeInference.h @@ -0,0 +1,611 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + Copyright 2022 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_STABLEHLO_TYPE_INFERENCE_H +#define STABLEHLO_DIALECT_STABLEHLO_TYPE_INFERENCE_H + +#include + +#include "mlir/IR/BuiltinAttributes.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/Dialect.h" +#include "mlir/IR/Location.h" +#include "mlir/IR/SymbolTable.h" +#include "mlir/IR/Types.h" +#include "mlir/Interfaces/InferTypeOpInterface.h" +#include "mlir/Support/LLVM.h" +#include "mlir/Support/LogicalResult.h" +#include "stablehlo/dialect/Base.h" + +namespace mlir { +namespace hlo { + +//===----------------------------------------------------------------------===// +// Utilities for shape functions +//===----------------------------------------------------------------------===// + +void reifyGatherDimSizes(int64_t resultRank, + llvm::function_ref getStartIndicesDim, + llvm::function_ref getSliceDim, + ArrayRef offsetDims, + ArrayRef collapsedSliceDims, + ArrayRef operandBatchingDims, + int64_t indexVectorDim, SmallVectorImpl& shape); + +// Convert a Nx2 dense int64 padding attribute to a list of tuples. +FailureOr>> convertPaddingAttribute( + std::optional optionalAttr, + std::optional loc); + +// Convert a 1D dense bool attribute to a list of values. +FailureOr> convertWindowReversalAttribute( + std::optional optionalAttr, std::optional loc, + StringRef attrName); + +LogicalResult checkDimInBounds(std::optional loc, int64_t dim, + int64_t upperBound, StringRef dimName, + StringRef upperBoundName, + bool upperBoundInclusive = false); + +LogicalResult checkDimsDistinct(std::optional loc, + ArrayRef lhsDims, + ArrayRef rhsDims, llvm::StringRef lhs, + llvm::StringRef rhs); + +bool verifyCompatibleDims(int64_t dimSize1, int64_t dimSize2); + +// WindowDimension described how the kernel window moves across the base area +// in a particular dimension. +// Describes the windowing in an operation such as convolution. +// The window is moved across a base area and for each position of the +// window a computation is performed. The field below describes the +// window and the movement of the window across a base area. +struct WindowDimension { + int64_t size = 0; + int64_t stride = 1; + int64_t paddingLow = 0; + int64_t paddingHigh = 0; + int64_t windowDilation = 1; + int64_t baseDilation = 1; + bool windowReversal = false; +}; + +FailureOr> +verifyWindowAttributesAndInferWindowDimensions( + ArrayRef windowDimensions, ArrayRef windowStrides, + ArrayRef> padding, + ArrayRef lhsDilation, ArrayRef rhsDilation, + ArrayRef windowReversal, std::optional loc); + +SmallVector inferWindowOutputShape(ArrayRef baseShape, + ArrayRef window); + +LogicalResult verifyReplicaGroups(std::optional location, + DenseIntElementsAttr replicaGroups, + bool allGroupsMustHaveSameSize, + bool useGlobalDeviceIds, + std::optional expectedGroupSize); + +LogicalResult verifyPrecisionConfig(std::optional loc, + std::optional maybeArrayAttr); + +LogicalResult verifyConvolutionAttributes( + std::optional location, Type lhsType, Type rhsType, + int64_t inputBatchDimension, int64_t inputFeatureDimension, + ArrayRef inputSpatialDimensions, + int64_t kernelInputFeatureDimension, int64_t kernelOutputFeatureDimension, + ArrayRef kernelSpatialDimensions, int64_t outputBatchDimension, + int64_t outputFeatureDimension, ArrayRef outputSpatialDimensions, + int64_t featureGroupCount, int64_t batchGroupCount, + std::optional precisionConfig); + +//===----------------------------------------------------------------------===// +// Shape functions for ops. +//===----------------------------------------------------------------------===// +// These functions have been moved out of StablehloOps.cpp in order to be +// shared with the MHLO dialect. +// Because of that, they cannot use any definitions in the StableHLO dialect +// (definitions in Base are fine, because they are shared with MHLO). +// As a result, these definitions (e.g. StableHLO ops and attributes) are +// decomposed into smaller pieces which are passed as individual parameters. +// These parameters have the same names as in the ODS and come in the same +// order in which they are declared in the ODS. + +LogicalResult inferAbsOp(std::optional, Value operand, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferAfterAllOp(HloDialectInterface* dialect, + std::optional location, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferAllToAllOp( + std::optional location, ValueRange operands, + int64_t splitDimension, int64_t concatDimension, int64_t splitCount, + DenseIntElementsAttr replicaGroups, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferAllReduceOp( + std::optional location, ValueRange operands, Region& computation, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferBatchNormGradOp( + std::optional location, Value operand, Value scale, Value mean, + Value variance, Value gradOutput, int64_t featureIndex, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferBatchNormInferenceOp( + std::optional location, Value operand, Value scale, Value offset, + Value mean, Value variance, int64_t featureIndex, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferBatchNormTrainingOp( + std::optional location, Value operand, Value scale, Value offset, + int64_t featureIndex, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferBroadcastOp( + std::optional location, Value operand, + ArrayRef broadcastSizes, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferCaseOp(std::optional location, Value index, + RegionRange branches, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferCholeskyOp( + std::optional location, Value a, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferClampOp( + std::optional location, Value min, Value operand, Value max, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferCollectiveBroadcastOp( + std::optional, ValueRange operands, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferCollectivePermuteOp( + std::optional, ValueRange operands, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferCompareOp( + MLIRContext* context, std::optional, Value lhs, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferComplexOp(std::optional location, Value lhs, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferConcatenateOp(std::optional location, + TypeRange inputTypes, int64_t dimension, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferConstantOp(std::optional, ElementsAttr value, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferConvertOp( + std::optional location, Value operand, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferConvolutionOp( + std::optional location, Type lhsType, Type rhsType, + std::optional> windowStrides, + std::optional padding, + std::optional> lhsDilation, + std::optional> rhsDilation, + std::optional> windowReversal, int64_t inputBatchDimension, + int64_t inputFeatureDimension, ArrayRef inputSpatialDimensions, + int64_t kernelInputFeatureDimension, int64_t kernelOutputFeatureDimension, + ArrayRef kernelSpatialDimensions, int64_t outputBatchDimension, + int64_t outputFeatureDimension, ArrayRef outputSpatialDimensions, + int64_t featureGroupCount, int64_t batchGroupCount, + std::optional precisionConfig, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferCreateTokenOp(HloDialectInterface* dialect, + std::optional location, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferDotOp( + std::optional location, RankedTensorType lhsType, + RankedTensorType rhsType, std::optional precisionConfig, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult checkDotGeneralConstraints( + std::optional location, Type lhsType, Type rhsType, + ArrayRef lhsBatchingDimensions, + ArrayRef rhsBatchingDimensions, + ArrayRef lhsContractingDimensions, + ArrayRef rhsContractingDimensions, + std::optional precisionConfig); + +LogicalResult inferDotGeneralOp( + std::optional location, Type lhsType, Type rhsType, + ArrayRef lhsBatchingDimensions, + ArrayRef rhsBatchingDimensions, + ArrayRef lhsContractingDimensions, + ArrayRef rhsContractingDimensions, + std::optional precisionConfig, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferDynamicConvOp( + std::optional location, Type lhsType, Type rhsType, Value padding, + std::optional> windowStrides, + std::optional> lhsDilation, + std::optional> rhsDilation, + std::optional> windowReversal, int64_t inputBatchDimension, + int64_t inputFeatureDimension, ArrayRef inputSpatialDimensions, + int64_t kernelInputFeatureDimension, int64_t kernelOutputFeatureDimension, + ArrayRef kernelSpatialDimensions, int64_t outputBatchDimension, + int64_t outputFeatureDimension, ArrayRef outputSpatialDimensions, + int64_t featureGroupCount, int64_t batchGroupCount, + std::optional precisionConfig, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferDynamicGatherOp( + std::optional location, Value operand, Value startIndices, + Value sliceSizes, ArrayRef offsetDims, + ArrayRef collapsedSliceDims, ArrayRef operandBatchingDims, + ArrayRef startIndicesBatchingDims, ArrayRef startIndexMap, + int64_t indexVectorDim, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferDynamicSliceOp( + std::optional location, Type operandType, + TypeRange startIndicesTypes, ArrayRef sliceSizes, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferDynamicUpdateSliceOp( + std::optional location, Value operand, Value update, + ValueRange startIndices, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferFftOp( + std::optional location, Value operand, bool isFftTypeRfft, + bool isFftTypeIrfft, ArrayRef fftLength, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferGatherOp( + std::optional location, Value operand, Value startIndices, + ArrayRef offsetDims, ArrayRef collapsedSliceDims, + ArrayRef operandBatchingDims, + ArrayRef startIndicesBatchingDims, ArrayRef startIndexMap, + int64_t indexVectorDim, ArrayRef sliceSizes, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferGetDimensionSizeOp( + std::optional location, Type operandType, int64_t dimension, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferGetTupleElementOp( + std::optional location, Value operand, int32_t index, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferImagOp(std::optional location, Value operand, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferIsFiniteOp(MLIRContext* context, std::optional, + Value x, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferIfOp(std::optional location, Value pred, + RegionRange branches, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferMapOp( + std::optional location, ValueRange inputs, + ArrayRef dimensions, Region& computation, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferOptimizationBarrierOp( + std::optional location, ValueRange operand, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferOutfeedOp(HloDialectInterface* dialect, + std::optional location, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferPadOp(std::optional location, Type operandType, + Type paddingValueType, + ArrayRef edgePaddingLow, + ArrayRef edgePaddingHigh, + ArrayRef interiorPadding, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferPartitionIdOp(MLIRContext* context, + std::optional location, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferRealOp(std::optional location, Value operand, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferReduceOp( + std::optional location, TypeRange inputTypes, + ArrayRef dimensions, Region& body, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferReduceWindowOp( + std::optional location, ValueRange inputs, ValueRange initValues, + ArrayRef windowDimensions, + std::optional> windowStrides, + std::optional> baseDilations, + std::optional> windowDilations, + std::optional padding, Region& body, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferReplicaIdOp(MLIRContext* context, std::optional, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferReverseOp(std::optional location, Type operandType, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferRngOp( + std::optional location, Value a, Value b, Value shape, + bool isRngDistributionUniform, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferScatterOp(std::optional location, + ValueRange inputs, Region& update_computation, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferSelectOp( + std::optional location, Value pred, Value onTrue, Value onFalse, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferSelectAndScatterOp( + std::optional location, Value operand, Region& scatter, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferSendOp(HloDialectInterface* dialect, + std::optional location, + bool isDeviceToDevice, bool isDeviceToHost, + bool isHostTransfer, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferSetDimensionSizeOp( + HloDialectInterface* dialect, std::optional location, + Type operandType, Value size, int64_t dimension, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferSliceOp(std::optional location, Type operandType, + ArrayRef startIndices, + ArrayRef limitIndices, + ArrayRef strides, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferSortOp( + std::optional location, ValueRange inputs, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferTopKOp( + std::optional location, Value operand, int64_t k, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferTransposeOp(std::optional loc, Value operand, + ArrayRef permutation, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferTriangularSolveOp( + std::optional location, Value a, Value b, bool leftSide, + bool isTransposeAInvalid, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferTupleOp(MLIRContext* context, + std::optional location, ValueRange val, + SmallVectorImpl& inferredReturnTypes); + +LogicalResult inferUniformDequantizeOp( + std::optional location, Value operand, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferUniformQuantizeOp( + std::optional location, Value operand, + SmallVectorImpl& inferredReturnShapes); + +LogicalResult inferWhileOp(std::optional location, ValueRange operand, + SmallVectorImpl& inferredReturnTypes); + +//===----------------------------------------------------------------------===// +// Verifiers for ops. +//===----------------------------------------------------------------------===// + +LogicalResult verifyAddOp(std::optional location, Operation* op, + Type lhsType, Type rhsType, Type resultType); + +LogicalResult verifyAllGatherOp(std::optional location, + ValueRange operands, int64_t allGatherDim, + DenseIntElementsAttr replicaGroups, + int64_t channelId, bool useGlobalDeviceIds, + ValueRange results); + +LogicalResult verifyAllReduceOp(std::optional location, + ValueRange operands, + DenseIntElementsAttr replicaGroups, + int64_t channelId, bool useGlobalDeviceIds, + Region& computation); + +LogicalResult verifyBitcastConvertOp(std::optional location, + Value operand, Value result); + +LogicalResult verifyBroadcastInDimOp(std::optional location, + Value operand, + ArrayRef broadcastDimensions, + Value result); + +LogicalResult verifyCollectiveBroadcastOp(std::optional location, + DenseIntElementsAttr replicaGroups); + +LogicalResult verifyCollectivePermuteOp(std::optional location, + DenseIntElementsAttr sourceTargetPairs); + +LogicalResult verifyCompositeOp(std::optional location, Operation* op, + StringRef name, StringRef decomposition, + SymbolTableCollection& symbolTable); + +LogicalResult verifyConvolutionOp( + std::optional location, Type lhsType, Type rhsType, + std::optional> windowStrides, + std::optional padding, + std::optional> lhsDilation, + std::optional> rhsDilation, + std::optional> windowReversal, int64_t inputBatchDimension, + int64_t inputFeatureDimension, ArrayRef inputSpatialDimensions, + int64_t kernelInputFeatureDimension, int64_t kernelOutputFeatureDimension, + ArrayRef kernelSpatialDimensions, int64_t outputBatchDimension, + int64_t outputFeatureDimension, ArrayRef outputSpatialDimensions, + int64_t featureGroupCount, int64_t batchGroupCount, + std::optional precisionConfig, Type resultType); + +LogicalResult verifyDotOp(std::optional location, + RankedTensorType lhsType, RankedTensorType rhsType, + std::optional precisionConfig, + Value result); + +LogicalResult verifyDotGeneralOp(std::optional location, Value lhs, + Value rhs, + ArrayRef lhsBatchingDimensions, + ArrayRef rhsBatchingDimensions, + ArrayRef lhsContractingDimensions, + ArrayRef rhsContractingDimensions, + std::optional precisionConfig, + bool isDefaultPrecisionConfig, + bool hasAlgorithmSpecified, Value result); + +LogicalResult verifyDotAlgorithmAttr( + ::llvm::function_ref emitError, Type lhsPrecisionType, + Type rhsPrecisionType, Type accumulationType, int64_t lhsComponentCount, + int64_t rhsComponentCount, int64_t numPrimitiveOperations, + bool allowImpreciseAccumulation); + +LogicalResult verifyDynamicBroadcastInDimOp( + std::optional location, Value operand, Value outputDimensions, + ArrayRef broadcastDimensions, + std::optional> knownExpandingDimensions, + std::optional> knownNonexpandingDimensions, Value result); + +LogicalResult verifyDynamicConvOp( + std::optional location, Type lhsType, Type rhsType, Value padding, + std::optional> windowStrides, + std::optional> lhsDilation, + std::optional> rhsDilation, + std::optional> windowReversal, int64_t inputBatchDimension, + int64_t inputFeatureDimension, ArrayRef inputSpatialDimensions, + int64_t kernelInputFeatureDimension, int64_t kernelOutputFeatureDimension, + ArrayRef kernelSpatialDimensions, int64_t outputBatchDimension, + int64_t outputFeatureDimension, ArrayRef outputSpatialDimensions, + int64_t featureGroupCount, int64_t batchGroupCount, + std::optional precisionConfig, Type resultType); + +LogicalResult verifyDynamicIotaOp(std::optional location, + Value outputShape, int64_t iotaDimension, + Value result); + +LogicalResult verifyDynamicPadOp(std::optional location, + Value operand, Value paddingValue, + Value edgePaddingLow, Value edgePaddingHigh, + Value interiorPadding, Value result); + +LogicalResult verifyDynamicReshapeOp(std::optional location, + Value operand, Value outputShape, + Value result); + +LogicalResult verifyInfeedOp(HloDialectInterface* dialect, + std::optional location, + std::optional layout, + ValueRange results); + +LogicalResult verifyIotaOp(std::optional location, + int64_t iotaDimension, Value result); + +LogicalResult verifyRealDynamicSliceOp(std::optional location, + Value operand, Value startIndices, + Value limitIndices, Value strides); + +LogicalResult verifyRecvOp(HloDialectInterface* dialect, + std::optional location, + bool isDeviceToDevice, bool isHostToDevice, + bool isHostTransfer, ValueRange results); + +LogicalResult verifyReduceOp(std::optional location, + ValueRange inputs, ValueRange initValues, + ArrayRef dimensions, Region& body); + +LogicalResult verifyReduceOpInputsAndInferShape( + std::optional location, SmallVector inputTypes, + ArrayRef dimensions, SmallVector& newDimensions, + Attribute& encoding); + +LogicalResult verifyReduceScatterOp(std::optional location, + Value operand, int64_t scatterDimension, + DenseIntElementsAttr replicaGroups, + int64_t channelId, bool useGlobalDeviceIds, + Region& computation, Value result); + +LogicalResult verifyReduceWindowOp( + std::optional location, ValueRange inputs, ValueRange initValues, + ArrayRef windowDimensions, + std::optional> windowStrides, + std::optional> baseDilations, + std::optional> windowDilations, + std::optional padding, Region& body); + +LogicalResult verifyReshapeOp(std::optional location, Value operand, + Value result); + +LogicalResult verifyReverseOp(std::optional location, Value operand, + llvm::ArrayRef dimensions); + +LogicalResult verifyRngBitGeneratorOp(std::optional location, + Value initialState, Value outputState); + +LogicalResult verifyScatterOp( + std::optional location, ValueRange inputs, Value scatterIndices, + ValueRange updates, ArrayRef updateWindowDims, + ArrayRef insertedWindowDims, ArrayRef inputBatchingDims, + ArrayRef scatterIndicesBatchingDims, + ArrayRef scatterDimsToOperandDims, int64_t indexVectorDim, + Region& updateComputation); + +LogicalResult verifySelectAndScatterOp( + std::optional location, Value operand, Value source, + Value initValue, std::optional> windowDimensions, + std::optional> windowStrides, + std::optional padding, Region& select, + Region& scatter); + +LogicalResult verifySortOp(std::optional location, ValueRange inputs, + int64_t dimension, Region& comparator); + +LogicalResult verifyTransposeOp(std::optional location, + Type operandType, ArrayRef permutation, + Type resultType); + +LogicalResult verifyUniformQuantizeOp(std::optional location, + Value operand, Value result); + +LogicalResult verifyWhileOp(std::optional location, + ValueRange operand, Region& cond, Region& body); + +LogicalResult verifyResultAccuracyCombination( + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, APFloat atol, + APFloat rtol, int64_t ulps, StringRef mode); + +LogicalResult verifyResultAccuracyAttr( + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, APFloat atol, + APFloat rtol, int64_t ulps, StringRef mode); +} // end namespace hlo +} // end namespace mlir + +#endif // STABLEHLO_DIALECT_STABLEHLO_TYPE_INFERENCE_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/Version.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/Version.h new file mode 100644 index 0000000000000000000000000000000000000000..eb35ad528a12ac8995c86f90ca5951ca8639322d --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/Version.h @@ -0,0 +1,109 @@ +/* Copyright 2023 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_VERSION_H +#define STABLEHLO_DIALECT_VERSION_H + +#include +#include +#include +#include + +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Regex.h" +#include "llvm/Support/raw_ostream.h" +#include "mlir/IR/Diagnostics.h" +#include "mlir/Support/LogicalResult.h" + +namespace mlir { +namespace vhlo { + +class Version { + public: + /// Convenience method to extract major, minor, patch and create a Version + /// from a StringRef of the form `#.#.#`. Returns failure if invalid string. + static FailureOr fromString(llvm::StringRef versionRef); + + /// Return a Version representing the current VHLO dialect version. + static Version getCurrentVersion() { return Version(1, 10, 10); } + + /// Return a Version representing the minimum supported VHLO dialect version. + static Version getMinimumVersion() { return Version(0, 9, 0); } + + // CompatibilityRequirement is used to get a viable target version to use for + // `serializePortableArtifact` given a compatibility requirement specified as + // a duration. + // + // New enum values can be added per use case. + // + // Values represent a minimum requirement, i.e. WEEK_4 will return a >=4w + // old version, the specific implementation detail can be updated at any time + // by the community as long as it satisfies the requirement. + // + // Given that integration into XLA is not immediate, coarse intervals work + // better than providing a specific date. + enum class CompatibilityRequirement { + NONE = 0, // No compat requirement, use latest version. + WEEK_4 = 1, // 1 month requirement + WEEK_12 = 2, // 3 month requirement + MAX = 3, // Maximum compat, use minimum supported version + }; + + // Get a viable target version to use for `serializePortableArtifact` for a + // given compatibility requirement. See `CompatibilityRequirement` for + // details. + static Version fromCompatibilityRequirement( + CompatibilityRequirement requirement); + + /// Return the MLIR Bytecode Format associated with the version instance. + /// Returns failure if version is not in compatibility window. + FailureOr getBytecodeVersion() const; + + /// Construct Version from major, minor, patch integers. + Version(int64_t major, int64_t minor, int64_t patch) + : majorMinorPatch({major, minor, patch}) {} + + int64_t getMajor() const { return majorMinorPatch[0]; } + int64_t getMinor() const { return majorMinorPatch[1]; } + int64_t getPatch() const { return majorMinorPatch[2]; } + + bool operator<(const Version& other) const { + // Uses lexicographical_compare + return majorMinorPatch < other.majorMinorPatch; + } + bool operator==(const Version& other) const { + return majorMinorPatch == other.majorMinorPatch; + } + bool operator<=(const Version& other) const { + return majorMinorPatch <= other.majorMinorPatch; + } + std::string toString() const { + std::ostringstream os; + os << getMajor() << '.' << getMinor() << '.' << getPatch(); + return os.str(); + } + + private: + std::array majorMinorPatch; +}; + +mlir::Diagnostic& operator<<(mlir::Diagnostic& diag, const Version& version); +llvm::raw_ostream& operator<<(llvm::raw_ostream& os, const Version& version); + +} // namespace vhlo +} // namespace mlir + +#endif // STABLEHLO_DIALECT_VERSION_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloAttrInterfaces.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloAttrInterfaces.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..ed073c017980e7fa879f2439cb965724ecbe7a7e --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloAttrInterfaces.cpp.inc @@ -0,0 +1,18 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + + +/// Returns the minimum version of the VHLO dialect an attribute is supported in. +mlir::vhlo::Version mlir::vhlo::VersionedAttrInterface::getMinVersion() const { + return getImpl()->getMinVersion(getImpl(), *this); + } + +/// Returns the maximum version (inclusive) of the VHLO dialect an attribute is supported in. +mlir::vhlo::Version mlir::vhlo::VersionedAttrInterface::getMaxVersion() const { + return getImpl()->getMaxVersion(getImpl(), *this); + } diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloAttrInterfaces.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloAttrInterfaces.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..c2f0e4502911cb8a6f00ed5b57da6d1ff2c9a0f6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloAttrInterfaces.h.inc @@ -0,0 +1,85 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace vhlo { +class VersionedAttrInterface; +namespace detail { +struct VersionedAttrInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + mlir::vhlo::Version (*getMinVersion)(const Concept *impl, ::mlir::Attribute ); + mlir::vhlo::Version (*getMaxVersion)(const Concept *impl, ::mlir::Attribute ); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::vhlo::VersionedAttrInterface; + Model() : Concept{getMinVersion, getMaxVersion} {} + + static inline mlir::vhlo::Version getMinVersion(const Concept *impl, ::mlir::Attribute tablegen_opaque_val); + static inline mlir::vhlo::Version getMaxVersion(const Concept *impl, ::mlir::Attribute tablegen_opaque_val); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::vhlo::VersionedAttrInterface; + FallbackModel() : Concept{getMinVersion, getMaxVersion} {} + + static inline mlir::vhlo::Version getMinVersion(const Concept *impl, ::mlir::Attribute tablegen_opaque_val); + static inline mlir::vhlo::Version getMaxVersion(const Concept *impl, ::mlir::Attribute tablegen_opaque_val); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteAttr; + }; +}; +template +struct VersionedAttrInterfaceTrait; + +} // namespace detail +class VersionedAttrInterface : public ::mlir::AttributeInterface { +public: + using ::mlir::AttributeInterface::AttributeInterface; + template + struct Trait : public detail::VersionedAttrInterfaceTrait {}; + + /// Returns the minimum version of the VHLO dialect an attribute is supported in. + mlir::vhlo::Version getMinVersion() const; + + /// Returns the maximum version (inclusive) of the VHLO dialect an attribute is supported in. + mlir::vhlo::Version getMaxVersion() const; +}; +namespace detail { + template + struct VersionedAttrInterfaceTrait : public ::mlir::AttributeInterface::Trait { + }; +}// namespace detail +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +template +mlir::vhlo::Version detail::VersionedAttrInterfaceInterfaceTraits::Model::getMinVersion(const Concept *impl, ::mlir::Attribute tablegen_opaque_val) { + return (::llvm::cast(tablegen_opaque_val)).getMinVersion(); +} +template +mlir::vhlo::Version detail::VersionedAttrInterfaceInterfaceTraits::Model::getMaxVersion(const Concept *impl, ::mlir::Attribute tablegen_opaque_val) { + return (::llvm::cast(tablegen_opaque_val)).getMaxVersion(); +} +template +mlir::vhlo::Version detail::VersionedAttrInterfaceInterfaceTraits::FallbackModel::getMinVersion(const Concept *impl, ::mlir::Attribute tablegen_opaque_val) { + return static_cast(impl)->getMinVersion(tablegen_opaque_val); +} +template +mlir::vhlo::Version detail::VersionedAttrInterfaceInterfaceTraits::FallbackModel::getMaxVersion(const Concept *impl, ::mlir::Attribute tablegen_opaque_val) { + return static_cast(impl)->getMaxVersion(tablegen_opaque_val); +} +} // namespace vhlo +} // namespace mlir diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloAttrs.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloAttrs.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..aebee9135d2044e166e07f66e04427c33585feb9 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloAttrs.cpp.inc @@ -0,0 +1,1917 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_ATTRDEF_LIST +#undef GET_ATTRDEF_LIST + +::mlir::vhlo::ComparisonDirectionV1Attr, +::mlir::vhlo::ComparisonTypeV1Attr, +::mlir::vhlo::CustomCallApiVersionV1Attr, +::mlir::vhlo::FftTypeV1Attr, +::mlir::vhlo::PrecisionV1Attr, +::mlir::vhlo::RngAlgorithmV1Attr, +::mlir::vhlo::RngDistributionV1Attr, +::mlir::vhlo::TransposeV1Attr, +::mlir::vhlo::ResultAccuracyModeV1Attr, +::mlir::vhlo::ArrayV1Attr, +::mlir::vhlo::BooleanV1Attr, +::mlir::vhlo::DictionaryV1Attr, +::mlir::vhlo::FloatV1Attr, +::mlir::vhlo::IntegerV1Attr, +::mlir::vhlo::OutputOperandAliasV1Attr, +::mlir::vhlo::StringV1Attr, +::mlir::vhlo::TensorV1Attr, +::mlir::vhlo::TypeV1Attr, +::mlir::vhlo::TypeExtensionsV1Attr, +::mlir::vhlo::ResultAccuracyV1Attr + +#endif // GET_ATTRDEF_LIST + +#ifdef GET_ATTRDEF_CLASSES +#undef GET_ATTRDEF_CLASSES + +static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) { + return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser) + .Case(::mlir::vhlo::ComparisonDirectionV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::ComparisonDirectionV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::ComparisonTypeV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::ComparisonTypeV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::CustomCallApiVersionV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::CustomCallApiVersionV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FftTypeV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FftTypeV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::PrecisionV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::PrecisionV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::RngAlgorithmV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::RngAlgorithmV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::RngDistributionV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::RngDistributionV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::TransposeV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::TransposeV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::ResultAccuracyModeV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::ResultAccuracyModeV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::ArrayV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::ArrayV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::BooleanV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::BooleanV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::DictionaryV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::DictionaryV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IntegerV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IntegerV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::OutputOperandAliasV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::OutputOperandAliasV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::StringV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::StringV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::TensorV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::TensorV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::TypeV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::TypeV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::TypeExtensionsV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::TypeExtensionsV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::ResultAccuracyV1Attr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::ResultAccuracyV1Attr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Default([&](llvm::StringRef keyword, llvm::SMLoc) { + *mnemonic = keyword; + return std::nullopt; + }); +} + +static ::llvm::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) { + return ::llvm::TypeSwitch<::mlir::Attribute, ::llvm::LogicalResult>(def) .Case<::mlir::vhlo::ComparisonDirectionV1Attr>([&](auto t) { + printer << ::mlir::vhlo::ComparisonDirectionV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::ComparisonTypeV1Attr>([&](auto t) { + printer << ::mlir::vhlo::ComparisonTypeV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::CustomCallApiVersionV1Attr>([&](auto t) { + printer << ::mlir::vhlo::CustomCallApiVersionV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FftTypeV1Attr>([&](auto t) { + printer << ::mlir::vhlo::FftTypeV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::PrecisionV1Attr>([&](auto t) { + printer << ::mlir::vhlo::PrecisionV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::RngAlgorithmV1Attr>([&](auto t) { + printer << ::mlir::vhlo::RngAlgorithmV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::RngDistributionV1Attr>([&](auto t) { + printer << ::mlir::vhlo::RngDistributionV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::TransposeV1Attr>([&](auto t) { + printer << ::mlir::vhlo::TransposeV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::ResultAccuracyModeV1Attr>([&](auto t) { + printer << ::mlir::vhlo::ResultAccuracyModeV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::ArrayV1Attr>([&](auto t) { + printer << ::mlir::vhlo::ArrayV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::BooleanV1Attr>([&](auto t) { + printer << ::mlir::vhlo::BooleanV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::DictionaryV1Attr>([&](auto t) { + printer << ::mlir::vhlo::DictionaryV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatV1Attr>([&](auto t) { + printer << ::mlir::vhlo::FloatV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IntegerV1Attr>([&](auto t) { + printer << ::mlir::vhlo::IntegerV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::OutputOperandAliasV1Attr>([&](auto t) { + printer << ::mlir::vhlo::OutputOperandAliasV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::StringV1Attr>([&](auto t) { + printer << ::mlir::vhlo::StringV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::TensorV1Attr>([&](auto t) { + printer << ::mlir::vhlo::TensorV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::TypeV1Attr>([&](auto t) { + printer << ::mlir::vhlo::TypeV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::TypeExtensionsV1Attr>([&](auto t) { + printer << ::mlir::vhlo::TypeExtensionsV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::ResultAccuracyV1Attr>([&](auto t) { + printer << ::mlir::vhlo::ResultAccuracyV1Attr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Default([](auto) { return ::mlir::failure(); }); +} + +namespace mlir { +namespace vhlo { +namespace detail { +struct ComparisonDirectionV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::vhlo::ComparisonDirectionV1>; + ComparisonDirectionV1AttrStorage(::mlir::vhlo::ComparisonDirectionV1 value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static ComparisonDirectionV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) ComparisonDirectionV1AttrStorage(std::move(value)); + } + + ::mlir::vhlo::ComparisonDirectionV1 value; +}; +} // namespace detail +ComparisonDirectionV1Attr ComparisonDirectionV1Attr::get(::mlir::MLIRContext *context, ::mlir::vhlo::ComparisonDirectionV1 value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute ComparisonDirectionV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::vhlo::ComparisonDirectionV1> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::vhlo::ComparisonDirectionV1> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::vhlo::symbolizeComparisonDirectionV1(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::vhlo::ComparisonDirectionV1" << " to be one of: " << "EQ" << ", " << "NE" << ", " << "GE" << ", " << "GT" << ", " << "LE" << ", " << "LT")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_ComparisonDirectionAttrV1 parameter 'value' which is to be a `::mlir::vhlo::ComparisonDirectionV1`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return ComparisonDirectionV1Attr::get(odsParser.getContext(), + ::mlir::vhlo::ComparisonDirectionV1((*_result_value))); +} + +void ComparisonDirectionV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyComparisonDirectionV1(getValue()); +} + +::mlir::vhlo::ComparisonDirectionV1 ComparisonDirectionV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ComparisonDirectionV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct ComparisonTypeV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::vhlo::ComparisonTypeV1>; + ComparisonTypeV1AttrStorage(::mlir::vhlo::ComparisonTypeV1 value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static ComparisonTypeV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) ComparisonTypeV1AttrStorage(std::move(value)); + } + + ::mlir::vhlo::ComparisonTypeV1 value; +}; +} // namespace detail +ComparisonTypeV1Attr ComparisonTypeV1Attr::get(::mlir::MLIRContext *context, ::mlir::vhlo::ComparisonTypeV1 value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute ComparisonTypeV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::vhlo::ComparisonTypeV1> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::vhlo::ComparisonTypeV1> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::vhlo::symbolizeComparisonTypeV1(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::vhlo::ComparisonTypeV1" << " to be one of: " << "NOTYPE" << ", " << "FLOAT" << ", " << "TOTALORDER" << ", " << "SIGNED" << ", " << "UNSIGNED")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_ComparisonTypeAttrV1 parameter 'value' which is to be a `::mlir::vhlo::ComparisonTypeV1`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return ComparisonTypeV1Attr::get(odsParser.getContext(), + ::mlir::vhlo::ComparisonTypeV1((*_result_value))); +} + +void ComparisonTypeV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyComparisonTypeV1(getValue()); +} + +::mlir::vhlo::ComparisonTypeV1 ComparisonTypeV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ComparisonTypeV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct CustomCallApiVersionV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::vhlo::CustomCallApiVersionV1>; + CustomCallApiVersionV1AttrStorage(::mlir::vhlo::CustomCallApiVersionV1 value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static CustomCallApiVersionV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) CustomCallApiVersionV1AttrStorage(std::move(value)); + } + + ::mlir::vhlo::CustomCallApiVersionV1 value; +}; +} // namespace detail +CustomCallApiVersionV1Attr CustomCallApiVersionV1Attr::get(::mlir::MLIRContext *context, ::mlir::vhlo::CustomCallApiVersionV1 value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute CustomCallApiVersionV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::vhlo::CustomCallApiVersionV1> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::vhlo::CustomCallApiVersionV1> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::vhlo::symbolizeCustomCallApiVersionV1(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::vhlo::CustomCallApiVersionV1" << " to be one of: " << "API_VERSION_UNSPECIFIED" << ", " << "API_VERSION_ORIGINAL" << ", " << "API_VERSION_STATUS_RETURNING" << ", " << "API_VERSION_STATUS_RETURNING_UNIFIED" << ", " << "API_VERSION_TYPED_FFI")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_CustomCallApiVersionAttrV1 parameter 'value' which is to be a `::mlir::vhlo::CustomCallApiVersionV1`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return CustomCallApiVersionV1Attr::get(odsParser.getContext(), + ::mlir::vhlo::CustomCallApiVersionV1((*_result_value))); +} + +void CustomCallApiVersionV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyCustomCallApiVersionV1(getValue()); +} + +::mlir::vhlo::CustomCallApiVersionV1 CustomCallApiVersionV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CustomCallApiVersionV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct FftTypeV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::vhlo::FftTypeV1>; + FftTypeV1AttrStorage(::mlir::vhlo::FftTypeV1 value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static FftTypeV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) FftTypeV1AttrStorage(std::move(value)); + } + + ::mlir::vhlo::FftTypeV1 value; +}; +} // namespace detail +FftTypeV1Attr FftTypeV1Attr::get(::mlir::MLIRContext *context, ::mlir::vhlo::FftTypeV1 value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute FftTypeV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::vhlo::FftTypeV1> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::vhlo::FftTypeV1> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::vhlo::symbolizeFftTypeV1(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::vhlo::FftTypeV1" << " to be one of: " << "FFT" << ", " << "IFFT" << ", " << "RFFT" << ", " << "IRFFT")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_FftTypeAttrV1 parameter 'value' which is to be a `::mlir::vhlo::FftTypeV1`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return FftTypeV1Attr::get(odsParser.getContext(), + ::mlir::vhlo::FftTypeV1((*_result_value))); +} + +void FftTypeV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyFftTypeV1(getValue()); +} + +::mlir::vhlo::FftTypeV1 FftTypeV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FftTypeV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct PrecisionV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::vhlo::PrecisionV1>; + PrecisionV1AttrStorage(::mlir::vhlo::PrecisionV1 value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static PrecisionV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) PrecisionV1AttrStorage(std::move(value)); + } + + ::mlir::vhlo::PrecisionV1 value; +}; +} // namespace detail +PrecisionV1Attr PrecisionV1Attr::get(::mlir::MLIRContext *context, ::mlir::vhlo::PrecisionV1 value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute PrecisionV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::vhlo::PrecisionV1> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::vhlo::PrecisionV1> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::vhlo::symbolizePrecisionV1(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::vhlo::PrecisionV1" << " to be one of: " << "DEFAULT" << ", " << "HIGH" << ", " << "HIGHEST")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_PrecisionAttrV1 parameter 'value' which is to be a `::mlir::vhlo::PrecisionV1`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return PrecisionV1Attr::get(odsParser.getContext(), + ::mlir::vhlo::PrecisionV1((*_result_value))); +} + +void PrecisionV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyPrecisionV1(getValue()); +} + +::mlir::vhlo::PrecisionV1 PrecisionV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::PrecisionV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct RngAlgorithmV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::vhlo::RngAlgorithmV1>; + RngAlgorithmV1AttrStorage(::mlir::vhlo::RngAlgorithmV1 value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static RngAlgorithmV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) RngAlgorithmV1AttrStorage(std::move(value)); + } + + ::mlir::vhlo::RngAlgorithmV1 value; +}; +} // namespace detail +RngAlgorithmV1Attr RngAlgorithmV1Attr::get(::mlir::MLIRContext *context, ::mlir::vhlo::RngAlgorithmV1 value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute RngAlgorithmV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::vhlo::RngAlgorithmV1> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::vhlo::RngAlgorithmV1> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::vhlo::symbolizeRngAlgorithmV1(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::vhlo::RngAlgorithmV1" << " to be one of: " << "DEFAULT" << ", " << "THREE_FRY" << ", " << "PHILOX")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_RngAlgorithmAttrV1 parameter 'value' which is to be a `::mlir::vhlo::RngAlgorithmV1`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return RngAlgorithmV1Attr::get(odsParser.getContext(), + ::mlir::vhlo::RngAlgorithmV1((*_result_value))); +} + +void RngAlgorithmV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyRngAlgorithmV1(getValue()); +} + +::mlir::vhlo::RngAlgorithmV1 RngAlgorithmV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::RngAlgorithmV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct RngDistributionV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::vhlo::RngDistributionV1>; + RngDistributionV1AttrStorage(::mlir::vhlo::RngDistributionV1 value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static RngDistributionV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) RngDistributionV1AttrStorage(std::move(value)); + } + + ::mlir::vhlo::RngDistributionV1 value; +}; +} // namespace detail +RngDistributionV1Attr RngDistributionV1Attr::get(::mlir::MLIRContext *context, ::mlir::vhlo::RngDistributionV1 value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute RngDistributionV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::vhlo::RngDistributionV1> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::vhlo::RngDistributionV1> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::vhlo::symbolizeRngDistributionV1(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::vhlo::RngDistributionV1" << " to be one of: " << "UNIFORM" << ", " << "NORMAL")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_RngDistributionAttrV1 parameter 'value' which is to be a `::mlir::vhlo::RngDistributionV1`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return RngDistributionV1Attr::get(odsParser.getContext(), + ::mlir::vhlo::RngDistributionV1((*_result_value))); +} + +void RngDistributionV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyRngDistributionV1(getValue()); +} + +::mlir::vhlo::RngDistributionV1 RngDistributionV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::RngDistributionV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct TransposeV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::vhlo::TransposeV1>; + TransposeV1AttrStorage(::mlir::vhlo::TransposeV1 value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static TransposeV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) TransposeV1AttrStorage(std::move(value)); + } + + ::mlir::vhlo::TransposeV1 value; +}; +} // namespace detail +TransposeV1Attr TransposeV1Attr::get(::mlir::MLIRContext *context, ::mlir::vhlo::TransposeV1 value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute TransposeV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::vhlo::TransposeV1> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::vhlo::TransposeV1> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::vhlo::symbolizeTransposeV1(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::vhlo::TransposeV1" << " to be one of: " << "TRANSPOSE_INVALID" << ", " << "NO_TRANSPOSE" << ", " << "TRANSPOSE" << ", " << "ADJOINT")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_TransposeAttrV1 parameter 'value' which is to be a `::mlir::vhlo::TransposeV1`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return TransposeV1Attr::get(odsParser.getContext(), + ::mlir::vhlo::TransposeV1((*_result_value))); +} + +void TransposeV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyTransposeV1(getValue()); +} + +::mlir::vhlo::TransposeV1 TransposeV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TransposeV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct ResultAccuracyModeV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::vhlo::ResultAccuracyModeV1>; + ResultAccuracyModeV1AttrStorage(::mlir::vhlo::ResultAccuracyModeV1 value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static ResultAccuracyModeV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) ResultAccuracyModeV1AttrStorage(std::move(value)); + } + + ::mlir::vhlo::ResultAccuracyModeV1 value; +}; +} // namespace detail +ResultAccuracyModeV1Attr ResultAccuracyModeV1Attr::get(::mlir::MLIRContext *context, ::mlir::vhlo::ResultAccuracyModeV1 value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute ResultAccuracyModeV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::vhlo::ResultAccuracyModeV1> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::vhlo::ResultAccuracyModeV1> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::vhlo::symbolizeResultAccuracyModeV1(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::llvm::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::vhlo::ResultAccuracyModeV1" << " to be one of: " << "DEFAULT" << ", " << "HIGHEST" << ", " << "TOLERANCE")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_ResultAccuracyModeV1Attr parameter 'value' which is to be a `::mlir::vhlo::ResultAccuracyModeV1`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return ResultAccuracyModeV1Attr::get(odsParser.getContext(), + ::mlir::vhlo::ResultAccuracyModeV1((*_result_value))); +} + +void ResultAccuracyModeV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyResultAccuracyModeV1(getValue()); +} + +::mlir::vhlo::ResultAccuracyModeV1 ResultAccuracyModeV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ResultAccuracyModeV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct ArrayV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef>; + ArrayV1AttrStorage(::llvm::ArrayRef value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static ArrayV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + value = allocator.copyInto(value); + return new (allocator.allocate()) ArrayV1AttrStorage(std::move(value)); + } + + ::llvm::ArrayRef value; +}; +} // namespace detail +ArrayV1Attr ArrayV1Attr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute ArrayV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::llvm::SmallVector> _result_value; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + { + auto odsCustomLoc = odsParser.getCurrentLocation(); + (void)odsCustomLoc; + auto odsCustomResult = parseAttributeArray(odsParser, + ::mlir::detail::unwrapForCustomParse(_result_value)); + if (::mlir::failed(odsCustomResult)) return {}; + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'value'"); + return {}; + } + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_value)); + return ArrayV1Attr::get(odsParser.getContext(), + ::llvm::ArrayRef((*_result_value))); +} + +void ArrayV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + printAttributeArray(odsPrinter, + getValue()); + odsPrinter << ">"; +} + +::llvm::ArrayRef ArrayV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ArrayV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct BooleanV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple; + BooleanV1AttrStorage(bool value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static BooleanV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) BooleanV1AttrStorage(std::move(value)); + } + + bool value; +}; +} // namespace detail +BooleanV1Attr BooleanV1Attr::get(::mlir::MLIRContext *context, bool value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute BooleanV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr _result_value; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'value' + _result_value = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_BooleanAttrV1 parameter 'value' which is to be a `bool`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_value)); + return BooleanV1Attr::get(odsParser.getContext(), + bool((*_result_value))); +} + +void BooleanV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter.printStrippedAttrOrType(getValue()); + odsPrinter << ">"; +} + +bool BooleanV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::BooleanV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct DictionaryV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef>>; + DictionaryV1AttrStorage(::llvm::ArrayRef> value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static DictionaryV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + value = allocator.copyInto(value); + return new (allocator.allocate()) DictionaryV1AttrStorage(std::move(value)); + } + + ::llvm::ArrayRef> value; +}; +} // namespace detail +LogicalResult DictionaryV1Attr::verify( + llvm::function_ref errFn, + ArrayRef> value) { + for (auto & entry : value) { + if (!isFromVhlo(entry.first)) errFn() << "expected VHLO key attribute"; + } + return success(); +} +DictionaryV1Attr DictionaryV1Attr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef> value) { + return Base::get(context, std::move(value)); +} + +DictionaryV1Attr DictionaryV1Attr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef> value) { + return Base::getChecked(emitError, context, value); +} + +::llvm::LogicalResult DictionaryV1Attr::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef> value) { + if (::mlir::failed(verify(emitError, value))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::Attribute DictionaryV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::llvm::SmallVector>> _result_value; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + { + auto odsCustomLoc = odsParser.getCurrentLocation(); + (void)odsCustomLoc; + auto odsCustomResult = parseAttributeDictionary(odsParser, + ::mlir::detail::unwrapForCustomParse(_result_value)); + if (::mlir::failed(odsCustomResult)) return {}; + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'value'"); + return {}; + } + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_value)); + return odsParser.getChecked(odsLoc, odsParser.getContext(), + ::llvm::ArrayRef>((*_result_value))); +} + +void DictionaryV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + printAttributeDictionary(odsPrinter, + getValue()); + odsPrinter << ">"; +} + +::llvm::ArrayRef> DictionaryV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DictionaryV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct FloatV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple; + FloatV1AttrStorage(mlir::Type type, ::llvm::APFloat value) : type(std::move(type)), value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(type, value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (type == std::get<0>(tblgenKey)) && (value.bitwiseIsEqual(std::get<1>(tblgenKey))); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); + } + + static FloatV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto type = std::move(std::get<0>(tblgenKey)); + auto value = std::move(std::get<1>(tblgenKey)); + return new (allocator.allocate()) FloatV1AttrStorage(std::move(type), std::move(value)); + } + + mlir::Type type; + ::llvm::APFloat value; +}; +} // namespace detail +LogicalResult FloatV1Attr::verify( + llvm::function_ref errFn, mlir::Type type, APFloat value) { + if (!isFromVhlo(type)) return errFn() << "expected VHLO type"; + return success(); +} +FloatV1Attr FloatV1Attr::get(::mlir::MLIRContext *context, mlir::Type type, ::llvm::APFloat value) { + return Base::get(context, std::move(type), std::move(value)); +} + +FloatV1Attr FloatV1Attr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, mlir::Type type, ::llvm::APFloat value) { + return Base::getChecked(emitError, context, type, value); +} + +::llvm::LogicalResult FloatV1Attr::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, mlir::Type type, ::llvm::APFloat value) { + if (::mlir::failed(verify(emitError, type, value))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::Attribute FloatV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr _result_type; + ::mlir::FailureOr<::llvm::APFloat> _result_value; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'value' + _result_value = + [&]() -> FailureOr { + double value; + if (failed(odsParser.parseFloat(value))) { + return failure(); + } + return APFloat(value); + }() + ; + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_FloatAttrV1 parameter 'value' which is to be a `::llvm::APFloat`"); + return {}; + } + // Parse literal ':' + if (odsParser.parseColon()) return {}; + + // Parse variable 'type' + _result_type = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_type)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_FloatAttrV1 parameter 'type' which is to be a `mlir::Type`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_type)); + assert(::mlir::succeeded(_result_value)); + return odsParser.getChecked(odsLoc, odsParser.getContext(), + mlir::Type((*_result_type)), + ::llvm::APFloat((*_result_value))); +} + +void FloatV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter.printFloat(getValue());; + odsPrinter << ' ' << ":"; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getType()); + odsPrinter << ">"; +} + +mlir::Type FloatV1Attr::getType() const { + return getImpl()->type; +} + +::llvm::APFloat FloatV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct IntegerV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple; + IntegerV1AttrStorage(mlir::Type type, ::llvm::APInt value) : type(std::move(type)), value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(type, value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (type == std::get<0>(tblgenKey)) && (value.getBitWidth() == std::get<1>(tblgenKey).getBitWidth() && value == std::get<1>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); + } + + static IntegerV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto type = std::move(std::get<0>(tblgenKey)); + auto value = std::move(std::get<1>(tblgenKey)); + return new (allocator.allocate()) IntegerV1AttrStorage(std::move(type), std::move(value)); + } + + mlir::Type type; + ::llvm::APInt value; +}; +} // namespace detail +LogicalResult IntegerV1Attr::verify( + llvm::function_ref errFn, mlir::Type type, APInt value) { + if (!isFromVhlo(type)) return errFn() << "expected VHLO type"; + return success(); +} +IntegerV1Attr IntegerV1Attr::get(::mlir::MLIRContext *context, mlir::Type type, ::llvm::APInt value) { + return Base::get(context, std::move(type), std::move(value)); +} + +IntegerV1Attr IntegerV1Attr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, mlir::Type type, ::llvm::APInt value) { + return Base::getChecked(emitError, context, type, value); +} + +::llvm::LogicalResult IntegerV1Attr::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, mlir::Type type, ::llvm::APInt value) { + if (::mlir::failed(verify(emitError, type, value))) + return ::mlir::failure(); + return ::mlir::success(); +} + +mlir::Type IntegerV1Attr::getType() const { + return getImpl()->type; +} + +::llvm::APInt IntegerV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct OutputOperandAliasV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef, int64_t, ::llvm::ArrayRef>; + OutputOperandAliasV1AttrStorage(::llvm::ArrayRef outputTupleIndices, int64_t operandIndex, ::llvm::ArrayRef operandTupleIndices) : outputTupleIndices(std::move(outputTupleIndices)), operandIndex(std::move(operandIndex)), operandTupleIndices(std::move(operandTupleIndices)) {} + + KeyTy getAsKey() const { + return KeyTy(outputTupleIndices, operandIndex, operandTupleIndices); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (outputTupleIndices == std::get<0>(tblgenKey)) && (operandIndex == std::get<1>(tblgenKey)) && (operandTupleIndices == std::get<2>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey)); + } + + static OutputOperandAliasV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto outputTupleIndices = std::move(std::get<0>(tblgenKey)); + auto operandIndex = std::move(std::get<1>(tblgenKey)); + auto operandTupleIndices = std::move(std::get<2>(tblgenKey)); + outputTupleIndices = allocator.copyInto(outputTupleIndices); + operandTupleIndices = allocator.copyInto(operandTupleIndices); + return new (allocator.allocate()) OutputOperandAliasV1AttrStorage(std::move(outputTupleIndices), std::move(operandIndex), std::move(operandTupleIndices)); + } + + ::llvm::ArrayRef outputTupleIndices; + int64_t operandIndex; + ::llvm::ArrayRef operandTupleIndices; +}; +} // namespace detail +OutputOperandAliasV1Attr OutputOperandAliasV1Attr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef outputTupleIndices, int64_t operandIndex, ::llvm::ArrayRef operandTupleIndices) { + return Base::get(context, std::move(outputTupleIndices), std::move(operandIndex), std::move(operandTupleIndices)); +} + +::mlir::Attribute OutputOperandAliasV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::llvm::SmallVector> _result_outputTupleIndices; + ::mlir::FailureOr _result_operandIndex; + ::mlir::FailureOr<::llvm::SmallVector> _result_operandTupleIndices; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + // Parse parameter struct + bool _seen_outputTupleIndices = false; + bool _seen_operandIndex = false; + bool _seen_operandTupleIndices = false; + { + const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool { + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + if (!_seen_outputTupleIndices && _paramKey == "outputTupleIndices") { + _seen_outputTupleIndices = true; + + // Parse variable 'outputTupleIndices' + _result_outputTupleIndices = mlir::hlo::parseDimSizes(odsParser); + if (::mlir::failed(_result_outputTupleIndices)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_OutputOperandAliasAttrV1 parameter 'outputTupleIndices' which is to be a `::llvm::ArrayRef`"); + return {}; + } + } else if (!_seen_operandIndex && _paramKey == "operandIndex") { + _seen_operandIndex = true; + + // Parse variable 'operandIndex' + _result_operandIndex = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_operandIndex)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_OutputOperandAliasAttrV1 parameter 'operandIndex' which is to be a `int64_t`"); + return {}; + } + } else if (!_seen_operandTupleIndices && _paramKey == "operandTupleIndices") { + _seen_operandTupleIndices = true; + + // Parse variable 'operandTupleIndices' + _result_operandTupleIndices = mlir::hlo::parseDimSizes(odsParser); + if (::mlir::failed(_result_operandTupleIndices)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_OutputOperandAliasAttrV1 parameter 'operandTupleIndices' which is to be a `::llvm::ArrayRef`"); + return {}; + } + } else { + odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey; + return {}; + } + return true; + }; + for (unsigned odsStructIndex = 0; odsStructIndex < 3; ++odsStructIndex) { + ::llvm::StringRef _paramKey; + if (odsParser.parseKeyword(&_paramKey)) { + odsParser.emitError(odsParser.getCurrentLocation(), + "expected a parameter name in struct"); + return {}; + } + if (!_loop_body(_paramKey)) return {}; + if ((odsStructIndex != 3 - 1) && odsParser.parseComma()) + return {}; + } + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_outputTupleIndices)); + assert(::mlir::succeeded(_result_operandIndex)); + assert(::mlir::succeeded(_result_operandTupleIndices)); + return OutputOperandAliasV1Attr::get(odsParser.getContext(), + ::llvm::ArrayRef((*_result_outputTupleIndices)), + int64_t((*_result_operandIndex)), + ::llvm::ArrayRef((*_result_operandTupleIndices))); +} + +void OutputOperandAliasV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + { + bool _firstPrinted = true; + if (!_firstPrinted) odsPrinter << ", "; + _firstPrinted = false; + odsPrinter << "outputTupleIndices = "; + mlir::hlo::printDimSizes(odsPrinter, getOutputTupleIndices()); + if (!_firstPrinted) odsPrinter << ", "; + _firstPrinted = false; + odsPrinter << "operandIndex = "; + odsPrinter.printStrippedAttrOrType(getOperandIndex()); + if (!_firstPrinted) odsPrinter << ", "; + _firstPrinted = false; + odsPrinter << "operandTupleIndices = "; + mlir::hlo::printDimSizes(odsPrinter, getOperandTupleIndices()); + } + odsPrinter << ">"; +} + +::llvm::ArrayRef OutputOperandAliasV1Attr::getOutputTupleIndices() const { + return getImpl()->outputTupleIndices; +} + +int64_t OutputOperandAliasV1Attr::getOperandIndex() const { + return getImpl()->operandIndex; +} + +::llvm::ArrayRef OutputOperandAliasV1Attr::getOperandTupleIndices() const { + return getImpl()->operandTupleIndices; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::OutputOperandAliasV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct StringV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::llvm::StringRef>; + StringV1AttrStorage(::llvm::StringRef value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static StringV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + value = allocator.copyInto(value); + return new (allocator.allocate()) StringV1AttrStorage(std::move(value)); + } + + ::llvm::StringRef value; +}; +} // namespace detail +StringV1Attr StringV1Attr::get(::mlir::MLIRContext *context, ::llvm::StringRef value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute StringV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr _result_value; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + { + auto odsCustomLoc = odsParser.getCurrentLocation(); + (void)odsCustomLoc; + auto odsCustomResult = parseEscapedString(odsParser, + ::mlir::detail::unwrapForCustomParse(_result_value)); + if (::mlir::failed(odsCustomResult)) return {}; + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'value'"); + return {}; + } + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_value)); + return StringV1Attr::get(odsParser.getContext(), + ::llvm::StringRef((*_result_value))); +} + +void StringV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + printEscapedString(odsPrinter, + getValue()); + odsPrinter << ">"; +} + +::llvm::StringRef StringV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::StringV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct TensorV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::Type, ::llvm::ArrayRef>; + TensorV1AttrStorage(::mlir::Type type, ::llvm::ArrayRef data) : type(std::move(type)), data(std::move(data)) {} + + KeyTy getAsKey() const { + return KeyTy(type, data); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (type == std::get<0>(tblgenKey)) && (data == std::get<1>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); + } + + static TensorV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto type = std::move(std::get<0>(tblgenKey)); + auto data = std::move(std::get<1>(tblgenKey)); + data = allocator.copyInto(data); + return new (allocator.allocate()) TensorV1AttrStorage(std::move(type), std::move(data)); + } + + ::mlir::Type type; + ::llvm::ArrayRef data; +}; +} // namespace detail +LogicalResult TensorV1Attr::verify( + llvm::function_ref errFn, mlir::Type type, ArrayRef) { + if (!isFromVhlo(type)) errFn() << "expected VHLO type"; + return success(); +} +TensorV1Attr TensorV1Attr::get(::mlir::MLIRContext *context, ::mlir::Type type, ::llvm::ArrayRef data) { + return Base::get(context, std::move(type), std::move(data)); +} + +TensorV1Attr TensorV1Attr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::mlir::Type type, ::llvm::ArrayRef data) { + return Base::getChecked(emitError, context, type, data); +} + +::llvm::LogicalResult TensorV1Attr::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type type, ::llvm::ArrayRef data) { + if (::mlir::failed(verify(emitError, type, data))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::Type TensorV1Attr::getType() const { + return getImpl()->type; +} + +::llvm::ArrayRef TensorV1Attr::getData() const { + return getImpl()->data; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TensorV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct TypeV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::Type>; + TypeV1AttrStorage(::mlir::Type value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static TypeV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) TypeV1AttrStorage(std::move(value)); + } + + ::mlir::Type value; +}; +} // namespace detail +LogicalResult TypeV1Attr::verify( + llvm::function_ref errFn, mlir::Type value) { + if (!isFromVhlo(value)) return errFn() << "expected VHLO type"; + return success(); +} +TypeV1Attr TypeV1Attr::get(::mlir::MLIRContext *context, ::mlir::Type value) { + return Base::get(context, std::move(value)); +} + +TypeV1Attr TypeV1Attr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::mlir::Type value) { + return Base::getChecked(emitError, context, value); +} + +::llvm::LogicalResult TypeV1Attr::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type value) { + if (::mlir::failed(verify(emitError, value))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::Attribute TypeV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::Type> _result_value; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'value' + _result_value = ::mlir::FieldParser<::mlir::Type>::parse(odsParser); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_TypeAttrV1 parameter 'value' which is to be a `::mlir::Type`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_value)); + return odsParser.getChecked(odsLoc, odsParser.getContext(), + ::mlir::Type((*_result_value))); +} + +void TypeV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter.printStrippedAttrOrType(getValue()); + odsPrinter << ">"; +} + +::mlir::Type TypeV1Attr::getValue() const { + return getImpl()->value; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TypeV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct TypeExtensionsV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef>; + TypeExtensionsV1AttrStorage(::llvm::ArrayRef bounds) : bounds(std::move(bounds)) {} + + KeyTy getAsKey() const { + return KeyTy(bounds); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (bounds == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static TypeExtensionsV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto bounds = std::move(std::get<0>(tblgenKey)); + bounds = allocator.copyInto(bounds); + return new (allocator.allocate()) TypeExtensionsV1AttrStorage(std::move(bounds)); + } + + ::llvm::ArrayRef bounds; +}; +} // namespace detail +TypeExtensionsV1Attr TypeExtensionsV1Attr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef bounds) { + return Base::get(context, std::move(bounds)); +} + +::mlir::Attribute TypeExtensionsV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::llvm::SmallVector> _result_bounds; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + // Parse parameter struct + bool _seen_bounds = false; + { + const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool { + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + if (!_seen_bounds && _paramKey == "bounds") { + _seen_bounds = true; + + // Parse variable 'bounds' + _result_bounds = mlir::hlo::parseDimSizes(odsParser); + if (::mlir::failed(_result_bounds)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_TypeExtensionsAttrV1 parameter 'bounds' which is to be a `::llvm::ArrayRef`"); + return {}; + } + } else { + odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey; + return {}; + } + return true; + }; + for (unsigned odsStructIndex = 0; odsStructIndex < 1; ++odsStructIndex) { + ::llvm::StringRef _paramKey; + if (odsParser.parseKeyword(&_paramKey)) { + odsParser.emitError(odsParser.getCurrentLocation(), + "expected a parameter name in struct"); + return {}; + } + if (!_loop_body(_paramKey)) return {}; + if ((odsStructIndex != 1 - 1) && odsParser.parseComma()) + return {}; + } + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_bounds)); + return TypeExtensionsV1Attr::get(odsParser.getContext(), + ::llvm::ArrayRef((*_result_bounds))); +} + +void TypeExtensionsV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + { + bool _firstPrinted = true; + if (!_firstPrinted) odsPrinter << ", "; + _firstPrinted = false; + odsPrinter << "bounds = "; + mlir::hlo::printDimSizes(odsPrinter, getBounds()); + } + odsPrinter << ">"; +} + +::llvm::ArrayRef TypeExtensionsV1Attr::getBounds() const { + return getImpl()->bounds; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TypeExtensionsV1Attr) +namespace mlir { +namespace vhlo { +namespace detail { +struct ResultAccuracyV1AttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::llvm::APFloat, ::llvm::APFloat, int64_t, mlir::Attribute>; + ResultAccuracyV1AttrStorage(::llvm::APFloat atol, ::llvm::APFloat rtol, int64_t ulps, mlir::Attribute mode) : atol(std::move(atol)), rtol(std::move(rtol)), ulps(std::move(ulps)), mode(std::move(mode)) {} + + KeyTy getAsKey() const { + return KeyTy(atol, rtol, ulps, mode); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (atol.bitwiseIsEqual(std::get<0>(tblgenKey))) && (rtol.bitwiseIsEqual(std::get<1>(tblgenKey))) && (ulps == std::get<2>(tblgenKey)) && (mode == std::get<3>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey)); + } + + static ResultAccuracyV1AttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto atol = std::move(std::get<0>(tblgenKey)); + auto rtol = std::move(std::get<1>(tblgenKey)); + auto ulps = std::move(std::get<2>(tblgenKey)); + auto mode = std::move(std::get<3>(tblgenKey)); + return new (allocator.allocate()) ResultAccuracyV1AttrStorage(std::move(atol), std::move(rtol), std::move(ulps), std::move(mode)); + } + + ::llvm::APFloat atol; + ::llvm::APFloat rtol; + int64_t ulps; + mlir::Attribute mode; +}; +} // namespace detail +LogicalResult ResultAccuracyV1Attr::verify( + llvm::function_ref errFn, + APFloat atol, APFloat rtol, int64_t ulps, + mlir::Attribute mode) { + if (!isFromVhlo(mode)) return errFn() << "expected VHLO result accuracy mode"; + return success(); + } +ResultAccuracyV1Attr ResultAccuracyV1Attr::get(::mlir::MLIRContext *context, ::llvm::APFloat atol, ::llvm::APFloat rtol, int64_t ulps, mlir::Attribute mode) { + return Base::get(context, std::move(atol), std::move(rtol), std::move(ulps), std::move(mode)); +} + +ResultAccuracyV1Attr ResultAccuracyV1Attr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::APFloat atol, ::llvm::APFloat rtol, int64_t ulps, mlir::Attribute mode) { + return Base::getChecked(emitError, context, atol, rtol, ulps, mode); +} + +::llvm::LogicalResult ResultAccuracyV1Attr::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::APFloat atol, ::llvm::APFloat rtol, int64_t ulps, mlir::Attribute mode) { + if (::mlir::failed(verify(emitError, atol, rtol, ulps, mode))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::Attribute ResultAccuracyV1Attr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::llvm::APFloat> _result_atol; + ::mlir::FailureOr<::llvm::APFloat> _result_rtol; + ::mlir::FailureOr _result_ulps; + ::mlir::FailureOr _result_mode; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + // Parse parameter struct + bool _seen_atol = false; + bool _seen_rtol = false; + bool _seen_ulps = false; + bool _seen_mode = false; + { + const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool { + // Parse literal '=' + if (odsParser.parseEqual()) return {}; + if (!_seen_atol && _paramKey == "atol") { + _seen_atol = true; + + // Parse variable 'atol' + _result_atol = + [&]() -> FailureOr { + double value; + if (failed(odsParser.parseFloat(value))) { + return failure(); + } + return APFloat(value); + }() + ; + if (::mlir::failed(_result_atol)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_ResultAccuracyAttrV1 parameter 'atol' which is to be a `::llvm::APFloat`"); + return {}; + } + } else if (!_seen_rtol && _paramKey == "rtol") { + _seen_rtol = true; + + // Parse variable 'rtol' + _result_rtol = + [&]() -> FailureOr { + double value; + if (failed(odsParser.parseFloat(value))) { + return failure(); + } + return APFloat(value); + }() + ; + if (::mlir::failed(_result_rtol)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_ResultAccuracyAttrV1 parameter 'rtol' which is to be a `::llvm::APFloat`"); + return {}; + } + } else if (!_seen_ulps && _paramKey == "ulps") { + _seen_ulps = true; + + // Parse variable 'ulps' + _result_ulps = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_ulps)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_ResultAccuracyAttrV1 parameter 'ulps' which is to be a `int64_t`"); + return {}; + } + } else if (!_seen_mode && _paramKey == "mode") { + _seen_mode = true; + + // Parse variable 'mode' + _result_mode = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_mode)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_ResultAccuracyAttrV1 parameter 'mode' which is to be a `mlir::Attribute`"); + return {}; + } + } else { + odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey; + return {}; + } + return true; + }; + for (unsigned odsStructIndex = 0; odsStructIndex < 4; ++odsStructIndex) { + ::llvm::StringRef _paramKey; + if (odsParser.parseKeyword(&_paramKey)) { + odsParser.emitError(odsParser.getCurrentLocation(), + "expected a parameter name in struct"); + return {}; + } + if (!_loop_body(_paramKey)) return {}; + if ((odsStructIndex != 4 - 1) && odsParser.parseComma()) + return {}; + } + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_atol)); + assert(::mlir::succeeded(_result_rtol)); + assert(::mlir::succeeded(_result_ulps)); + assert(::mlir::succeeded(_result_mode)); + return odsParser.getChecked(odsLoc, odsParser.getContext(), + ::llvm::APFloat((*_result_atol)), + ::llvm::APFloat((*_result_rtol)), + int64_t((*_result_ulps)), + mlir::Attribute((*_result_mode))); +} + +void ResultAccuracyV1Attr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + { + bool _firstPrinted = true; + if (!_firstPrinted) odsPrinter << ", "; + _firstPrinted = false; + odsPrinter << "atol = "; + odsPrinter.printFloat(getAtol());; + if (!_firstPrinted) odsPrinter << ", "; + _firstPrinted = false; + odsPrinter << "rtol = "; + odsPrinter.printFloat(getRtol());; + if (!_firstPrinted) odsPrinter << ", "; + _firstPrinted = false; + odsPrinter << "ulps = "; + odsPrinter.printStrippedAttrOrType(getUlps()); + if (!_firstPrinted) odsPrinter << ", "; + _firstPrinted = false; + odsPrinter << "mode = "; + odsPrinter.printStrippedAttrOrType(getMode()); + } + odsPrinter << ">"; +} + +::llvm::APFloat ResultAccuracyV1Attr::getAtol() const { + return getImpl()->atol; +} + +::llvm::APFloat ResultAccuracyV1Attr::getRtol() const { + return getImpl()->rtol; +} + +int64_t ResultAccuracyV1Attr::getUlps() const { + return getImpl()->ulps; +} + +mlir::Attribute ResultAccuracyV1Attr::getMode() const { + return getImpl()->mode; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ResultAccuracyV1Attr) + +#endif // GET_ATTRDEF_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloAttrs.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloAttrs.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..1121a578d01426c0b161f0fe9290fe40f0e27ca0 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloAttrs.h.inc @@ -0,0 +1,565 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_ATTRDEF_CLASSES +#undef GET_ATTRDEF_CLASSES + + +namespace mlir { +class AsmParser; +class AsmPrinter; +} // namespace mlir +namespace mlir { +namespace vhlo { +/// ComparisonDirectionV1 +class ComparisonDirectionV1Attr; +/// ComparisonTypeV1 +class ComparisonTypeV1Attr; +/// CustomCallApiVersionV1 +class CustomCallApiVersionV1Attr; +/// FftTypeV1 +class FftTypeV1Attr; +/// PrecisionV1 +class PrecisionV1Attr; +/// RngAlgorithmV1 +class RngAlgorithmV1Attr; +/// RngDistributionV1 +class RngDistributionV1Attr; +/// TransposeV1 +class TransposeV1Attr; +/// ResultAccuracyModeV1 +class ResultAccuracyModeV1Attr; +class ArrayV1Attr; +class BooleanV1Attr; +class DictionaryV1Attr; +class FloatV1Attr; +class IntegerV1Attr; +class OutputOperandAliasV1Attr; +class StringV1Attr; +class TensorV1Attr; +class TypeV1Attr; +class TypeExtensionsV1Attr; +/// The requested accuracy for transcendental unary ops. +class ResultAccuracyV1Attr; +namespace detail { +struct ComparisonDirectionV1AttrStorage; +} // namespace detail +class ComparisonDirectionV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.comparison_direction_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static ComparisonDirectionV1Attr get(::mlir::MLIRContext *context, ::mlir::vhlo::ComparisonDirectionV1 value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"comparison_direction_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::vhlo::ComparisonDirectionV1 getValue() const; +}; +namespace detail { +struct ComparisonTypeV1AttrStorage; +} // namespace detail +class ComparisonTypeV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.comparison_type_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static ComparisonTypeV1Attr get(::mlir::MLIRContext *context, ::mlir::vhlo::ComparisonTypeV1 value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"comparison_type_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::vhlo::ComparisonTypeV1 getValue() const; +}; +namespace detail { +struct CustomCallApiVersionV1AttrStorage; +} // namespace detail +class CustomCallApiVersionV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.api_version_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static CustomCallApiVersionV1Attr get(::mlir::MLIRContext *context, ::mlir::vhlo::CustomCallApiVersionV1 value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"api_version_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::vhlo::CustomCallApiVersionV1 getValue() const; +}; +namespace detail { +struct FftTypeV1AttrStorage; +} // namespace detail +class FftTypeV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.fft_type_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static FftTypeV1Attr get(::mlir::MLIRContext *context, ::mlir::vhlo::FftTypeV1 value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"fft_type_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::vhlo::FftTypeV1 getValue() const; +}; +namespace detail { +struct PrecisionV1AttrStorage; +} // namespace detail +class PrecisionV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.precision_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static PrecisionV1Attr get(::mlir::MLIRContext *context, ::mlir::vhlo::PrecisionV1 value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"precision_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::vhlo::PrecisionV1 getValue() const; +}; +namespace detail { +struct RngAlgorithmV1AttrStorage; +} // namespace detail +class RngAlgorithmV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.rng_algorithm_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static RngAlgorithmV1Attr get(::mlir::MLIRContext *context, ::mlir::vhlo::RngAlgorithmV1 value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"rng_algorithm_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::vhlo::RngAlgorithmV1 getValue() const; +}; +namespace detail { +struct RngDistributionV1AttrStorage; +} // namespace detail +class RngDistributionV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.rng_distribution_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static RngDistributionV1Attr get(::mlir::MLIRContext *context, ::mlir::vhlo::RngDistributionV1 value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"rng_distribution_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::vhlo::RngDistributionV1 getValue() const; +}; +namespace detail { +struct TransposeV1AttrStorage; +} // namespace detail +class TransposeV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.transpose_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static TransposeV1Attr get(::mlir::MLIRContext *context, ::mlir::vhlo::TransposeV1 value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"transpose_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::vhlo::TransposeV1 getValue() const; +}; +namespace detail { +struct ResultAccuracyModeV1AttrStorage; +} // namespace detail +class ResultAccuracyModeV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(1, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.result_accuracy_mode_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static ResultAccuracyModeV1Attr get(::mlir::MLIRContext *context, ::mlir::vhlo::ResultAccuracyModeV1 value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"result_accuracy_mode_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::vhlo::ResultAccuracyModeV1 getValue() const; +}; +namespace detail { +struct ArrayV1AttrStorage; +} // namespace detail +class ArrayV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.array_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static ArrayV1Attr get(::mlir::MLIRContext *context, ::llvm::ArrayRef value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"array_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef getValue() const; +}; +namespace detail { +struct BooleanV1AttrStorage; +} // namespace detail +class BooleanV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.bool_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static BooleanV1Attr get(::mlir::MLIRContext *context, bool value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"bool_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + bool getValue() const; +}; +namespace detail { +struct DictionaryV1AttrStorage; +} // namespace detail +class DictionaryV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.dict_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + using Base::getChecked; + static DictionaryV1Attr get(::mlir::MLIRContext *context, ::llvm::ArrayRef> value); + static DictionaryV1Attr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef> value); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef> value); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef> value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"dict_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef> getValue() const; +}; +namespace detail { +struct FloatV1AttrStorage; +} // namespace detail +class FloatV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.float_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + using Base::getChecked; + static FloatV1Attr get(::mlir::MLIRContext *context, mlir::Type type, ::llvm::APFloat value); + static FloatV1Attr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, mlir::Type type, ::llvm::APFloat value); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, mlir::Type type, ::llvm::APFloat value); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, mlir::Type type, ::llvm::APFloat value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"float_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + mlir::Type getType() const; + ::llvm::APFloat getValue() const; +}; +namespace detail { +struct IntegerV1AttrStorage; +} // namespace detail +class IntegerV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.integer_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + using Base::getChecked; + static IntegerV1Attr get(::mlir::MLIRContext *context, mlir::Type type, ::llvm::APInt value); + static IntegerV1Attr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, mlir::Type type, ::llvm::APInt value); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, mlir::Type type, ::llvm::APInt value); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, mlir::Type type, ::llvm::APInt value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"integer_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + mlir::Type getType() const; + ::llvm::APInt getValue() const; +}; +namespace detail { +struct OutputOperandAliasV1AttrStorage; +} // namespace detail +class OutputOperandAliasV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.output_operand_alias_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static OutputOperandAliasV1Attr get(::mlir::MLIRContext *context, ::llvm::ArrayRef outputTupleIndices, int64_t operandIndex, ::llvm::ArrayRef operandTupleIndices); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"output_operand_alias_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef getOutputTupleIndices() const; + int64_t getOperandIndex() const; + ::llvm::ArrayRef getOperandTupleIndices() const; +}; +namespace detail { +struct StringV1AttrStorage; +} // namespace detail +class StringV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.string_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static StringV1Attr get(::mlir::MLIRContext *context, ::llvm::StringRef value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"string_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::StringRef getValue() const; +}; +namespace detail { +struct TensorV1AttrStorage; +} // namespace detail +class TensorV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.tensor_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + using Base::getChecked; + static TensorV1Attr get(::mlir::MLIRContext *context, ::mlir::Type type, ::llvm::ArrayRef data); + static TensorV1Attr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::mlir::Type type, ::llvm::ArrayRef data); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type type, ::llvm::ArrayRef data); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type type, ::llvm::ArrayRef data); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"tensor_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::Type getType() const; + ::llvm::ArrayRef getData() const; +}; +namespace detail { +struct TypeV1AttrStorage; +} // namespace detail +class TypeV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.type_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + using Base::getChecked; + static TypeV1Attr get(::mlir::MLIRContext *context, ::mlir::Type value); + static TypeV1Attr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::mlir::Type value); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type value); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"type_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::Type getValue() const; +}; +namespace detail { +struct TypeExtensionsV1AttrStorage; +} // namespace detail +class TypeExtensionsV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.type_extensions_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static TypeExtensionsV1Attr get(::mlir::MLIRContext *context, ::llvm::ArrayRef bounds); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"type_extensions_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef getBounds() const; +}; +namespace detail { +struct ResultAccuracyV1AttrStorage; +} // namespace detail +class ResultAccuracyV1Attr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(1, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.result_accuracy_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + using Base::getChecked; + static ResultAccuracyV1Attr get(::mlir::MLIRContext *context, ::llvm::APFloat atol, ::llvm::APFloat rtol, int64_t ulps, mlir::Attribute mode); + static ResultAccuracyV1Attr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::APFloat atol, ::llvm::APFloat rtol, int64_t ulps, mlir::Attribute mode); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::APFloat atol, ::llvm::APFloat rtol, int64_t ulps, mlir::Attribute mode); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::APFloat atol, ::llvm::APFloat rtol, int64_t ulps, mlir::Attribute mode); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"result_accuracy_v1"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::APFloat getAtol() const; + ::llvm::APFloat getRtol() const; + int64_t getUlps() const; + mlir::Attribute getMode() const; +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ComparisonDirectionV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ComparisonTypeV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CustomCallApiVersionV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FftTypeV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::PrecisionV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::RngAlgorithmV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::RngDistributionV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TransposeV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ResultAccuracyModeV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ArrayV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::BooleanV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DictionaryV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::OutputOperandAliasV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::StringV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TensorV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TypeV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TypeExtensionsV1Attr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ResultAccuracyV1Attr) + +#endif // GET_ATTRDEF_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloBytecode.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloBytecode.h new file mode 100644 index 0000000000000000000000000000000000000000..b59c04a90d835f5cf5b63fc9ec675a9fb75bd588 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloBytecode.h @@ -0,0 +1,28 @@ +/* Copyright 2022 The StableHLO Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_VHLO_BYTECODE_H +#define STABLEHLO_DIALECT_VHLO_BYTECODE_H + +namespace mlir { +namespace vhlo { +class VhloDialect; + +// Add the interface necessary for encoding and decoding VHLO dialect +// components in bytecode. +void addBytecodeInterface(VhloDialect *dialect); +} // namespace vhlo +} // namespace mlir + +#endif // STABLEHLO_DIALECT_VHLO_BYTECODE_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloEnums.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloEnums.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..4d668cc5a10628b74aa405920acbd008888e0303 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloEnums.cpp.inc @@ -0,0 +1,303 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: VhloEnums.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace vhlo { +::llvm::StringRef stringifyComparisonDirectionV1(ComparisonDirectionV1 val) { + switch (val) { + case ComparisonDirectionV1::EQ: return "EQ"; + case ComparisonDirectionV1::NE: return "NE"; + case ComparisonDirectionV1::GE: return "GE"; + case ComparisonDirectionV1::GT: return "GT"; + case ComparisonDirectionV1::LE: return "LE"; + case ComparisonDirectionV1::LT: return "LT"; + } + return ""; +} + +::std::optional symbolizeComparisonDirectionV1(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("EQ", ComparisonDirectionV1::EQ) + .Case("NE", ComparisonDirectionV1::NE) + .Case("GE", ComparisonDirectionV1::GE) + .Case("GT", ComparisonDirectionV1::GT) + .Case("LE", ComparisonDirectionV1::LE) + .Case("LT", ComparisonDirectionV1::LT) + .Default(::std::nullopt); +} +::std::optional symbolizeComparisonDirectionV1(uint32_t value) { + switch (value) { + case 0: return ComparisonDirectionV1::EQ; + case 1: return ComparisonDirectionV1::NE; + case 2: return ComparisonDirectionV1::GE; + case 3: return ComparisonDirectionV1::GT; + case 4: return ComparisonDirectionV1::LE; + case 5: return ComparisonDirectionV1::LT; + default: return ::std::nullopt; + } +} + +} // namespace vhlo +} // namespace mlir + +namespace mlir { +namespace vhlo { +::llvm::StringRef stringifyComparisonTypeV1(ComparisonTypeV1 val) { + switch (val) { + case ComparisonTypeV1::NOTYPE: return "NOTYPE"; + case ComparisonTypeV1::FLOAT: return "FLOAT"; + case ComparisonTypeV1::TOTALORDER: return "TOTALORDER"; + case ComparisonTypeV1::SIGNED: return "SIGNED"; + case ComparisonTypeV1::UNSIGNED: return "UNSIGNED"; + } + return ""; +} + +::std::optional symbolizeComparisonTypeV1(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("NOTYPE", ComparisonTypeV1::NOTYPE) + .Case("FLOAT", ComparisonTypeV1::FLOAT) + .Case("TOTALORDER", ComparisonTypeV1::TOTALORDER) + .Case("SIGNED", ComparisonTypeV1::SIGNED) + .Case("UNSIGNED", ComparisonTypeV1::UNSIGNED) + .Default(::std::nullopt); +} +::std::optional symbolizeComparisonTypeV1(uint32_t value) { + switch (value) { + case 0: return ComparisonTypeV1::NOTYPE; + case 1: return ComparisonTypeV1::FLOAT; + case 2: return ComparisonTypeV1::TOTALORDER; + case 3: return ComparisonTypeV1::SIGNED; + case 4: return ComparisonTypeV1::UNSIGNED; + default: return ::std::nullopt; + } +} + +} // namespace vhlo +} // namespace mlir + +namespace mlir { +namespace vhlo { +::llvm::StringRef stringifyCustomCallApiVersionV1(CustomCallApiVersionV1 val) { + switch (val) { + case CustomCallApiVersionV1::API_VERSION_UNSPECIFIED: return "API_VERSION_UNSPECIFIED"; + case CustomCallApiVersionV1::API_VERSION_ORIGINAL: return "API_VERSION_ORIGINAL"; + case CustomCallApiVersionV1::API_VERSION_STATUS_RETURNING: return "API_VERSION_STATUS_RETURNING"; + case CustomCallApiVersionV1::API_VERSION_STATUS_RETURNING_UNIFIED: return "API_VERSION_STATUS_RETURNING_UNIFIED"; + case CustomCallApiVersionV1::API_VERSION_TYPED_FFI: return "API_VERSION_TYPED_FFI"; + } + return ""; +} + +::std::optional symbolizeCustomCallApiVersionV1(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("API_VERSION_UNSPECIFIED", CustomCallApiVersionV1::API_VERSION_UNSPECIFIED) + .Case("API_VERSION_ORIGINAL", CustomCallApiVersionV1::API_VERSION_ORIGINAL) + .Case("API_VERSION_STATUS_RETURNING", CustomCallApiVersionV1::API_VERSION_STATUS_RETURNING) + .Case("API_VERSION_STATUS_RETURNING_UNIFIED", CustomCallApiVersionV1::API_VERSION_STATUS_RETURNING_UNIFIED) + .Case("API_VERSION_TYPED_FFI", CustomCallApiVersionV1::API_VERSION_TYPED_FFI) + .Default(::std::nullopt); +} +::std::optional symbolizeCustomCallApiVersionV1(uint32_t value) { + switch (value) { + case 0: return CustomCallApiVersionV1::API_VERSION_UNSPECIFIED; + case 1: return CustomCallApiVersionV1::API_VERSION_ORIGINAL; + case 2: return CustomCallApiVersionV1::API_VERSION_STATUS_RETURNING; + case 3: return CustomCallApiVersionV1::API_VERSION_STATUS_RETURNING_UNIFIED; + case 4: return CustomCallApiVersionV1::API_VERSION_TYPED_FFI; + default: return ::std::nullopt; + } +} + +} // namespace vhlo +} // namespace mlir + +namespace mlir { +namespace vhlo { +::llvm::StringRef stringifyFftTypeV1(FftTypeV1 val) { + switch (val) { + case FftTypeV1::FFT: return "FFT"; + case FftTypeV1::IFFT: return "IFFT"; + case FftTypeV1::RFFT: return "RFFT"; + case FftTypeV1::IRFFT: return "IRFFT"; + } + return ""; +} + +::std::optional symbolizeFftTypeV1(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("FFT", FftTypeV1::FFT) + .Case("IFFT", FftTypeV1::IFFT) + .Case("RFFT", FftTypeV1::RFFT) + .Case("IRFFT", FftTypeV1::IRFFT) + .Default(::std::nullopt); +} +::std::optional symbolizeFftTypeV1(uint32_t value) { + switch (value) { + case 0: return FftTypeV1::FFT; + case 1: return FftTypeV1::IFFT; + case 2: return FftTypeV1::RFFT; + case 3: return FftTypeV1::IRFFT; + default: return ::std::nullopt; + } +} + +} // namespace vhlo +} // namespace mlir + +namespace mlir { +namespace vhlo { +::llvm::StringRef stringifyPrecisionV1(PrecisionV1 val) { + switch (val) { + case PrecisionV1::DEFAULT: return "DEFAULT"; + case PrecisionV1::HIGH: return "HIGH"; + case PrecisionV1::HIGHEST: return "HIGHEST"; + } + return ""; +} + +::std::optional symbolizePrecisionV1(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("DEFAULT", PrecisionV1::DEFAULT) + .Case("HIGH", PrecisionV1::HIGH) + .Case("HIGHEST", PrecisionV1::HIGHEST) + .Default(::std::nullopt); +} +::std::optional symbolizePrecisionV1(uint32_t value) { + switch (value) { + case 0: return PrecisionV1::DEFAULT; + case 1: return PrecisionV1::HIGH; + case 2: return PrecisionV1::HIGHEST; + default: return ::std::nullopt; + } +} + +} // namespace vhlo +} // namespace mlir + +namespace mlir { +namespace vhlo { +::llvm::StringRef stringifyResultAccuracyModeV1(ResultAccuracyModeV1 val) { + switch (val) { + case ResultAccuracyModeV1::DEFAULT: return "DEFAULT"; + case ResultAccuracyModeV1::HIGHEST: return "HIGHEST"; + case ResultAccuracyModeV1::TOLERANCE: return "TOLERANCE"; + } + return ""; +} + +::std::optional symbolizeResultAccuracyModeV1(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("DEFAULT", ResultAccuracyModeV1::DEFAULT) + .Case("HIGHEST", ResultAccuracyModeV1::HIGHEST) + .Case("TOLERANCE", ResultAccuracyModeV1::TOLERANCE) + .Default(::std::nullopt); +} +::std::optional symbolizeResultAccuracyModeV1(uint32_t value) { + switch (value) { + case 0: return ResultAccuracyModeV1::DEFAULT; + case 1: return ResultAccuracyModeV1::HIGHEST; + case 2: return ResultAccuracyModeV1::TOLERANCE; + default: return ::std::nullopt; + } +} + +} // namespace vhlo +} // namespace mlir + +namespace mlir { +namespace vhlo { +::llvm::StringRef stringifyRngAlgorithmV1(RngAlgorithmV1 val) { + switch (val) { + case RngAlgorithmV1::DEFAULT: return "DEFAULT"; + case RngAlgorithmV1::THREE_FRY: return "THREE_FRY"; + case RngAlgorithmV1::PHILOX: return "PHILOX"; + } + return ""; +} + +::std::optional symbolizeRngAlgorithmV1(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("DEFAULT", RngAlgorithmV1::DEFAULT) + .Case("THREE_FRY", RngAlgorithmV1::THREE_FRY) + .Case("PHILOX", RngAlgorithmV1::PHILOX) + .Default(::std::nullopt); +} +::std::optional symbolizeRngAlgorithmV1(uint32_t value) { + switch (value) { + case 0: return RngAlgorithmV1::DEFAULT; + case 1: return RngAlgorithmV1::THREE_FRY; + case 2: return RngAlgorithmV1::PHILOX; + default: return ::std::nullopt; + } +} + +} // namespace vhlo +} // namespace mlir + +namespace mlir { +namespace vhlo { +::llvm::StringRef stringifyRngDistributionV1(RngDistributionV1 val) { + switch (val) { + case RngDistributionV1::UNIFORM: return "UNIFORM"; + case RngDistributionV1::NORMAL: return "NORMAL"; + } + return ""; +} + +::std::optional symbolizeRngDistributionV1(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("UNIFORM", RngDistributionV1::UNIFORM) + .Case("NORMAL", RngDistributionV1::NORMAL) + .Default(::std::nullopt); +} +::std::optional symbolizeRngDistributionV1(uint32_t value) { + switch (value) { + case 1: return RngDistributionV1::UNIFORM; + case 2: return RngDistributionV1::NORMAL; + default: return ::std::nullopt; + } +} + +} // namespace vhlo +} // namespace mlir + +namespace mlir { +namespace vhlo { +::llvm::StringRef stringifyTransposeV1(TransposeV1 val) { + switch (val) { + case TransposeV1::TRANSPOSE_INVALID: return "TRANSPOSE_INVALID"; + case TransposeV1::NO_TRANSPOSE: return "NO_TRANSPOSE"; + case TransposeV1::TRANSPOSE: return "TRANSPOSE"; + case TransposeV1::ADJOINT: return "ADJOINT"; + } + return ""; +} + +::std::optional symbolizeTransposeV1(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("TRANSPOSE_INVALID", TransposeV1::TRANSPOSE_INVALID) + .Case("NO_TRANSPOSE", TransposeV1::NO_TRANSPOSE) + .Case("TRANSPOSE", TransposeV1::TRANSPOSE) + .Case("ADJOINT", TransposeV1::ADJOINT) + .Default(::std::nullopt); +} +::std::optional symbolizeTransposeV1(uint32_t value) { + switch (value) { + case 0: return TransposeV1::TRANSPOSE_INVALID; + case 1: return TransposeV1::NO_TRANSPOSE; + case 2: return TransposeV1::TRANSPOSE; + case 3: return TransposeV1::ADJOINT; + default: return ::std::nullopt; + } +} + +} // namespace vhlo +} // namespace mlir + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloEnums.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloEnums.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..4ef9766d36ea50fe546c00180eb0e3400ca1b033 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloEnums.h.inc @@ -0,0 +1,944 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: VhloEnums.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace vhlo { +// ComparisonDirectionV1 +enum class ComparisonDirectionV1 : uint32_t { + EQ = 0, + NE = 1, + GE = 2, + GT = 3, + LE = 4, + LT = 5, +}; + +::std::optional symbolizeComparisonDirectionV1(uint32_t); +::llvm::StringRef stringifyComparisonDirectionV1(ComparisonDirectionV1); +::std::optional symbolizeComparisonDirectionV1(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForComparisonDirectionV1() { + return 5; +} + + +inline ::llvm::StringRef stringifyEnum(ComparisonDirectionV1 enumValue) { + return stringifyComparisonDirectionV1(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeComparisonDirectionV1(str); +} +} // namespace vhlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vhlo::ComparisonDirectionV1, ::mlir::vhlo::ComparisonDirectionV1> { + template + static FailureOr<::mlir::vhlo::ComparisonDirectionV1> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for ComparisonDirectionV1"); + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::ComparisonDirectionV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::ComparisonDirectionV1>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [EQ, NE, GE, GT, LE, LT] for ComparisonDirectionV1, got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::vhlo::ComparisonDirectionV1>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::vhlo::ComparisonDirectionV1>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::ComparisonDirectionV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::ComparisonDirectionV1>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [EQ, NE, GE, GT, LE, LT] for ComparisonDirectionV1, got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vhlo::ComparisonDirectionV1 value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vhlo::ComparisonDirectionV1> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vhlo::ComparisonDirectionV1 getEmptyKey() { + return static_cast<::mlir::vhlo::ComparisonDirectionV1>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vhlo::ComparisonDirectionV1 getTombstoneKey() { + return static_cast<::mlir::vhlo::ComparisonDirectionV1>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vhlo::ComparisonDirectionV1 &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vhlo::ComparisonDirectionV1 &lhs, const ::mlir::vhlo::ComparisonDirectionV1 &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace vhlo { +// ComparisonTypeV1 +enum class ComparisonTypeV1 : uint32_t { + NOTYPE = 0, + FLOAT = 1, + TOTALORDER = 2, + SIGNED = 3, + UNSIGNED = 4, +}; + +::std::optional symbolizeComparisonTypeV1(uint32_t); +::llvm::StringRef stringifyComparisonTypeV1(ComparisonTypeV1); +::std::optional symbolizeComparisonTypeV1(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForComparisonTypeV1() { + return 4; +} + + +inline ::llvm::StringRef stringifyEnum(ComparisonTypeV1 enumValue) { + return stringifyComparisonTypeV1(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeComparisonTypeV1(str); +} +} // namespace vhlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vhlo::ComparisonTypeV1, ::mlir::vhlo::ComparisonTypeV1> { + template + static FailureOr<::mlir::vhlo::ComparisonTypeV1> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for ComparisonTypeV1"); + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::ComparisonTypeV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::ComparisonTypeV1>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [NOTYPE, FLOAT, TOTALORDER, SIGNED, UNSIGNED] for ComparisonTypeV1, got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::vhlo::ComparisonTypeV1>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::vhlo::ComparisonTypeV1>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::ComparisonTypeV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::ComparisonTypeV1>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [NOTYPE, FLOAT, TOTALORDER, SIGNED, UNSIGNED] for ComparisonTypeV1, got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vhlo::ComparisonTypeV1 value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vhlo::ComparisonTypeV1> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vhlo::ComparisonTypeV1 getEmptyKey() { + return static_cast<::mlir::vhlo::ComparisonTypeV1>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vhlo::ComparisonTypeV1 getTombstoneKey() { + return static_cast<::mlir::vhlo::ComparisonTypeV1>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vhlo::ComparisonTypeV1 &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vhlo::ComparisonTypeV1 &lhs, const ::mlir::vhlo::ComparisonTypeV1 &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace vhlo { +// CustomCallApiVersionV1 +enum class CustomCallApiVersionV1 : uint32_t { + API_VERSION_UNSPECIFIED = 0, + API_VERSION_ORIGINAL = 1, + API_VERSION_STATUS_RETURNING = 2, + API_VERSION_STATUS_RETURNING_UNIFIED = 3, + API_VERSION_TYPED_FFI = 4, +}; + +::std::optional symbolizeCustomCallApiVersionV1(uint32_t); +::llvm::StringRef stringifyCustomCallApiVersionV1(CustomCallApiVersionV1); +::std::optional symbolizeCustomCallApiVersionV1(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForCustomCallApiVersionV1() { + return 4; +} + + +inline ::llvm::StringRef stringifyEnum(CustomCallApiVersionV1 enumValue) { + return stringifyCustomCallApiVersionV1(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeCustomCallApiVersionV1(str); +} +} // namespace vhlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vhlo::CustomCallApiVersionV1, ::mlir::vhlo::CustomCallApiVersionV1> { + template + static FailureOr<::mlir::vhlo::CustomCallApiVersionV1> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for CustomCallApiVersionV1"); + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::CustomCallApiVersionV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::CustomCallApiVersionV1>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [API_VERSION_UNSPECIFIED, API_VERSION_ORIGINAL, API_VERSION_STATUS_RETURNING, API_VERSION_STATUS_RETURNING_UNIFIED, API_VERSION_TYPED_FFI] for CustomCallApiVersionV1, got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::vhlo::CustomCallApiVersionV1>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::vhlo::CustomCallApiVersionV1>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::CustomCallApiVersionV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::CustomCallApiVersionV1>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [API_VERSION_UNSPECIFIED, API_VERSION_ORIGINAL, API_VERSION_STATUS_RETURNING, API_VERSION_STATUS_RETURNING_UNIFIED, API_VERSION_TYPED_FFI] for CustomCallApiVersionV1, got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vhlo::CustomCallApiVersionV1 value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vhlo::CustomCallApiVersionV1> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vhlo::CustomCallApiVersionV1 getEmptyKey() { + return static_cast<::mlir::vhlo::CustomCallApiVersionV1>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vhlo::CustomCallApiVersionV1 getTombstoneKey() { + return static_cast<::mlir::vhlo::CustomCallApiVersionV1>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vhlo::CustomCallApiVersionV1 &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vhlo::CustomCallApiVersionV1 &lhs, const ::mlir::vhlo::CustomCallApiVersionV1 &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace vhlo { +// FftTypeV1 +enum class FftTypeV1 : uint32_t { + FFT = 0, + IFFT = 1, + RFFT = 2, + IRFFT = 3, +}; + +::std::optional symbolizeFftTypeV1(uint32_t); +::llvm::StringRef stringifyFftTypeV1(FftTypeV1); +::std::optional symbolizeFftTypeV1(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForFftTypeV1() { + return 3; +} + + +inline ::llvm::StringRef stringifyEnum(FftTypeV1 enumValue) { + return stringifyFftTypeV1(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeFftTypeV1(str); +} +} // namespace vhlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vhlo::FftTypeV1, ::mlir::vhlo::FftTypeV1> { + template + static FailureOr<::mlir::vhlo::FftTypeV1> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for FftTypeV1"); + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::FftTypeV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::FftTypeV1>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [FFT, IFFT, RFFT, IRFFT] for FftTypeV1, got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::vhlo::FftTypeV1>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::vhlo::FftTypeV1>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::FftTypeV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::FftTypeV1>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [FFT, IFFT, RFFT, IRFFT] for FftTypeV1, got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vhlo::FftTypeV1 value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vhlo::FftTypeV1> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vhlo::FftTypeV1 getEmptyKey() { + return static_cast<::mlir::vhlo::FftTypeV1>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vhlo::FftTypeV1 getTombstoneKey() { + return static_cast<::mlir::vhlo::FftTypeV1>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vhlo::FftTypeV1 &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vhlo::FftTypeV1 &lhs, const ::mlir::vhlo::FftTypeV1 &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace vhlo { +// PrecisionV1 +enum class PrecisionV1 : uint32_t { + DEFAULT = 0, + HIGH = 1, + HIGHEST = 2, +}; + +::std::optional symbolizePrecisionV1(uint32_t); +::llvm::StringRef stringifyPrecisionV1(PrecisionV1); +::std::optional symbolizePrecisionV1(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForPrecisionV1() { + return 2; +} + + +inline ::llvm::StringRef stringifyEnum(PrecisionV1 enumValue) { + return stringifyPrecisionV1(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizePrecisionV1(str); +} +} // namespace vhlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vhlo::PrecisionV1, ::mlir::vhlo::PrecisionV1> { + template + static FailureOr<::mlir::vhlo::PrecisionV1> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for PrecisionV1"); + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::PrecisionV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::PrecisionV1>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [DEFAULT, HIGH, HIGHEST] for PrecisionV1, got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::vhlo::PrecisionV1>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::vhlo::PrecisionV1>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::PrecisionV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::PrecisionV1>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [DEFAULT, HIGH, HIGHEST] for PrecisionV1, got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vhlo::PrecisionV1 value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vhlo::PrecisionV1> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vhlo::PrecisionV1 getEmptyKey() { + return static_cast<::mlir::vhlo::PrecisionV1>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vhlo::PrecisionV1 getTombstoneKey() { + return static_cast<::mlir::vhlo::PrecisionV1>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vhlo::PrecisionV1 &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vhlo::PrecisionV1 &lhs, const ::mlir::vhlo::PrecisionV1 &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace vhlo { +// ResultAccuracyModeV1 +enum class ResultAccuracyModeV1 : uint32_t { + DEFAULT = 0, + HIGHEST = 1, + TOLERANCE = 2, +}; + +::std::optional symbolizeResultAccuracyModeV1(uint32_t); +::llvm::StringRef stringifyResultAccuracyModeV1(ResultAccuracyModeV1); +::std::optional symbolizeResultAccuracyModeV1(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForResultAccuracyModeV1() { + return 2; +} + + +inline ::llvm::StringRef stringifyEnum(ResultAccuracyModeV1 enumValue) { + return stringifyResultAccuracyModeV1(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeResultAccuracyModeV1(str); +} +} // namespace vhlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vhlo::ResultAccuracyModeV1, ::mlir::vhlo::ResultAccuracyModeV1> { + template + static FailureOr<::mlir::vhlo::ResultAccuracyModeV1> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for ResultAccuracyModeV1"); + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::ResultAccuracyModeV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::ResultAccuracyModeV1>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [DEFAULT, HIGHEST, TOLERANCE] for ResultAccuracyModeV1, got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::vhlo::ResultAccuracyModeV1>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::vhlo::ResultAccuracyModeV1>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::ResultAccuracyModeV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::ResultAccuracyModeV1>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [DEFAULT, HIGHEST, TOLERANCE] for ResultAccuracyModeV1, got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vhlo::ResultAccuracyModeV1 value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vhlo::ResultAccuracyModeV1> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vhlo::ResultAccuracyModeV1 getEmptyKey() { + return static_cast<::mlir::vhlo::ResultAccuracyModeV1>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vhlo::ResultAccuracyModeV1 getTombstoneKey() { + return static_cast<::mlir::vhlo::ResultAccuracyModeV1>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vhlo::ResultAccuracyModeV1 &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vhlo::ResultAccuracyModeV1 &lhs, const ::mlir::vhlo::ResultAccuracyModeV1 &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace vhlo { +// RngAlgorithmV1 +enum class RngAlgorithmV1 : uint32_t { + DEFAULT = 0, + THREE_FRY = 1, + PHILOX = 2, +}; + +::std::optional symbolizeRngAlgorithmV1(uint32_t); +::llvm::StringRef stringifyRngAlgorithmV1(RngAlgorithmV1); +::std::optional symbolizeRngAlgorithmV1(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForRngAlgorithmV1() { + return 2; +} + + +inline ::llvm::StringRef stringifyEnum(RngAlgorithmV1 enumValue) { + return stringifyRngAlgorithmV1(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeRngAlgorithmV1(str); +} +} // namespace vhlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vhlo::RngAlgorithmV1, ::mlir::vhlo::RngAlgorithmV1> { + template + static FailureOr<::mlir::vhlo::RngAlgorithmV1> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for RngAlgorithmV1"); + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::RngAlgorithmV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::RngAlgorithmV1>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [DEFAULT, THREE_FRY, PHILOX] for RngAlgorithmV1, got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::vhlo::RngAlgorithmV1>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::vhlo::RngAlgorithmV1>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::RngAlgorithmV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::RngAlgorithmV1>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [DEFAULT, THREE_FRY, PHILOX] for RngAlgorithmV1, got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vhlo::RngAlgorithmV1 value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vhlo::RngAlgorithmV1> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vhlo::RngAlgorithmV1 getEmptyKey() { + return static_cast<::mlir::vhlo::RngAlgorithmV1>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vhlo::RngAlgorithmV1 getTombstoneKey() { + return static_cast<::mlir::vhlo::RngAlgorithmV1>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vhlo::RngAlgorithmV1 &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vhlo::RngAlgorithmV1 &lhs, const ::mlir::vhlo::RngAlgorithmV1 &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace vhlo { +// RngDistributionV1 +enum class RngDistributionV1 : uint32_t { + UNIFORM = 1, + NORMAL = 2, +}; + +::std::optional symbolizeRngDistributionV1(uint32_t); +::llvm::StringRef stringifyRngDistributionV1(RngDistributionV1); +::std::optional symbolizeRngDistributionV1(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForRngDistributionV1() { + return 2; +} + + +inline ::llvm::StringRef stringifyEnum(RngDistributionV1 enumValue) { + return stringifyRngDistributionV1(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeRngDistributionV1(str); +} +} // namespace vhlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vhlo::RngDistributionV1, ::mlir::vhlo::RngDistributionV1> { + template + static FailureOr<::mlir::vhlo::RngDistributionV1> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for RngDistributionV1"); + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::RngDistributionV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::RngDistributionV1>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [UNIFORM, NORMAL] for RngDistributionV1, got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::vhlo::RngDistributionV1>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::vhlo::RngDistributionV1>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::RngDistributionV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::RngDistributionV1>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [UNIFORM, NORMAL] for RngDistributionV1, got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vhlo::RngDistributionV1 value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vhlo::RngDistributionV1> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vhlo::RngDistributionV1 getEmptyKey() { + return static_cast<::mlir::vhlo::RngDistributionV1>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vhlo::RngDistributionV1 getTombstoneKey() { + return static_cast<::mlir::vhlo::RngDistributionV1>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vhlo::RngDistributionV1 &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vhlo::RngDistributionV1 &lhs, const ::mlir::vhlo::RngDistributionV1 &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace vhlo { +// TransposeV1 +enum class TransposeV1 : uint32_t { + TRANSPOSE_INVALID = 0, + NO_TRANSPOSE = 1, + TRANSPOSE = 2, + ADJOINT = 3, +}; + +::std::optional symbolizeTransposeV1(uint32_t); +::llvm::StringRef stringifyTransposeV1(TransposeV1); +::std::optional symbolizeTransposeV1(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForTransposeV1() { + return 3; +} + + +inline ::llvm::StringRef stringifyEnum(TransposeV1 enumValue) { + return stringifyTransposeV1(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeTransposeV1(str); +} +} // namespace vhlo +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vhlo::TransposeV1, ::mlir::vhlo::TransposeV1> { + template + static FailureOr<::mlir::vhlo::TransposeV1> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for TransposeV1"); + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::TransposeV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::TransposeV1>(enumKeyword)) + return *attr; + return parser.emitError(loc, "expected one of [TRANSPOSE_INVALID, NO_TRANSPOSE, TRANSPOSE, ADJOINT] for TransposeV1, got: ") << enumKeyword; + } +}; + +/// Support for std::optional, useful in attribute/type definition where the enum is +/// used as: +/// +/// let parameters = (ins OptionalParameter<"std::optional">:$value); +template<> +struct FieldParser, std::optional<::mlir::vhlo::TransposeV1>> { + template + static FailureOr> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return std::optional<::mlir::vhlo::TransposeV1>{}; + + // Symbolize the keyword. + if (::std::optional<::mlir::vhlo::TransposeV1> attr = ::mlir::vhlo::symbolizeEnum<::mlir::vhlo::TransposeV1>(enumKeyword)) + return attr; + return parser.emitError(loc, "expected one of [TRANSPOSE_INVALID, NO_TRANSPOSE, TRANSPOSE, ADJOINT] for TransposeV1, got: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vhlo::TransposeV1 value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vhlo::TransposeV1> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vhlo::TransposeV1 getEmptyKey() { + return static_cast<::mlir::vhlo::TransposeV1>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vhlo::TransposeV1 getTombstoneKey() { + return static_cast<::mlir::vhlo::TransposeV1>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vhlo::TransposeV1 &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vhlo::TransposeV1 &lhs, const ::mlir::vhlo::TransposeV1 &rhs) { + return lhs == rhs; + } +}; +} + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOpInterfaces.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOpInterfaces.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..e22bc7c26235397415480708c7f5158601b05574 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOpInterfaces.cpp.inc @@ -0,0 +1,24 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + + +/// Validate versioned constraints on a versioned op. +/// Used if the spec'ed constraints of an op change over time. +mlir::LogicalResult mlir::vhlo::VersionedOpConstraintInterface::validateConstraint(mlir::Operation* op, mlir::vhlo::Version targetVersion) { + return getImpl()->validateConstraint(getImpl(), getOperation(), op, targetVersion); + } + +/// Returns the minimum version of the VHLO dialect an op is supported in. +mlir::vhlo::Version mlir::vhlo::VersionedOpInterface::getMinVersion() { + return getImpl()->getMinVersion(getImpl(), getOperation()); + } + +/// Returns the maximum version (inclusive) of the VHLO dialect an op is supported in. +mlir::vhlo::Version mlir::vhlo::VersionedOpInterface::getMaxVersion() { + return getImpl()->getMaxVersion(getImpl(), getOperation()); + } diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOpInterfaces.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOpInterfaces.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..1fa311b0ae17f74436602e1e44a2f59a991e8900 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOpInterfaces.h.inc @@ -0,0 +1,149 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace vhlo { +class VersionedOpInterface; +namespace detail { +struct VersionedOpInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + mlir::vhlo::Version (*getMinVersion)(const Concept *impl, ::mlir::Operation *); + mlir::vhlo::Version (*getMaxVersion)(const Concept *impl, ::mlir::Operation *); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::vhlo::VersionedOpInterface; + Model() : Concept{getMinVersion, getMaxVersion} {} + + static inline mlir::vhlo::Version getMinVersion(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline mlir::vhlo::Version getMaxVersion(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::vhlo::VersionedOpInterface; + FallbackModel() : Concept{getMinVersion, getMaxVersion} {} + + static inline mlir::vhlo::Version getMinVersion(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline mlir::vhlo::Version getMaxVersion(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteOp; + }; +}; +template +struct VersionedOpInterfaceTrait; + +} // namespace detail +class VersionedOpInterface : public ::mlir::OpInterface { +public: + using ::mlir::OpInterface::OpInterface; + template + struct Trait : public detail::VersionedOpInterfaceTrait {}; + + /// Returns the minimum version of the VHLO dialect an op is supported in. + mlir::vhlo::Version getMinVersion(); + + /// Returns the maximum version (inclusive) of the VHLO dialect an op is supported in. + mlir::vhlo::Version getMaxVersion(); +}; +namespace detail { + template + struct VersionedOpInterfaceTrait : public ::mlir::OpInterface::Trait { + }; +}// namespace detail +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class VersionedOpConstraintInterface; +namespace detail { +struct VersionedOpConstraintInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + mlir::LogicalResult (*validateConstraint)(const Concept *impl, ::mlir::Operation *, mlir::Operation*, mlir::vhlo::Version); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::vhlo::VersionedOpConstraintInterface; + Model() : Concept{validateConstraint} {} + + static inline mlir::LogicalResult validateConstraint(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, mlir::Operation* op, mlir::vhlo::Version targetVersion); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::vhlo::VersionedOpConstraintInterface; + FallbackModel() : Concept{validateConstraint} {} + + static inline mlir::LogicalResult validateConstraint(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, mlir::Operation* op, mlir::vhlo::Version targetVersion); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteOp; + }; +}; +template +struct VersionedOpConstraintInterfaceTrait; + +} // namespace detail +class VersionedOpConstraintInterface : public ::mlir::OpInterface { +public: + using ::mlir::OpInterface::OpInterface; + template + struct Trait : public detail::VersionedOpConstraintInterfaceTrait {}; + + /// Validate versioned constraints on a versioned op. + /// Used if the spec'ed constraints of an op change over time. + mlir::LogicalResult validateConstraint(mlir::Operation* op, mlir::vhlo::Version targetVersion); +}; +namespace detail { + template + struct VersionedOpConstraintInterfaceTrait : public ::mlir::OpInterface::Trait { + }; +}// namespace detail +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +template +mlir::vhlo::Version detail::VersionedOpInterfaceInterfaceTraits::Model::getMinVersion(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).getMinVersion(); +} +template +mlir::vhlo::Version detail::VersionedOpInterfaceInterfaceTraits::Model::getMaxVersion(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).getMaxVersion(); +} +template +mlir::vhlo::Version detail::VersionedOpInterfaceInterfaceTraits::FallbackModel::getMinVersion(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->getMinVersion(tablegen_opaque_val); +} +template +mlir::vhlo::Version detail::VersionedOpInterfaceInterfaceTraits::FallbackModel::getMaxVersion(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->getMaxVersion(tablegen_opaque_val); +} +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +template +mlir::LogicalResult detail::VersionedOpConstraintInterfaceInterfaceTraits::Model::validateConstraint(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, mlir::Operation* op, mlir::vhlo::Version targetVersion) { + return (llvm::cast(tablegen_opaque_val)).validateConstraint(op, targetVersion); +} +template +mlir::LogicalResult detail::VersionedOpConstraintInterfaceInterfaceTraits::FallbackModel::validateConstraint(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, mlir::Operation* op, mlir::vhlo::Version targetVersion) { + return static_cast(impl)->validateConstraint(tablegen_opaque_val, op, targetVersion); +} +} // namespace vhlo +} // namespace mlir diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOps.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOps.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..3208eacf3bea72d0ea540e7cbb96d1ca136d53cb --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOps.cpp.inc @@ -0,0 +1,34325 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: VhloOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_OP_LIST +#undef GET_OP_LIST + +::mlir::vhlo::AbsOpV1, +::mlir::vhlo::AddOpV1, +::mlir::vhlo::AfterAllOpV1, +::mlir::vhlo::AllGatherOpV1, +::mlir::vhlo::AllGatherOpV2, +::mlir::vhlo::AllReduceOpV1, +::mlir::vhlo::AllReduceOpV2, +::mlir::vhlo::AllToAllOpV1, +::mlir::vhlo::AllToAllOpV2, +::mlir::vhlo::AndOpV1, +::mlir::vhlo::Atan2OpV1, +::mlir::vhlo::BatchNormGradOpV1, +::mlir::vhlo::BatchNormInferenceOpV1, +::mlir::vhlo::BatchNormTrainingOpV1, +::mlir::vhlo::BitcastConvertOpV1, +::mlir::vhlo::BroadcastInDimOpV1, +::mlir::vhlo::BroadcastOpV1, +::mlir::vhlo::CallOpV1, +::mlir::vhlo::CaseOpV1, +::mlir::vhlo::CbrtOpV1, +::mlir::vhlo::CbrtOpV2, +::mlir::vhlo::CeilOpV1, +::mlir::vhlo::CholeskyOpV1, +::mlir::vhlo::ClampOpV1, +::mlir::vhlo::ClzOpV1, +::mlir::vhlo::CollectiveBroadcastOpV1, +::mlir::vhlo::CollectivePermuteOpV1, +::mlir::vhlo::CompareOpV1, +::mlir::vhlo::ComplexOpV1, +::mlir::vhlo::CompositeOpV1, +::mlir::vhlo::ConcatenateOpV1, +::mlir::vhlo::ConstantOpV1, +::mlir::vhlo::ConvertOpV1, +::mlir::vhlo::ConvolutionOpV1, +::mlir::vhlo::CosineOpV1, +::mlir::vhlo::CosineOpV2, +::mlir::vhlo::CreateTokenOpV1, +::mlir::vhlo::CrossReplicaSumOpV1, +::mlir::vhlo::CustomCallOpV1, +::mlir::vhlo::DivOpV1, +::mlir::vhlo::DotGeneralOpV1, +::mlir::vhlo::DotGeneralOpV2, +::mlir::vhlo::DotOpV1, +::mlir::vhlo::DynamicBroadcastInDimOpV1, +::mlir::vhlo::DynamicConvOpV1, +::mlir::vhlo::DynamicConvOpV2, +::mlir::vhlo::DynamicGatherOpV1, +::mlir::vhlo::DynamicGatherOpV2, +::mlir::vhlo::DynamicIotaOpV1, +::mlir::vhlo::DynamicPadOpV1, +::mlir::vhlo::DynamicReshapeOpV1, +::mlir::vhlo::DynamicSliceOpV1, +::mlir::vhlo::DynamicUpdateSliceOpV1, +::mlir::vhlo::EinsumOpV1, +::mlir::vhlo::ExpOpV1, +::mlir::vhlo::ExpOpV2, +::mlir::vhlo::Expm1OpV1, +::mlir::vhlo::Expm1OpV2, +::mlir::vhlo::FftOpV1, +::mlir::vhlo::FloorOpV1, +::mlir::vhlo::FuncOpV1, +::mlir::vhlo::GatherOpV1, +::mlir::vhlo::GatherOpV2, +::mlir::vhlo::GetDimensionSizeOpV1, +::mlir::vhlo::GetTupleElementOpV1, +::mlir::vhlo::IfOpV1, +::mlir::vhlo::ImagOpV1, +::mlir::vhlo::InfeedOpV1, +::mlir::vhlo::IotaOpV1, +::mlir::vhlo::IsFiniteOpV1, +::mlir::vhlo::Log1pOpV1, +::mlir::vhlo::Log1pOpV2, +::mlir::vhlo::LogOpV1, +::mlir::vhlo::LogOpV2, +::mlir::vhlo::LogisticOpV1, +::mlir::vhlo::LogisticOpV2, +::mlir::vhlo::MapOpV1, +::mlir::vhlo::MaxOpV1, +::mlir::vhlo::MinOpV1, +::mlir::vhlo::MulOpV1, +::mlir::vhlo::NegOpV1, +::mlir::vhlo::NotOpV1, +::mlir::vhlo::OptimizationBarrierOpV1, +::mlir::vhlo::OrOpV1, +::mlir::vhlo::OutfeedOpV1, +::mlir::vhlo::PadOpV1, +::mlir::vhlo::PartitionIdOpV1, +::mlir::vhlo::PopulationCountOpV1, +::mlir::vhlo::PowOpV1, +::mlir::vhlo::RealDynamicSliceOpV1, +::mlir::vhlo::RealOpV1, +::mlir::vhlo::RecvOpV1, +::mlir::vhlo::ReduceOpV1, +::mlir::vhlo::ReducePrecisionOpV1, +::mlir::vhlo::ReduceScatterOpV1, +::mlir::vhlo::ReduceWindowOpV1, +::mlir::vhlo::RemOpV1, +::mlir::vhlo::ReplicaIdOpV1, +::mlir::vhlo::ReshapeOpV1, +::mlir::vhlo::ReturnOpV1, +::mlir::vhlo::ReverseOpV1, +::mlir::vhlo::RngBitGeneratorOpV1, +::mlir::vhlo::RngOpV1, +::mlir::vhlo::RoundNearestEvenOpV1, +::mlir::vhlo::RoundOpV1, +::mlir::vhlo::RsqrtOpV1, +::mlir::vhlo::RsqrtOpV2, +::mlir::vhlo::ScatterOpV1, +::mlir::vhlo::ScatterOpV2, +::mlir::vhlo::SelectAndScatterOpV1, +::mlir::vhlo::SelectOpV1, +::mlir::vhlo::SendOpV1, +::mlir::vhlo::SetDimensionSizeOpV1, +::mlir::vhlo::ShiftLeftOpV1, +::mlir::vhlo::ShiftRightArithmeticOpV1, +::mlir::vhlo::ShiftRightLogicalOpV1, +::mlir::vhlo::SignOpV1, +::mlir::vhlo::SineOpV1, +::mlir::vhlo::SineOpV2, +::mlir::vhlo::SliceOpV1, +::mlir::vhlo::SortOpV1, +::mlir::vhlo::SqrtOpV1, +::mlir::vhlo::SqrtOpV2, +::mlir::vhlo::SubtractOpV1, +::mlir::vhlo::TanOpV1, +::mlir::vhlo::TanOpV2, +::mlir::vhlo::TanhOpV1, +::mlir::vhlo::TanhOpV2, +::mlir::vhlo::TorchIndexSelectOpV1, +::mlir::vhlo::TransposeOpV1, +::mlir::vhlo::TriangularSolveOpV1, +::mlir::vhlo::TupleOpV1, +::mlir::vhlo::UnaryEinsumOpV1, +::mlir::vhlo::UniformDequantizeOpV1, +::mlir::vhlo::UniformQuantizeOpV1, +::mlir::vhlo::WhileOpV1, +::mlir::vhlo::XorOpV1 +#endif // GET_OP_LIST + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace vhlo { + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_VhloOps1( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((true))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be any type, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_VhloOps2( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((true))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be variadic of any type, but got " << type; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_VhloOps1( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((true))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: any attribute"; + return ::mlir::success(); +} +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_VhloOps1( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_VhloOps1(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::llvm::LogicalResult __mlir_ods_local_region_constraint_VhloOps1( + ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, + unsigned regionIndex) { + if (!((true))) { + return op->emitOpError("region #") << regionIndex + << (regionName.empty() ? " " : " ('" + regionName + "') ") + << "failed to verify constraint: any region"; + } + return ::mlir::success(); +} +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AbsOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AbsOpV1GenericAdaptorBase::AbsOpV1GenericAdaptorBase(AbsOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +AbsOpV1Adaptor::AbsOpV1Adaptor(AbsOpV1 op) : AbsOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AbsOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult AbsOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AbsOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AbsOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AbsOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AbsOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AbsOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AbsOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AbsOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void AbsOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AbsOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AbsOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult AbsOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AbsOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version AbsOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version AbsOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::AbsOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AddOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AddOpV1GenericAdaptorBase::AddOpV1GenericAdaptorBase(AddOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +AddOpV1Adaptor::AddOpV1Adaptor(AddOpV1 op) : AddOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AddOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult AddOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AddOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AddOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AddOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AddOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AddOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AddOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AddOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void AddOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AddOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AddOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult AddOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AddOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version AddOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version AddOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::AddOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AfterAllOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AfterAllOpV1GenericAdaptorBase::AfterAllOpV1GenericAdaptorBase(AfterAllOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair AfterAllOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +} // namespace detail +AfterAllOpV1Adaptor::AfterAllOpV1Adaptor(AfterAllOpV1 op) : AfterAllOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AfterAllOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair AfterAllOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange AfterAllOpV1::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult AfterAllOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AfterAllOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AfterAllOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AfterAllOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AfterAllOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AfterAllOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AfterAllOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AfterAllOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs) { + odsState.addOperands(inputs); + odsState.addTypes(result); +} + +void AfterAllOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AfterAllOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult AfterAllOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AfterAllOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version AfterAllOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version AfterAllOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::AfterAllOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AllGatherOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AllGatherOpV1GenericAdaptorBase::AllGatherOpV1GenericAdaptorBase(AllGatherOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute AllGatherOpV1GenericAdaptorBase::getAllGatherDim() { + auto attr = getAllGatherDimAttr(); + return attr; +} + +::mlir::Attribute AllGatherOpV1GenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute AllGatherOpV1GenericAdaptorBase::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute AllGatherOpV1GenericAdaptorBase::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + return attr; +} + +} // namespace detail +AllGatherOpV1Adaptor::AllGatherOpV1Adaptor(AllGatherOpV1 op) : AllGatherOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AllGatherOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_all_gather_dim = getProperties().all_gather_dim; (void)tblgen_all_gather_dim; + if (!tblgen_all_gather_dim) return emitError(loc, "'vhlo.all_gather_v1' op ""requires attribute 'all_gather_dim'"); + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitError(loc, "'vhlo.all_gather_v1' op ""requires attribute 'channel_id'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'vhlo.all_gather_v1' op ""requires attribute 'replica_groups'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + if (!tblgen_use_global_device_ids) return emitError(loc, "'vhlo.all_gather_v1' op ""requires attribute 'use_global_device_ids'"); + + if (tblgen_all_gather_dim && !((true))) + return emitError(loc, "'vhlo.all_gather_v1' op ""attribute 'all_gather_dim' failed to satisfy constraint: any attribute"); + + if (tblgen_replica_groups && !((true))) + return emitError(loc, "'vhlo.all_gather_v1' op ""attribute 'replica_groups' failed to satisfy constraint: any attribute"); + + if (tblgen_channel_id && !((true))) + return emitError(loc, "'vhlo.all_gather_v1' op ""attribute 'channel_id' failed to satisfy constraint: any attribute"); + + if (tblgen_use_global_device_ids && !((true))) + return emitError(loc, "'vhlo.all_gather_v1' op ""attribute 'use_global_device_ids' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult AllGatherOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.all_gather_dim; + auto attr = dict.get("all_gather_dim"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `all_gather_dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.channel_id; + auto attr = dict.get("channel_id"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_id` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.use_global_device_ids; + auto attr = dict.get("use_global_device_ids"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `use_global_device_ids` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute AllGatherOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.all_gather_dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("all_gather_dim", + propStorage)); + } + + { + const auto &propStorage = prop.channel_id; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_id", + propStorage)); + } + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + { + const auto &propStorage = prop.use_global_device_ids; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("use_global_device_ids", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AllGatherOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.all_gather_dim.getAsOpaquePointer()), + llvm::hash_value(prop.channel_id.getAsOpaquePointer()), + llvm::hash_value(prop.replica_groups.getAsOpaquePointer()), + llvm::hash_value(prop.use_global_device_ids.getAsOpaquePointer())); +} + +std::optional AllGatherOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "all_gather_dim") + return prop.all_gather_dim; + + if (name == "channel_id") + return prop.channel_id; + + if (name == "replica_groups") + return prop.replica_groups; + + if (name == "use_global_device_ids") + return prop.use_global_device_ids; + return std::nullopt; +} + +void AllGatherOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "all_gather_dim") { + prop.all_gather_dim = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "channel_id") { + prop.channel_id = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "use_global_device_ids") { + prop.use_global_device_ids = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void AllGatherOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.all_gather_dim) attrs.append("all_gather_dim", prop.all_gather_dim); + + if (prop.channel_id) attrs.append("channel_id", prop.channel_id); + + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); + + if (prop.use_global_device_ids) attrs.append("use_global_device_ids", prop.use_global_device_ids); +} + +::llvm::LogicalResult AllGatherOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getAllGatherDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "all_gather_dim", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getChannelIdAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "channel_id", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUseGlobalDeviceIdsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "use_global_device_ids", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllGatherOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.all_gather_dim))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.channel_id))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.use_global_device_ids))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AllGatherOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.all_gather_dim); + writer.writeAttribute(prop.channel_id); + writer.writeAttribute(prop.replica_groups); + writer.writeAttribute(prop.use_global_device_ids); +} + +::mlir::Attribute AllGatherOpV1::getAllGatherDim() { + auto attr = getAllGatherDimAttr(); + return attr; +} + +::mlir::Attribute AllGatherOpV1::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute AllGatherOpV1::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute AllGatherOpV1::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + return attr; +} + +void AllGatherOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute all_gather_dim, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids) { + odsState.addOperands(operand); + odsState.getOrAddProperties().all_gather_dim = all_gather_dim; + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.getOrAddProperties().channel_id = channel_id; + odsState.getOrAddProperties().use_global_device_ids = use_global_device_ids; + odsState.addTypes(result); +} + +void AllGatherOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute all_gather_dim, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids) { + odsState.addOperands(operand); + odsState.getOrAddProperties().all_gather_dim = all_gather_dim; + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.getOrAddProperties().channel_id = channel_id; + odsState.getOrAddProperties().use_global_device_ids = use_global_device_ids; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AllGatherOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void AllGatherOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult AllGatherOpV1::verifyInvariantsImpl() { + auto tblgen_all_gather_dim = getProperties().all_gather_dim; (void)tblgen_all_gather_dim; + if (!tblgen_all_gather_dim) return emitOpError("requires attribute 'all_gather_dim'"); + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitOpError("requires attribute 'channel_id'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + if (!tblgen_use_global_device_ids) return emitOpError("requires attribute 'use_global_device_ids'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_all_gather_dim, "all_gather_dim"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_channel_id, "channel_id"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_use_global_device_ids, "use_global_device_ids"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllGatherOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version AllGatherOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version AllGatherOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 4, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::AllGatherOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AllGatherOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AllGatherOpV2GenericAdaptorBase::AllGatherOpV2GenericAdaptorBase(AllGatherOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair AllGatherOpV2GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute AllGatherOpV2GenericAdaptorBase::getAllGatherDim() { + auto attr = getAllGatherDimAttr(); + return attr; +} + +::mlir::Attribute AllGatherOpV2GenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute AllGatherOpV2GenericAdaptorBase::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute AllGatherOpV2GenericAdaptorBase::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + return attr; +} + +} // namespace detail +AllGatherOpV2Adaptor::AllGatherOpV2Adaptor(AllGatherOpV2 op) : AllGatherOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AllGatherOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_all_gather_dim = getProperties().all_gather_dim; (void)tblgen_all_gather_dim; + if (!tblgen_all_gather_dim) return emitError(loc, "'vhlo.all_gather_v2' op ""requires attribute 'all_gather_dim'"); + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitError(loc, "'vhlo.all_gather_v2' op ""requires attribute 'channel_id'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'vhlo.all_gather_v2' op ""requires attribute 'replica_groups'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + if (!tblgen_use_global_device_ids) return emitError(loc, "'vhlo.all_gather_v2' op ""requires attribute 'use_global_device_ids'"); + + if (tblgen_all_gather_dim && !((true))) + return emitError(loc, "'vhlo.all_gather_v2' op ""attribute 'all_gather_dim' failed to satisfy constraint: any attribute"); + + if (tblgen_replica_groups && !((true))) + return emitError(loc, "'vhlo.all_gather_v2' op ""attribute 'replica_groups' failed to satisfy constraint: any attribute"); + + if (tblgen_channel_id && !((true))) + return emitError(loc, "'vhlo.all_gather_v2' op ""attribute 'channel_id' failed to satisfy constraint: any attribute"); + + if (tblgen_use_global_device_ids && !((true))) + return emitError(loc, "'vhlo.all_gather_v2' op ""attribute 'use_global_device_ids' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair AllGatherOpV2::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange AllGatherOpV2::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair AllGatherOpV2::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult AllGatherOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.all_gather_dim; + auto attr = dict.get("all_gather_dim"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `all_gather_dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.channel_id; + auto attr = dict.get("channel_id"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_id` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.use_global_device_ids; + auto attr = dict.get("use_global_device_ids"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `use_global_device_ids` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute AllGatherOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.all_gather_dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("all_gather_dim", + propStorage)); + } + + { + const auto &propStorage = prop.channel_id; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_id", + propStorage)); + } + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + { + const auto &propStorage = prop.use_global_device_ids; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("use_global_device_ids", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AllGatherOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.all_gather_dim.getAsOpaquePointer()), + llvm::hash_value(prop.channel_id.getAsOpaquePointer()), + llvm::hash_value(prop.replica_groups.getAsOpaquePointer()), + llvm::hash_value(prop.use_global_device_ids.getAsOpaquePointer())); +} + +std::optional AllGatherOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "all_gather_dim") + return prop.all_gather_dim; + + if (name == "channel_id") + return prop.channel_id; + + if (name == "replica_groups") + return prop.replica_groups; + + if (name == "use_global_device_ids") + return prop.use_global_device_ids; + return std::nullopt; +} + +void AllGatherOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "all_gather_dim") { + prop.all_gather_dim = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "channel_id") { + prop.channel_id = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "use_global_device_ids") { + prop.use_global_device_ids = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void AllGatherOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.all_gather_dim) attrs.append("all_gather_dim", prop.all_gather_dim); + + if (prop.channel_id) attrs.append("channel_id", prop.channel_id); + + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); + + if (prop.use_global_device_ids) attrs.append("use_global_device_ids", prop.use_global_device_ids); +} + +::llvm::LogicalResult AllGatherOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getAllGatherDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "all_gather_dim", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getChannelIdAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "channel_id", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUseGlobalDeviceIdsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "use_global_device_ids", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllGatherOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.all_gather_dim))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.channel_id))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.use_global_device_ids))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AllGatherOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.all_gather_dim); + writer.writeAttribute(prop.channel_id); + writer.writeAttribute(prop.replica_groups); + writer.writeAttribute(prop.use_global_device_ids); +} + +::mlir::Attribute AllGatherOpV2::getAllGatherDim() { + auto attr = getAllGatherDimAttr(); + return attr; +} + +::mlir::Attribute AllGatherOpV2::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute AllGatherOpV2::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute AllGatherOpV2::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + return attr; +} + +void AllGatherOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange operands, ::mlir::Attribute all_gather_dim, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids) { + odsState.addOperands(operands); + odsState.getOrAddProperties().all_gather_dim = all_gather_dim; + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.getOrAddProperties().channel_id = channel_id; + odsState.getOrAddProperties().use_global_device_ids = use_global_device_ids; + odsState.addTypes(results); +} + +void AllGatherOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void AllGatherOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult AllGatherOpV2::verifyInvariantsImpl() { + auto tblgen_all_gather_dim = getProperties().all_gather_dim; (void)tblgen_all_gather_dim; + if (!tblgen_all_gather_dim) return emitOpError("requires attribute 'all_gather_dim'"); + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitOpError("requires attribute 'channel_id'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + if (!tblgen_use_global_device_ids) return emitOpError("requires attribute 'use_global_device_ids'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_all_gather_dim, "all_gather_dim"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_channel_id, "channel_id"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_use_global_device_ids, "use_global_device_ids"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllGatherOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version AllGatherOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 5, 0); +} +mlir::vhlo::Version AllGatherOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::AllGatherOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AllReduceOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AllReduceOpV1GenericAdaptorBase::AllReduceOpV1GenericAdaptorBase(AllReduceOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute AllReduceOpV1GenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute AllReduceOpV1GenericAdaptorBase::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute AllReduceOpV1GenericAdaptorBase::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + return attr; +} + +} // namespace detail +AllReduceOpV1Adaptor::AllReduceOpV1Adaptor(AllReduceOpV1 op) : AllReduceOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AllReduceOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitError(loc, "'vhlo.all_reduce_v1' op ""requires attribute 'channel_id'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'vhlo.all_reduce_v1' op ""requires attribute 'replica_groups'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + if (!tblgen_use_global_device_ids) return emitError(loc, "'vhlo.all_reduce_v1' op ""requires attribute 'use_global_device_ids'"); + + if (tblgen_replica_groups && !((true))) + return emitError(loc, "'vhlo.all_reduce_v1' op ""attribute 'replica_groups' failed to satisfy constraint: any attribute"); + + if (tblgen_channel_id && !((true))) + return emitError(loc, "'vhlo.all_reduce_v1' op ""attribute 'channel_id' failed to satisfy constraint: any attribute"); + + if (tblgen_use_global_device_ids && !((true))) + return emitError(loc, "'vhlo.all_reduce_v1' op ""attribute 'use_global_device_ids' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult AllReduceOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_id; + auto attr = dict.get("channel_id"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_id` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.use_global_device_ids; + auto attr = dict.get("use_global_device_ids"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `use_global_device_ids` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute AllReduceOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_id; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_id", + propStorage)); + } + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + { + const auto &propStorage = prop.use_global_device_ids; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("use_global_device_ids", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AllReduceOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_id.getAsOpaquePointer()), + llvm::hash_value(prop.replica_groups.getAsOpaquePointer()), + llvm::hash_value(prop.use_global_device_ids.getAsOpaquePointer())); +} + +std::optional AllReduceOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_id") + return prop.channel_id; + + if (name == "replica_groups") + return prop.replica_groups; + + if (name == "use_global_device_ids") + return prop.use_global_device_ids; + return std::nullopt; +} + +void AllReduceOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_id") { + prop.channel_id = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "use_global_device_ids") { + prop.use_global_device_ids = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void AllReduceOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_id) attrs.append("channel_id", prop.channel_id); + + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); + + if (prop.use_global_device_ids) attrs.append("use_global_device_ids", prop.use_global_device_ids); +} + +::llvm::LogicalResult AllReduceOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelIdAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "channel_id", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUseGlobalDeviceIdsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "use_global_device_ids", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllReduceOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.channel_id))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.use_global_device_ids))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AllReduceOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.channel_id); + writer.writeAttribute(prop.replica_groups); + writer.writeAttribute(prop.use_global_device_ids); +} + +::mlir::Attribute AllReduceOpV1::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute AllReduceOpV1::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute AllReduceOpV1::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + return attr; +} + +void AllReduceOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids) { + odsState.addOperands(operand); + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.getOrAddProperties().channel_id = channel_id; + odsState.getOrAddProperties().use_global_device_ids = use_global_device_ids; + (void)odsState.addRegion(); + odsState.addTypes(result); +} + +void AllReduceOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids) { + odsState.addOperands(operand); + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.getOrAddProperties().channel_id = channel_id; + odsState.getOrAddProperties().use_global_device_ids = use_global_device_ids; + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AllReduceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void AllReduceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult AllReduceOpV1::verifyInvariantsImpl() { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitOpError("requires attribute 'channel_id'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + if (!tblgen_use_global_device_ids) return emitOpError("requires attribute 'use_global_device_ids'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_channel_id, "channel_id"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_use_global_device_ids, "use_global_device_ids"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "computation", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllReduceOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version AllReduceOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version AllReduceOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 4, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::AllReduceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AllReduceOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AllReduceOpV2GenericAdaptorBase::AllReduceOpV2GenericAdaptorBase(AllReduceOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair AllReduceOpV2GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute AllReduceOpV2GenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute AllReduceOpV2GenericAdaptorBase::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute AllReduceOpV2GenericAdaptorBase::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + return attr; +} + +} // namespace detail +AllReduceOpV2Adaptor::AllReduceOpV2Adaptor(AllReduceOpV2 op) : AllReduceOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AllReduceOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitError(loc, "'vhlo.all_reduce_v2' op ""requires attribute 'channel_id'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'vhlo.all_reduce_v2' op ""requires attribute 'replica_groups'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + if (!tblgen_use_global_device_ids) return emitError(loc, "'vhlo.all_reduce_v2' op ""requires attribute 'use_global_device_ids'"); + + if (tblgen_replica_groups && !((true))) + return emitError(loc, "'vhlo.all_reduce_v2' op ""attribute 'replica_groups' failed to satisfy constraint: any attribute"); + + if (tblgen_channel_id && !((true))) + return emitError(loc, "'vhlo.all_reduce_v2' op ""attribute 'channel_id' failed to satisfy constraint: any attribute"); + + if (tblgen_use_global_device_ids && !((true))) + return emitError(loc, "'vhlo.all_reduce_v2' op ""attribute 'use_global_device_ids' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair AllReduceOpV2::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange AllReduceOpV2::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair AllReduceOpV2::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult AllReduceOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_id; + auto attr = dict.get("channel_id"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_id` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.use_global_device_ids; + auto attr = dict.get("use_global_device_ids"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `use_global_device_ids` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute AllReduceOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_id; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_id", + propStorage)); + } + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + { + const auto &propStorage = prop.use_global_device_ids; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("use_global_device_ids", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AllReduceOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_id.getAsOpaquePointer()), + llvm::hash_value(prop.replica_groups.getAsOpaquePointer()), + llvm::hash_value(prop.use_global_device_ids.getAsOpaquePointer())); +} + +std::optional AllReduceOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_id") + return prop.channel_id; + + if (name == "replica_groups") + return prop.replica_groups; + + if (name == "use_global_device_ids") + return prop.use_global_device_ids; + return std::nullopt; +} + +void AllReduceOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_id") { + prop.channel_id = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "use_global_device_ids") { + prop.use_global_device_ids = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void AllReduceOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_id) attrs.append("channel_id", prop.channel_id); + + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); + + if (prop.use_global_device_ids) attrs.append("use_global_device_ids", prop.use_global_device_ids); +} + +::llvm::LogicalResult AllReduceOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelIdAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "channel_id", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUseGlobalDeviceIdsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "use_global_device_ids", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllReduceOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.channel_id))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.use_global_device_ids))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AllReduceOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.channel_id); + writer.writeAttribute(prop.replica_groups); + writer.writeAttribute(prop.use_global_device_ids); +} + +::mlir::Attribute AllReduceOpV2::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute AllReduceOpV2::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute AllReduceOpV2::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + return attr; +} + +void AllReduceOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange operands, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids) { + odsState.addOperands(operands); + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.getOrAddProperties().channel_id = channel_id; + odsState.getOrAddProperties().use_global_device_ids = use_global_device_ids; + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void AllReduceOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void AllReduceOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult AllReduceOpV2::verifyInvariantsImpl() { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitOpError("requires attribute 'channel_id'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + if (!tblgen_use_global_device_ids) return emitOpError("requires attribute 'use_global_device_ids'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_channel_id, "channel_id"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_use_global_device_ids, "use_global_device_ids"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "computation", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllReduceOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version AllReduceOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 5, 0); +} +mlir::vhlo::Version AllReduceOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::AllReduceOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AllToAllOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AllToAllOpV1GenericAdaptorBase::AllToAllOpV1GenericAdaptorBase(AllToAllOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute AllToAllOpV1GenericAdaptorBase::getSplitDimension() { + auto attr = getSplitDimensionAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV1GenericAdaptorBase::getConcatDimension() { + auto attr = getConcatDimensionAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV1GenericAdaptorBase::getSplitCount() { + auto attr = getSplitCountAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV1GenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV1GenericAdaptorBase::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +} // namespace detail +AllToAllOpV1Adaptor::AllToAllOpV1Adaptor(AllToAllOpV1 op) : AllToAllOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AllToAllOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitError(loc, "'vhlo.all_to_all_v1' op ""requires attribute 'channel_id'"); + auto tblgen_concat_dimension = getProperties().concat_dimension; (void)tblgen_concat_dimension; + if (!tblgen_concat_dimension) return emitError(loc, "'vhlo.all_to_all_v1' op ""requires attribute 'concat_dimension'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'vhlo.all_to_all_v1' op ""requires attribute 'replica_groups'"); + auto tblgen_split_count = getProperties().split_count; (void)tblgen_split_count; + if (!tblgen_split_count) return emitError(loc, "'vhlo.all_to_all_v1' op ""requires attribute 'split_count'"); + auto tblgen_split_dimension = getProperties().split_dimension; (void)tblgen_split_dimension; + if (!tblgen_split_dimension) return emitError(loc, "'vhlo.all_to_all_v1' op ""requires attribute 'split_dimension'"); + + if (tblgen_split_dimension && !((true))) + return emitError(loc, "'vhlo.all_to_all_v1' op ""attribute 'split_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_concat_dimension && !((true))) + return emitError(loc, "'vhlo.all_to_all_v1' op ""attribute 'concat_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_split_count && !((true))) + return emitError(loc, "'vhlo.all_to_all_v1' op ""attribute 'split_count' failed to satisfy constraint: any attribute"); + + if (tblgen_replica_groups && !((true))) + return emitError(loc, "'vhlo.all_to_all_v1' op ""attribute 'replica_groups' failed to satisfy constraint: any attribute"); + + if (tblgen_channel_id && !((true))) + return emitError(loc, "'vhlo.all_to_all_v1' op ""attribute 'channel_id' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult AllToAllOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_id; + auto attr = dict.get("channel_id"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_id` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.concat_dimension; + auto attr = dict.get("concat_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `concat_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.split_count; + auto attr = dict.get("split_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `split_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.split_dimension; + auto attr = dict.get("split_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `split_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute AllToAllOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_id; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_id", + propStorage)); + } + + { + const auto &propStorage = prop.concat_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("concat_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + { + const auto &propStorage = prop.split_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("split_count", + propStorage)); + } + + { + const auto &propStorage = prop.split_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("split_dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AllToAllOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_id.getAsOpaquePointer()), + llvm::hash_value(prop.concat_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.replica_groups.getAsOpaquePointer()), + llvm::hash_value(prop.split_count.getAsOpaquePointer()), + llvm::hash_value(prop.split_dimension.getAsOpaquePointer())); +} + +std::optional AllToAllOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_id") + return prop.channel_id; + + if (name == "concat_dimension") + return prop.concat_dimension; + + if (name == "replica_groups") + return prop.replica_groups; + + if (name == "split_count") + return prop.split_count; + + if (name == "split_dimension") + return prop.split_dimension; + return std::nullopt; +} + +void AllToAllOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_id") { + prop.channel_id = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "concat_dimension") { + prop.concat_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "split_count") { + prop.split_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "split_dimension") { + prop.split_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void AllToAllOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_id) attrs.append("channel_id", prop.channel_id); + + if (prop.concat_dimension) attrs.append("concat_dimension", prop.concat_dimension); + + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); + + if (prop.split_count) attrs.append("split_count", prop.split_count); + + if (prop.split_dimension) attrs.append("split_dimension", prop.split_dimension); +} + +::llvm::LogicalResult AllToAllOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelIdAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "channel_id", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getConcatDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "concat_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSplitCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "split_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSplitDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "split_dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllToAllOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.channel_id))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.concat_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.split_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.split_dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AllToAllOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.channel_id); + writer.writeAttribute(prop.concat_dimension); + writer.writeAttribute(prop.replica_groups); + writer.writeAttribute(prop.split_count); + writer.writeAttribute(prop.split_dimension); +} + +::mlir::Attribute AllToAllOpV1::getSplitDimension() { + auto attr = getSplitDimensionAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV1::getConcatDimension() { + auto attr = getConcatDimensionAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV1::getSplitCount() { + auto attr = getSplitCountAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV1::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV1::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +void AllToAllOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute split_dimension, ::mlir::Attribute concat_dimension, ::mlir::Attribute split_count, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id) { + odsState.addOperands(operand); + odsState.getOrAddProperties().split_dimension = split_dimension; + odsState.getOrAddProperties().concat_dimension = concat_dimension; + odsState.getOrAddProperties().split_count = split_count; + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.getOrAddProperties().channel_id = channel_id; + odsState.addTypes(result); +} + +void AllToAllOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute split_dimension, ::mlir::Attribute concat_dimension, ::mlir::Attribute split_count, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id) { + odsState.addOperands(operand); + odsState.getOrAddProperties().split_dimension = split_dimension; + odsState.getOrAddProperties().concat_dimension = concat_dimension; + odsState.getOrAddProperties().split_count = split_count; + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.getOrAddProperties().channel_id = channel_id; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AllToAllOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void AllToAllOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult AllToAllOpV1::verifyInvariantsImpl() { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitOpError("requires attribute 'channel_id'"); + auto tblgen_concat_dimension = getProperties().concat_dimension; (void)tblgen_concat_dimension; + if (!tblgen_concat_dimension) return emitOpError("requires attribute 'concat_dimension'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + auto tblgen_split_count = getProperties().split_count; (void)tblgen_split_count; + if (!tblgen_split_count) return emitOpError("requires attribute 'split_count'"); + auto tblgen_split_dimension = getProperties().split_dimension; (void)tblgen_split_dimension; + if (!tblgen_split_dimension) return emitOpError("requires attribute 'split_dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_split_dimension, "split_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_concat_dimension, "concat_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_split_count, "split_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_channel_id, "channel_id"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllToAllOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version AllToAllOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version AllToAllOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 4, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::AllToAllOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AllToAllOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AllToAllOpV2GenericAdaptorBase::AllToAllOpV2GenericAdaptorBase(AllToAllOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair AllToAllOpV2GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute AllToAllOpV2GenericAdaptorBase::getSplitDimension() { + auto attr = getSplitDimensionAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV2GenericAdaptorBase::getConcatDimension() { + auto attr = getConcatDimensionAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV2GenericAdaptorBase::getSplitCount() { + auto attr = getSplitCountAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV2GenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV2GenericAdaptorBase::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +} // namespace detail +AllToAllOpV2Adaptor::AllToAllOpV2Adaptor(AllToAllOpV2 op) : AllToAllOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AllToAllOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitError(loc, "'vhlo.all_to_all_v2' op ""requires attribute 'channel_id'"); + auto tblgen_concat_dimension = getProperties().concat_dimension; (void)tblgen_concat_dimension; + if (!tblgen_concat_dimension) return emitError(loc, "'vhlo.all_to_all_v2' op ""requires attribute 'concat_dimension'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'vhlo.all_to_all_v2' op ""requires attribute 'replica_groups'"); + auto tblgen_split_count = getProperties().split_count; (void)tblgen_split_count; + if (!tblgen_split_count) return emitError(loc, "'vhlo.all_to_all_v2' op ""requires attribute 'split_count'"); + auto tblgen_split_dimension = getProperties().split_dimension; (void)tblgen_split_dimension; + if (!tblgen_split_dimension) return emitError(loc, "'vhlo.all_to_all_v2' op ""requires attribute 'split_dimension'"); + + if (tblgen_split_dimension && !((true))) + return emitError(loc, "'vhlo.all_to_all_v2' op ""attribute 'split_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_concat_dimension && !((true))) + return emitError(loc, "'vhlo.all_to_all_v2' op ""attribute 'concat_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_split_count && !((true))) + return emitError(loc, "'vhlo.all_to_all_v2' op ""attribute 'split_count' failed to satisfy constraint: any attribute"); + + if (tblgen_replica_groups && !((true))) + return emitError(loc, "'vhlo.all_to_all_v2' op ""attribute 'replica_groups' failed to satisfy constraint: any attribute"); + + if (tblgen_channel_id && !((true))) + return emitError(loc, "'vhlo.all_to_all_v2' op ""attribute 'channel_id' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair AllToAllOpV2::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange AllToAllOpV2::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair AllToAllOpV2::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult AllToAllOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_id; + auto attr = dict.get("channel_id"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_id` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.concat_dimension; + auto attr = dict.get("concat_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `concat_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.split_count; + auto attr = dict.get("split_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `split_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.split_dimension; + auto attr = dict.get("split_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `split_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute AllToAllOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_id; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_id", + propStorage)); + } + + { + const auto &propStorage = prop.concat_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("concat_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + { + const auto &propStorage = prop.split_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("split_count", + propStorage)); + } + + { + const auto &propStorage = prop.split_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("split_dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AllToAllOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_id.getAsOpaquePointer()), + llvm::hash_value(prop.concat_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.replica_groups.getAsOpaquePointer()), + llvm::hash_value(prop.split_count.getAsOpaquePointer()), + llvm::hash_value(prop.split_dimension.getAsOpaquePointer())); +} + +std::optional AllToAllOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_id") + return prop.channel_id; + + if (name == "concat_dimension") + return prop.concat_dimension; + + if (name == "replica_groups") + return prop.replica_groups; + + if (name == "split_count") + return prop.split_count; + + if (name == "split_dimension") + return prop.split_dimension; + return std::nullopt; +} + +void AllToAllOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_id") { + prop.channel_id = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "concat_dimension") { + prop.concat_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "split_count") { + prop.split_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "split_dimension") { + prop.split_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void AllToAllOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_id) attrs.append("channel_id", prop.channel_id); + + if (prop.concat_dimension) attrs.append("concat_dimension", prop.concat_dimension); + + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); + + if (prop.split_count) attrs.append("split_count", prop.split_count); + + if (prop.split_dimension) attrs.append("split_dimension", prop.split_dimension); +} + +::llvm::LogicalResult AllToAllOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelIdAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "channel_id", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getConcatDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "concat_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSplitCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "split_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSplitDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "split_dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllToAllOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.channel_id))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.concat_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.split_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.split_dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AllToAllOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.channel_id); + writer.writeAttribute(prop.concat_dimension); + writer.writeAttribute(prop.replica_groups); + writer.writeAttribute(prop.split_count); + writer.writeAttribute(prop.split_dimension); +} + +::mlir::Attribute AllToAllOpV2::getSplitDimension() { + auto attr = getSplitDimensionAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV2::getConcatDimension() { + auto attr = getConcatDimensionAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV2::getSplitCount() { + auto attr = getSplitCountAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV2::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute AllToAllOpV2::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +void AllToAllOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange operands, ::mlir::Attribute split_dimension, ::mlir::Attribute concat_dimension, ::mlir::Attribute split_count, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id) { + odsState.addOperands(operands); + odsState.getOrAddProperties().split_dimension = split_dimension; + odsState.getOrAddProperties().concat_dimension = concat_dimension; + odsState.getOrAddProperties().split_count = split_count; + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.getOrAddProperties().channel_id = channel_id; + odsState.addTypes(results); +} + +void AllToAllOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void AllToAllOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult AllToAllOpV2::verifyInvariantsImpl() { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitOpError("requires attribute 'channel_id'"); + auto tblgen_concat_dimension = getProperties().concat_dimension; (void)tblgen_concat_dimension; + if (!tblgen_concat_dimension) return emitOpError("requires attribute 'concat_dimension'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + auto tblgen_split_count = getProperties().split_count; (void)tblgen_split_count; + if (!tblgen_split_count) return emitOpError("requires attribute 'split_count'"); + auto tblgen_split_dimension = getProperties().split_dimension; (void)tblgen_split_dimension; + if (!tblgen_split_dimension) return emitOpError("requires attribute 'split_dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_split_dimension, "split_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_concat_dimension, "concat_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_split_count, "split_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_channel_id, "channel_id"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AllToAllOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version AllToAllOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 5, 0); +} +mlir::vhlo::Version AllToAllOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::AllToAllOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AndOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AndOpV1GenericAdaptorBase::AndOpV1GenericAdaptorBase(AndOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +AndOpV1Adaptor::AndOpV1Adaptor(AndOpV1 op) : AndOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult AndOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult AndOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute AndOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AndOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional AndOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void AndOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void AndOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult AndOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void AndOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void AndOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AndOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AndOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult AndOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult AndOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version AndOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version AndOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::AndOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::Atan2OpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +Atan2OpV1GenericAdaptorBase::Atan2OpV1GenericAdaptorBase(Atan2OpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +Atan2OpV1Adaptor::Atan2OpV1Adaptor(Atan2OpV1 op) : Atan2OpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult Atan2OpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult Atan2OpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute Atan2OpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code Atan2OpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional Atan2OpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void Atan2OpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void Atan2OpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult Atan2OpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void Atan2OpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void Atan2OpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void Atan2OpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void Atan2OpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult Atan2OpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult Atan2OpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version Atan2OpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version Atan2OpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::Atan2OpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::BatchNormGradOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BatchNormGradOpV1GenericAdaptorBase::BatchNormGradOpV1GenericAdaptorBase(BatchNormGradOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute BatchNormGradOpV1GenericAdaptorBase::getEpsilon() { + auto attr = getEpsilonAttr(); + return attr; +} + +::mlir::Attribute BatchNormGradOpV1GenericAdaptorBase::getFeatureIndex() { + auto attr = getFeatureIndexAttr(); + return attr; +} + +} // namespace detail +BatchNormGradOpV1Adaptor::BatchNormGradOpV1Adaptor(BatchNormGradOpV1 op) : BatchNormGradOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BatchNormGradOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_epsilon = getProperties().epsilon; (void)tblgen_epsilon; + if (!tblgen_epsilon) return emitError(loc, "'vhlo.batch_norm_grad_v1' op ""requires attribute 'epsilon'"); + auto tblgen_feature_index = getProperties().feature_index; (void)tblgen_feature_index; + if (!tblgen_feature_index) return emitError(loc, "'vhlo.batch_norm_grad_v1' op ""requires attribute 'feature_index'"); + + if (tblgen_epsilon && !((true))) + return emitError(loc, "'vhlo.batch_norm_grad_v1' op ""attribute 'epsilon' failed to satisfy constraint: any attribute"); + + if (tblgen_feature_index && !((true))) + return emitError(loc, "'vhlo.batch_norm_grad_v1' op ""attribute 'feature_index' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +void BatchNormGradOpV1::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { + auto resultGroup0 = getODSResults(0); + if (!resultGroup0.empty()) + setNameFn(*resultGroup0.begin(), "grad_operand"); + auto resultGroup1 = getODSResults(1); + if (!resultGroup1.empty()) + setNameFn(*resultGroup1.begin(), "grad_scale"); + auto resultGroup2 = getODSResults(2); + if (!resultGroup2.empty()) + setNameFn(*resultGroup2.begin(), "grad_offset"); +} + +::llvm::LogicalResult BatchNormGradOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.epsilon; + auto attr = dict.get("epsilon"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `epsilon` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.feature_index; + auto attr = dict.get("feature_index"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `feature_index` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BatchNormGradOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.epsilon; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("epsilon", + propStorage)); + } + + { + const auto &propStorage = prop.feature_index; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("feature_index", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BatchNormGradOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.epsilon.getAsOpaquePointer()), + llvm::hash_value(prop.feature_index.getAsOpaquePointer())); +} + +std::optional BatchNormGradOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "epsilon") + return prop.epsilon; + + if (name == "feature_index") + return prop.feature_index; + return std::nullopt; +} + +void BatchNormGradOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "epsilon") { + prop.epsilon = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "feature_index") { + prop.feature_index = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BatchNormGradOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.epsilon) attrs.append("epsilon", prop.epsilon); + + if (prop.feature_index) attrs.append("feature_index", prop.feature_index); +} + +::llvm::LogicalResult BatchNormGradOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getEpsilonAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "epsilon", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFeatureIndexAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "feature_index", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormGradOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.epsilon))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.feature_index))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BatchNormGradOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.epsilon); + writer.writeAttribute(prop.feature_index); +} + +::mlir::Attribute BatchNormGradOpV1::getEpsilon() { + auto attr = getEpsilonAttr(); + return attr; +} + +::mlir::Attribute BatchNormGradOpV1::getFeatureIndex() { + auto attr = getFeatureIndexAttr(); + return attr; +} + +void BatchNormGradOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type grad_operand, ::mlir::Type grad_scale, ::mlir::Type grad_offset, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::mlir::Attribute epsilon, ::mlir::Attribute feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.addOperands(grad_output); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + odsState.addTypes(grad_operand); + odsState.addTypes(grad_scale); + odsState.addTypes(grad_offset); +} + +void BatchNormGradOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::mlir::Attribute epsilon, ::mlir::Attribute feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.addOperands(grad_output); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + assert(resultTypes.size() == 3u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BatchNormGradOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 3u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BatchNormGradOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 3u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult BatchNormGradOpV1::verifyInvariantsImpl() { + auto tblgen_epsilon = getProperties().epsilon; (void)tblgen_epsilon; + if (!tblgen_epsilon) return emitOpError("requires attribute 'epsilon'"); + auto tblgen_feature_index = getProperties().feature_index; (void)tblgen_feature_index; + if (!tblgen_feature_index) return emitOpError("requires attribute 'feature_index'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_epsilon, "epsilon"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_feature_index, "feature_index"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSResults(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSResults(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormGradOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version BatchNormGradOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version BatchNormGradOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::BatchNormGradOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::BatchNormInferenceOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BatchNormInferenceOpV1GenericAdaptorBase::BatchNormInferenceOpV1GenericAdaptorBase(BatchNormInferenceOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute BatchNormInferenceOpV1GenericAdaptorBase::getEpsilon() { + auto attr = getEpsilonAttr(); + return attr; +} + +::mlir::Attribute BatchNormInferenceOpV1GenericAdaptorBase::getFeatureIndex() { + auto attr = getFeatureIndexAttr(); + return attr; +} + +} // namespace detail +BatchNormInferenceOpV1Adaptor::BatchNormInferenceOpV1Adaptor(BatchNormInferenceOpV1 op) : BatchNormInferenceOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BatchNormInferenceOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_epsilon = getProperties().epsilon; (void)tblgen_epsilon; + if (!tblgen_epsilon) return emitError(loc, "'vhlo.batch_norm_inference_v1' op ""requires attribute 'epsilon'"); + auto tblgen_feature_index = getProperties().feature_index; (void)tblgen_feature_index; + if (!tblgen_feature_index) return emitError(loc, "'vhlo.batch_norm_inference_v1' op ""requires attribute 'feature_index'"); + + if (tblgen_epsilon && !((true))) + return emitError(loc, "'vhlo.batch_norm_inference_v1' op ""attribute 'epsilon' failed to satisfy constraint: any attribute"); + + if (tblgen_feature_index && !((true))) + return emitError(loc, "'vhlo.batch_norm_inference_v1' op ""attribute 'feature_index' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormInferenceOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.epsilon; + auto attr = dict.get("epsilon"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `epsilon` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.feature_index; + auto attr = dict.get("feature_index"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `feature_index` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BatchNormInferenceOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.epsilon; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("epsilon", + propStorage)); + } + + { + const auto &propStorage = prop.feature_index; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("feature_index", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BatchNormInferenceOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.epsilon.getAsOpaquePointer()), + llvm::hash_value(prop.feature_index.getAsOpaquePointer())); +} + +std::optional BatchNormInferenceOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "epsilon") + return prop.epsilon; + + if (name == "feature_index") + return prop.feature_index; + return std::nullopt; +} + +void BatchNormInferenceOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "epsilon") { + prop.epsilon = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "feature_index") { + prop.feature_index = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BatchNormInferenceOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.epsilon) attrs.append("epsilon", prop.epsilon); + + if (prop.feature_index) attrs.append("feature_index", prop.feature_index); +} + +::llvm::LogicalResult BatchNormInferenceOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getEpsilonAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "epsilon", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFeatureIndexAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "feature_index", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormInferenceOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.epsilon))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.feature_index))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BatchNormInferenceOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.epsilon); + writer.writeAttribute(prop.feature_index); +} + +::mlir::Attribute BatchNormInferenceOpV1::getEpsilon() { + auto attr = getEpsilonAttr(); + return attr; +} + +::mlir::Attribute BatchNormInferenceOpV1::getFeatureIndex() { + auto attr = getFeatureIndexAttr(); + return attr; +} + +void BatchNormInferenceOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Attribute epsilon, ::mlir::Attribute feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + odsState.addTypes(result); +} + +void BatchNormInferenceOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Attribute epsilon, ::mlir::Attribute feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.addOperands(mean); + odsState.addOperands(variance); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BatchNormInferenceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BatchNormInferenceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult BatchNormInferenceOpV1::verifyInvariantsImpl() { + auto tblgen_epsilon = getProperties().epsilon; (void)tblgen_epsilon; + if (!tblgen_epsilon) return emitOpError("requires attribute 'epsilon'"); + auto tblgen_feature_index = getProperties().feature_index; (void)tblgen_feature_index; + if (!tblgen_feature_index) return emitOpError("requires attribute 'feature_index'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_epsilon, "epsilon"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_feature_index, "feature_index"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormInferenceOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version BatchNormInferenceOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version BatchNormInferenceOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::BatchNormInferenceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::BatchNormTrainingOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BatchNormTrainingOpV1GenericAdaptorBase::BatchNormTrainingOpV1GenericAdaptorBase(BatchNormTrainingOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute BatchNormTrainingOpV1GenericAdaptorBase::getEpsilon() { + auto attr = getEpsilonAttr(); + return attr; +} + +::mlir::Attribute BatchNormTrainingOpV1GenericAdaptorBase::getFeatureIndex() { + auto attr = getFeatureIndexAttr(); + return attr; +} + +} // namespace detail +BatchNormTrainingOpV1Adaptor::BatchNormTrainingOpV1Adaptor(BatchNormTrainingOpV1 op) : BatchNormTrainingOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BatchNormTrainingOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_epsilon = getProperties().epsilon; (void)tblgen_epsilon; + if (!tblgen_epsilon) return emitError(loc, "'vhlo.batch_norm_training_v1' op ""requires attribute 'epsilon'"); + auto tblgen_feature_index = getProperties().feature_index; (void)tblgen_feature_index; + if (!tblgen_feature_index) return emitError(loc, "'vhlo.batch_norm_training_v1' op ""requires attribute 'feature_index'"); + + if (tblgen_epsilon && !((true))) + return emitError(loc, "'vhlo.batch_norm_training_v1' op ""attribute 'epsilon' failed to satisfy constraint: any attribute"); + + if (tblgen_feature_index && !((true))) + return emitError(loc, "'vhlo.batch_norm_training_v1' op ""attribute 'feature_index' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +void BatchNormTrainingOpV1::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { + auto resultGroup0 = getODSResults(0); + if (!resultGroup0.empty()) + setNameFn(*resultGroup0.begin(), "output"); + auto resultGroup1 = getODSResults(1); + if (!resultGroup1.empty()) + setNameFn(*resultGroup1.begin(), "batch_mean"); + auto resultGroup2 = getODSResults(2); + if (!resultGroup2.empty()) + setNameFn(*resultGroup2.begin(), "batch_var"); +} + +::llvm::LogicalResult BatchNormTrainingOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.epsilon; + auto attr = dict.get("epsilon"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `epsilon` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.feature_index; + auto attr = dict.get("feature_index"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `feature_index` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BatchNormTrainingOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.epsilon; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("epsilon", + propStorage)); + } + + { + const auto &propStorage = prop.feature_index; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("feature_index", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BatchNormTrainingOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.epsilon.getAsOpaquePointer()), + llvm::hash_value(prop.feature_index.getAsOpaquePointer())); +} + +std::optional BatchNormTrainingOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "epsilon") + return prop.epsilon; + + if (name == "feature_index") + return prop.feature_index; + return std::nullopt; +} + +void BatchNormTrainingOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "epsilon") { + prop.epsilon = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "feature_index") { + prop.feature_index = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BatchNormTrainingOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.epsilon) attrs.append("epsilon", prop.epsilon); + + if (prop.feature_index) attrs.append("feature_index", prop.feature_index); +} + +::llvm::LogicalResult BatchNormTrainingOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getEpsilonAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "epsilon", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFeatureIndexAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "feature_index", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormTrainingOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.epsilon))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.feature_index))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BatchNormTrainingOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.epsilon); + writer.writeAttribute(prop.feature_index); +} + +::mlir::Attribute BatchNormTrainingOpV1::getEpsilon() { + auto attr = getEpsilonAttr(); + return attr; +} + +::mlir::Attribute BatchNormTrainingOpV1::getFeatureIndex() { + auto attr = getFeatureIndexAttr(); + return attr; +} + +void BatchNormTrainingOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Type batch_mean, ::mlir::Type batch_var, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Attribute epsilon, ::mlir::Attribute feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + odsState.addTypes(output); + odsState.addTypes(batch_mean); + odsState.addTypes(batch_var); +} + +void BatchNormTrainingOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Attribute epsilon, ::mlir::Attribute feature_index) { + odsState.addOperands(operand); + odsState.addOperands(scale); + odsState.addOperands(offset); + odsState.getOrAddProperties().epsilon = epsilon; + odsState.getOrAddProperties().feature_index = feature_index; + assert(resultTypes.size() == 3u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BatchNormTrainingOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 3u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BatchNormTrainingOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 3u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult BatchNormTrainingOpV1::verifyInvariantsImpl() { + auto tblgen_epsilon = getProperties().epsilon; (void)tblgen_epsilon; + if (!tblgen_epsilon) return emitOpError("requires attribute 'epsilon'"); + auto tblgen_feature_index = getProperties().feature_index; (void)tblgen_feature_index; + if (!tblgen_feature_index) return emitOpError("requires attribute 'feature_index'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_epsilon, "epsilon"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_feature_index, "feature_index"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSResults(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSResults(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BatchNormTrainingOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version BatchNormTrainingOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version BatchNormTrainingOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::BatchNormTrainingOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::BitcastConvertOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BitcastConvertOpV1GenericAdaptorBase::BitcastConvertOpV1GenericAdaptorBase(BitcastConvertOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +BitcastConvertOpV1Adaptor::BitcastConvertOpV1Adaptor(BitcastConvertOpV1 op) : BitcastConvertOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BitcastConvertOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult BitcastConvertOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute BitcastConvertOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BitcastConvertOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional BitcastConvertOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void BitcastConvertOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void BitcastConvertOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult BitcastConvertOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void BitcastConvertOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void BitcastConvertOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BitcastConvertOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void BitcastConvertOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult BitcastConvertOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BitcastConvertOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version BitcastConvertOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version BitcastConvertOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::BitcastConvertOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::BroadcastInDimOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastInDimOpV1GenericAdaptorBase::BroadcastInDimOpV1GenericAdaptorBase(BroadcastInDimOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute BroadcastInDimOpV1GenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr; +} + +} // namespace detail +BroadcastInDimOpV1Adaptor::BroadcastInDimOpV1Adaptor(BroadcastInDimOpV1 op) : BroadcastInDimOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastInDimOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + if (!tblgen_broadcast_dimensions) return emitError(loc, "'vhlo.broadcast_in_dim_v1' op ""requires attribute 'broadcast_dimensions'"); + + if (tblgen_broadcast_dimensions && !((true))) + return emitError(loc, "'vhlo.broadcast_in_dim_v1' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastInDimOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastInDimOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastInDimOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer())); +} + +std::optional BroadcastInDimOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + return std::nullopt; +} + +void BroadcastInDimOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastInDimOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); +} + +::llvm::LogicalResult BroadcastInDimOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastInDimOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastInDimOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.broadcast_dimensions); +} + +::mlir::Attribute BroadcastInDimOpV1::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr; +} + +void BroadcastInDimOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute broadcast_dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + odsState.addTypes(result); +} + +void BroadcastInDimOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute broadcast_dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastInDimOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastInDimOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult BroadcastInDimOpV1::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + if (!tblgen_broadcast_dimensions) return emitOpError("requires attribute 'broadcast_dimensions'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastInDimOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version BroadcastInDimOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version BroadcastInDimOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::BroadcastInDimOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::BroadcastOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastOpV1GenericAdaptorBase::BroadcastOpV1GenericAdaptorBase(BroadcastOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute BroadcastOpV1GenericAdaptorBase::getBroadcastSizes() { + auto attr = getBroadcastSizesAttr(); + return attr; +} + +} // namespace detail +BroadcastOpV1Adaptor::BroadcastOpV1Adaptor(BroadcastOpV1 op) : BroadcastOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult BroadcastOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_sizes = getProperties().broadcast_sizes; (void)tblgen_broadcast_sizes; + if (!tblgen_broadcast_sizes) return emitError(loc, "'vhlo.broadcast_v1' op ""requires attribute 'broadcast_sizes'"); + + if (tblgen_broadcast_sizes && !((true))) + return emitError(loc, "'vhlo.broadcast_v1' op ""attribute 'broadcast_sizes' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_sizes; + auto attr = dict.get("broadcast_sizes"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_sizes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_sizes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_sizes", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_sizes.getAsOpaquePointer())); +} + +std::optional BroadcastOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_sizes") + return prop.broadcast_sizes; + return std::nullopt; +} + +void BroadcastOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_sizes") { + prop.broadcast_sizes = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_sizes) attrs.append("broadcast_sizes", prop.broadcast_sizes); +} + +::llvm::LogicalResult BroadcastOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastSizesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "broadcast_sizes", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.broadcast_sizes))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.broadcast_sizes); +} + +::mlir::Attribute BroadcastOpV1::getBroadcastSizes() { + auto attr = getBroadcastSizesAttr(); + return attr; +} + +void BroadcastOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute broadcast_sizes) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_sizes = broadcast_sizes; + odsState.addTypes(result); +} + +void BroadcastOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute broadcast_sizes) { + odsState.addOperands(operand); + odsState.getOrAddProperties().broadcast_sizes = broadcast_sizes; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void BroadcastOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult BroadcastOpV1::verifyInvariantsImpl() { + auto tblgen_broadcast_sizes = getProperties().broadcast_sizes; (void)tblgen_broadcast_sizes; + if (!tblgen_broadcast_sizes) return emitOpError("requires attribute 'broadcast_sizes'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_broadcast_sizes, "broadcast_sizes"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult BroadcastOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version BroadcastOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version BroadcastOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::BroadcastOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CallOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CallOpV1GenericAdaptorBase::CallOpV1GenericAdaptorBase(CallOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair CallOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute CallOpV1GenericAdaptorBase::getCallee() { + auto attr = getCalleeAttr(); + return attr; +} + +} // namespace detail +CallOpV1Adaptor::CallOpV1Adaptor(CallOpV1 op) : CallOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CallOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_callee = getProperties().callee; (void)tblgen_callee; + if (!tblgen_callee) return emitError(loc, "'vhlo.call_v1' op ""requires attribute 'callee'"); + + if (tblgen_callee && !((true))) + return emitError(loc, "'vhlo.call_v1' op ""attribute 'callee' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair CallOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange CallOpV1::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair CallOpV1::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult CallOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.callee; + auto attr = dict.get("callee"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `callee` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CallOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.callee; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("callee", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CallOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.callee.getAsOpaquePointer())); +} + +std::optional CallOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "callee") + return prop.callee; + return std::nullopt; +} + +void CallOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "callee") { + prop.callee = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CallOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.callee) attrs.append("callee", prop.callee); +} + +::llvm::LogicalResult CallOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getCalleeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "callee", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CallOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.callee))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CallOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.callee); +} + +::mlir::Attribute CallOpV1::getCallee() { + auto attr = getCalleeAttr(); + return attr; +} + +void CallOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Attribute callee, ::mlir::ValueRange operands) { + odsState.addOperands(operands); + odsState.getOrAddProperties().callee = callee; + odsState.addTypes(results); +} + +void CallOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CallOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CallOpV1::verifyInvariantsImpl() { + auto tblgen_callee = getProperties().callee; (void)tblgen_callee; + if (!tblgen_callee) return emitOpError("requires attribute 'callee'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_callee, "callee"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CallOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CallOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version CallOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CallOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CaseOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CaseOpV1GenericAdaptorBase::CaseOpV1GenericAdaptorBase(CaseOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +CaseOpV1Adaptor::CaseOpV1Adaptor(CaseOpV1 op) : CaseOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CaseOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair CaseOpV1::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult CaseOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute CaseOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CaseOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional CaseOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void CaseOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void CaseOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult CaseOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void CaseOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value index, unsigned branchesCount) { + odsState.addOperands(index); + for (unsigned i = 0; i < branchesCount; ++i) + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void CaseOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != numRegions; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void CaseOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != numRegions; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CaseOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : getBranches()) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "branches", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CaseOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CaseOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version CaseOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CaseOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CbrtOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CbrtOpV1GenericAdaptorBase::CbrtOpV1GenericAdaptorBase(CbrtOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +CbrtOpV1Adaptor::CbrtOpV1Adaptor(CbrtOpV1 op) : CbrtOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CbrtOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult CbrtOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute CbrtOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CbrtOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional CbrtOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void CbrtOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void CbrtOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult CbrtOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void CbrtOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void CbrtOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CbrtOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CbrtOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CbrtOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CbrtOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CbrtOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version CbrtOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 9, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CbrtOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CbrtOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CbrtOpV2GenericAdaptorBase::CbrtOpV2GenericAdaptorBase(CbrtOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute CbrtOpV2GenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +} // namespace detail +CbrtOpV2Adaptor::CbrtOpV2Adaptor(CbrtOpV2 op) : CbrtOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CbrtOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitError(loc, "'vhlo.cbrt_v2' op ""requires attribute 'result_accuracy'"); + + if (tblgen_result_accuracy && !((true))) + return emitError(loc, "'vhlo.cbrt_v2' op ""attribute 'result_accuracy' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult CbrtOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CbrtOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CbrtOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional CbrtOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void CbrtOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CbrtOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult CbrtOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CbrtOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CbrtOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_accuracy); +} + +::mlir::Attribute CbrtOpV2::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +void CbrtOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + odsState.addTypes(result); +} + +void CbrtOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CbrtOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CbrtOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CbrtOpV2::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitOpError("requires attribute 'result_accuracy'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CbrtOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CbrtOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 10, 0); +} +mlir::vhlo::Version CbrtOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CbrtOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CeilOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CeilOpV1GenericAdaptorBase::CeilOpV1GenericAdaptorBase(CeilOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +CeilOpV1Adaptor::CeilOpV1Adaptor(CeilOpV1 op) : CeilOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CeilOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult CeilOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute CeilOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CeilOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional CeilOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void CeilOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void CeilOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult CeilOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void CeilOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void CeilOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CeilOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CeilOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CeilOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CeilOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CeilOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version CeilOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CeilOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CholeskyOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CholeskyOpV1GenericAdaptorBase::CholeskyOpV1GenericAdaptorBase(CholeskyOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute CholeskyOpV1GenericAdaptorBase::getLower() { + auto attr = getLowerAttr(); + return attr; +} + +} // namespace detail +CholeskyOpV1Adaptor::CholeskyOpV1Adaptor(CholeskyOpV1 op) : CholeskyOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CholeskyOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_lower = getProperties().lower; (void)tblgen_lower; + if (!tblgen_lower) return emitError(loc, "'vhlo.cholesky_v1' op ""requires attribute 'lower'"); + + if (tblgen_lower && !((true))) + return emitError(loc, "'vhlo.cholesky_v1' op ""attribute 'lower' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult CholeskyOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.lower; + auto attr = dict.get("lower"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lower` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CholeskyOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.lower; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lower", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CholeskyOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.lower.getAsOpaquePointer())); +} + +std::optional CholeskyOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "lower") + return prop.lower; + return std::nullopt; +} + +void CholeskyOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "lower") { + prop.lower = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CholeskyOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.lower) attrs.append("lower", prop.lower); +} + +::llvm::LogicalResult CholeskyOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getLowerAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "lower", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CholeskyOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.lower))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CholeskyOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.lower); +} + +::mlir::Attribute CholeskyOpV1::getLower() { + auto attr = getLowerAttr(); + return attr; +} + +void CholeskyOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, ::mlir::Attribute lower) { + odsState.addOperands(a); + odsState.getOrAddProperties().lower = lower; + odsState.addTypes(result); +} + +void CholeskyOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Attribute lower) { + odsState.addOperands(a); + odsState.getOrAddProperties().lower = lower; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CholeskyOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CholeskyOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CholeskyOpV1::verifyInvariantsImpl() { + auto tblgen_lower = getProperties().lower; (void)tblgen_lower; + if (!tblgen_lower) return emitOpError("requires attribute 'lower'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_lower, "lower"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CholeskyOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CholeskyOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version CholeskyOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CholeskyOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ClampOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ClampOpV1GenericAdaptorBase::ClampOpV1GenericAdaptorBase(ClampOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ClampOpV1Adaptor::ClampOpV1Adaptor(ClampOpV1 op) : ClampOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ClampOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ClampOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ClampOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ClampOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ClampOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ClampOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ClampOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ClampOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ClampOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value min, ::mlir::Value operand, ::mlir::Value max) { + odsState.addOperands(min); + odsState.addOperands(operand); + odsState.addOperands(max); + odsState.addTypes(result); +} + +void ClampOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value min, ::mlir::Value operand, ::mlir::Value max) { + odsState.addOperands(min); + odsState.addOperands(operand); + odsState.addOperands(max); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ClampOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ClampOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ClampOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ClampOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ClampOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ClampOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ClampOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ClzOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ClzOpV1GenericAdaptorBase::ClzOpV1GenericAdaptorBase(ClzOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ClzOpV1Adaptor::ClzOpV1Adaptor(ClzOpV1 op) : ClzOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ClzOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ClzOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ClzOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ClzOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ClzOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ClzOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ClzOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ClzOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ClzOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void ClzOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ClzOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ClzOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ClzOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ClzOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ClzOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ClzOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ClzOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CollectiveBroadcastOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CollectiveBroadcastOpV1GenericAdaptorBase::CollectiveBroadcastOpV1GenericAdaptorBase(CollectiveBroadcastOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute CollectiveBroadcastOpV1GenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute CollectiveBroadcastOpV1GenericAdaptorBase::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +} // namespace detail +CollectiveBroadcastOpV1Adaptor::CollectiveBroadcastOpV1Adaptor(CollectiveBroadcastOpV1 op) : CollectiveBroadcastOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CollectiveBroadcastOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitError(loc, "'vhlo.collective_broadcast_v1' op ""requires attribute 'channel_id'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'vhlo.collective_broadcast_v1' op ""requires attribute 'replica_groups'"); + + if (tblgen_replica_groups && !((true))) + return emitError(loc, "'vhlo.collective_broadcast_v1' op ""attribute 'replica_groups' failed to satisfy constraint: any attribute"); + + if (tblgen_channel_id && !((true))) + return emitError(loc, "'vhlo.collective_broadcast_v1' op ""attribute 'channel_id' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult CollectiveBroadcastOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_id; + auto attr = dict.get("channel_id"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_id` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CollectiveBroadcastOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_id; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_id", + propStorage)); + } + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CollectiveBroadcastOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_id.getAsOpaquePointer()), + llvm::hash_value(prop.replica_groups.getAsOpaquePointer())); +} + +std::optional CollectiveBroadcastOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_id") + return prop.channel_id; + + if (name == "replica_groups") + return prop.replica_groups; + return std::nullopt; +} + +void CollectiveBroadcastOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_id") { + prop.channel_id = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CollectiveBroadcastOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_id) attrs.append("channel_id", prop.channel_id); + + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); +} + +::llvm::LogicalResult CollectiveBroadcastOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelIdAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "channel_id", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CollectiveBroadcastOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.channel_id))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CollectiveBroadcastOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.channel_id); + writer.writeAttribute(prop.replica_groups); +} + +::mlir::Attribute CollectiveBroadcastOpV1::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute CollectiveBroadcastOpV1::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +void CollectiveBroadcastOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id) { + odsState.addOperands(operand); + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.getOrAddProperties().channel_id = channel_id; + odsState.addTypes(result); +} + +void CollectiveBroadcastOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id) { + odsState.addOperands(operand); + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.getOrAddProperties().channel_id = channel_id; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CollectiveBroadcastOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CollectiveBroadcastOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CollectiveBroadcastOpV1::verifyInvariantsImpl() { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitOpError("requires attribute 'channel_id'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_channel_id, "channel_id"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CollectiveBroadcastOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CollectiveBroadcastOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 16, 0); +} +mlir::vhlo::Version CollectiveBroadcastOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CollectiveBroadcastOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CollectivePermuteOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CollectivePermuteOpV1GenericAdaptorBase::CollectivePermuteOpV1GenericAdaptorBase(CollectivePermuteOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute CollectivePermuteOpV1GenericAdaptorBase::getSourceTargetPairs() { + auto attr = getSourceTargetPairsAttr(); + return attr; +} + +::mlir::Attribute CollectivePermuteOpV1GenericAdaptorBase::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +} // namespace detail +CollectivePermuteOpV1Adaptor::CollectivePermuteOpV1Adaptor(CollectivePermuteOpV1 op) : CollectivePermuteOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CollectivePermuteOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitError(loc, "'vhlo.collective_permute_v1' op ""requires attribute 'channel_id'"); + auto tblgen_source_target_pairs = getProperties().source_target_pairs; (void)tblgen_source_target_pairs; + if (!tblgen_source_target_pairs) return emitError(loc, "'vhlo.collective_permute_v1' op ""requires attribute 'source_target_pairs'"); + + if (tblgen_source_target_pairs && !((true))) + return emitError(loc, "'vhlo.collective_permute_v1' op ""attribute 'source_target_pairs' failed to satisfy constraint: any attribute"); + + if (tblgen_channel_id && !((true))) + return emitError(loc, "'vhlo.collective_permute_v1' op ""attribute 'channel_id' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult CollectivePermuteOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_id; + auto attr = dict.get("channel_id"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_id` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.source_target_pairs; + auto attr = dict.get("source_target_pairs"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `source_target_pairs` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CollectivePermuteOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_id; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_id", + propStorage)); + } + + { + const auto &propStorage = prop.source_target_pairs; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("source_target_pairs", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CollectivePermuteOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_id.getAsOpaquePointer()), + llvm::hash_value(prop.source_target_pairs.getAsOpaquePointer())); +} + +std::optional CollectivePermuteOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_id") + return prop.channel_id; + + if (name == "source_target_pairs") + return prop.source_target_pairs; + return std::nullopt; +} + +void CollectivePermuteOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_id") { + prop.channel_id = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "source_target_pairs") { + prop.source_target_pairs = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CollectivePermuteOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_id) attrs.append("channel_id", prop.channel_id); + + if (prop.source_target_pairs) attrs.append("source_target_pairs", prop.source_target_pairs); +} + +::llvm::LogicalResult CollectivePermuteOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelIdAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "channel_id", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSourceTargetPairsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "source_target_pairs", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CollectivePermuteOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.channel_id))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.source_target_pairs))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CollectivePermuteOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.channel_id); + writer.writeAttribute(prop.source_target_pairs); +} + +::mlir::Attribute CollectivePermuteOpV1::getSourceTargetPairs() { + auto attr = getSourceTargetPairsAttr(); + return attr; +} + +::mlir::Attribute CollectivePermuteOpV1::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +void CollectivePermuteOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute source_target_pairs, ::mlir::Attribute channel_id) { + odsState.addOperands(operand); + odsState.getOrAddProperties().source_target_pairs = source_target_pairs; + odsState.getOrAddProperties().channel_id = channel_id; + odsState.addTypes(result); +} + +void CollectivePermuteOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute source_target_pairs, ::mlir::Attribute channel_id) { + odsState.addOperands(operand); + odsState.getOrAddProperties().source_target_pairs = source_target_pairs; + odsState.getOrAddProperties().channel_id = channel_id; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CollectivePermuteOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CollectivePermuteOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CollectivePermuteOpV1::verifyInvariantsImpl() { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitOpError("requires attribute 'channel_id'"); + auto tblgen_source_target_pairs = getProperties().source_target_pairs; (void)tblgen_source_target_pairs; + if (!tblgen_source_target_pairs) return emitOpError("requires attribute 'source_target_pairs'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_source_target_pairs, "source_target_pairs"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_channel_id, "channel_id"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CollectivePermuteOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CollectivePermuteOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version CollectivePermuteOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CollectivePermuteOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CompareOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CompareOpV1GenericAdaptorBase::CompareOpV1GenericAdaptorBase(CompareOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute CompareOpV1GenericAdaptorBase::getComparisonDirection() { + auto attr = getComparisonDirectionAttr(); + return attr; +} + +::mlir::Attribute CompareOpV1GenericAdaptorBase::getCompareType() { + auto attr = getCompareTypeAttr(); + return attr; +} + +} // namespace detail +CompareOpV1Adaptor::CompareOpV1Adaptor(CompareOpV1 op) : CompareOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CompareOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_compare_type = getProperties().compare_type; (void)tblgen_compare_type; + if (!tblgen_compare_type) return emitError(loc, "'vhlo.compare_v1' op ""requires attribute 'compare_type'"); + auto tblgen_comparison_direction = getProperties().comparison_direction; (void)tblgen_comparison_direction; + if (!tblgen_comparison_direction) return emitError(loc, "'vhlo.compare_v1' op ""requires attribute 'comparison_direction'"); + + if (tblgen_comparison_direction && !((true))) + return emitError(loc, "'vhlo.compare_v1' op ""attribute 'comparison_direction' failed to satisfy constraint: any attribute"); + + if (tblgen_compare_type && !((true))) + return emitError(loc, "'vhlo.compare_v1' op ""attribute 'compare_type' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult CompareOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.compare_type; + auto attr = dict.get("compare_type"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `compare_type` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.comparison_direction; + auto attr = dict.get("comparison_direction"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `comparison_direction` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CompareOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.compare_type; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("compare_type", + propStorage)); + } + + { + const auto &propStorage = prop.comparison_direction; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("comparison_direction", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CompareOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.compare_type.getAsOpaquePointer()), + llvm::hash_value(prop.comparison_direction.getAsOpaquePointer())); +} + +std::optional CompareOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "compare_type") + return prop.compare_type; + + if (name == "comparison_direction") + return prop.comparison_direction; + return std::nullopt; +} + +void CompareOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "compare_type") { + prop.compare_type = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "comparison_direction") { + prop.comparison_direction = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CompareOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.compare_type) attrs.append("compare_type", prop.compare_type); + + if (prop.comparison_direction) attrs.append("comparison_direction", prop.comparison_direction); +} + +::llvm::LogicalResult CompareOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getCompareTypeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "compare_type", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getComparisonDirectionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "comparison_direction", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CompareOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.compare_type))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.comparison_direction))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CompareOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.compare_type); + writer.writeAttribute(prop.comparison_direction); +} + +::mlir::Attribute CompareOpV1::getComparisonDirection() { + auto attr = getComparisonDirectionAttr(); + return attr; +} + +::mlir::Attribute CompareOpV1::getCompareType() { + auto attr = getCompareTypeAttr(); + return attr; +} + +void CompareOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute comparison_direction, ::mlir::Attribute compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().comparison_direction = comparison_direction; + odsState.getOrAddProperties().compare_type = compare_type; + odsState.addTypes(result); +} + +void CompareOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute comparison_direction, ::mlir::Attribute compare_type) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().comparison_direction = comparison_direction; + odsState.getOrAddProperties().compare_type = compare_type; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CompareOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CompareOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CompareOpV1::verifyInvariantsImpl() { + auto tblgen_compare_type = getProperties().compare_type; (void)tblgen_compare_type; + if (!tblgen_compare_type) return emitOpError("requires attribute 'compare_type'"); + auto tblgen_comparison_direction = getProperties().comparison_direction; (void)tblgen_comparison_direction; + if (!tblgen_comparison_direction) return emitOpError("requires attribute 'comparison_direction'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_comparison_direction, "comparison_direction"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_compare_type, "compare_type"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CompareOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CompareOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version CompareOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CompareOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ComplexOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ComplexOpV1GenericAdaptorBase::ComplexOpV1GenericAdaptorBase(ComplexOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ComplexOpV1Adaptor::ComplexOpV1Adaptor(ComplexOpV1 op) : ComplexOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ComplexOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ComplexOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ComplexOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ComplexOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ComplexOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ComplexOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ComplexOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ComplexOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ComplexOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void ComplexOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ComplexOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ComplexOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ComplexOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ComplexOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ComplexOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ComplexOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ComplexOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CompositeOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CompositeOpV1GenericAdaptorBase::CompositeOpV1GenericAdaptorBase(CompositeOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair CompositeOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute CompositeOpV1GenericAdaptorBase::getName() { + auto attr = getNameAttr(); + return attr; +} + +::mlir::Attribute CompositeOpV1GenericAdaptorBase::getCompositeAttributes() { + auto attr = getCompositeAttributesAttr(); + return attr; +} + +::mlir::Attribute CompositeOpV1GenericAdaptorBase::getDecomposition() { + auto attr = getDecompositionAttr(); + return attr; +} + +::mlir::Attribute CompositeOpV1GenericAdaptorBase::getVersion() { + auto attr = getVersionAttr(); + return attr; +} + +} // namespace detail +CompositeOpV1Adaptor::CompositeOpV1Adaptor(CompositeOpV1 op) : CompositeOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CompositeOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_composite_attributes = getProperties().composite_attributes; (void)tblgen_composite_attributes; + if (!tblgen_composite_attributes) return emitError(loc, "'vhlo.composite_v1' op ""requires attribute 'composite_attributes'"); + auto tblgen_decomposition = getProperties().decomposition; (void)tblgen_decomposition; + if (!tblgen_decomposition) return emitError(loc, "'vhlo.composite_v1' op ""requires attribute 'decomposition'"); + auto tblgen_name = getProperties().name; (void)tblgen_name; + if (!tblgen_name) return emitError(loc, "'vhlo.composite_v1' op ""requires attribute 'name'"); + auto tblgen_version = getProperties().version; (void)tblgen_version; + if (!tblgen_version) return emitError(loc, "'vhlo.composite_v1' op ""requires attribute 'version'"); + + if (tblgen_name && !((true))) + return emitError(loc, "'vhlo.composite_v1' op ""attribute 'name' failed to satisfy constraint: any attribute"); + + if (tblgen_composite_attributes && !((true))) + return emitError(loc, "'vhlo.composite_v1' op ""attribute 'composite_attributes' failed to satisfy constraint: any attribute"); + + if (tblgen_decomposition && !((true))) + return emitError(loc, "'vhlo.composite_v1' op ""attribute 'decomposition' failed to satisfy constraint: any attribute"); + + if (tblgen_version && !((true))) + return emitError(loc, "'vhlo.composite_v1' op ""attribute 'version' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair CompositeOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange CompositeOpV1::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair CompositeOpV1::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult CompositeOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.composite_attributes; + auto attr = dict.get("composite_attributes"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `composite_attributes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.decomposition; + auto attr = dict.get("decomposition"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `decomposition` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.name; + auto attr = dict.get("name"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.version; + auto attr = dict.get("version"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `version` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CompositeOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.composite_attributes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("composite_attributes", + propStorage)); + } + + { + const auto &propStorage = prop.decomposition; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("decomposition", + propStorage)); + } + + { + const auto &propStorage = prop.name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("name", + propStorage)); + } + + { + const auto &propStorage = prop.version; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("version", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CompositeOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.composite_attributes.getAsOpaquePointer()), + llvm::hash_value(prop.decomposition.getAsOpaquePointer()), + llvm::hash_value(prop.name.getAsOpaquePointer()), + llvm::hash_value(prop.version.getAsOpaquePointer())); +} + +std::optional CompositeOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "composite_attributes") + return prop.composite_attributes; + + if (name == "decomposition") + return prop.decomposition; + + if (name == "name") + return prop.name; + + if (name == "version") + return prop.version; + return std::nullopt; +} + +void CompositeOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "composite_attributes") { + prop.composite_attributes = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "decomposition") { + prop.decomposition = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "name") { + prop.name = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "version") { + prop.version = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CompositeOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.composite_attributes) attrs.append("composite_attributes", prop.composite_attributes); + + if (prop.decomposition) attrs.append("decomposition", prop.decomposition); + + if (prop.name) attrs.append("name", prop.name); + + if (prop.version) attrs.append("version", prop.version); +} + +::llvm::LogicalResult CompositeOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getCompositeAttributesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "composite_attributes", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getDecompositionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "decomposition", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "name", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getVersionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "version", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CompositeOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.composite_attributes))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.decomposition))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.name))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.version))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CompositeOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.composite_attributes); + writer.writeAttribute(prop.decomposition); + writer.writeAttribute(prop.name); + writer.writeAttribute(prop.version); +} + +::mlir::Attribute CompositeOpV1::getName() { + auto attr = getNameAttr(); + return attr; +} + +::mlir::Attribute CompositeOpV1::getCompositeAttributes() { + auto attr = getCompositeAttributesAttr(); + return attr; +} + +::mlir::Attribute CompositeOpV1::getDecomposition() { + auto attr = getDecompositionAttr(); + return attr; +} + +::mlir::Attribute CompositeOpV1::getVersion() { + auto attr = getVersionAttr(); + return attr; +} + +void CompositeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::Attribute name, ::mlir::Attribute composite_attributes, ::mlir::Attribute decomposition, ::mlir::Attribute version) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().name = name; + odsState.getOrAddProperties().composite_attributes = composite_attributes; + odsState.getOrAddProperties().decomposition = decomposition; + odsState.getOrAddProperties().version = version; + odsState.addTypes(results); +} + +void CompositeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CompositeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CompositeOpV1::verifyInvariantsImpl() { + auto tblgen_composite_attributes = getProperties().composite_attributes; (void)tblgen_composite_attributes; + if (!tblgen_composite_attributes) return emitOpError("requires attribute 'composite_attributes'"); + auto tblgen_decomposition = getProperties().decomposition; (void)tblgen_decomposition; + if (!tblgen_decomposition) return emitOpError("requires attribute 'decomposition'"); + auto tblgen_name = getProperties().name; (void)tblgen_name; + if (!tblgen_name) return emitOpError("requires attribute 'name'"); + auto tblgen_version = getProperties().version; (void)tblgen_version; + if (!tblgen_version) return emitOpError("requires attribute 'version'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_name, "name"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_composite_attributes, "composite_attributes"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_decomposition, "decomposition"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_version, "version"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CompositeOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CompositeOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 19, 0); +} +mlir::vhlo::Version CompositeOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CompositeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ConcatenateOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConcatenateOpV1GenericAdaptorBase::ConcatenateOpV1GenericAdaptorBase(ConcatenateOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair ConcatenateOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute ConcatenateOpV1GenericAdaptorBase::getDimension() { + auto attr = getDimensionAttr(); + return attr; +} + +} // namespace detail +ConcatenateOpV1Adaptor::ConcatenateOpV1Adaptor(ConcatenateOpV1 op) : ConcatenateOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ConcatenateOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitError(loc, "'vhlo.concatenate_v1' op ""requires attribute 'dimension'"); + + if (tblgen_dimension && !((true))) + return emitError(loc, "'vhlo.concatenate_v1' op ""attribute 'dimension' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair ConcatenateOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange ConcatenateOpV1::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult ConcatenateOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimension; + auto attr = dict.get("dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ConcatenateOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConcatenateOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimension.getAsOpaquePointer())); +} + +std::optional ConcatenateOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimension") + return prop.dimension; + return std::nullopt; +} + +void ConcatenateOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimension") { + prop.dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ConcatenateOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimension) attrs.append("dimension", prop.dimension); +} + +::llvm::LogicalResult ConcatenateOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConcatenateOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConcatenateOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimension); +} + +::mlir::Attribute ConcatenateOpV1::getDimension() { + auto attr = getDimensionAttr(); + return attr; +} + +void ConcatenateOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs, ::mlir::Attribute dimension) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = dimension; + odsState.addTypes(result); +} + +void ConcatenateOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Attribute dimension) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = dimension; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConcatenateOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ConcatenateOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ConcatenateOpV1::verifyInvariantsImpl() { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitOpError("requires attribute 'dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_dimension, "dimension"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConcatenateOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ConcatenateOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ConcatenateOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ConcatenateOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ConstantOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConstantOpV1GenericAdaptorBase::ConstantOpV1GenericAdaptorBase(ConstantOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute ConstantOpV1GenericAdaptorBase::getValue() { + auto attr = getValueAttr(); + return attr; +} + +} // namespace detail +ConstantOpV1Adaptor::ConstantOpV1Adaptor(ConstantOpV1 op) : ConstantOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ConstantOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_value = getProperties().value; (void)tblgen_value; + if (!tblgen_value) return emitError(loc, "'vhlo.constant_v1' op ""requires attribute 'value'"); + + if (tblgen_value && !((true))) + return emitError(loc, "'vhlo.constant_v1' op ""attribute 'value' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult ConstantOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.value; + auto attr = dict.get("value"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `value` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ConstantOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.value; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("value", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConstantOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.value.getAsOpaquePointer())); +} + +std::optional ConstantOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "value") + return prop.value; + return std::nullopt; +} + +void ConstantOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "value") { + prop.value = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ConstantOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.value) attrs.append("value", prop.value); +} + +::llvm::LogicalResult ConstantOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getValueAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "value", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConstantOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.value))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConstantOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.value); +} + +::mlir::Attribute ConstantOpV1::getValue() { + auto attr = getValueAttr(); + return attr; +} + +void ConstantOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Attribute value) { + odsState.getOrAddProperties().value = value; + odsState.addTypes(output); +} + +void ConstantOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Attribute value) { + odsState.getOrAddProperties().value = value; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConstantOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ConstantOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ConstantOpV1::verifyInvariantsImpl() { + auto tblgen_value = getProperties().value; (void)tblgen_value; + if (!tblgen_value) return emitOpError("requires attribute 'value'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_value, "value"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConstantOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ConstantOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ConstantOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ConstantOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ConvertOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConvertOpV1GenericAdaptorBase::ConvertOpV1GenericAdaptorBase(ConvertOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ConvertOpV1Adaptor::ConvertOpV1Adaptor(ConvertOpV1 op) : ConvertOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ConvertOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ConvertOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ConvertOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConvertOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ConvertOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ConvertOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ConvertOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ConvertOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ConvertOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void ConvertOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConvertOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ConvertOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ConvertOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConvertOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ConvertOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ConvertOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ConvertOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ConvolutionOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConvolutionOpV1GenericAdaptorBase::ConvolutionOpV1GenericAdaptorBase(ConvolutionOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getPadding() { + auto attr = getPaddingAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getLhsDilation() { + auto attr = getLhsDilationAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getRhsDilation() { + auto attr = getRhsDilationAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getWindowReversal() { + auto attr = getWindowReversalAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getInputBatchDimension() { + auto attr = getInputBatchDimensionAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getInputFeatureDimension() { + auto attr = getInputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getInputSpatialDimensions() { + auto attr = getInputSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getKernelInputFeatureDimension() { + auto attr = getKernelInputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getKernelOutputFeatureDimension() { + auto attr = getKernelOutputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getKernelSpatialDimensions() { + auto attr = getKernelSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getOutputBatchDimension() { + auto attr = getOutputBatchDimensionAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getOutputFeatureDimension() { + auto attr = getOutputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getOutputSpatialDimensions() { + auto attr = getOutputSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getFeatureGroupCount() { + auto attr = getFeatureGroupCountAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getBatchGroupCount() { + auto attr = getBatchGroupCountAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1GenericAdaptorBase::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr; +} + +} // namespace detail +ConvolutionOpV1Adaptor::ConvolutionOpV1Adaptor(ConvolutionOpV1 op) : ConvolutionOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ConvolutionOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_batch_group_count = getProperties().batch_group_count; (void)tblgen_batch_group_count; + if (!tblgen_batch_group_count) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'batch_group_count'"); + auto tblgen_feature_group_count = getProperties().feature_group_count; (void)tblgen_feature_group_count; + if (!tblgen_feature_group_count) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'feature_group_count'"); + auto tblgen_input_batch_dimension = getProperties().input_batch_dimension; (void)tblgen_input_batch_dimension; + if (!tblgen_input_batch_dimension) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'input_batch_dimension'"); + auto tblgen_input_feature_dimension = getProperties().input_feature_dimension; (void)tblgen_input_feature_dimension; + if (!tblgen_input_feature_dimension) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'input_feature_dimension'"); + auto tblgen_input_spatial_dimensions = getProperties().input_spatial_dimensions; (void)tblgen_input_spatial_dimensions; + if (!tblgen_input_spatial_dimensions) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'input_spatial_dimensions'"); + auto tblgen_kernel_input_feature_dimension = getProperties().kernel_input_feature_dimension; (void)tblgen_kernel_input_feature_dimension; + if (!tblgen_kernel_input_feature_dimension) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'kernel_input_feature_dimension'"); + auto tblgen_kernel_output_feature_dimension = getProperties().kernel_output_feature_dimension; (void)tblgen_kernel_output_feature_dimension; + if (!tblgen_kernel_output_feature_dimension) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'kernel_output_feature_dimension'"); + auto tblgen_kernel_spatial_dimensions = getProperties().kernel_spatial_dimensions; (void)tblgen_kernel_spatial_dimensions; + if (!tblgen_kernel_spatial_dimensions) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'kernel_spatial_dimensions'"); + auto tblgen_lhs_dilation = getProperties().lhs_dilation; (void)tblgen_lhs_dilation; + if (!tblgen_lhs_dilation) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'lhs_dilation'"); + auto tblgen_output_batch_dimension = getProperties().output_batch_dimension; (void)tblgen_output_batch_dimension; + if (!tblgen_output_batch_dimension) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'output_batch_dimension'"); + auto tblgen_output_feature_dimension = getProperties().output_feature_dimension; (void)tblgen_output_feature_dimension; + if (!tblgen_output_feature_dimension) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'output_feature_dimension'"); + auto tblgen_output_spatial_dimensions = getProperties().output_spatial_dimensions; (void)tblgen_output_spatial_dimensions; + if (!tblgen_output_spatial_dimensions) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'output_spatial_dimensions'"); + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + if (!tblgen_padding) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'padding'"); + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + if (!tblgen_precision_config) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'precision_config'"); + auto tblgen_rhs_dilation = getProperties().rhs_dilation; (void)tblgen_rhs_dilation; + if (!tblgen_rhs_dilation) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'rhs_dilation'"); + auto tblgen_window_reversal = getProperties().window_reversal; (void)tblgen_window_reversal; + if (!tblgen_window_reversal) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'window_reversal'"); + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + if (!tblgen_window_strides) return emitError(loc, "'vhlo.convolution_v1' op ""requires attribute 'window_strides'"); + + if (tblgen_window_strides && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'window_strides' failed to satisfy constraint: any attribute"); + + if (tblgen_padding && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'padding' failed to satisfy constraint: any attribute"); + + if (tblgen_lhs_dilation && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'lhs_dilation' failed to satisfy constraint: any attribute"); + + if (tblgen_rhs_dilation && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'rhs_dilation' failed to satisfy constraint: any attribute"); + + if (tblgen_window_reversal && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'window_reversal' failed to satisfy constraint: any attribute"); + + if (tblgen_input_batch_dimension && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'input_batch_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_input_feature_dimension && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'input_feature_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_input_spatial_dimensions && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'input_spatial_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_kernel_input_feature_dimension && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'kernel_input_feature_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_kernel_output_feature_dimension && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'kernel_output_feature_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_kernel_spatial_dimensions && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'kernel_spatial_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_output_batch_dimension && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'output_batch_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_output_feature_dimension && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'output_feature_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_output_spatial_dimensions && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'output_spatial_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_feature_group_count && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'feature_group_count' failed to satisfy constraint: any attribute"); + + if (tblgen_batch_group_count && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'batch_group_count' failed to satisfy constraint: any attribute"); + + if (tblgen_precision_config && !((true))) + return emitError(loc, "'vhlo.convolution_v1' op ""attribute 'precision_config' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult ConvolutionOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.batch_group_count; + auto attr = dict.get("batch_group_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `batch_group_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.feature_group_count; + auto attr = dict.get("feature_group_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `feature_group_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.input_batch_dimension; + auto attr = dict.get("input_batch_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `input_batch_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.input_feature_dimension; + auto attr = dict.get("input_feature_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `input_feature_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.input_spatial_dimensions; + auto attr = dict.get("input_spatial_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `input_spatial_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.kernel_input_feature_dimension; + auto attr = dict.get("kernel_input_feature_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kernel_input_feature_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.kernel_output_feature_dimension; + auto attr = dict.get("kernel_output_feature_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kernel_output_feature_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.kernel_spatial_dimensions; + auto attr = dict.get("kernel_spatial_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kernel_spatial_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.lhs_dilation; + auto attr = dict.get("lhs_dilation"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lhs_dilation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.output_batch_dimension; + auto attr = dict.get("output_batch_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `output_batch_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.output_feature_dimension; + auto attr = dict.get("output_feature_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `output_feature_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.output_spatial_dimensions; + auto attr = dict.get("output_spatial_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `output_spatial_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.padding; + auto attr = dict.get("padding"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `padding` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.precision_config; + auto attr = dict.get("precision_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `precision_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.rhs_dilation; + auto attr = dict.get("rhs_dilation"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rhs_dilation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_reversal; + auto attr = dict.get("window_reversal"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_reversal` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_strides; + auto attr = dict.get("window_strides"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ConvolutionOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.batch_group_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("batch_group_count", + propStorage)); + } + + { + const auto &propStorage = prop.feature_group_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("feature_group_count", + propStorage)); + } + + { + const auto &propStorage = prop.input_batch_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("input_batch_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.input_feature_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("input_feature_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.input_spatial_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("input_spatial_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.kernel_input_feature_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kernel_input_feature_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.kernel_output_feature_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kernel_output_feature_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.kernel_spatial_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kernel_spatial_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.lhs_dilation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lhs_dilation", + propStorage)); + } + + { + const auto &propStorage = prop.output_batch_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("output_batch_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.output_feature_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("output_feature_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.output_spatial_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("output_spatial_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.padding; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("padding", + propStorage)); + } + + { + const auto &propStorage = prop.precision_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("precision_config", + propStorage)); + } + + { + const auto &propStorage = prop.rhs_dilation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rhs_dilation", + propStorage)); + } + + { + const auto &propStorage = prop.window_reversal; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_reversal", + propStorage)); + } + + { + const auto &propStorage = prop.window_strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_strides", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConvolutionOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.batch_group_count.getAsOpaquePointer()), + llvm::hash_value(prop.feature_group_count.getAsOpaquePointer()), + llvm::hash_value(prop.input_batch_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.input_feature_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.input_spatial_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.kernel_input_feature_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.kernel_output_feature_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.kernel_spatial_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.lhs_dilation.getAsOpaquePointer()), + llvm::hash_value(prop.output_batch_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.output_feature_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.output_spatial_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.padding.getAsOpaquePointer()), + llvm::hash_value(prop.precision_config.getAsOpaquePointer()), + llvm::hash_value(prop.rhs_dilation.getAsOpaquePointer()), + llvm::hash_value(prop.window_reversal.getAsOpaquePointer()), + llvm::hash_value(prop.window_strides.getAsOpaquePointer())); +} + +std::optional ConvolutionOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "batch_group_count") + return prop.batch_group_count; + + if (name == "feature_group_count") + return prop.feature_group_count; + + if (name == "input_batch_dimension") + return prop.input_batch_dimension; + + if (name == "input_feature_dimension") + return prop.input_feature_dimension; + + if (name == "input_spatial_dimensions") + return prop.input_spatial_dimensions; + + if (name == "kernel_input_feature_dimension") + return prop.kernel_input_feature_dimension; + + if (name == "kernel_output_feature_dimension") + return prop.kernel_output_feature_dimension; + + if (name == "kernel_spatial_dimensions") + return prop.kernel_spatial_dimensions; + + if (name == "lhs_dilation") + return prop.lhs_dilation; + + if (name == "output_batch_dimension") + return prop.output_batch_dimension; + + if (name == "output_feature_dimension") + return prop.output_feature_dimension; + + if (name == "output_spatial_dimensions") + return prop.output_spatial_dimensions; + + if (name == "padding") + return prop.padding; + + if (name == "precision_config") + return prop.precision_config; + + if (name == "rhs_dilation") + return prop.rhs_dilation; + + if (name == "window_reversal") + return prop.window_reversal; + + if (name == "window_strides") + return prop.window_strides; + return std::nullopt; +} + +void ConvolutionOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "batch_group_count") { + prop.batch_group_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "feature_group_count") { + prop.feature_group_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "input_batch_dimension") { + prop.input_batch_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "input_feature_dimension") { + prop.input_feature_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "input_spatial_dimensions") { + prop.input_spatial_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "kernel_input_feature_dimension") { + prop.kernel_input_feature_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "kernel_output_feature_dimension") { + prop.kernel_output_feature_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "kernel_spatial_dimensions") { + prop.kernel_spatial_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "lhs_dilation") { + prop.lhs_dilation = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "output_batch_dimension") { + prop.output_batch_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "output_feature_dimension") { + prop.output_feature_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "output_spatial_dimensions") { + prop.output_spatial_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "padding") { + prop.padding = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "precision_config") { + prop.precision_config = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "rhs_dilation") { + prop.rhs_dilation = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_reversal") { + prop.window_reversal = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_strides") { + prop.window_strides = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ConvolutionOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.batch_group_count) attrs.append("batch_group_count", prop.batch_group_count); + + if (prop.feature_group_count) attrs.append("feature_group_count", prop.feature_group_count); + + if (prop.input_batch_dimension) attrs.append("input_batch_dimension", prop.input_batch_dimension); + + if (prop.input_feature_dimension) attrs.append("input_feature_dimension", prop.input_feature_dimension); + + if (prop.input_spatial_dimensions) attrs.append("input_spatial_dimensions", prop.input_spatial_dimensions); + + if (prop.kernel_input_feature_dimension) attrs.append("kernel_input_feature_dimension", prop.kernel_input_feature_dimension); + + if (prop.kernel_output_feature_dimension) attrs.append("kernel_output_feature_dimension", prop.kernel_output_feature_dimension); + + if (prop.kernel_spatial_dimensions) attrs.append("kernel_spatial_dimensions", prop.kernel_spatial_dimensions); + + if (prop.lhs_dilation) attrs.append("lhs_dilation", prop.lhs_dilation); + + if (prop.output_batch_dimension) attrs.append("output_batch_dimension", prop.output_batch_dimension); + + if (prop.output_feature_dimension) attrs.append("output_feature_dimension", prop.output_feature_dimension); + + if (prop.output_spatial_dimensions) attrs.append("output_spatial_dimensions", prop.output_spatial_dimensions); + + if (prop.padding) attrs.append("padding", prop.padding); + + if (prop.precision_config) attrs.append("precision_config", prop.precision_config); + + if (prop.rhs_dilation) attrs.append("rhs_dilation", prop.rhs_dilation); + + if (prop.window_reversal) attrs.append("window_reversal", prop.window_reversal); + + if (prop.window_strides) attrs.append("window_strides", prop.window_strides); +} + +::llvm::LogicalResult ConvolutionOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBatchGroupCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "batch_group_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFeatureGroupCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "feature_group_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInputBatchDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "input_batch_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInputFeatureDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "input_feature_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInputSpatialDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "input_spatial_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKernelInputFeatureDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "kernel_input_feature_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKernelOutputFeatureDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "kernel_output_feature_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKernelSpatialDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "kernel_spatial_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLhsDilationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "lhs_dilation", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOutputBatchDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "output_batch_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOutputFeatureDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "output_feature_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOutputSpatialDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "output_spatial_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPaddingAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "padding", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPrecisionConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "precision_config", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRhsDilationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "rhs_dilation", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowReversalAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "window_reversal", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "window_strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConvolutionOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.batch_group_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.feature_group_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.input_batch_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.input_feature_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.input_spatial_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.kernel_input_feature_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.kernel_output_feature_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.kernel_spatial_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.lhs_dilation))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.output_batch_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.output_feature_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.output_spatial_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.padding))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.precision_config))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.rhs_dilation))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.window_reversal))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.window_strides))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConvolutionOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.batch_group_count); + writer.writeAttribute(prop.feature_group_count); + writer.writeAttribute(prop.input_batch_dimension); + writer.writeAttribute(prop.input_feature_dimension); + writer.writeAttribute(prop.input_spatial_dimensions); + writer.writeAttribute(prop.kernel_input_feature_dimension); + writer.writeAttribute(prop.kernel_output_feature_dimension); + writer.writeAttribute(prop.kernel_spatial_dimensions); + writer.writeAttribute(prop.lhs_dilation); + writer.writeAttribute(prop.output_batch_dimension); + writer.writeAttribute(prop.output_feature_dimension); + writer.writeAttribute(prop.output_spatial_dimensions); + writer.writeAttribute(prop.padding); + writer.writeAttribute(prop.precision_config); + writer.writeAttribute(prop.rhs_dilation); + writer.writeAttribute(prop.window_reversal); + writer.writeAttribute(prop.window_strides); +} + +::mlir::Attribute ConvolutionOpV1::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getPadding() { + auto attr = getPaddingAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getLhsDilation() { + auto attr = getLhsDilationAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getRhsDilation() { + auto attr = getRhsDilationAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getWindowReversal() { + auto attr = getWindowReversalAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getInputBatchDimension() { + auto attr = getInputBatchDimensionAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getInputFeatureDimension() { + auto attr = getInputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getInputSpatialDimensions() { + auto attr = getInputSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getKernelInputFeatureDimension() { + auto attr = getKernelInputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getKernelOutputFeatureDimension() { + auto attr = getKernelOutputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getKernelSpatialDimensions() { + auto attr = getKernelSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getOutputBatchDimension() { + auto attr = getOutputBatchDimensionAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getOutputFeatureDimension() { + auto attr = getOutputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getOutputSpatialDimensions() { + auto attr = getOutputSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getFeatureGroupCount() { + auto attr = getFeatureGroupCountAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getBatchGroupCount() { + auto attr = getBatchGroupCountAttr(); + return attr; +} + +::mlir::Attribute ConvolutionOpV1::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr; +} + +void ConvolutionOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute window_strides, ::mlir::Attribute padding, ::mlir::Attribute lhs_dilation, ::mlir::Attribute rhs_dilation, ::mlir::Attribute window_reversal, ::mlir::Attribute input_batch_dimension, ::mlir::Attribute input_feature_dimension, ::mlir::Attribute input_spatial_dimensions, ::mlir::Attribute kernel_input_feature_dimension, ::mlir::Attribute kernel_output_feature_dimension, ::mlir::Attribute kernel_spatial_dimensions, ::mlir::Attribute output_batch_dimension, ::mlir::Attribute output_feature_dimension, ::mlir::Attribute output_spatial_dimensions, ::mlir::Attribute feature_group_count, ::mlir::Attribute batch_group_count, ::mlir::Attribute precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().window_strides = window_strides; + odsState.getOrAddProperties().padding = padding; + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + odsState.getOrAddProperties().window_reversal = window_reversal; + odsState.getOrAddProperties().input_batch_dimension = input_batch_dimension; + odsState.getOrAddProperties().input_feature_dimension = input_feature_dimension; + odsState.getOrAddProperties().input_spatial_dimensions = input_spatial_dimensions; + odsState.getOrAddProperties().kernel_input_feature_dimension = kernel_input_feature_dimension; + odsState.getOrAddProperties().kernel_output_feature_dimension = kernel_output_feature_dimension; + odsState.getOrAddProperties().kernel_spatial_dimensions = kernel_spatial_dimensions; + odsState.getOrAddProperties().output_batch_dimension = output_batch_dimension; + odsState.getOrAddProperties().output_feature_dimension = output_feature_dimension; + odsState.getOrAddProperties().output_spatial_dimensions = output_spatial_dimensions; + odsState.getOrAddProperties().feature_group_count = feature_group_count; + odsState.getOrAddProperties().batch_group_count = batch_group_count; + odsState.getOrAddProperties().precision_config = precision_config; + odsState.addTypes(result); +} + +void ConvolutionOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute window_strides, ::mlir::Attribute padding, ::mlir::Attribute lhs_dilation, ::mlir::Attribute rhs_dilation, ::mlir::Attribute window_reversal, ::mlir::Attribute input_batch_dimension, ::mlir::Attribute input_feature_dimension, ::mlir::Attribute input_spatial_dimensions, ::mlir::Attribute kernel_input_feature_dimension, ::mlir::Attribute kernel_output_feature_dimension, ::mlir::Attribute kernel_spatial_dimensions, ::mlir::Attribute output_batch_dimension, ::mlir::Attribute output_feature_dimension, ::mlir::Attribute output_spatial_dimensions, ::mlir::Attribute feature_group_count, ::mlir::Attribute batch_group_count, ::mlir::Attribute precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().window_strides = window_strides; + odsState.getOrAddProperties().padding = padding; + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + odsState.getOrAddProperties().window_reversal = window_reversal; + odsState.getOrAddProperties().input_batch_dimension = input_batch_dimension; + odsState.getOrAddProperties().input_feature_dimension = input_feature_dimension; + odsState.getOrAddProperties().input_spatial_dimensions = input_spatial_dimensions; + odsState.getOrAddProperties().kernel_input_feature_dimension = kernel_input_feature_dimension; + odsState.getOrAddProperties().kernel_output_feature_dimension = kernel_output_feature_dimension; + odsState.getOrAddProperties().kernel_spatial_dimensions = kernel_spatial_dimensions; + odsState.getOrAddProperties().output_batch_dimension = output_batch_dimension; + odsState.getOrAddProperties().output_feature_dimension = output_feature_dimension; + odsState.getOrAddProperties().output_spatial_dimensions = output_spatial_dimensions; + odsState.getOrAddProperties().feature_group_count = feature_group_count; + odsState.getOrAddProperties().batch_group_count = batch_group_count; + odsState.getOrAddProperties().precision_config = precision_config; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConvolutionOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ConvolutionOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ConvolutionOpV1::verifyInvariantsImpl() { + auto tblgen_batch_group_count = getProperties().batch_group_count; (void)tblgen_batch_group_count; + if (!tblgen_batch_group_count) return emitOpError("requires attribute 'batch_group_count'"); + auto tblgen_feature_group_count = getProperties().feature_group_count; (void)tblgen_feature_group_count; + if (!tblgen_feature_group_count) return emitOpError("requires attribute 'feature_group_count'"); + auto tblgen_input_batch_dimension = getProperties().input_batch_dimension; (void)tblgen_input_batch_dimension; + if (!tblgen_input_batch_dimension) return emitOpError("requires attribute 'input_batch_dimension'"); + auto tblgen_input_feature_dimension = getProperties().input_feature_dimension; (void)tblgen_input_feature_dimension; + if (!tblgen_input_feature_dimension) return emitOpError("requires attribute 'input_feature_dimension'"); + auto tblgen_input_spatial_dimensions = getProperties().input_spatial_dimensions; (void)tblgen_input_spatial_dimensions; + if (!tblgen_input_spatial_dimensions) return emitOpError("requires attribute 'input_spatial_dimensions'"); + auto tblgen_kernel_input_feature_dimension = getProperties().kernel_input_feature_dimension; (void)tblgen_kernel_input_feature_dimension; + if (!tblgen_kernel_input_feature_dimension) return emitOpError("requires attribute 'kernel_input_feature_dimension'"); + auto tblgen_kernel_output_feature_dimension = getProperties().kernel_output_feature_dimension; (void)tblgen_kernel_output_feature_dimension; + if (!tblgen_kernel_output_feature_dimension) return emitOpError("requires attribute 'kernel_output_feature_dimension'"); + auto tblgen_kernel_spatial_dimensions = getProperties().kernel_spatial_dimensions; (void)tblgen_kernel_spatial_dimensions; + if (!tblgen_kernel_spatial_dimensions) return emitOpError("requires attribute 'kernel_spatial_dimensions'"); + auto tblgen_lhs_dilation = getProperties().lhs_dilation; (void)tblgen_lhs_dilation; + if (!tblgen_lhs_dilation) return emitOpError("requires attribute 'lhs_dilation'"); + auto tblgen_output_batch_dimension = getProperties().output_batch_dimension; (void)tblgen_output_batch_dimension; + if (!tblgen_output_batch_dimension) return emitOpError("requires attribute 'output_batch_dimension'"); + auto tblgen_output_feature_dimension = getProperties().output_feature_dimension; (void)tblgen_output_feature_dimension; + if (!tblgen_output_feature_dimension) return emitOpError("requires attribute 'output_feature_dimension'"); + auto tblgen_output_spatial_dimensions = getProperties().output_spatial_dimensions; (void)tblgen_output_spatial_dimensions; + if (!tblgen_output_spatial_dimensions) return emitOpError("requires attribute 'output_spatial_dimensions'"); + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + if (!tblgen_padding) return emitOpError("requires attribute 'padding'"); + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + if (!tblgen_precision_config) return emitOpError("requires attribute 'precision_config'"); + auto tblgen_rhs_dilation = getProperties().rhs_dilation; (void)tblgen_rhs_dilation; + if (!tblgen_rhs_dilation) return emitOpError("requires attribute 'rhs_dilation'"); + auto tblgen_window_reversal = getProperties().window_reversal; (void)tblgen_window_reversal; + if (!tblgen_window_reversal) return emitOpError("requires attribute 'window_reversal'"); + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + if (!tblgen_window_strides) return emitOpError("requires attribute 'window_strides'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_window_strides, "window_strides"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_padding, "padding"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_lhs_dilation, "lhs_dilation"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_rhs_dilation, "rhs_dilation"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_window_reversal, "window_reversal"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_input_batch_dimension, "input_batch_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_input_feature_dimension, "input_feature_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_input_spatial_dimensions, "input_spatial_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_kernel_input_feature_dimension, "kernel_input_feature_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_kernel_output_feature_dimension, "kernel_output_feature_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_kernel_spatial_dimensions, "kernel_spatial_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_output_batch_dimension, "output_batch_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_output_feature_dimension, "output_feature_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_output_spatial_dimensions, "output_spatial_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_feature_group_count, "feature_group_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_batch_group_count, "batch_group_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_precision_config, "precision_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ConvolutionOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ConvolutionOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ConvolutionOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ConvolutionOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CosineOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CosineOpV1GenericAdaptorBase::CosineOpV1GenericAdaptorBase(CosineOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +CosineOpV1Adaptor::CosineOpV1Adaptor(CosineOpV1 op) : CosineOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CosineOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult CosineOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute CosineOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CosineOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional CosineOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void CosineOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void CosineOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult CosineOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void CosineOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void CosineOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CosineOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CosineOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CosineOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CosineOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CosineOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version CosineOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 9, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CosineOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CosineOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CosineOpV2GenericAdaptorBase::CosineOpV2GenericAdaptorBase(CosineOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute CosineOpV2GenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +} // namespace detail +CosineOpV2Adaptor::CosineOpV2Adaptor(CosineOpV2 op) : CosineOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CosineOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitError(loc, "'vhlo.cosine_v2' op ""requires attribute 'result_accuracy'"); + + if (tblgen_result_accuracy && !((true))) + return emitError(loc, "'vhlo.cosine_v2' op ""attribute 'result_accuracy' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult CosineOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CosineOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CosineOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional CosineOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void CosineOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CosineOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult CosineOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CosineOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CosineOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_accuracy); +} + +::mlir::Attribute CosineOpV2::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +void CosineOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + odsState.addTypes(result); +} + +void CosineOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CosineOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CosineOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CosineOpV2::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitOpError("requires attribute 'result_accuracy'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CosineOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CosineOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 10, 0); +} +mlir::vhlo::Version CosineOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CosineOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CreateTokenOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CreateTokenOpV1GenericAdaptorBase::CreateTokenOpV1GenericAdaptorBase(CreateTokenOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +CreateTokenOpV1Adaptor::CreateTokenOpV1Adaptor(CreateTokenOpV1 op) : CreateTokenOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CreateTokenOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult CreateTokenOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute CreateTokenOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CreateTokenOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional CreateTokenOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void CreateTokenOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void CreateTokenOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult CreateTokenOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void CreateTokenOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output) { + odsState.addTypes(output); +} + +void CreateTokenOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CreateTokenOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CreateTokenOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CreateTokenOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CreateTokenOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CreateTokenOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version CreateTokenOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CreateTokenOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CrossReplicaSumOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CrossReplicaSumOpV1GenericAdaptorBase::CrossReplicaSumOpV1GenericAdaptorBase(CrossReplicaSumOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute CrossReplicaSumOpV1GenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +} // namespace detail +CrossReplicaSumOpV1Adaptor::CrossReplicaSumOpV1Adaptor(CrossReplicaSumOpV1 op) : CrossReplicaSumOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CrossReplicaSumOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'vhlo.cross-replica-sum_v1' op ""requires attribute 'replica_groups'"); + + if (tblgen_replica_groups && !((true))) + return emitError(loc, "'vhlo.cross-replica-sum_v1' op ""attribute 'replica_groups' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult CrossReplicaSumOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CrossReplicaSumOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CrossReplicaSumOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.replica_groups.getAsOpaquePointer())); +} + +std::optional CrossReplicaSumOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "replica_groups") + return prop.replica_groups; + return std::nullopt; +} + +void CrossReplicaSumOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CrossReplicaSumOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); +} + +::llvm::LogicalResult CrossReplicaSumOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CrossReplicaSumOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CrossReplicaSumOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.replica_groups); +} + +::mlir::Attribute CrossReplicaSumOpV1::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +void CrossReplicaSumOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute replica_groups) { + odsState.addOperands(operand); + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.addTypes(result); +} + +void CrossReplicaSumOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute replica_groups) { + odsState.addOperands(operand); + odsState.getOrAddProperties().replica_groups = replica_groups; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CrossReplicaSumOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CrossReplicaSumOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CrossReplicaSumOpV1::verifyInvariantsImpl() { + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CrossReplicaSumOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CrossReplicaSumOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version CrossReplicaSumOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CrossReplicaSumOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CustomCallOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CustomCallOpV1GenericAdaptorBase::CustomCallOpV1GenericAdaptorBase(CustomCallOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair CustomCallOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute CustomCallOpV1GenericAdaptorBase::getCallTargetName() { + auto attr = getCallTargetNameAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1GenericAdaptorBase::getHasSideEffect() { + auto attr = getHasSideEffectAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1GenericAdaptorBase::getBackendConfig() { + auto attr = getBackendConfigAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1GenericAdaptorBase::getApiVersion() { + auto attr = getApiVersionAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1GenericAdaptorBase::getCalledComputations() { + auto attr = getCalledComputationsAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1GenericAdaptorBase::getOperandLayouts() { + auto attr = getOperandLayoutsAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1GenericAdaptorBase::getResultLayouts() { + auto attr = getResultLayoutsAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1GenericAdaptorBase::getOutputOperandAliases() { + auto attr = getOutputOperandAliasesAttr(); + return attr; +} + +} // namespace detail +CustomCallOpV1Adaptor::CustomCallOpV1Adaptor(CustomCallOpV1 op) : CustomCallOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult CustomCallOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_api_version = getProperties().api_version; (void)tblgen_api_version; + if (!tblgen_api_version) return emitError(loc, "'vhlo.custom_call_v1' op ""requires attribute 'api_version'"); + auto tblgen_backend_config = getProperties().backend_config; (void)tblgen_backend_config; + if (!tblgen_backend_config) return emitError(loc, "'vhlo.custom_call_v1' op ""requires attribute 'backend_config'"); + auto tblgen_call_target_name = getProperties().call_target_name; (void)tblgen_call_target_name; + if (!tblgen_call_target_name) return emitError(loc, "'vhlo.custom_call_v1' op ""requires attribute 'call_target_name'"); + auto tblgen_called_computations = getProperties().called_computations; (void)tblgen_called_computations; + if (!tblgen_called_computations) return emitError(loc, "'vhlo.custom_call_v1' op ""requires attribute 'called_computations'"); + auto tblgen_has_side_effect = getProperties().has_side_effect; (void)tblgen_has_side_effect; + if (!tblgen_has_side_effect) return emitError(loc, "'vhlo.custom_call_v1' op ""requires attribute 'has_side_effect'"); + auto tblgen_operand_layouts = getProperties().operand_layouts; (void)tblgen_operand_layouts; + if (!tblgen_operand_layouts) return emitError(loc, "'vhlo.custom_call_v1' op ""requires attribute 'operand_layouts'"); + auto tblgen_output_operand_aliases = getProperties().output_operand_aliases; (void)tblgen_output_operand_aliases; + if (!tblgen_output_operand_aliases) return emitError(loc, "'vhlo.custom_call_v1' op ""requires attribute 'output_operand_aliases'"); + auto tblgen_result_layouts = getProperties().result_layouts; (void)tblgen_result_layouts; + if (!tblgen_result_layouts) return emitError(loc, "'vhlo.custom_call_v1' op ""requires attribute 'result_layouts'"); + + if (tblgen_call_target_name && !((true))) + return emitError(loc, "'vhlo.custom_call_v1' op ""attribute 'call_target_name' failed to satisfy constraint: any attribute"); + + if (tblgen_has_side_effect && !((true))) + return emitError(loc, "'vhlo.custom_call_v1' op ""attribute 'has_side_effect' failed to satisfy constraint: any attribute"); + + if (tblgen_backend_config && !((true))) + return emitError(loc, "'vhlo.custom_call_v1' op ""attribute 'backend_config' failed to satisfy constraint: any attribute"); + + if (tblgen_api_version && !((true))) + return emitError(loc, "'vhlo.custom_call_v1' op ""attribute 'api_version' failed to satisfy constraint: any attribute"); + + if (tblgen_called_computations && !((true))) + return emitError(loc, "'vhlo.custom_call_v1' op ""attribute 'called_computations' failed to satisfy constraint: any attribute"); + + if (tblgen_operand_layouts && !((true))) + return emitError(loc, "'vhlo.custom_call_v1' op ""attribute 'operand_layouts' failed to satisfy constraint: any attribute"); + + if (tblgen_result_layouts && !((true))) + return emitError(loc, "'vhlo.custom_call_v1' op ""attribute 'result_layouts' failed to satisfy constraint: any attribute"); + + if (tblgen_output_operand_aliases && !((true))) + return emitError(loc, "'vhlo.custom_call_v1' op ""attribute 'output_operand_aliases' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair CustomCallOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange CustomCallOpV1::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair CustomCallOpV1::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult CustomCallOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.api_version; + auto attr = dict.get("api_version"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `api_version` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.backend_config; + auto attr = dict.get("backend_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `backend_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.call_target_name; + auto attr = dict.get("call_target_name"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `call_target_name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.called_computations; + auto attr = dict.get("called_computations"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `called_computations` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.has_side_effect; + auto attr = dict.get("has_side_effect"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `has_side_effect` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.operand_layouts; + auto attr = dict.get("operand_layouts"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `operand_layouts` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.output_operand_aliases; + auto attr = dict.get("output_operand_aliases"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `output_operand_aliases` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.result_layouts; + auto attr = dict.get("result_layouts"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_layouts` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CustomCallOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.api_version; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("api_version", + propStorage)); + } + + { + const auto &propStorage = prop.backend_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("backend_config", + propStorage)); + } + + { + const auto &propStorage = prop.call_target_name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("call_target_name", + propStorage)); + } + + { + const auto &propStorage = prop.called_computations; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("called_computations", + propStorage)); + } + + { + const auto &propStorage = prop.has_side_effect; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("has_side_effect", + propStorage)); + } + + { + const auto &propStorage = prop.operand_layouts; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("operand_layouts", + propStorage)); + } + + { + const auto &propStorage = prop.output_operand_aliases; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("output_operand_aliases", + propStorage)); + } + + { + const auto &propStorage = prop.result_layouts; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_layouts", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CustomCallOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.api_version.getAsOpaquePointer()), + llvm::hash_value(prop.backend_config.getAsOpaquePointer()), + llvm::hash_value(prop.call_target_name.getAsOpaquePointer()), + llvm::hash_value(prop.called_computations.getAsOpaquePointer()), + llvm::hash_value(prop.has_side_effect.getAsOpaquePointer()), + llvm::hash_value(prop.operand_layouts.getAsOpaquePointer()), + llvm::hash_value(prop.output_operand_aliases.getAsOpaquePointer()), + llvm::hash_value(prop.result_layouts.getAsOpaquePointer())); +} + +std::optional CustomCallOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "api_version") + return prop.api_version; + + if (name == "backend_config") + return prop.backend_config; + + if (name == "call_target_name") + return prop.call_target_name; + + if (name == "called_computations") + return prop.called_computations; + + if (name == "has_side_effect") + return prop.has_side_effect; + + if (name == "operand_layouts") + return prop.operand_layouts; + + if (name == "output_operand_aliases") + return prop.output_operand_aliases; + + if (name == "result_layouts") + return prop.result_layouts; + return std::nullopt; +} + +void CustomCallOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "api_version") { + prop.api_version = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "backend_config") { + prop.backend_config = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "call_target_name") { + prop.call_target_name = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "called_computations") { + prop.called_computations = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "has_side_effect") { + prop.has_side_effect = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "operand_layouts") { + prop.operand_layouts = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "output_operand_aliases") { + prop.output_operand_aliases = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "result_layouts") { + prop.result_layouts = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CustomCallOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.api_version) attrs.append("api_version", prop.api_version); + + if (prop.backend_config) attrs.append("backend_config", prop.backend_config); + + if (prop.call_target_name) attrs.append("call_target_name", prop.call_target_name); + + if (prop.called_computations) attrs.append("called_computations", prop.called_computations); + + if (prop.has_side_effect) attrs.append("has_side_effect", prop.has_side_effect); + + if (prop.operand_layouts) attrs.append("operand_layouts", prop.operand_layouts); + + if (prop.output_operand_aliases) attrs.append("output_operand_aliases", prop.output_operand_aliases); + + if (prop.result_layouts) attrs.append("result_layouts", prop.result_layouts); +} + +::llvm::LogicalResult CustomCallOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getApiVersionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "api_version", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getBackendConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "backend_config", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getCallTargetNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "call_target_name", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getCalledComputationsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "called_computations", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getHasSideEffectAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "has_side_effect", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOperandLayoutsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "operand_layouts", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOutputOperandAliasesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "output_operand_aliases", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getResultLayoutsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "result_layouts", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult CustomCallOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.api_version))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.backend_config))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.call_target_name))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.called_computations))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.has_side_effect))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.operand_layouts))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.output_operand_aliases))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.result_layouts))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CustomCallOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.api_version); + writer.writeAttribute(prop.backend_config); + writer.writeAttribute(prop.call_target_name); + writer.writeAttribute(prop.called_computations); + writer.writeAttribute(prop.has_side_effect); + writer.writeAttribute(prop.operand_layouts); + writer.writeAttribute(prop.output_operand_aliases); + writer.writeAttribute(prop.result_layouts); +} + +::mlir::Attribute CustomCallOpV1::getCallTargetName() { + auto attr = getCallTargetNameAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1::getHasSideEffect() { + auto attr = getHasSideEffectAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1::getBackendConfig() { + auto attr = getBackendConfigAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1::getApiVersion() { + auto attr = getApiVersionAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1::getCalledComputations() { + auto attr = getCalledComputationsAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1::getOperandLayouts() { + auto attr = getOperandLayoutsAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1::getResultLayouts() { + auto attr = getResultLayoutsAttr(); + return attr; +} + +::mlir::Attribute CustomCallOpV1::getOutputOperandAliases() { + auto attr = getOutputOperandAliasesAttr(); + return attr; +} + +void CustomCallOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::Attribute call_target_name, ::mlir::Attribute has_side_effect, ::mlir::Attribute backend_config, ::mlir::Attribute api_version, ::mlir::Attribute called_computations, ::mlir::Attribute operand_layouts, ::mlir::Attribute result_layouts, ::mlir::Attribute output_operand_aliases) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().call_target_name = call_target_name; + odsState.getOrAddProperties().has_side_effect = has_side_effect; + odsState.getOrAddProperties().backend_config = backend_config; + odsState.getOrAddProperties().api_version = api_version; + odsState.getOrAddProperties().called_computations = called_computations; + odsState.getOrAddProperties().operand_layouts = operand_layouts; + odsState.getOrAddProperties().result_layouts = result_layouts; + odsState.getOrAddProperties().output_operand_aliases = output_operand_aliases; + odsState.addTypes(results); +} + +void CustomCallOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void CustomCallOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult CustomCallOpV1::verifyInvariantsImpl() { + auto tblgen_api_version = getProperties().api_version; (void)tblgen_api_version; + if (!tblgen_api_version) return emitOpError("requires attribute 'api_version'"); + auto tblgen_backend_config = getProperties().backend_config; (void)tblgen_backend_config; + if (!tblgen_backend_config) return emitOpError("requires attribute 'backend_config'"); + auto tblgen_call_target_name = getProperties().call_target_name; (void)tblgen_call_target_name; + if (!tblgen_call_target_name) return emitOpError("requires attribute 'call_target_name'"); + auto tblgen_called_computations = getProperties().called_computations; (void)tblgen_called_computations; + if (!tblgen_called_computations) return emitOpError("requires attribute 'called_computations'"); + auto tblgen_has_side_effect = getProperties().has_side_effect; (void)tblgen_has_side_effect; + if (!tblgen_has_side_effect) return emitOpError("requires attribute 'has_side_effect'"); + auto tblgen_operand_layouts = getProperties().operand_layouts; (void)tblgen_operand_layouts; + if (!tblgen_operand_layouts) return emitOpError("requires attribute 'operand_layouts'"); + auto tblgen_output_operand_aliases = getProperties().output_operand_aliases; (void)tblgen_output_operand_aliases; + if (!tblgen_output_operand_aliases) return emitOpError("requires attribute 'output_operand_aliases'"); + auto tblgen_result_layouts = getProperties().result_layouts; (void)tblgen_result_layouts; + if (!tblgen_result_layouts) return emitOpError("requires attribute 'result_layouts'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_call_target_name, "call_target_name"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_has_side_effect, "has_side_effect"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_backend_config, "backend_config"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_api_version, "api_version"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_called_computations, "called_computations"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_operand_layouts, "operand_layouts"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_result_layouts, "result_layouts"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_output_operand_aliases, "output_operand_aliases"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult CustomCallOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version CustomCallOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version CustomCallOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::CustomCallOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DivOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DivOpV1GenericAdaptorBase::DivOpV1GenericAdaptorBase(DivOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +DivOpV1Adaptor::DivOpV1Adaptor(DivOpV1 op) : DivOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DivOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult DivOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute DivOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DivOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional DivOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void DivOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void DivOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult DivOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void DivOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void DivOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DivOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DivOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DivOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DivOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DivOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version DivOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DivOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DotGeneralOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DotGeneralOpV1GenericAdaptorBase::DotGeneralOpV1GenericAdaptorBase(DotGeneralOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute DotGeneralOpV1GenericAdaptorBase::getLhsBatchingDimensions() { + auto attr = getLhsBatchingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV1GenericAdaptorBase::getRhsBatchingDimensions() { + auto attr = getRhsBatchingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV1GenericAdaptorBase::getLhsContractingDimensions() { + auto attr = getLhsContractingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV1GenericAdaptorBase::getRhsContractingDimensions() { + auto attr = getRhsContractingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV1GenericAdaptorBase::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr; +} + +} // namespace detail +DotGeneralOpV1Adaptor::DotGeneralOpV1Adaptor(DotGeneralOpV1 op) : DotGeneralOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DotGeneralOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_lhs_batching_dimensions = getProperties().lhs_batching_dimensions; (void)tblgen_lhs_batching_dimensions; + if (!tblgen_lhs_batching_dimensions) return emitError(loc, "'vhlo.dot_general_v1' op ""requires attribute 'lhs_batching_dimensions'"); + auto tblgen_lhs_contracting_dimensions = getProperties().lhs_contracting_dimensions; (void)tblgen_lhs_contracting_dimensions; + if (!tblgen_lhs_contracting_dimensions) return emitError(loc, "'vhlo.dot_general_v1' op ""requires attribute 'lhs_contracting_dimensions'"); + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + if (!tblgen_precision_config) return emitError(loc, "'vhlo.dot_general_v1' op ""requires attribute 'precision_config'"); + auto tblgen_rhs_batching_dimensions = getProperties().rhs_batching_dimensions; (void)tblgen_rhs_batching_dimensions; + if (!tblgen_rhs_batching_dimensions) return emitError(loc, "'vhlo.dot_general_v1' op ""requires attribute 'rhs_batching_dimensions'"); + auto tblgen_rhs_contracting_dimensions = getProperties().rhs_contracting_dimensions; (void)tblgen_rhs_contracting_dimensions; + if (!tblgen_rhs_contracting_dimensions) return emitError(loc, "'vhlo.dot_general_v1' op ""requires attribute 'rhs_contracting_dimensions'"); + + if (tblgen_lhs_batching_dimensions && !((true))) + return emitError(loc, "'vhlo.dot_general_v1' op ""attribute 'lhs_batching_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_rhs_batching_dimensions && !((true))) + return emitError(loc, "'vhlo.dot_general_v1' op ""attribute 'rhs_batching_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_lhs_contracting_dimensions && !((true))) + return emitError(loc, "'vhlo.dot_general_v1' op ""attribute 'lhs_contracting_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_rhs_contracting_dimensions && !((true))) + return emitError(loc, "'vhlo.dot_general_v1' op ""attribute 'rhs_contracting_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_precision_config && !((true))) + return emitError(loc, "'vhlo.dot_general_v1' op ""attribute 'precision_config' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult DotGeneralOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.lhs_batching_dimensions; + auto attr = dict.get("lhs_batching_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lhs_batching_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.lhs_contracting_dimensions; + auto attr = dict.get("lhs_contracting_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lhs_contracting_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.precision_config; + auto attr = dict.get("precision_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `precision_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.rhs_batching_dimensions; + auto attr = dict.get("rhs_batching_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rhs_batching_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.rhs_contracting_dimensions; + auto attr = dict.get("rhs_contracting_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rhs_contracting_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DotGeneralOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.lhs_batching_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lhs_batching_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.lhs_contracting_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lhs_contracting_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.precision_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("precision_config", + propStorage)); + } + + { + const auto &propStorage = prop.rhs_batching_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rhs_batching_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.rhs_contracting_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rhs_contracting_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DotGeneralOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.lhs_batching_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.lhs_contracting_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.precision_config.getAsOpaquePointer()), + llvm::hash_value(prop.rhs_batching_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.rhs_contracting_dimensions.getAsOpaquePointer())); +} + +std::optional DotGeneralOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "lhs_batching_dimensions") + return prop.lhs_batching_dimensions; + + if (name == "lhs_contracting_dimensions") + return prop.lhs_contracting_dimensions; + + if (name == "precision_config") + return prop.precision_config; + + if (name == "rhs_batching_dimensions") + return prop.rhs_batching_dimensions; + + if (name == "rhs_contracting_dimensions") + return prop.rhs_contracting_dimensions; + return std::nullopt; +} + +void DotGeneralOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "lhs_batching_dimensions") { + prop.lhs_batching_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "lhs_contracting_dimensions") { + prop.lhs_contracting_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "precision_config") { + prop.precision_config = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "rhs_batching_dimensions") { + prop.rhs_batching_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "rhs_contracting_dimensions") { + prop.rhs_contracting_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DotGeneralOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.lhs_batching_dimensions) attrs.append("lhs_batching_dimensions", prop.lhs_batching_dimensions); + + if (prop.lhs_contracting_dimensions) attrs.append("lhs_contracting_dimensions", prop.lhs_contracting_dimensions); + + if (prop.precision_config) attrs.append("precision_config", prop.precision_config); + + if (prop.rhs_batching_dimensions) attrs.append("rhs_batching_dimensions", prop.rhs_batching_dimensions); + + if (prop.rhs_contracting_dimensions) attrs.append("rhs_contracting_dimensions", prop.rhs_contracting_dimensions); +} + +::llvm::LogicalResult DotGeneralOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getLhsBatchingDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "lhs_batching_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLhsContractingDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "lhs_contracting_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPrecisionConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "precision_config", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRhsBatchingDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "rhs_batching_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRhsContractingDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "rhs_contracting_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DotGeneralOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.lhs_batching_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.lhs_contracting_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.precision_config))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.rhs_batching_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.rhs_contracting_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DotGeneralOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.lhs_batching_dimensions); + writer.writeAttribute(prop.lhs_contracting_dimensions); + writer.writeAttribute(prop.precision_config); + writer.writeAttribute(prop.rhs_batching_dimensions); + writer.writeAttribute(prop.rhs_contracting_dimensions); +} + +::mlir::Attribute DotGeneralOpV1::getLhsBatchingDimensions() { + auto attr = getLhsBatchingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV1::getRhsBatchingDimensions() { + auto attr = getRhsBatchingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV1::getLhsContractingDimensions() { + auto attr = getLhsContractingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV1::getRhsContractingDimensions() { + auto attr = getRhsContractingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV1::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr; +} + +void DotGeneralOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute lhs_batching_dimensions, ::mlir::Attribute rhs_batching_dimensions, ::mlir::Attribute lhs_contracting_dimensions, ::mlir::Attribute rhs_contracting_dimensions, ::mlir::Attribute precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().lhs_batching_dimensions = lhs_batching_dimensions; + odsState.getOrAddProperties().rhs_batching_dimensions = rhs_batching_dimensions; + odsState.getOrAddProperties().lhs_contracting_dimensions = lhs_contracting_dimensions; + odsState.getOrAddProperties().rhs_contracting_dimensions = rhs_contracting_dimensions; + odsState.getOrAddProperties().precision_config = precision_config; + odsState.addTypes(result); +} + +void DotGeneralOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute lhs_batching_dimensions, ::mlir::Attribute rhs_batching_dimensions, ::mlir::Attribute lhs_contracting_dimensions, ::mlir::Attribute rhs_contracting_dimensions, ::mlir::Attribute precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().lhs_batching_dimensions = lhs_batching_dimensions; + odsState.getOrAddProperties().rhs_batching_dimensions = rhs_batching_dimensions; + odsState.getOrAddProperties().lhs_contracting_dimensions = lhs_contracting_dimensions; + odsState.getOrAddProperties().rhs_contracting_dimensions = rhs_contracting_dimensions; + odsState.getOrAddProperties().precision_config = precision_config; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DotGeneralOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DotGeneralOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DotGeneralOpV1::verifyInvariantsImpl() { + auto tblgen_lhs_batching_dimensions = getProperties().lhs_batching_dimensions; (void)tblgen_lhs_batching_dimensions; + if (!tblgen_lhs_batching_dimensions) return emitOpError("requires attribute 'lhs_batching_dimensions'"); + auto tblgen_lhs_contracting_dimensions = getProperties().lhs_contracting_dimensions; (void)tblgen_lhs_contracting_dimensions; + if (!tblgen_lhs_contracting_dimensions) return emitOpError("requires attribute 'lhs_contracting_dimensions'"); + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + if (!tblgen_precision_config) return emitOpError("requires attribute 'precision_config'"); + auto tblgen_rhs_batching_dimensions = getProperties().rhs_batching_dimensions; (void)tblgen_rhs_batching_dimensions; + if (!tblgen_rhs_batching_dimensions) return emitOpError("requires attribute 'rhs_batching_dimensions'"); + auto tblgen_rhs_contracting_dimensions = getProperties().rhs_contracting_dimensions; (void)tblgen_rhs_contracting_dimensions; + if (!tblgen_rhs_contracting_dimensions) return emitOpError("requires attribute 'rhs_contracting_dimensions'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_lhs_batching_dimensions, "lhs_batching_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_rhs_batching_dimensions, "rhs_batching_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_lhs_contracting_dimensions, "lhs_contracting_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_rhs_contracting_dimensions, "rhs_contracting_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_precision_config, "precision_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DotGeneralOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DotGeneralOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version DotGeneralOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 5, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DotGeneralOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DotGeneralOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DotGeneralOpV2GenericAdaptorBase::DotGeneralOpV2GenericAdaptorBase(DotGeneralOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute DotGeneralOpV2GenericAdaptorBase::getLhsBatchingDimensions() { + auto attr = getLhsBatchingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2GenericAdaptorBase::getRhsBatchingDimensions() { + auto attr = getRhsBatchingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2GenericAdaptorBase::getLhsContractingDimensions() { + auto attr = getLhsContractingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2GenericAdaptorBase::getRhsContractingDimensions() { + auto attr = getRhsContractingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2GenericAdaptorBase::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2GenericAdaptorBase::getLhsPrecisionType() { + auto attr = getLhsPrecisionTypeAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2GenericAdaptorBase::getRhsPrecisionType() { + auto attr = getRhsPrecisionTypeAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2GenericAdaptorBase::getAccumulationType() { + auto attr = getAccumulationTypeAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2GenericAdaptorBase::getLhsComponentCount() { + auto attr = getLhsComponentCountAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2GenericAdaptorBase::getRhsComponentCount() { + auto attr = getRhsComponentCountAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2GenericAdaptorBase::getNumPrimitiveOperations() { + auto attr = getNumPrimitiveOperationsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2GenericAdaptorBase::getAllowImpreciseAccumulation() { + auto attr = getAllowImpreciseAccumulationAttr(); + return attr; +} + +} // namespace detail +DotGeneralOpV2Adaptor::DotGeneralOpV2Adaptor(DotGeneralOpV2 op) : DotGeneralOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DotGeneralOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_accumulation_type = getProperties().accumulation_type; (void)tblgen_accumulation_type; + if (!tblgen_accumulation_type) return emitError(loc, "'vhlo.dot_general_v2' op ""requires attribute 'accumulation_type'"); + auto tblgen_allow_imprecise_accumulation = getProperties().allow_imprecise_accumulation; (void)tblgen_allow_imprecise_accumulation; + if (!tblgen_allow_imprecise_accumulation) return emitError(loc, "'vhlo.dot_general_v2' op ""requires attribute 'allow_imprecise_accumulation'"); + auto tblgen_lhs_batching_dimensions = getProperties().lhs_batching_dimensions; (void)tblgen_lhs_batching_dimensions; + if (!tblgen_lhs_batching_dimensions) return emitError(loc, "'vhlo.dot_general_v2' op ""requires attribute 'lhs_batching_dimensions'"); + auto tblgen_lhs_component_count = getProperties().lhs_component_count; (void)tblgen_lhs_component_count; + if (!tblgen_lhs_component_count) return emitError(loc, "'vhlo.dot_general_v2' op ""requires attribute 'lhs_component_count'"); + auto tblgen_lhs_contracting_dimensions = getProperties().lhs_contracting_dimensions; (void)tblgen_lhs_contracting_dimensions; + if (!tblgen_lhs_contracting_dimensions) return emitError(loc, "'vhlo.dot_general_v2' op ""requires attribute 'lhs_contracting_dimensions'"); + auto tblgen_lhs_precision_type = getProperties().lhs_precision_type; (void)tblgen_lhs_precision_type; + if (!tblgen_lhs_precision_type) return emitError(loc, "'vhlo.dot_general_v2' op ""requires attribute 'lhs_precision_type'"); + auto tblgen_num_primitive_operations = getProperties().num_primitive_operations; (void)tblgen_num_primitive_operations; + if (!tblgen_num_primitive_operations) return emitError(loc, "'vhlo.dot_general_v2' op ""requires attribute 'num_primitive_operations'"); + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + if (!tblgen_precision_config) return emitError(loc, "'vhlo.dot_general_v2' op ""requires attribute 'precision_config'"); + auto tblgen_rhs_batching_dimensions = getProperties().rhs_batching_dimensions; (void)tblgen_rhs_batching_dimensions; + if (!tblgen_rhs_batching_dimensions) return emitError(loc, "'vhlo.dot_general_v2' op ""requires attribute 'rhs_batching_dimensions'"); + auto tblgen_rhs_component_count = getProperties().rhs_component_count; (void)tblgen_rhs_component_count; + if (!tblgen_rhs_component_count) return emitError(loc, "'vhlo.dot_general_v2' op ""requires attribute 'rhs_component_count'"); + auto tblgen_rhs_contracting_dimensions = getProperties().rhs_contracting_dimensions; (void)tblgen_rhs_contracting_dimensions; + if (!tblgen_rhs_contracting_dimensions) return emitError(loc, "'vhlo.dot_general_v2' op ""requires attribute 'rhs_contracting_dimensions'"); + auto tblgen_rhs_precision_type = getProperties().rhs_precision_type; (void)tblgen_rhs_precision_type; + if (!tblgen_rhs_precision_type) return emitError(loc, "'vhlo.dot_general_v2' op ""requires attribute 'rhs_precision_type'"); + + if (tblgen_lhs_batching_dimensions && !((true))) + return emitError(loc, "'vhlo.dot_general_v2' op ""attribute 'lhs_batching_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_rhs_batching_dimensions && !((true))) + return emitError(loc, "'vhlo.dot_general_v2' op ""attribute 'rhs_batching_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_lhs_contracting_dimensions && !((true))) + return emitError(loc, "'vhlo.dot_general_v2' op ""attribute 'lhs_contracting_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_rhs_contracting_dimensions && !((true))) + return emitError(loc, "'vhlo.dot_general_v2' op ""attribute 'rhs_contracting_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_precision_config && !((true))) + return emitError(loc, "'vhlo.dot_general_v2' op ""attribute 'precision_config' failed to satisfy constraint: any attribute"); + + if (tblgen_lhs_precision_type && !((true))) + return emitError(loc, "'vhlo.dot_general_v2' op ""attribute 'lhs_precision_type' failed to satisfy constraint: any attribute"); + + if (tblgen_rhs_precision_type && !((true))) + return emitError(loc, "'vhlo.dot_general_v2' op ""attribute 'rhs_precision_type' failed to satisfy constraint: any attribute"); + + if (tblgen_accumulation_type && !((true))) + return emitError(loc, "'vhlo.dot_general_v2' op ""attribute 'accumulation_type' failed to satisfy constraint: any attribute"); + + if (tblgen_lhs_component_count && !((true))) + return emitError(loc, "'vhlo.dot_general_v2' op ""attribute 'lhs_component_count' failed to satisfy constraint: any attribute"); + + if (tblgen_rhs_component_count && !((true))) + return emitError(loc, "'vhlo.dot_general_v2' op ""attribute 'rhs_component_count' failed to satisfy constraint: any attribute"); + + if (tblgen_num_primitive_operations && !((true))) + return emitError(loc, "'vhlo.dot_general_v2' op ""attribute 'num_primitive_operations' failed to satisfy constraint: any attribute"); + + if (tblgen_allow_imprecise_accumulation && !((true))) + return emitError(loc, "'vhlo.dot_general_v2' op ""attribute 'allow_imprecise_accumulation' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult DotGeneralOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.accumulation_type; + auto attr = dict.get("accumulation_type"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `accumulation_type` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.allow_imprecise_accumulation; + auto attr = dict.get("allow_imprecise_accumulation"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `allow_imprecise_accumulation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.lhs_batching_dimensions; + auto attr = dict.get("lhs_batching_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lhs_batching_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.lhs_component_count; + auto attr = dict.get("lhs_component_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lhs_component_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.lhs_contracting_dimensions; + auto attr = dict.get("lhs_contracting_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lhs_contracting_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.lhs_precision_type; + auto attr = dict.get("lhs_precision_type"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lhs_precision_type` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.num_primitive_operations; + auto attr = dict.get("num_primitive_operations"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `num_primitive_operations` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.precision_config; + auto attr = dict.get("precision_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `precision_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.rhs_batching_dimensions; + auto attr = dict.get("rhs_batching_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rhs_batching_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.rhs_component_count; + auto attr = dict.get("rhs_component_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rhs_component_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.rhs_contracting_dimensions; + auto attr = dict.get("rhs_contracting_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rhs_contracting_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.rhs_precision_type; + auto attr = dict.get("rhs_precision_type"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rhs_precision_type` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DotGeneralOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.accumulation_type; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("accumulation_type", + propStorage)); + } + + { + const auto &propStorage = prop.allow_imprecise_accumulation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("allow_imprecise_accumulation", + propStorage)); + } + + { + const auto &propStorage = prop.lhs_batching_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lhs_batching_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.lhs_component_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lhs_component_count", + propStorage)); + } + + { + const auto &propStorage = prop.lhs_contracting_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lhs_contracting_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.lhs_precision_type; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lhs_precision_type", + propStorage)); + } + + { + const auto &propStorage = prop.num_primitive_operations; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("num_primitive_operations", + propStorage)); + } + + { + const auto &propStorage = prop.precision_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("precision_config", + propStorage)); + } + + { + const auto &propStorage = prop.rhs_batching_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rhs_batching_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.rhs_component_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rhs_component_count", + propStorage)); + } + + { + const auto &propStorage = prop.rhs_contracting_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rhs_contracting_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.rhs_precision_type; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rhs_precision_type", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DotGeneralOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.accumulation_type.getAsOpaquePointer()), + llvm::hash_value(prop.allow_imprecise_accumulation.getAsOpaquePointer()), + llvm::hash_value(prop.lhs_batching_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.lhs_component_count.getAsOpaquePointer()), + llvm::hash_value(prop.lhs_contracting_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.lhs_precision_type.getAsOpaquePointer()), + llvm::hash_value(prop.num_primitive_operations.getAsOpaquePointer()), + llvm::hash_value(prop.precision_config.getAsOpaquePointer()), + llvm::hash_value(prop.rhs_batching_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.rhs_component_count.getAsOpaquePointer()), + llvm::hash_value(prop.rhs_contracting_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.rhs_precision_type.getAsOpaquePointer())); +} + +std::optional DotGeneralOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "accumulation_type") + return prop.accumulation_type; + + if (name == "allow_imprecise_accumulation") + return prop.allow_imprecise_accumulation; + + if (name == "lhs_batching_dimensions") + return prop.lhs_batching_dimensions; + + if (name == "lhs_component_count") + return prop.lhs_component_count; + + if (name == "lhs_contracting_dimensions") + return prop.lhs_contracting_dimensions; + + if (name == "lhs_precision_type") + return prop.lhs_precision_type; + + if (name == "num_primitive_operations") + return prop.num_primitive_operations; + + if (name == "precision_config") + return prop.precision_config; + + if (name == "rhs_batching_dimensions") + return prop.rhs_batching_dimensions; + + if (name == "rhs_component_count") + return prop.rhs_component_count; + + if (name == "rhs_contracting_dimensions") + return prop.rhs_contracting_dimensions; + + if (name == "rhs_precision_type") + return prop.rhs_precision_type; + return std::nullopt; +} + +void DotGeneralOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "accumulation_type") { + prop.accumulation_type = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "allow_imprecise_accumulation") { + prop.allow_imprecise_accumulation = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "lhs_batching_dimensions") { + prop.lhs_batching_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "lhs_component_count") { + prop.lhs_component_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "lhs_contracting_dimensions") { + prop.lhs_contracting_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "lhs_precision_type") { + prop.lhs_precision_type = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "num_primitive_operations") { + prop.num_primitive_operations = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "precision_config") { + prop.precision_config = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "rhs_batching_dimensions") { + prop.rhs_batching_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "rhs_component_count") { + prop.rhs_component_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "rhs_contracting_dimensions") { + prop.rhs_contracting_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "rhs_precision_type") { + prop.rhs_precision_type = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DotGeneralOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.accumulation_type) attrs.append("accumulation_type", prop.accumulation_type); + + if (prop.allow_imprecise_accumulation) attrs.append("allow_imprecise_accumulation", prop.allow_imprecise_accumulation); + + if (prop.lhs_batching_dimensions) attrs.append("lhs_batching_dimensions", prop.lhs_batching_dimensions); + + if (prop.lhs_component_count) attrs.append("lhs_component_count", prop.lhs_component_count); + + if (prop.lhs_contracting_dimensions) attrs.append("lhs_contracting_dimensions", prop.lhs_contracting_dimensions); + + if (prop.lhs_precision_type) attrs.append("lhs_precision_type", prop.lhs_precision_type); + + if (prop.num_primitive_operations) attrs.append("num_primitive_operations", prop.num_primitive_operations); + + if (prop.precision_config) attrs.append("precision_config", prop.precision_config); + + if (prop.rhs_batching_dimensions) attrs.append("rhs_batching_dimensions", prop.rhs_batching_dimensions); + + if (prop.rhs_component_count) attrs.append("rhs_component_count", prop.rhs_component_count); + + if (prop.rhs_contracting_dimensions) attrs.append("rhs_contracting_dimensions", prop.rhs_contracting_dimensions); + + if (prop.rhs_precision_type) attrs.append("rhs_precision_type", prop.rhs_precision_type); +} + +::llvm::LogicalResult DotGeneralOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getAccumulationTypeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "accumulation_type", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getAllowImpreciseAccumulationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "allow_imprecise_accumulation", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLhsBatchingDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "lhs_batching_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLhsComponentCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "lhs_component_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLhsContractingDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "lhs_contracting_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLhsPrecisionTypeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "lhs_precision_type", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getNumPrimitiveOperationsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "num_primitive_operations", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPrecisionConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "precision_config", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRhsBatchingDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "rhs_batching_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRhsComponentCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "rhs_component_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRhsContractingDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "rhs_contracting_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRhsPrecisionTypeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "rhs_precision_type", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DotGeneralOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.accumulation_type))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.allow_imprecise_accumulation))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.lhs_batching_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.lhs_component_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.lhs_contracting_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.lhs_precision_type))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.num_primitive_operations))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.precision_config))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.rhs_batching_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.rhs_component_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.rhs_contracting_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.rhs_precision_type))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DotGeneralOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.accumulation_type); + writer.writeAttribute(prop.allow_imprecise_accumulation); + writer.writeAttribute(prop.lhs_batching_dimensions); + writer.writeAttribute(prop.lhs_component_count); + writer.writeAttribute(prop.lhs_contracting_dimensions); + writer.writeAttribute(prop.lhs_precision_type); + writer.writeAttribute(prop.num_primitive_operations); + writer.writeAttribute(prop.precision_config); + writer.writeAttribute(prop.rhs_batching_dimensions); + writer.writeAttribute(prop.rhs_component_count); + writer.writeAttribute(prop.rhs_contracting_dimensions); + writer.writeAttribute(prop.rhs_precision_type); +} + +::mlir::Attribute DotGeneralOpV2::getLhsBatchingDimensions() { + auto attr = getLhsBatchingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2::getRhsBatchingDimensions() { + auto attr = getRhsBatchingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2::getLhsContractingDimensions() { + auto attr = getLhsContractingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2::getRhsContractingDimensions() { + auto attr = getRhsContractingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2::getLhsPrecisionType() { + auto attr = getLhsPrecisionTypeAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2::getRhsPrecisionType() { + auto attr = getRhsPrecisionTypeAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2::getAccumulationType() { + auto attr = getAccumulationTypeAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2::getLhsComponentCount() { + auto attr = getLhsComponentCountAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2::getRhsComponentCount() { + auto attr = getRhsComponentCountAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2::getNumPrimitiveOperations() { + auto attr = getNumPrimitiveOperationsAttr(); + return attr; +} + +::mlir::Attribute DotGeneralOpV2::getAllowImpreciseAccumulation() { + auto attr = getAllowImpreciseAccumulationAttr(); + return attr; +} + +void DotGeneralOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute lhs_batching_dimensions, ::mlir::Attribute rhs_batching_dimensions, ::mlir::Attribute lhs_contracting_dimensions, ::mlir::Attribute rhs_contracting_dimensions, ::mlir::Attribute precision_config, ::mlir::Attribute lhs_precision_type, ::mlir::Attribute rhs_precision_type, ::mlir::Attribute accumulation_type, ::mlir::Attribute lhs_component_count, ::mlir::Attribute rhs_component_count, ::mlir::Attribute num_primitive_operations, ::mlir::Attribute allow_imprecise_accumulation) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().lhs_batching_dimensions = lhs_batching_dimensions; + odsState.getOrAddProperties().rhs_batching_dimensions = rhs_batching_dimensions; + odsState.getOrAddProperties().lhs_contracting_dimensions = lhs_contracting_dimensions; + odsState.getOrAddProperties().rhs_contracting_dimensions = rhs_contracting_dimensions; + odsState.getOrAddProperties().precision_config = precision_config; + odsState.getOrAddProperties().lhs_precision_type = lhs_precision_type; + odsState.getOrAddProperties().rhs_precision_type = rhs_precision_type; + odsState.getOrAddProperties().accumulation_type = accumulation_type; + odsState.getOrAddProperties().lhs_component_count = lhs_component_count; + odsState.getOrAddProperties().rhs_component_count = rhs_component_count; + odsState.getOrAddProperties().num_primitive_operations = num_primitive_operations; + odsState.getOrAddProperties().allow_imprecise_accumulation = allow_imprecise_accumulation; + odsState.addTypes(result); +} + +void DotGeneralOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute lhs_batching_dimensions, ::mlir::Attribute rhs_batching_dimensions, ::mlir::Attribute lhs_contracting_dimensions, ::mlir::Attribute rhs_contracting_dimensions, ::mlir::Attribute precision_config, ::mlir::Attribute lhs_precision_type, ::mlir::Attribute rhs_precision_type, ::mlir::Attribute accumulation_type, ::mlir::Attribute lhs_component_count, ::mlir::Attribute rhs_component_count, ::mlir::Attribute num_primitive_operations, ::mlir::Attribute allow_imprecise_accumulation) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().lhs_batching_dimensions = lhs_batching_dimensions; + odsState.getOrAddProperties().rhs_batching_dimensions = rhs_batching_dimensions; + odsState.getOrAddProperties().lhs_contracting_dimensions = lhs_contracting_dimensions; + odsState.getOrAddProperties().rhs_contracting_dimensions = rhs_contracting_dimensions; + odsState.getOrAddProperties().precision_config = precision_config; + odsState.getOrAddProperties().lhs_precision_type = lhs_precision_type; + odsState.getOrAddProperties().rhs_precision_type = rhs_precision_type; + odsState.getOrAddProperties().accumulation_type = accumulation_type; + odsState.getOrAddProperties().lhs_component_count = lhs_component_count; + odsState.getOrAddProperties().rhs_component_count = rhs_component_count; + odsState.getOrAddProperties().num_primitive_operations = num_primitive_operations; + odsState.getOrAddProperties().allow_imprecise_accumulation = allow_imprecise_accumulation; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DotGeneralOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DotGeneralOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DotGeneralOpV2::verifyInvariantsImpl() { + auto tblgen_accumulation_type = getProperties().accumulation_type; (void)tblgen_accumulation_type; + if (!tblgen_accumulation_type) return emitOpError("requires attribute 'accumulation_type'"); + auto tblgen_allow_imprecise_accumulation = getProperties().allow_imprecise_accumulation; (void)tblgen_allow_imprecise_accumulation; + if (!tblgen_allow_imprecise_accumulation) return emitOpError("requires attribute 'allow_imprecise_accumulation'"); + auto tblgen_lhs_batching_dimensions = getProperties().lhs_batching_dimensions; (void)tblgen_lhs_batching_dimensions; + if (!tblgen_lhs_batching_dimensions) return emitOpError("requires attribute 'lhs_batching_dimensions'"); + auto tblgen_lhs_component_count = getProperties().lhs_component_count; (void)tblgen_lhs_component_count; + if (!tblgen_lhs_component_count) return emitOpError("requires attribute 'lhs_component_count'"); + auto tblgen_lhs_contracting_dimensions = getProperties().lhs_contracting_dimensions; (void)tblgen_lhs_contracting_dimensions; + if (!tblgen_lhs_contracting_dimensions) return emitOpError("requires attribute 'lhs_contracting_dimensions'"); + auto tblgen_lhs_precision_type = getProperties().lhs_precision_type; (void)tblgen_lhs_precision_type; + if (!tblgen_lhs_precision_type) return emitOpError("requires attribute 'lhs_precision_type'"); + auto tblgen_num_primitive_operations = getProperties().num_primitive_operations; (void)tblgen_num_primitive_operations; + if (!tblgen_num_primitive_operations) return emitOpError("requires attribute 'num_primitive_operations'"); + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + if (!tblgen_precision_config) return emitOpError("requires attribute 'precision_config'"); + auto tblgen_rhs_batching_dimensions = getProperties().rhs_batching_dimensions; (void)tblgen_rhs_batching_dimensions; + if (!tblgen_rhs_batching_dimensions) return emitOpError("requires attribute 'rhs_batching_dimensions'"); + auto tblgen_rhs_component_count = getProperties().rhs_component_count; (void)tblgen_rhs_component_count; + if (!tblgen_rhs_component_count) return emitOpError("requires attribute 'rhs_component_count'"); + auto tblgen_rhs_contracting_dimensions = getProperties().rhs_contracting_dimensions; (void)tblgen_rhs_contracting_dimensions; + if (!tblgen_rhs_contracting_dimensions) return emitOpError("requires attribute 'rhs_contracting_dimensions'"); + auto tblgen_rhs_precision_type = getProperties().rhs_precision_type; (void)tblgen_rhs_precision_type; + if (!tblgen_rhs_precision_type) return emitOpError("requires attribute 'rhs_precision_type'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_lhs_batching_dimensions, "lhs_batching_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_rhs_batching_dimensions, "rhs_batching_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_lhs_contracting_dimensions, "lhs_contracting_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_rhs_contracting_dimensions, "rhs_contracting_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_precision_config, "precision_config"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_lhs_precision_type, "lhs_precision_type"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_rhs_precision_type, "rhs_precision_type"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_accumulation_type, "accumulation_type"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_lhs_component_count, "lhs_component_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_rhs_component_count, "rhs_component_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_num_primitive_operations, "num_primitive_operations"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_allow_imprecise_accumulation, "allow_imprecise_accumulation"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DotGeneralOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DotGeneralOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 6, 0); +} +mlir::vhlo::Version DotGeneralOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DotGeneralOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DotOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DotOpV1GenericAdaptorBase::DotOpV1GenericAdaptorBase(DotOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute DotOpV1GenericAdaptorBase::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr; +} + +} // namespace detail +DotOpV1Adaptor::DotOpV1Adaptor(DotOpV1 op) : DotOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DotOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + if (!tblgen_precision_config) return emitError(loc, "'vhlo.dot_v1' op ""requires attribute 'precision_config'"); + + if (tblgen_precision_config && !((true))) + return emitError(loc, "'vhlo.dot_v1' op ""attribute 'precision_config' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult DotOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.precision_config; + auto attr = dict.get("precision_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `precision_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DotOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.precision_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("precision_config", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DotOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.precision_config.getAsOpaquePointer())); +} + +std::optional DotOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "precision_config") + return prop.precision_config; + return std::nullopt; +} + +void DotOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "precision_config") { + prop.precision_config = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DotOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.precision_config) attrs.append("precision_config", prop.precision_config); +} + +::llvm::LogicalResult DotOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getPrecisionConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "precision_config", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DotOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.precision_config))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DotOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.precision_config); +} + +::mlir::Attribute DotOpV1::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr; +} + +void DotOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().precision_config = precision_config; + odsState.addTypes(result); +} + +void DotOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().precision_config = precision_config; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DotOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DotOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DotOpV1::verifyInvariantsImpl() { + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + if (!tblgen_precision_config) return emitOpError("requires attribute 'precision_config'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_precision_config, "precision_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DotOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DotOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version DotOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DotOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicBroadcastInDimOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicBroadcastInDimOpV1GenericAdaptorBase::DynamicBroadcastInDimOpV1GenericAdaptorBase(DynamicBroadcastInDimOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute DynamicBroadcastInDimOpV1GenericAdaptorBase::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicBroadcastInDimOpV1GenericAdaptorBase::getKnownExpandingDimensions() { + auto attr = getKnownExpandingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicBroadcastInDimOpV1GenericAdaptorBase::getKnownNonexpandingDimensions() { + auto attr = getKnownNonexpandingDimensionsAttr(); + return attr; +} + +} // namespace detail +DynamicBroadcastInDimOpV1Adaptor::DynamicBroadcastInDimOpV1Adaptor(DynamicBroadcastInDimOpV1 op) : DynamicBroadcastInDimOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicBroadcastInDimOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + if (!tblgen_broadcast_dimensions) return emitError(loc, "'vhlo.dynamic_broadcast_in_dim_v1' op ""requires attribute 'broadcast_dimensions'"); + auto tblgen_known_expanding_dimensions = getProperties().known_expanding_dimensions; (void)tblgen_known_expanding_dimensions; + if (!tblgen_known_expanding_dimensions) return emitError(loc, "'vhlo.dynamic_broadcast_in_dim_v1' op ""requires attribute 'known_expanding_dimensions'"); + auto tblgen_known_nonexpanding_dimensions = getProperties().known_nonexpanding_dimensions; (void)tblgen_known_nonexpanding_dimensions; + if (!tblgen_known_nonexpanding_dimensions) return emitError(loc, "'vhlo.dynamic_broadcast_in_dim_v1' op ""requires attribute 'known_nonexpanding_dimensions'"); + + if (tblgen_broadcast_dimensions && !((true))) + return emitError(loc, "'vhlo.dynamic_broadcast_in_dim_v1' op ""attribute 'broadcast_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_known_expanding_dimensions && !((true))) + return emitError(loc, "'vhlo.dynamic_broadcast_in_dim_v1' op ""attribute 'known_expanding_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_known_nonexpanding_dimensions && !((true))) + return emitError(loc, "'vhlo.dynamic_broadcast_in_dim_v1' op ""attribute 'known_nonexpanding_dimensions' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicBroadcastInDimOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.broadcast_dimensions; + auto attr = dict.get("broadcast_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `broadcast_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.known_expanding_dimensions; + auto attr = dict.get("known_expanding_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `known_expanding_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.known_nonexpanding_dimensions; + auto attr = dict.get("known_nonexpanding_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `known_nonexpanding_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicBroadcastInDimOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.broadcast_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("broadcast_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.known_expanding_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("known_expanding_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.known_nonexpanding_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("known_nonexpanding_dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicBroadcastInDimOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.broadcast_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.known_expanding_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.known_nonexpanding_dimensions.getAsOpaquePointer())); +} + +std::optional DynamicBroadcastInDimOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "broadcast_dimensions") + return prop.broadcast_dimensions; + + if (name == "known_expanding_dimensions") + return prop.known_expanding_dimensions; + + if (name == "known_nonexpanding_dimensions") + return prop.known_nonexpanding_dimensions; + return std::nullopt; +} + +void DynamicBroadcastInDimOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "broadcast_dimensions") { + prop.broadcast_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "known_expanding_dimensions") { + prop.known_expanding_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "known_nonexpanding_dimensions") { + prop.known_nonexpanding_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DynamicBroadcastInDimOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.broadcast_dimensions) attrs.append("broadcast_dimensions", prop.broadcast_dimensions); + + if (prop.known_expanding_dimensions) attrs.append("known_expanding_dimensions", prop.known_expanding_dimensions); + + if (prop.known_nonexpanding_dimensions) attrs.append("known_nonexpanding_dimensions", prop.known_nonexpanding_dimensions); +} + +::llvm::LogicalResult DynamicBroadcastInDimOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBroadcastDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "broadcast_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKnownExpandingDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "known_expanding_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKnownNonexpandingDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "known_nonexpanding_dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicBroadcastInDimOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.broadcast_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.known_expanding_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.known_nonexpanding_dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicBroadcastInDimOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.broadcast_dimensions); + writer.writeAttribute(prop.known_expanding_dimensions); + writer.writeAttribute(prop.known_nonexpanding_dimensions); +} + +::mlir::Attribute DynamicBroadcastInDimOpV1::getBroadcastDimensions() { + auto attr = getBroadcastDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicBroadcastInDimOpV1::getKnownExpandingDimensions() { + auto attr = getKnownExpandingDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicBroadcastInDimOpV1::getKnownNonexpandingDimensions() { + auto attr = getKnownNonexpandingDimensionsAttr(); + return attr; +} + +void DynamicBroadcastInDimOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value output_dimensions, ::mlir::Attribute broadcast_dimensions, ::mlir::Attribute known_expanding_dimensions, ::mlir::Attribute known_nonexpanding_dimensions) { + odsState.addOperands(operand); + odsState.addOperands(output_dimensions); + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + odsState.getOrAddProperties().known_expanding_dimensions = known_expanding_dimensions; + odsState.getOrAddProperties().known_nonexpanding_dimensions = known_nonexpanding_dimensions; + odsState.addTypes(result); +} + +void DynamicBroadcastInDimOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value output_dimensions, ::mlir::Attribute broadcast_dimensions, ::mlir::Attribute known_expanding_dimensions, ::mlir::Attribute known_nonexpanding_dimensions) { + odsState.addOperands(operand); + odsState.addOperands(output_dimensions); + odsState.getOrAddProperties().broadcast_dimensions = broadcast_dimensions; + odsState.getOrAddProperties().known_expanding_dimensions = known_expanding_dimensions; + odsState.getOrAddProperties().known_nonexpanding_dimensions = known_nonexpanding_dimensions; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicBroadcastInDimOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DynamicBroadcastInDimOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicBroadcastInDimOpV1::verifyInvariantsImpl() { + auto tblgen_broadcast_dimensions = getProperties().broadcast_dimensions; (void)tblgen_broadcast_dimensions; + if (!tblgen_broadcast_dimensions) return emitOpError("requires attribute 'broadcast_dimensions'"); + auto tblgen_known_expanding_dimensions = getProperties().known_expanding_dimensions; (void)tblgen_known_expanding_dimensions; + if (!tblgen_known_expanding_dimensions) return emitOpError("requires attribute 'known_expanding_dimensions'"); + auto tblgen_known_nonexpanding_dimensions = getProperties().known_nonexpanding_dimensions; (void)tblgen_known_nonexpanding_dimensions; + if (!tblgen_known_nonexpanding_dimensions) return emitOpError("requires attribute 'known_nonexpanding_dimensions'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_broadcast_dimensions, "broadcast_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_known_expanding_dimensions, "known_expanding_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_known_nonexpanding_dimensions, "known_nonexpanding_dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicBroadcastInDimOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DynamicBroadcastInDimOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version DynamicBroadcastInDimOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicBroadcastInDimOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicConvOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicConvOpV1GenericAdaptorBase::DynamicConvOpV1GenericAdaptorBase(DynamicConvOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getPadding() { + auto attr = getPaddingAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getLhsDilation() { + auto attr = getLhsDilationAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getRhsDilation() { + auto attr = getRhsDilationAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getWindowReversal() { + auto attr = getWindowReversalAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getInputBatchDimension() { + auto attr = getInputBatchDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getInputFeatureDimension() { + auto attr = getInputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getInputSpatialDimensions() { + auto attr = getInputSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getKernelInputFeatureDimension() { + auto attr = getKernelInputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getKernelOutputFeatureDimension() { + auto attr = getKernelOutputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getKernelSpatialDimensions() { + auto attr = getKernelSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getOutputBatchDimension() { + auto attr = getOutputBatchDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getOutputFeatureDimension() { + auto attr = getOutputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getOutputSpatialDimensions() { + auto attr = getOutputSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getFeatureGroupCount() { + auto attr = getFeatureGroupCountAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getBatchGroupCount() { + auto attr = getBatchGroupCountAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1GenericAdaptorBase::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr; +} + +} // namespace detail +DynamicConvOpV1Adaptor::DynamicConvOpV1Adaptor(DynamicConvOpV1 op) : DynamicConvOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicConvOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_batch_group_count = getProperties().batch_group_count; (void)tblgen_batch_group_count; + if (!tblgen_batch_group_count) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'batch_group_count'"); + auto tblgen_feature_group_count = getProperties().feature_group_count; (void)tblgen_feature_group_count; + if (!tblgen_feature_group_count) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'feature_group_count'"); + auto tblgen_input_batch_dimension = getProperties().input_batch_dimension; (void)tblgen_input_batch_dimension; + if (!tblgen_input_batch_dimension) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'input_batch_dimension'"); + auto tblgen_input_feature_dimension = getProperties().input_feature_dimension; (void)tblgen_input_feature_dimension; + if (!tblgen_input_feature_dimension) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'input_feature_dimension'"); + auto tblgen_input_spatial_dimensions = getProperties().input_spatial_dimensions; (void)tblgen_input_spatial_dimensions; + if (!tblgen_input_spatial_dimensions) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'input_spatial_dimensions'"); + auto tblgen_kernel_input_feature_dimension = getProperties().kernel_input_feature_dimension; (void)tblgen_kernel_input_feature_dimension; + if (!tblgen_kernel_input_feature_dimension) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'kernel_input_feature_dimension'"); + auto tblgen_kernel_output_feature_dimension = getProperties().kernel_output_feature_dimension; (void)tblgen_kernel_output_feature_dimension; + if (!tblgen_kernel_output_feature_dimension) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'kernel_output_feature_dimension'"); + auto tblgen_kernel_spatial_dimensions = getProperties().kernel_spatial_dimensions; (void)tblgen_kernel_spatial_dimensions; + if (!tblgen_kernel_spatial_dimensions) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'kernel_spatial_dimensions'"); + auto tblgen_lhs_dilation = getProperties().lhs_dilation; (void)tblgen_lhs_dilation; + if (!tblgen_lhs_dilation) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'lhs_dilation'"); + auto tblgen_output_batch_dimension = getProperties().output_batch_dimension; (void)tblgen_output_batch_dimension; + if (!tblgen_output_batch_dimension) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'output_batch_dimension'"); + auto tblgen_output_feature_dimension = getProperties().output_feature_dimension; (void)tblgen_output_feature_dimension; + if (!tblgen_output_feature_dimension) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'output_feature_dimension'"); + auto tblgen_output_spatial_dimensions = getProperties().output_spatial_dimensions; (void)tblgen_output_spatial_dimensions; + if (!tblgen_output_spatial_dimensions) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'output_spatial_dimensions'"); + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + if (!tblgen_padding) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'padding'"); + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + if (!tblgen_precision_config) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'precision_config'"); + auto tblgen_rhs_dilation = getProperties().rhs_dilation; (void)tblgen_rhs_dilation; + if (!tblgen_rhs_dilation) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'rhs_dilation'"); + auto tblgen_window_reversal = getProperties().window_reversal; (void)tblgen_window_reversal; + if (!tblgen_window_reversal) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'window_reversal'"); + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + if (!tblgen_window_strides) return emitError(loc, "'vhlo.dynamic_conv_v1' op ""requires attribute 'window_strides'"); + + if (tblgen_window_strides && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'window_strides' failed to satisfy constraint: any attribute"); + + if (tblgen_padding && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'padding' failed to satisfy constraint: any attribute"); + + if (tblgen_lhs_dilation && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'lhs_dilation' failed to satisfy constraint: any attribute"); + + if (tblgen_rhs_dilation && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'rhs_dilation' failed to satisfy constraint: any attribute"); + + if (tblgen_window_reversal && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'window_reversal' failed to satisfy constraint: any attribute"); + + if (tblgen_input_batch_dimension && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'input_batch_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_input_feature_dimension && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'input_feature_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_input_spatial_dimensions && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'input_spatial_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_kernel_input_feature_dimension && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'kernel_input_feature_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_kernel_output_feature_dimension && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'kernel_output_feature_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_kernel_spatial_dimensions && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'kernel_spatial_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_output_batch_dimension && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'output_batch_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_output_feature_dimension && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'output_feature_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_output_spatial_dimensions && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'output_spatial_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_feature_group_count && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'feature_group_count' failed to satisfy constraint: any attribute"); + + if (tblgen_batch_group_count && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'batch_group_count' failed to satisfy constraint: any attribute"); + + if (tblgen_precision_config && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v1' op ""attribute 'precision_config' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicConvOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.batch_group_count; + auto attr = dict.get("batch_group_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `batch_group_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.feature_group_count; + auto attr = dict.get("feature_group_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `feature_group_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.input_batch_dimension; + auto attr = dict.get("input_batch_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `input_batch_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.input_feature_dimension; + auto attr = dict.get("input_feature_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `input_feature_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.input_spatial_dimensions; + auto attr = dict.get("input_spatial_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `input_spatial_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.kernel_input_feature_dimension; + auto attr = dict.get("kernel_input_feature_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kernel_input_feature_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.kernel_output_feature_dimension; + auto attr = dict.get("kernel_output_feature_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kernel_output_feature_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.kernel_spatial_dimensions; + auto attr = dict.get("kernel_spatial_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kernel_spatial_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.lhs_dilation; + auto attr = dict.get("lhs_dilation"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lhs_dilation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.output_batch_dimension; + auto attr = dict.get("output_batch_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `output_batch_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.output_feature_dimension; + auto attr = dict.get("output_feature_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `output_feature_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.output_spatial_dimensions; + auto attr = dict.get("output_spatial_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `output_spatial_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.padding; + auto attr = dict.get("padding"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `padding` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.precision_config; + auto attr = dict.get("precision_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `precision_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.rhs_dilation; + auto attr = dict.get("rhs_dilation"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rhs_dilation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_reversal; + auto attr = dict.get("window_reversal"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_reversal` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_strides; + auto attr = dict.get("window_strides"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicConvOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.batch_group_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("batch_group_count", + propStorage)); + } + + { + const auto &propStorage = prop.feature_group_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("feature_group_count", + propStorage)); + } + + { + const auto &propStorage = prop.input_batch_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("input_batch_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.input_feature_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("input_feature_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.input_spatial_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("input_spatial_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.kernel_input_feature_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kernel_input_feature_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.kernel_output_feature_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kernel_output_feature_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.kernel_spatial_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kernel_spatial_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.lhs_dilation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lhs_dilation", + propStorage)); + } + + { + const auto &propStorage = prop.output_batch_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("output_batch_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.output_feature_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("output_feature_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.output_spatial_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("output_spatial_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.padding; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("padding", + propStorage)); + } + + { + const auto &propStorage = prop.precision_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("precision_config", + propStorage)); + } + + { + const auto &propStorage = prop.rhs_dilation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rhs_dilation", + propStorage)); + } + + { + const auto &propStorage = prop.window_reversal; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_reversal", + propStorage)); + } + + { + const auto &propStorage = prop.window_strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_strides", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicConvOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.batch_group_count.getAsOpaquePointer()), + llvm::hash_value(prop.feature_group_count.getAsOpaquePointer()), + llvm::hash_value(prop.input_batch_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.input_feature_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.input_spatial_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.kernel_input_feature_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.kernel_output_feature_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.kernel_spatial_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.lhs_dilation.getAsOpaquePointer()), + llvm::hash_value(prop.output_batch_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.output_feature_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.output_spatial_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.padding.getAsOpaquePointer()), + llvm::hash_value(prop.precision_config.getAsOpaquePointer()), + llvm::hash_value(prop.rhs_dilation.getAsOpaquePointer()), + llvm::hash_value(prop.window_reversal.getAsOpaquePointer()), + llvm::hash_value(prop.window_strides.getAsOpaquePointer())); +} + +std::optional DynamicConvOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "batch_group_count") + return prop.batch_group_count; + + if (name == "feature_group_count") + return prop.feature_group_count; + + if (name == "input_batch_dimension") + return prop.input_batch_dimension; + + if (name == "input_feature_dimension") + return prop.input_feature_dimension; + + if (name == "input_spatial_dimensions") + return prop.input_spatial_dimensions; + + if (name == "kernel_input_feature_dimension") + return prop.kernel_input_feature_dimension; + + if (name == "kernel_output_feature_dimension") + return prop.kernel_output_feature_dimension; + + if (name == "kernel_spatial_dimensions") + return prop.kernel_spatial_dimensions; + + if (name == "lhs_dilation") + return prop.lhs_dilation; + + if (name == "output_batch_dimension") + return prop.output_batch_dimension; + + if (name == "output_feature_dimension") + return prop.output_feature_dimension; + + if (name == "output_spatial_dimensions") + return prop.output_spatial_dimensions; + + if (name == "padding") + return prop.padding; + + if (name == "precision_config") + return prop.precision_config; + + if (name == "rhs_dilation") + return prop.rhs_dilation; + + if (name == "window_reversal") + return prop.window_reversal; + + if (name == "window_strides") + return prop.window_strides; + return std::nullopt; +} + +void DynamicConvOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "batch_group_count") { + prop.batch_group_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "feature_group_count") { + prop.feature_group_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "input_batch_dimension") { + prop.input_batch_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "input_feature_dimension") { + prop.input_feature_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "input_spatial_dimensions") { + prop.input_spatial_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "kernel_input_feature_dimension") { + prop.kernel_input_feature_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "kernel_output_feature_dimension") { + prop.kernel_output_feature_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "kernel_spatial_dimensions") { + prop.kernel_spatial_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "lhs_dilation") { + prop.lhs_dilation = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "output_batch_dimension") { + prop.output_batch_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "output_feature_dimension") { + prop.output_feature_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "output_spatial_dimensions") { + prop.output_spatial_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "padding") { + prop.padding = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "precision_config") { + prop.precision_config = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "rhs_dilation") { + prop.rhs_dilation = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_reversal") { + prop.window_reversal = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_strides") { + prop.window_strides = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DynamicConvOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.batch_group_count) attrs.append("batch_group_count", prop.batch_group_count); + + if (prop.feature_group_count) attrs.append("feature_group_count", prop.feature_group_count); + + if (prop.input_batch_dimension) attrs.append("input_batch_dimension", prop.input_batch_dimension); + + if (prop.input_feature_dimension) attrs.append("input_feature_dimension", prop.input_feature_dimension); + + if (prop.input_spatial_dimensions) attrs.append("input_spatial_dimensions", prop.input_spatial_dimensions); + + if (prop.kernel_input_feature_dimension) attrs.append("kernel_input_feature_dimension", prop.kernel_input_feature_dimension); + + if (prop.kernel_output_feature_dimension) attrs.append("kernel_output_feature_dimension", prop.kernel_output_feature_dimension); + + if (prop.kernel_spatial_dimensions) attrs.append("kernel_spatial_dimensions", prop.kernel_spatial_dimensions); + + if (prop.lhs_dilation) attrs.append("lhs_dilation", prop.lhs_dilation); + + if (prop.output_batch_dimension) attrs.append("output_batch_dimension", prop.output_batch_dimension); + + if (prop.output_feature_dimension) attrs.append("output_feature_dimension", prop.output_feature_dimension); + + if (prop.output_spatial_dimensions) attrs.append("output_spatial_dimensions", prop.output_spatial_dimensions); + + if (prop.padding) attrs.append("padding", prop.padding); + + if (prop.precision_config) attrs.append("precision_config", prop.precision_config); + + if (prop.rhs_dilation) attrs.append("rhs_dilation", prop.rhs_dilation); + + if (prop.window_reversal) attrs.append("window_reversal", prop.window_reversal); + + if (prop.window_strides) attrs.append("window_strides", prop.window_strides); +} + +::llvm::LogicalResult DynamicConvOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBatchGroupCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "batch_group_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFeatureGroupCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "feature_group_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInputBatchDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "input_batch_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInputFeatureDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "input_feature_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInputSpatialDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "input_spatial_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKernelInputFeatureDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "kernel_input_feature_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKernelOutputFeatureDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "kernel_output_feature_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKernelSpatialDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "kernel_spatial_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLhsDilationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "lhs_dilation", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOutputBatchDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "output_batch_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOutputFeatureDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "output_feature_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOutputSpatialDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "output_spatial_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPaddingAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "padding", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPrecisionConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "precision_config", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRhsDilationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "rhs_dilation", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowReversalAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "window_reversal", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "window_strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicConvOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.batch_group_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.feature_group_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.input_batch_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.input_feature_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.input_spatial_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.kernel_input_feature_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.kernel_output_feature_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.kernel_spatial_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.lhs_dilation))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.output_batch_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.output_feature_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.output_spatial_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.padding))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.precision_config))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.rhs_dilation))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.window_reversal))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.window_strides))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicConvOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.batch_group_count); + writer.writeAttribute(prop.feature_group_count); + writer.writeAttribute(prop.input_batch_dimension); + writer.writeAttribute(prop.input_feature_dimension); + writer.writeAttribute(prop.input_spatial_dimensions); + writer.writeAttribute(prop.kernel_input_feature_dimension); + writer.writeAttribute(prop.kernel_output_feature_dimension); + writer.writeAttribute(prop.kernel_spatial_dimensions); + writer.writeAttribute(prop.lhs_dilation); + writer.writeAttribute(prop.output_batch_dimension); + writer.writeAttribute(prop.output_feature_dimension); + writer.writeAttribute(prop.output_spatial_dimensions); + writer.writeAttribute(prop.padding); + writer.writeAttribute(prop.precision_config); + writer.writeAttribute(prop.rhs_dilation); + writer.writeAttribute(prop.window_reversal); + writer.writeAttribute(prop.window_strides); +} + +::mlir::Attribute DynamicConvOpV1::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getPadding() { + auto attr = getPaddingAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getLhsDilation() { + auto attr = getLhsDilationAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getRhsDilation() { + auto attr = getRhsDilationAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getWindowReversal() { + auto attr = getWindowReversalAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getInputBatchDimension() { + auto attr = getInputBatchDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getInputFeatureDimension() { + auto attr = getInputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getInputSpatialDimensions() { + auto attr = getInputSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getKernelInputFeatureDimension() { + auto attr = getKernelInputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getKernelOutputFeatureDimension() { + auto attr = getKernelOutputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getKernelSpatialDimensions() { + auto attr = getKernelSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getOutputBatchDimension() { + auto attr = getOutputBatchDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getOutputFeatureDimension() { + auto attr = getOutputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getOutputSpatialDimensions() { + auto attr = getOutputSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getFeatureGroupCount() { + auto attr = getFeatureGroupCountAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getBatchGroupCount() { + auto attr = getBatchGroupCountAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV1::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr; +} + +void DynamicConvOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value d_padding, ::mlir::Attribute window_strides, ::mlir::Attribute padding, ::mlir::Attribute lhs_dilation, ::mlir::Attribute rhs_dilation, ::mlir::Attribute window_reversal, ::mlir::Attribute input_batch_dimension, ::mlir::Attribute input_feature_dimension, ::mlir::Attribute input_spatial_dimensions, ::mlir::Attribute kernel_input_feature_dimension, ::mlir::Attribute kernel_output_feature_dimension, ::mlir::Attribute kernel_spatial_dimensions, ::mlir::Attribute output_batch_dimension, ::mlir::Attribute output_feature_dimension, ::mlir::Attribute output_spatial_dimensions, ::mlir::Attribute feature_group_count, ::mlir::Attribute batch_group_count, ::mlir::Attribute precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(d_padding); + odsState.getOrAddProperties().window_strides = window_strides; + odsState.getOrAddProperties().padding = padding; + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + odsState.getOrAddProperties().window_reversal = window_reversal; + odsState.getOrAddProperties().input_batch_dimension = input_batch_dimension; + odsState.getOrAddProperties().input_feature_dimension = input_feature_dimension; + odsState.getOrAddProperties().input_spatial_dimensions = input_spatial_dimensions; + odsState.getOrAddProperties().kernel_input_feature_dimension = kernel_input_feature_dimension; + odsState.getOrAddProperties().kernel_output_feature_dimension = kernel_output_feature_dimension; + odsState.getOrAddProperties().kernel_spatial_dimensions = kernel_spatial_dimensions; + odsState.getOrAddProperties().output_batch_dimension = output_batch_dimension; + odsState.getOrAddProperties().output_feature_dimension = output_feature_dimension; + odsState.getOrAddProperties().output_spatial_dimensions = output_spatial_dimensions; + odsState.getOrAddProperties().feature_group_count = feature_group_count; + odsState.getOrAddProperties().batch_group_count = batch_group_count; + odsState.getOrAddProperties().precision_config = precision_config; + odsState.addTypes(result); +} + +void DynamicConvOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value d_padding, ::mlir::Attribute window_strides, ::mlir::Attribute padding, ::mlir::Attribute lhs_dilation, ::mlir::Attribute rhs_dilation, ::mlir::Attribute window_reversal, ::mlir::Attribute input_batch_dimension, ::mlir::Attribute input_feature_dimension, ::mlir::Attribute input_spatial_dimensions, ::mlir::Attribute kernel_input_feature_dimension, ::mlir::Attribute kernel_output_feature_dimension, ::mlir::Attribute kernel_spatial_dimensions, ::mlir::Attribute output_batch_dimension, ::mlir::Attribute output_feature_dimension, ::mlir::Attribute output_spatial_dimensions, ::mlir::Attribute feature_group_count, ::mlir::Attribute batch_group_count, ::mlir::Attribute precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(d_padding); + odsState.getOrAddProperties().window_strides = window_strides; + odsState.getOrAddProperties().padding = padding; + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + odsState.getOrAddProperties().window_reversal = window_reversal; + odsState.getOrAddProperties().input_batch_dimension = input_batch_dimension; + odsState.getOrAddProperties().input_feature_dimension = input_feature_dimension; + odsState.getOrAddProperties().input_spatial_dimensions = input_spatial_dimensions; + odsState.getOrAddProperties().kernel_input_feature_dimension = kernel_input_feature_dimension; + odsState.getOrAddProperties().kernel_output_feature_dimension = kernel_output_feature_dimension; + odsState.getOrAddProperties().kernel_spatial_dimensions = kernel_spatial_dimensions; + odsState.getOrAddProperties().output_batch_dimension = output_batch_dimension; + odsState.getOrAddProperties().output_feature_dimension = output_feature_dimension; + odsState.getOrAddProperties().output_spatial_dimensions = output_spatial_dimensions; + odsState.getOrAddProperties().feature_group_count = feature_group_count; + odsState.getOrAddProperties().batch_group_count = batch_group_count; + odsState.getOrAddProperties().precision_config = precision_config; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicConvOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DynamicConvOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicConvOpV1::verifyInvariantsImpl() { + auto tblgen_batch_group_count = getProperties().batch_group_count; (void)tblgen_batch_group_count; + if (!tblgen_batch_group_count) return emitOpError("requires attribute 'batch_group_count'"); + auto tblgen_feature_group_count = getProperties().feature_group_count; (void)tblgen_feature_group_count; + if (!tblgen_feature_group_count) return emitOpError("requires attribute 'feature_group_count'"); + auto tblgen_input_batch_dimension = getProperties().input_batch_dimension; (void)tblgen_input_batch_dimension; + if (!tblgen_input_batch_dimension) return emitOpError("requires attribute 'input_batch_dimension'"); + auto tblgen_input_feature_dimension = getProperties().input_feature_dimension; (void)tblgen_input_feature_dimension; + if (!tblgen_input_feature_dimension) return emitOpError("requires attribute 'input_feature_dimension'"); + auto tblgen_input_spatial_dimensions = getProperties().input_spatial_dimensions; (void)tblgen_input_spatial_dimensions; + if (!tblgen_input_spatial_dimensions) return emitOpError("requires attribute 'input_spatial_dimensions'"); + auto tblgen_kernel_input_feature_dimension = getProperties().kernel_input_feature_dimension; (void)tblgen_kernel_input_feature_dimension; + if (!tblgen_kernel_input_feature_dimension) return emitOpError("requires attribute 'kernel_input_feature_dimension'"); + auto tblgen_kernel_output_feature_dimension = getProperties().kernel_output_feature_dimension; (void)tblgen_kernel_output_feature_dimension; + if (!tblgen_kernel_output_feature_dimension) return emitOpError("requires attribute 'kernel_output_feature_dimension'"); + auto tblgen_kernel_spatial_dimensions = getProperties().kernel_spatial_dimensions; (void)tblgen_kernel_spatial_dimensions; + if (!tblgen_kernel_spatial_dimensions) return emitOpError("requires attribute 'kernel_spatial_dimensions'"); + auto tblgen_lhs_dilation = getProperties().lhs_dilation; (void)tblgen_lhs_dilation; + if (!tblgen_lhs_dilation) return emitOpError("requires attribute 'lhs_dilation'"); + auto tblgen_output_batch_dimension = getProperties().output_batch_dimension; (void)tblgen_output_batch_dimension; + if (!tblgen_output_batch_dimension) return emitOpError("requires attribute 'output_batch_dimension'"); + auto tblgen_output_feature_dimension = getProperties().output_feature_dimension; (void)tblgen_output_feature_dimension; + if (!tblgen_output_feature_dimension) return emitOpError("requires attribute 'output_feature_dimension'"); + auto tblgen_output_spatial_dimensions = getProperties().output_spatial_dimensions; (void)tblgen_output_spatial_dimensions; + if (!tblgen_output_spatial_dimensions) return emitOpError("requires attribute 'output_spatial_dimensions'"); + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + if (!tblgen_padding) return emitOpError("requires attribute 'padding'"); + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + if (!tblgen_precision_config) return emitOpError("requires attribute 'precision_config'"); + auto tblgen_rhs_dilation = getProperties().rhs_dilation; (void)tblgen_rhs_dilation; + if (!tblgen_rhs_dilation) return emitOpError("requires attribute 'rhs_dilation'"); + auto tblgen_window_reversal = getProperties().window_reversal; (void)tblgen_window_reversal; + if (!tblgen_window_reversal) return emitOpError("requires attribute 'window_reversal'"); + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + if (!tblgen_window_strides) return emitOpError("requires attribute 'window_strides'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_window_strides, "window_strides"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_padding, "padding"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_lhs_dilation, "lhs_dilation"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_rhs_dilation, "rhs_dilation"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_window_reversal, "window_reversal"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_input_batch_dimension, "input_batch_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_input_feature_dimension, "input_feature_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_input_spatial_dimensions, "input_spatial_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_kernel_input_feature_dimension, "kernel_input_feature_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_kernel_output_feature_dimension, "kernel_output_feature_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_kernel_spatial_dimensions, "kernel_spatial_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_output_batch_dimension, "output_batch_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_output_feature_dimension, "output_feature_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_output_spatial_dimensions, "output_spatial_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_feature_group_count, "feature_group_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_batch_group_count, "batch_group_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_precision_config, "precision_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicConvOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DynamicConvOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version DynamicConvOpV1::getMaxVersion() { + return mlir::vhlo::Version(0, 19, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicConvOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicConvOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicConvOpV2GenericAdaptorBase::DynamicConvOpV2GenericAdaptorBase(DynamicConvOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getLhsDilation() { + auto attr = getLhsDilationAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getRhsDilation() { + auto attr = getRhsDilationAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getWindowReversal() { + auto attr = getWindowReversalAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getInputBatchDimension() { + auto attr = getInputBatchDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getInputFeatureDimension() { + auto attr = getInputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getInputSpatialDimensions() { + auto attr = getInputSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getKernelInputFeatureDimension() { + auto attr = getKernelInputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getKernelOutputFeatureDimension() { + auto attr = getKernelOutputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getKernelSpatialDimensions() { + auto attr = getKernelSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getOutputBatchDimension() { + auto attr = getOutputBatchDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getOutputFeatureDimension() { + auto attr = getOutputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getOutputSpatialDimensions() { + auto attr = getOutputSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getFeatureGroupCount() { + auto attr = getFeatureGroupCountAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getBatchGroupCount() { + auto attr = getBatchGroupCountAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2GenericAdaptorBase::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr; +} + +} // namespace detail +DynamicConvOpV2Adaptor::DynamicConvOpV2Adaptor(DynamicConvOpV2 op) : DynamicConvOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicConvOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_batch_group_count = getProperties().batch_group_count; (void)tblgen_batch_group_count; + if (!tblgen_batch_group_count) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'batch_group_count'"); + auto tblgen_feature_group_count = getProperties().feature_group_count; (void)tblgen_feature_group_count; + if (!tblgen_feature_group_count) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'feature_group_count'"); + auto tblgen_input_batch_dimension = getProperties().input_batch_dimension; (void)tblgen_input_batch_dimension; + if (!tblgen_input_batch_dimension) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'input_batch_dimension'"); + auto tblgen_input_feature_dimension = getProperties().input_feature_dimension; (void)tblgen_input_feature_dimension; + if (!tblgen_input_feature_dimension) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'input_feature_dimension'"); + auto tblgen_input_spatial_dimensions = getProperties().input_spatial_dimensions; (void)tblgen_input_spatial_dimensions; + if (!tblgen_input_spatial_dimensions) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'input_spatial_dimensions'"); + auto tblgen_kernel_input_feature_dimension = getProperties().kernel_input_feature_dimension; (void)tblgen_kernel_input_feature_dimension; + if (!tblgen_kernel_input_feature_dimension) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'kernel_input_feature_dimension'"); + auto tblgen_kernel_output_feature_dimension = getProperties().kernel_output_feature_dimension; (void)tblgen_kernel_output_feature_dimension; + if (!tblgen_kernel_output_feature_dimension) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'kernel_output_feature_dimension'"); + auto tblgen_kernel_spatial_dimensions = getProperties().kernel_spatial_dimensions; (void)tblgen_kernel_spatial_dimensions; + if (!tblgen_kernel_spatial_dimensions) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'kernel_spatial_dimensions'"); + auto tblgen_lhs_dilation = getProperties().lhs_dilation; (void)tblgen_lhs_dilation; + if (!tblgen_lhs_dilation) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'lhs_dilation'"); + auto tblgen_output_batch_dimension = getProperties().output_batch_dimension; (void)tblgen_output_batch_dimension; + if (!tblgen_output_batch_dimension) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'output_batch_dimension'"); + auto tblgen_output_feature_dimension = getProperties().output_feature_dimension; (void)tblgen_output_feature_dimension; + if (!tblgen_output_feature_dimension) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'output_feature_dimension'"); + auto tblgen_output_spatial_dimensions = getProperties().output_spatial_dimensions; (void)tblgen_output_spatial_dimensions; + if (!tblgen_output_spatial_dimensions) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'output_spatial_dimensions'"); + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + if (!tblgen_precision_config) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'precision_config'"); + auto tblgen_rhs_dilation = getProperties().rhs_dilation; (void)tblgen_rhs_dilation; + if (!tblgen_rhs_dilation) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'rhs_dilation'"); + auto tblgen_window_reversal = getProperties().window_reversal; (void)tblgen_window_reversal; + if (!tblgen_window_reversal) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'window_reversal'"); + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + if (!tblgen_window_strides) return emitError(loc, "'vhlo.dynamic_conv_v2' op ""requires attribute 'window_strides'"); + + if (tblgen_window_strides && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'window_strides' failed to satisfy constraint: any attribute"); + + if (tblgen_lhs_dilation && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'lhs_dilation' failed to satisfy constraint: any attribute"); + + if (tblgen_rhs_dilation && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'rhs_dilation' failed to satisfy constraint: any attribute"); + + if (tblgen_window_reversal && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'window_reversal' failed to satisfy constraint: any attribute"); + + if (tblgen_input_batch_dimension && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'input_batch_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_input_feature_dimension && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'input_feature_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_input_spatial_dimensions && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'input_spatial_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_kernel_input_feature_dimension && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'kernel_input_feature_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_kernel_output_feature_dimension && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'kernel_output_feature_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_kernel_spatial_dimensions && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'kernel_spatial_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_output_batch_dimension && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'output_batch_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_output_feature_dimension && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'output_feature_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_output_spatial_dimensions && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'output_spatial_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_feature_group_count && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'feature_group_count' failed to satisfy constraint: any attribute"); + + if (tblgen_batch_group_count && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'batch_group_count' failed to satisfy constraint: any attribute"); + + if (tblgen_precision_config && !((true))) + return emitError(loc, "'vhlo.dynamic_conv_v2' op ""attribute 'precision_config' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicConvOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.batch_group_count; + auto attr = dict.get("batch_group_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `batch_group_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.feature_group_count; + auto attr = dict.get("feature_group_count"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `feature_group_count` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.input_batch_dimension; + auto attr = dict.get("input_batch_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `input_batch_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.input_feature_dimension; + auto attr = dict.get("input_feature_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `input_feature_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.input_spatial_dimensions; + auto attr = dict.get("input_spatial_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `input_spatial_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.kernel_input_feature_dimension; + auto attr = dict.get("kernel_input_feature_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kernel_input_feature_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.kernel_output_feature_dimension; + auto attr = dict.get("kernel_output_feature_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kernel_output_feature_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.kernel_spatial_dimensions; + auto attr = dict.get("kernel_spatial_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kernel_spatial_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.lhs_dilation; + auto attr = dict.get("lhs_dilation"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lhs_dilation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.output_batch_dimension; + auto attr = dict.get("output_batch_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `output_batch_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.output_feature_dimension; + auto attr = dict.get("output_feature_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `output_feature_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.output_spatial_dimensions; + auto attr = dict.get("output_spatial_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `output_spatial_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.precision_config; + auto attr = dict.get("precision_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `precision_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.rhs_dilation; + auto attr = dict.get("rhs_dilation"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rhs_dilation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_reversal; + auto attr = dict.get("window_reversal"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_reversal` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_strides; + auto attr = dict.get("window_strides"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicConvOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.batch_group_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("batch_group_count", + propStorage)); + } + + { + const auto &propStorage = prop.feature_group_count; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("feature_group_count", + propStorage)); + } + + { + const auto &propStorage = prop.input_batch_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("input_batch_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.input_feature_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("input_feature_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.input_spatial_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("input_spatial_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.kernel_input_feature_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kernel_input_feature_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.kernel_output_feature_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kernel_output_feature_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.kernel_spatial_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kernel_spatial_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.lhs_dilation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lhs_dilation", + propStorage)); + } + + { + const auto &propStorage = prop.output_batch_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("output_batch_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.output_feature_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("output_feature_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.output_spatial_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("output_spatial_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.precision_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("precision_config", + propStorage)); + } + + { + const auto &propStorage = prop.rhs_dilation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rhs_dilation", + propStorage)); + } + + { + const auto &propStorage = prop.window_reversal; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_reversal", + propStorage)); + } + + { + const auto &propStorage = prop.window_strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_strides", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicConvOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.batch_group_count.getAsOpaquePointer()), + llvm::hash_value(prop.feature_group_count.getAsOpaquePointer()), + llvm::hash_value(prop.input_batch_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.input_feature_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.input_spatial_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.kernel_input_feature_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.kernel_output_feature_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.kernel_spatial_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.lhs_dilation.getAsOpaquePointer()), + llvm::hash_value(prop.output_batch_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.output_feature_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.output_spatial_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.precision_config.getAsOpaquePointer()), + llvm::hash_value(prop.rhs_dilation.getAsOpaquePointer()), + llvm::hash_value(prop.window_reversal.getAsOpaquePointer()), + llvm::hash_value(prop.window_strides.getAsOpaquePointer())); +} + +std::optional DynamicConvOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "batch_group_count") + return prop.batch_group_count; + + if (name == "feature_group_count") + return prop.feature_group_count; + + if (name == "input_batch_dimension") + return prop.input_batch_dimension; + + if (name == "input_feature_dimension") + return prop.input_feature_dimension; + + if (name == "input_spatial_dimensions") + return prop.input_spatial_dimensions; + + if (name == "kernel_input_feature_dimension") + return prop.kernel_input_feature_dimension; + + if (name == "kernel_output_feature_dimension") + return prop.kernel_output_feature_dimension; + + if (name == "kernel_spatial_dimensions") + return prop.kernel_spatial_dimensions; + + if (name == "lhs_dilation") + return prop.lhs_dilation; + + if (name == "output_batch_dimension") + return prop.output_batch_dimension; + + if (name == "output_feature_dimension") + return prop.output_feature_dimension; + + if (name == "output_spatial_dimensions") + return prop.output_spatial_dimensions; + + if (name == "precision_config") + return prop.precision_config; + + if (name == "rhs_dilation") + return prop.rhs_dilation; + + if (name == "window_reversal") + return prop.window_reversal; + + if (name == "window_strides") + return prop.window_strides; + return std::nullopt; +} + +void DynamicConvOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "batch_group_count") { + prop.batch_group_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "feature_group_count") { + prop.feature_group_count = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "input_batch_dimension") { + prop.input_batch_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "input_feature_dimension") { + prop.input_feature_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "input_spatial_dimensions") { + prop.input_spatial_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "kernel_input_feature_dimension") { + prop.kernel_input_feature_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "kernel_output_feature_dimension") { + prop.kernel_output_feature_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "kernel_spatial_dimensions") { + prop.kernel_spatial_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "lhs_dilation") { + prop.lhs_dilation = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "output_batch_dimension") { + prop.output_batch_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "output_feature_dimension") { + prop.output_feature_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "output_spatial_dimensions") { + prop.output_spatial_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "precision_config") { + prop.precision_config = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "rhs_dilation") { + prop.rhs_dilation = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_reversal") { + prop.window_reversal = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_strides") { + prop.window_strides = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DynamicConvOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.batch_group_count) attrs.append("batch_group_count", prop.batch_group_count); + + if (prop.feature_group_count) attrs.append("feature_group_count", prop.feature_group_count); + + if (prop.input_batch_dimension) attrs.append("input_batch_dimension", prop.input_batch_dimension); + + if (prop.input_feature_dimension) attrs.append("input_feature_dimension", prop.input_feature_dimension); + + if (prop.input_spatial_dimensions) attrs.append("input_spatial_dimensions", prop.input_spatial_dimensions); + + if (prop.kernel_input_feature_dimension) attrs.append("kernel_input_feature_dimension", prop.kernel_input_feature_dimension); + + if (prop.kernel_output_feature_dimension) attrs.append("kernel_output_feature_dimension", prop.kernel_output_feature_dimension); + + if (prop.kernel_spatial_dimensions) attrs.append("kernel_spatial_dimensions", prop.kernel_spatial_dimensions); + + if (prop.lhs_dilation) attrs.append("lhs_dilation", prop.lhs_dilation); + + if (prop.output_batch_dimension) attrs.append("output_batch_dimension", prop.output_batch_dimension); + + if (prop.output_feature_dimension) attrs.append("output_feature_dimension", prop.output_feature_dimension); + + if (prop.output_spatial_dimensions) attrs.append("output_spatial_dimensions", prop.output_spatial_dimensions); + + if (prop.precision_config) attrs.append("precision_config", prop.precision_config); + + if (prop.rhs_dilation) attrs.append("rhs_dilation", prop.rhs_dilation); + + if (prop.window_reversal) attrs.append("window_reversal", prop.window_reversal); + + if (prop.window_strides) attrs.append("window_strides", prop.window_strides); +} + +::llvm::LogicalResult DynamicConvOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBatchGroupCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "batch_group_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFeatureGroupCountAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "feature_group_count", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInputBatchDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "input_batch_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInputFeatureDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "input_feature_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInputSpatialDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "input_spatial_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKernelInputFeatureDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "kernel_input_feature_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKernelOutputFeatureDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "kernel_output_feature_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKernelSpatialDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "kernel_spatial_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLhsDilationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "lhs_dilation", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOutputBatchDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "output_batch_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOutputFeatureDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "output_feature_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOutputSpatialDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "output_spatial_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPrecisionConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "precision_config", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRhsDilationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "rhs_dilation", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowReversalAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "window_reversal", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "window_strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicConvOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.batch_group_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.feature_group_count))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.input_batch_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.input_feature_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.input_spatial_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.kernel_input_feature_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.kernel_output_feature_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.kernel_spatial_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.lhs_dilation))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.output_batch_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.output_feature_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.output_spatial_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.precision_config))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.rhs_dilation))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.window_reversal))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.window_strides))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicConvOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.batch_group_count); + writer.writeAttribute(prop.feature_group_count); + writer.writeAttribute(prop.input_batch_dimension); + writer.writeAttribute(prop.input_feature_dimension); + writer.writeAttribute(prop.input_spatial_dimensions); + writer.writeAttribute(prop.kernel_input_feature_dimension); + writer.writeAttribute(prop.kernel_output_feature_dimension); + writer.writeAttribute(prop.kernel_spatial_dimensions); + writer.writeAttribute(prop.lhs_dilation); + writer.writeAttribute(prop.output_batch_dimension); + writer.writeAttribute(prop.output_feature_dimension); + writer.writeAttribute(prop.output_spatial_dimensions); + writer.writeAttribute(prop.precision_config); + writer.writeAttribute(prop.rhs_dilation); + writer.writeAttribute(prop.window_reversal); + writer.writeAttribute(prop.window_strides); +} + +::mlir::Attribute DynamicConvOpV2::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getLhsDilation() { + auto attr = getLhsDilationAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getRhsDilation() { + auto attr = getRhsDilationAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getWindowReversal() { + auto attr = getWindowReversalAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getInputBatchDimension() { + auto attr = getInputBatchDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getInputFeatureDimension() { + auto attr = getInputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getInputSpatialDimensions() { + auto attr = getInputSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getKernelInputFeatureDimension() { + auto attr = getKernelInputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getKernelOutputFeatureDimension() { + auto attr = getKernelOutputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getKernelSpatialDimensions() { + auto attr = getKernelSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getOutputBatchDimension() { + auto attr = getOutputBatchDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getOutputFeatureDimension() { + auto attr = getOutputFeatureDimensionAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getOutputSpatialDimensions() { + auto attr = getOutputSpatialDimensionsAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getFeatureGroupCount() { + auto attr = getFeatureGroupCountAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getBatchGroupCount() { + auto attr = getBatchGroupCountAttr(); + return attr; +} + +::mlir::Attribute DynamicConvOpV2::getPrecisionConfig() { + auto attr = getPrecisionConfigAttr(); + return attr; +} + +void DynamicConvOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value padding, ::mlir::Attribute window_strides, ::mlir::Attribute lhs_dilation, ::mlir::Attribute rhs_dilation, ::mlir::Attribute window_reversal, ::mlir::Attribute input_batch_dimension, ::mlir::Attribute input_feature_dimension, ::mlir::Attribute input_spatial_dimensions, ::mlir::Attribute kernel_input_feature_dimension, ::mlir::Attribute kernel_output_feature_dimension, ::mlir::Attribute kernel_spatial_dimensions, ::mlir::Attribute output_batch_dimension, ::mlir::Attribute output_feature_dimension, ::mlir::Attribute output_spatial_dimensions, ::mlir::Attribute feature_group_count, ::mlir::Attribute batch_group_count, ::mlir::Attribute precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(padding); + odsState.getOrAddProperties().window_strides = window_strides; + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + odsState.getOrAddProperties().window_reversal = window_reversal; + odsState.getOrAddProperties().input_batch_dimension = input_batch_dimension; + odsState.getOrAddProperties().input_feature_dimension = input_feature_dimension; + odsState.getOrAddProperties().input_spatial_dimensions = input_spatial_dimensions; + odsState.getOrAddProperties().kernel_input_feature_dimension = kernel_input_feature_dimension; + odsState.getOrAddProperties().kernel_output_feature_dimension = kernel_output_feature_dimension; + odsState.getOrAddProperties().kernel_spatial_dimensions = kernel_spatial_dimensions; + odsState.getOrAddProperties().output_batch_dimension = output_batch_dimension; + odsState.getOrAddProperties().output_feature_dimension = output_feature_dimension; + odsState.getOrAddProperties().output_spatial_dimensions = output_spatial_dimensions; + odsState.getOrAddProperties().feature_group_count = feature_group_count; + odsState.getOrAddProperties().batch_group_count = batch_group_count; + odsState.getOrAddProperties().precision_config = precision_config; + odsState.addTypes(result); +} + +void DynamicConvOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value padding, ::mlir::Attribute window_strides, ::mlir::Attribute lhs_dilation, ::mlir::Attribute rhs_dilation, ::mlir::Attribute window_reversal, ::mlir::Attribute input_batch_dimension, ::mlir::Attribute input_feature_dimension, ::mlir::Attribute input_spatial_dimensions, ::mlir::Attribute kernel_input_feature_dimension, ::mlir::Attribute kernel_output_feature_dimension, ::mlir::Attribute kernel_spatial_dimensions, ::mlir::Attribute output_batch_dimension, ::mlir::Attribute output_feature_dimension, ::mlir::Attribute output_spatial_dimensions, ::mlir::Attribute feature_group_count, ::mlir::Attribute batch_group_count, ::mlir::Attribute precision_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(padding); + odsState.getOrAddProperties().window_strides = window_strides; + odsState.getOrAddProperties().lhs_dilation = lhs_dilation; + odsState.getOrAddProperties().rhs_dilation = rhs_dilation; + odsState.getOrAddProperties().window_reversal = window_reversal; + odsState.getOrAddProperties().input_batch_dimension = input_batch_dimension; + odsState.getOrAddProperties().input_feature_dimension = input_feature_dimension; + odsState.getOrAddProperties().input_spatial_dimensions = input_spatial_dimensions; + odsState.getOrAddProperties().kernel_input_feature_dimension = kernel_input_feature_dimension; + odsState.getOrAddProperties().kernel_output_feature_dimension = kernel_output_feature_dimension; + odsState.getOrAddProperties().kernel_spatial_dimensions = kernel_spatial_dimensions; + odsState.getOrAddProperties().output_batch_dimension = output_batch_dimension; + odsState.getOrAddProperties().output_feature_dimension = output_feature_dimension; + odsState.getOrAddProperties().output_spatial_dimensions = output_spatial_dimensions; + odsState.getOrAddProperties().feature_group_count = feature_group_count; + odsState.getOrAddProperties().batch_group_count = batch_group_count; + odsState.getOrAddProperties().precision_config = precision_config; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicConvOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DynamicConvOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicConvOpV2::verifyInvariantsImpl() { + auto tblgen_batch_group_count = getProperties().batch_group_count; (void)tblgen_batch_group_count; + if (!tblgen_batch_group_count) return emitOpError("requires attribute 'batch_group_count'"); + auto tblgen_feature_group_count = getProperties().feature_group_count; (void)tblgen_feature_group_count; + if (!tblgen_feature_group_count) return emitOpError("requires attribute 'feature_group_count'"); + auto tblgen_input_batch_dimension = getProperties().input_batch_dimension; (void)tblgen_input_batch_dimension; + if (!tblgen_input_batch_dimension) return emitOpError("requires attribute 'input_batch_dimension'"); + auto tblgen_input_feature_dimension = getProperties().input_feature_dimension; (void)tblgen_input_feature_dimension; + if (!tblgen_input_feature_dimension) return emitOpError("requires attribute 'input_feature_dimension'"); + auto tblgen_input_spatial_dimensions = getProperties().input_spatial_dimensions; (void)tblgen_input_spatial_dimensions; + if (!tblgen_input_spatial_dimensions) return emitOpError("requires attribute 'input_spatial_dimensions'"); + auto tblgen_kernel_input_feature_dimension = getProperties().kernel_input_feature_dimension; (void)tblgen_kernel_input_feature_dimension; + if (!tblgen_kernel_input_feature_dimension) return emitOpError("requires attribute 'kernel_input_feature_dimension'"); + auto tblgen_kernel_output_feature_dimension = getProperties().kernel_output_feature_dimension; (void)tblgen_kernel_output_feature_dimension; + if (!tblgen_kernel_output_feature_dimension) return emitOpError("requires attribute 'kernel_output_feature_dimension'"); + auto tblgen_kernel_spatial_dimensions = getProperties().kernel_spatial_dimensions; (void)tblgen_kernel_spatial_dimensions; + if (!tblgen_kernel_spatial_dimensions) return emitOpError("requires attribute 'kernel_spatial_dimensions'"); + auto tblgen_lhs_dilation = getProperties().lhs_dilation; (void)tblgen_lhs_dilation; + if (!tblgen_lhs_dilation) return emitOpError("requires attribute 'lhs_dilation'"); + auto tblgen_output_batch_dimension = getProperties().output_batch_dimension; (void)tblgen_output_batch_dimension; + if (!tblgen_output_batch_dimension) return emitOpError("requires attribute 'output_batch_dimension'"); + auto tblgen_output_feature_dimension = getProperties().output_feature_dimension; (void)tblgen_output_feature_dimension; + if (!tblgen_output_feature_dimension) return emitOpError("requires attribute 'output_feature_dimension'"); + auto tblgen_output_spatial_dimensions = getProperties().output_spatial_dimensions; (void)tblgen_output_spatial_dimensions; + if (!tblgen_output_spatial_dimensions) return emitOpError("requires attribute 'output_spatial_dimensions'"); + auto tblgen_precision_config = getProperties().precision_config; (void)tblgen_precision_config; + if (!tblgen_precision_config) return emitOpError("requires attribute 'precision_config'"); + auto tblgen_rhs_dilation = getProperties().rhs_dilation; (void)tblgen_rhs_dilation; + if (!tblgen_rhs_dilation) return emitOpError("requires attribute 'rhs_dilation'"); + auto tblgen_window_reversal = getProperties().window_reversal; (void)tblgen_window_reversal; + if (!tblgen_window_reversal) return emitOpError("requires attribute 'window_reversal'"); + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + if (!tblgen_window_strides) return emitOpError("requires attribute 'window_strides'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_window_strides, "window_strides"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_lhs_dilation, "lhs_dilation"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_rhs_dilation, "rhs_dilation"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_window_reversal, "window_reversal"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_input_batch_dimension, "input_batch_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_input_feature_dimension, "input_feature_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_input_spatial_dimensions, "input_spatial_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_kernel_input_feature_dimension, "kernel_input_feature_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_kernel_output_feature_dimension, "kernel_output_feature_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_kernel_spatial_dimensions, "kernel_spatial_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_output_batch_dimension, "output_batch_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_output_feature_dimension, "output_feature_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_output_spatial_dimensions, "output_spatial_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_feature_group_count, "feature_group_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_batch_group_count, "batch_group_count"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_precision_config, "precision_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicConvOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DynamicConvOpV2::getMinVersion() { + return mlir::vhlo::Version(0, 20, 0); +} +mlir::vhlo::Version DynamicConvOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicConvOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicGatherOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicGatherOpV1GenericAdaptorBase::DynamicGatherOpV1GenericAdaptorBase(DynamicGatherOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute DynamicGatherOpV1GenericAdaptorBase::getOffsetDims() { + auto attr = getOffsetDimsAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV1GenericAdaptorBase::getCollapsedSliceDims() { + auto attr = getCollapsedSliceDimsAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV1GenericAdaptorBase::getStartIndexMap() { + auto attr = getStartIndexMapAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV1GenericAdaptorBase::getIndexVectorDim() { + auto attr = getIndexVectorDimAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV1GenericAdaptorBase::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + return attr; +} + +} // namespace detail +DynamicGatherOpV1Adaptor::DynamicGatherOpV1Adaptor(DynamicGatherOpV1 op) : DynamicGatherOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicGatherOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_collapsed_slice_dims = getProperties().collapsed_slice_dims; (void)tblgen_collapsed_slice_dims; + if (!tblgen_collapsed_slice_dims) return emitError(loc, "'vhlo.dynamic_gather_v1' op ""requires attribute 'collapsed_slice_dims'"); + auto tblgen_index_vector_dim = getProperties().index_vector_dim; (void)tblgen_index_vector_dim; + if (!tblgen_index_vector_dim) return emitError(loc, "'vhlo.dynamic_gather_v1' op ""requires attribute 'index_vector_dim'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + if (!tblgen_indices_are_sorted) return emitError(loc, "'vhlo.dynamic_gather_v1' op ""requires attribute 'indices_are_sorted'"); + auto tblgen_offset_dims = getProperties().offset_dims; (void)tblgen_offset_dims; + if (!tblgen_offset_dims) return emitError(loc, "'vhlo.dynamic_gather_v1' op ""requires attribute 'offset_dims'"); + auto tblgen_start_index_map = getProperties().start_index_map; (void)tblgen_start_index_map; + if (!tblgen_start_index_map) return emitError(loc, "'vhlo.dynamic_gather_v1' op ""requires attribute 'start_index_map'"); + + if (tblgen_offset_dims && !((true))) + return emitError(loc, "'vhlo.dynamic_gather_v1' op ""attribute 'offset_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_collapsed_slice_dims && !((true))) + return emitError(loc, "'vhlo.dynamic_gather_v1' op ""attribute 'collapsed_slice_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_start_index_map && !((true))) + return emitError(loc, "'vhlo.dynamic_gather_v1' op ""attribute 'start_index_map' failed to satisfy constraint: any attribute"); + + if (tblgen_index_vector_dim && !((true))) + return emitError(loc, "'vhlo.dynamic_gather_v1' op ""attribute 'index_vector_dim' failed to satisfy constraint: any attribute"); + + if (tblgen_indices_are_sorted && !((true))) + return emitError(loc, "'vhlo.dynamic_gather_v1' op ""attribute 'indices_are_sorted' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicGatherOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.collapsed_slice_dims; + auto attr = dict.get("collapsed_slice_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `collapsed_slice_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.index_vector_dim; + auto attr = dict.get("index_vector_dim"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `index_vector_dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.indices_are_sorted; + auto attr = dict.get("indices_are_sorted"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `indices_are_sorted` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.offset_dims; + auto attr = dict.get("offset_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `offset_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.start_index_map; + auto attr = dict.get("start_index_map"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `start_index_map` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicGatherOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.collapsed_slice_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("collapsed_slice_dims", + propStorage)); + } + + { + const auto &propStorage = prop.index_vector_dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("index_vector_dim", + propStorage)); + } + + { + const auto &propStorage = prop.indices_are_sorted; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("indices_are_sorted", + propStorage)); + } + + { + const auto &propStorage = prop.offset_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("offset_dims", + propStorage)); + } + + { + const auto &propStorage = prop.start_index_map; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("start_index_map", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicGatherOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.collapsed_slice_dims.getAsOpaquePointer()), + llvm::hash_value(prop.index_vector_dim.getAsOpaquePointer()), + llvm::hash_value(prop.indices_are_sorted.getAsOpaquePointer()), + llvm::hash_value(prop.offset_dims.getAsOpaquePointer()), + llvm::hash_value(prop.start_index_map.getAsOpaquePointer())); +} + +std::optional DynamicGatherOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "collapsed_slice_dims") + return prop.collapsed_slice_dims; + + if (name == "index_vector_dim") + return prop.index_vector_dim; + + if (name == "indices_are_sorted") + return prop.indices_are_sorted; + + if (name == "offset_dims") + return prop.offset_dims; + + if (name == "start_index_map") + return prop.start_index_map; + return std::nullopt; +} + +void DynamicGatherOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "collapsed_slice_dims") { + prop.collapsed_slice_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "index_vector_dim") { + prop.index_vector_dim = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "indices_are_sorted") { + prop.indices_are_sorted = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "offset_dims") { + prop.offset_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "start_index_map") { + prop.start_index_map = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DynamicGatherOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.collapsed_slice_dims) attrs.append("collapsed_slice_dims", prop.collapsed_slice_dims); + + if (prop.index_vector_dim) attrs.append("index_vector_dim", prop.index_vector_dim); + + if (prop.indices_are_sorted) attrs.append("indices_are_sorted", prop.indices_are_sorted); + + if (prop.offset_dims) attrs.append("offset_dims", prop.offset_dims); + + if (prop.start_index_map) attrs.append("start_index_map", prop.start_index_map); +} + +::llvm::LogicalResult DynamicGatherOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getCollapsedSliceDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "collapsed_slice_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIndexVectorDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "index_vector_dim", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIndicesAreSortedAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "indices_are_sorted", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOffsetDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "offset_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStartIndexMapAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "start_index_map", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicGatherOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.collapsed_slice_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.index_vector_dim))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.indices_are_sorted))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.offset_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.start_index_map))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicGatherOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.collapsed_slice_dims); + writer.writeAttribute(prop.index_vector_dim); + writer.writeAttribute(prop.indices_are_sorted); + writer.writeAttribute(prop.offset_dims); + writer.writeAttribute(prop.start_index_map); +} + +::mlir::Attribute DynamicGatherOpV1::getOffsetDims() { + auto attr = getOffsetDimsAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV1::getCollapsedSliceDims() { + auto attr = getCollapsedSliceDimsAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV1::getStartIndexMap() { + auto attr = getStartIndexMapAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV1::getIndexVectorDim() { + auto attr = getIndexVectorDimAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV1::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + return attr; +} + +void DynamicGatherOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(slice_sizes); + odsState.getOrAddProperties().offset_dims = offset_dims; + odsState.getOrAddProperties().collapsed_slice_dims = collapsed_slice_dims; + odsState.getOrAddProperties().start_index_map = start_index_map; + odsState.getOrAddProperties().index_vector_dim = index_vector_dim; + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + odsState.addTypes(result); +} + +void DynamicGatherOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(slice_sizes); + odsState.getOrAddProperties().offset_dims = offset_dims; + odsState.getOrAddProperties().collapsed_slice_dims = collapsed_slice_dims; + odsState.getOrAddProperties().start_index_map = start_index_map; + odsState.getOrAddProperties().index_vector_dim = index_vector_dim; + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicGatherOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DynamicGatherOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicGatherOpV1::verifyInvariantsImpl() { + auto tblgen_collapsed_slice_dims = getProperties().collapsed_slice_dims; (void)tblgen_collapsed_slice_dims; + if (!tblgen_collapsed_slice_dims) return emitOpError("requires attribute 'collapsed_slice_dims'"); + auto tblgen_index_vector_dim = getProperties().index_vector_dim; (void)tblgen_index_vector_dim; + if (!tblgen_index_vector_dim) return emitOpError("requires attribute 'index_vector_dim'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + if (!tblgen_indices_are_sorted) return emitOpError("requires attribute 'indices_are_sorted'"); + auto tblgen_offset_dims = getProperties().offset_dims; (void)tblgen_offset_dims; + if (!tblgen_offset_dims) return emitOpError("requires attribute 'offset_dims'"); + auto tblgen_start_index_map = getProperties().start_index_map; (void)tblgen_start_index_map; + if (!tblgen_start_index_map) return emitOpError("requires attribute 'start_index_map'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_offset_dims, "offset_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_collapsed_slice_dims, "collapsed_slice_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_start_index_map, "start_index_map"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_index_vector_dim, "index_vector_dim"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_indices_are_sorted, "indices_are_sorted"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicGatherOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DynamicGatherOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version DynamicGatherOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 0, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicGatherOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicGatherOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicGatherOpV2GenericAdaptorBase::DynamicGatherOpV2GenericAdaptorBase(DynamicGatherOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute DynamicGatherOpV2GenericAdaptorBase::getOffsetDims() { + auto attr = getOffsetDimsAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV2GenericAdaptorBase::getCollapsedSliceDims() { + auto attr = getCollapsedSliceDimsAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV2GenericAdaptorBase::getOperandBatchingDims() { + auto attr = getOperandBatchingDimsAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV2GenericAdaptorBase::getStartIndicesBatchingDims() { + auto attr = getStartIndicesBatchingDimsAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV2GenericAdaptorBase::getStartIndexMap() { + auto attr = getStartIndexMapAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV2GenericAdaptorBase::getIndexVectorDim() { + auto attr = getIndexVectorDimAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV2GenericAdaptorBase::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + return attr; +} + +} // namespace detail +DynamicGatherOpV2Adaptor::DynamicGatherOpV2Adaptor(DynamicGatherOpV2 op) : DynamicGatherOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicGatherOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_collapsed_slice_dims = getProperties().collapsed_slice_dims; (void)tblgen_collapsed_slice_dims; + if (!tblgen_collapsed_slice_dims) return emitError(loc, "'vhlo.dynamic_gather_v2' op ""requires attribute 'collapsed_slice_dims'"); + auto tblgen_index_vector_dim = getProperties().index_vector_dim; (void)tblgen_index_vector_dim; + if (!tblgen_index_vector_dim) return emitError(loc, "'vhlo.dynamic_gather_v2' op ""requires attribute 'index_vector_dim'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + if (!tblgen_indices_are_sorted) return emitError(loc, "'vhlo.dynamic_gather_v2' op ""requires attribute 'indices_are_sorted'"); + auto tblgen_offset_dims = getProperties().offset_dims; (void)tblgen_offset_dims; + if (!tblgen_offset_dims) return emitError(loc, "'vhlo.dynamic_gather_v2' op ""requires attribute 'offset_dims'"); + auto tblgen_operand_batching_dims = getProperties().operand_batching_dims; (void)tblgen_operand_batching_dims; + if (!tblgen_operand_batching_dims) return emitError(loc, "'vhlo.dynamic_gather_v2' op ""requires attribute 'operand_batching_dims'"); + auto tblgen_start_index_map = getProperties().start_index_map; (void)tblgen_start_index_map; + if (!tblgen_start_index_map) return emitError(loc, "'vhlo.dynamic_gather_v2' op ""requires attribute 'start_index_map'"); + auto tblgen_start_indices_batching_dims = getProperties().start_indices_batching_dims; (void)tblgen_start_indices_batching_dims; + if (!tblgen_start_indices_batching_dims) return emitError(loc, "'vhlo.dynamic_gather_v2' op ""requires attribute 'start_indices_batching_dims'"); + + if (tblgen_offset_dims && !((true))) + return emitError(loc, "'vhlo.dynamic_gather_v2' op ""attribute 'offset_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_collapsed_slice_dims && !((true))) + return emitError(loc, "'vhlo.dynamic_gather_v2' op ""attribute 'collapsed_slice_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_operand_batching_dims && !((true))) + return emitError(loc, "'vhlo.dynamic_gather_v2' op ""attribute 'operand_batching_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_start_indices_batching_dims && !((true))) + return emitError(loc, "'vhlo.dynamic_gather_v2' op ""attribute 'start_indices_batching_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_start_index_map && !((true))) + return emitError(loc, "'vhlo.dynamic_gather_v2' op ""attribute 'start_index_map' failed to satisfy constraint: any attribute"); + + if (tblgen_index_vector_dim && !((true))) + return emitError(loc, "'vhlo.dynamic_gather_v2' op ""attribute 'index_vector_dim' failed to satisfy constraint: any attribute"); + + if (tblgen_indices_are_sorted && !((true))) + return emitError(loc, "'vhlo.dynamic_gather_v2' op ""attribute 'indices_are_sorted' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicGatherOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.collapsed_slice_dims; + auto attr = dict.get("collapsed_slice_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `collapsed_slice_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.index_vector_dim; + auto attr = dict.get("index_vector_dim"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `index_vector_dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.indices_are_sorted; + auto attr = dict.get("indices_are_sorted"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `indices_are_sorted` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.offset_dims; + auto attr = dict.get("offset_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `offset_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.operand_batching_dims; + auto attr = dict.get("operand_batching_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `operand_batching_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.start_index_map; + auto attr = dict.get("start_index_map"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `start_index_map` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.start_indices_batching_dims; + auto attr = dict.get("start_indices_batching_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `start_indices_batching_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicGatherOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.collapsed_slice_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("collapsed_slice_dims", + propStorage)); + } + + { + const auto &propStorage = prop.index_vector_dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("index_vector_dim", + propStorage)); + } + + { + const auto &propStorage = prop.indices_are_sorted; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("indices_are_sorted", + propStorage)); + } + + { + const auto &propStorage = prop.offset_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("offset_dims", + propStorage)); + } + + { + const auto &propStorage = prop.operand_batching_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("operand_batching_dims", + propStorage)); + } + + { + const auto &propStorage = prop.start_index_map; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("start_index_map", + propStorage)); + } + + { + const auto &propStorage = prop.start_indices_batching_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("start_indices_batching_dims", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicGatherOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.collapsed_slice_dims.getAsOpaquePointer()), + llvm::hash_value(prop.index_vector_dim.getAsOpaquePointer()), + llvm::hash_value(prop.indices_are_sorted.getAsOpaquePointer()), + llvm::hash_value(prop.offset_dims.getAsOpaquePointer()), + llvm::hash_value(prop.operand_batching_dims.getAsOpaquePointer()), + llvm::hash_value(prop.start_index_map.getAsOpaquePointer()), + llvm::hash_value(prop.start_indices_batching_dims.getAsOpaquePointer())); +} + +std::optional DynamicGatherOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "collapsed_slice_dims") + return prop.collapsed_slice_dims; + + if (name == "index_vector_dim") + return prop.index_vector_dim; + + if (name == "indices_are_sorted") + return prop.indices_are_sorted; + + if (name == "offset_dims") + return prop.offset_dims; + + if (name == "operand_batching_dims") + return prop.operand_batching_dims; + + if (name == "start_index_map") + return prop.start_index_map; + + if (name == "start_indices_batching_dims") + return prop.start_indices_batching_dims; + return std::nullopt; +} + +void DynamicGatherOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "collapsed_slice_dims") { + prop.collapsed_slice_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "index_vector_dim") { + prop.index_vector_dim = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "indices_are_sorted") { + prop.indices_are_sorted = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "offset_dims") { + prop.offset_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "operand_batching_dims") { + prop.operand_batching_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "start_index_map") { + prop.start_index_map = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "start_indices_batching_dims") { + prop.start_indices_batching_dims = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DynamicGatherOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.collapsed_slice_dims) attrs.append("collapsed_slice_dims", prop.collapsed_slice_dims); + + if (prop.index_vector_dim) attrs.append("index_vector_dim", prop.index_vector_dim); + + if (prop.indices_are_sorted) attrs.append("indices_are_sorted", prop.indices_are_sorted); + + if (prop.offset_dims) attrs.append("offset_dims", prop.offset_dims); + + if (prop.operand_batching_dims) attrs.append("operand_batching_dims", prop.operand_batching_dims); + + if (prop.start_index_map) attrs.append("start_index_map", prop.start_index_map); + + if (prop.start_indices_batching_dims) attrs.append("start_indices_batching_dims", prop.start_indices_batching_dims); +} + +::llvm::LogicalResult DynamicGatherOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getCollapsedSliceDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "collapsed_slice_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIndexVectorDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "index_vector_dim", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIndicesAreSortedAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "indices_are_sorted", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOffsetDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "offset_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOperandBatchingDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "operand_batching_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStartIndexMapAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "start_index_map", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStartIndicesBatchingDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "start_indices_batching_dims", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicGatherOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.collapsed_slice_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.index_vector_dim))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.indices_are_sorted))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.offset_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.operand_batching_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.start_index_map))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.start_indices_batching_dims))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicGatherOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.collapsed_slice_dims); + writer.writeAttribute(prop.index_vector_dim); + writer.writeAttribute(prop.indices_are_sorted); + writer.writeAttribute(prop.offset_dims); + writer.writeAttribute(prop.operand_batching_dims); + writer.writeAttribute(prop.start_index_map); + writer.writeAttribute(prop.start_indices_batching_dims); +} + +::mlir::Attribute DynamicGatherOpV2::getOffsetDims() { + auto attr = getOffsetDimsAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV2::getCollapsedSliceDims() { + auto attr = getCollapsedSliceDimsAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV2::getOperandBatchingDims() { + auto attr = getOperandBatchingDimsAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV2::getStartIndicesBatchingDims() { + auto attr = getStartIndicesBatchingDimsAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV2::getStartIndexMap() { + auto attr = getStartIndexMapAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV2::getIndexVectorDim() { + auto attr = getIndexVectorDimAttr(); + return attr; +} + +::mlir::Attribute DynamicGatherOpV2::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + return attr; +} + +void DynamicGatherOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute operand_batching_dims, ::mlir::Attribute start_indices_batching_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(slice_sizes); + odsState.getOrAddProperties().offset_dims = offset_dims; + odsState.getOrAddProperties().collapsed_slice_dims = collapsed_slice_dims; + odsState.getOrAddProperties().operand_batching_dims = operand_batching_dims; + odsState.getOrAddProperties().start_indices_batching_dims = start_indices_batching_dims; + odsState.getOrAddProperties().start_index_map = start_index_map; + odsState.getOrAddProperties().index_vector_dim = index_vector_dim; + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + odsState.addTypes(result); +} + +void DynamicGatherOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute operand_batching_dims, ::mlir::Attribute start_indices_batching_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(slice_sizes); + odsState.getOrAddProperties().offset_dims = offset_dims; + odsState.getOrAddProperties().collapsed_slice_dims = collapsed_slice_dims; + odsState.getOrAddProperties().operand_batching_dims = operand_batching_dims; + odsState.getOrAddProperties().start_indices_batching_dims = start_indices_batching_dims; + odsState.getOrAddProperties().start_index_map = start_index_map; + odsState.getOrAddProperties().index_vector_dim = index_vector_dim; + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicGatherOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DynamicGatherOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicGatherOpV2::verifyInvariantsImpl() { + auto tblgen_collapsed_slice_dims = getProperties().collapsed_slice_dims; (void)tblgen_collapsed_slice_dims; + if (!tblgen_collapsed_slice_dims) return emitOpError("requires attribute 'collapsed_slice_dims'"); + auto tblgen_index_vector_dim = getProperties().index_vector_dim; (void)tblgen_index_vector_dim; + if (!tblgen_index_vector_dim) return emitOpError("requires attribute 'index_vector_dim'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + if (!tblgen_indices_are_sorted) return emitOpError("requires attribute 'indices_are_sorted'"); + auto tblgen_offset_dims = getProperties().offset_dims; (void)tblgen_offset_dims; + if (!tblgen_offset_dims) return emitOpError("requires attribute 'offset_dims'"); + auto tblgen_operand_batching_dims = getProperties().operand_batching_dims; (void)tblgen_operand_batching_dims; + if (!tblgen_operand_batching_dims) return emitOpError("requires attribute 'operand_batching_dims'"); + auto tblgen_start_index_map = getProperties().start_index_map; (void)tblgen_start_index_map; + if (!tblgen_start_index_map) return emitOpError("requires attribute 'start_index_map'"); + auto tblgen_start_indices_batching_dims = getProperties().start_indices_batching_dims; (void)tblgen_start_indices_batching_dims; + if (!tblgen_start_indices_batching_dims) return emitOpError("requires attribute 'start_indices_batching_dims'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_offset_dims, "offset_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_collapsed_slice_dims, "collapsed_slice_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_operand_batching_dims, "operand_batching_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_start_indices_batching_dims, "start_indices_batching_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_start_index_map, "start_index_map"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_index_vector_dim, "index_vector_dim"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_indices_are_sorted, "indices_are_sorted"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicGatherOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DynamicGatherOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 1, 0); +} +mlir::vhlo::Version DynamicGatherOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicGatherOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicIotaOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicIotaOpV1GenericAdaptorBase::DynamicIotaOpV1GenericAdaptorBase(DynamicIotaOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute DynamicIotaOpV1GenericAdaptorBase::getIotaDimension() { + auto attr = getIotaDimensionAttr(); + return attr; +} + +} // namespace detail +DynamicIotaOpV1Adaptor::DynamicIotaOpV1Adaptor(DynamicIotaOpV1 op) : DynamicIotaOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicIotaOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_iota_dimension = getProperties().iota_dimension; (void)tblgen_iota_dimension; + if (!tblgen_iota_dimension) return emitError(loc, "'vhlo.dynamic_iota_v1' op ""requires attribute 'iota_dimension'"); + + if (tblgen_iota_dimension && !((true))) + return emitError(loc, "'vhlo.dynamic_iota_v1' op ""attribute 'iota_dimension' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicIotaOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.iota_dimension; + auto attr = dict.get("iota_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `iota_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicIotaOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.iota_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("iota_dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicIotaOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.iota_dimension.getAsOpaquePointer())); +} + +std::optional DynamicIotaOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "iota_dimension") + return prop.iota_dimension; + return std::nullopt; +} + +void DynamicIotaOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "iota_dimension") { + prop.iota_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DynamicIotaOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.iota_dimension) attrs.append("iota_dimension", prop.iota_dimension); +} + +::llvm::LogicalResult DynamicIotaOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getIotaDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "iota_dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicIotaOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.iota_dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicIotaOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.iota_dimension); +} + +::mlir::Attribute DynamicIotaOpV1::getIotaDimension() { + auto attr = getIotaDimensionAttr(); + return attr; +} + +void DynamicIotaOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value output_shape, ::mlir::Attribute iota_dimension) { + odsState.addOperands(output_shape); + odsState.getOrAddProperties().iota_dimension = iota_dimension; + odsState.addTypes(result); +} + +void DynamicIotaOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value output_shape, ::mlir::Attribute iota_dimension) { + odsState.addOperands(output_shape); + odsState.getOrAddProperties().iota_dimension = iota_dimension; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicIotaOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DynamicIotaOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicIotaOpV1::verifyInvariantsImpl() { + auto tblgen_iota_dimension = getProperties().iota_dimension; (void)tblgen_iota_dimension; + if (!tblgen_iota_dimension) return emitOpError("requires attribute 'iota_dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_iota_dimension, "iota_dimension"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicIotaOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DynamicIotaOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version DynamicIotaOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicIotaOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicPadOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicPadOpV1GenericAdaptorBase::DynamicPadOpV1GenericAdaptorBase(DynamicPadOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +DynamicPadOpV1Adaptor::DynamicPadOpV1Adaptor(DynamicPadOpV1 op) : DynamicPadOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicPadOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicPadOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicPadOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicPadOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional DynamicPadOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void DynamicPadOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void DynamicPadOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult DynamicPadOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void DynamicPadOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::Value edge_padding_low, ::mlir::Value edge_padding_high, ::mlir::Value interior_padding) { + odsState.addOperands(operand); + odsState.addOperands(padding_value); + odsState.addOperands(edge_padding_low); + odsState.addOperands(edge_padding_high); + odsState.addOperands(interior_padding); + odsState.addTypes(result); +} + +void DynamicPadOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::Value edge_padding_low, ::mlir::Value edge_padding_high, ::mlir::Value interior_padding) { + odsState.addOperands(operand); + odsState.addOperands(padding_value); + odsState.addOperands(edge_padding_low); + odsState.addOperands(edge_padding_high); + odsState.addOperands(interior_padding); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicPadOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DynamicPadOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicPadOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicPadOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DynamicPadOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version DynamicPadOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicPadOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicReshapeOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicReshapeOpV1GenericAdaptorBase::DynamicReshapeOpV1GenericAdaptorBase(DynamicReshapeOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +DynamicReshapeOpV1Adaptor::DynamicReshapeOpV1Adaptor(DynamicReshapeOpV1 op) : DynamicReshapeOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicReshapeOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicReshapeOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicReshapeOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicReshapeOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional DynamicReshapeOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void DynamicReshapeOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void DynamicReshapeOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult DynamicReshapeOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void DynamicReshapeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value output_shape) { + odsState.addOperands(operand); + odsState.addOperands(output_shape); + odsState.addTypes(result); +} + +void DynamicReshapeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value output_shape) { + odsState.addOperands(operand); + odsState.addOperands(output_shape); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicReshapeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DynamicReshapeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicReshapeOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicReshapeOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DynamicReshapeOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version DynamicReshapeOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicReshapeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicSliceOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicSliceOpV1GenericAdaptorBase::DynamicSliceOpV1GenericAdaptorBase(DynamicSliceOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair DynamicSliceOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute DynamicSliceOpV1GenericAdaptorBase::getSliceSizes() { + auto attr = getSliceSizesAttr(); + return attr; +} + +} // namespace detail +DynamicSliceOpV1Adaptor::DynamicSliceOpV1Adaptor(DynamicSliceOpV1 op) : DynamicSliceOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicSliceOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_slice_sizes = getProperties().slice_sizes; (void)tblgen_slice_sizes; + if (!tblgen_slice_sizes) return emitError(loc, "'vhlo.dynamic_slice_v1' op ""requires attribute 'slice_sizes'"); + + if (tblgen_slice_sizes && !((true))) + return emitError(loc, "'vhlo.dynamic_slice_v1' op ""attribute 'slice_sizes' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair DynamicSliceOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange DynamicSliceOpV1::getStartIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult DynamicSliceOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.slice_sizes; + auto attr = dict.get("slice_sizes"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `slice_sizes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicSliceOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.slice_sizes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("slice_sizes", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicSliceOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.slice_sizes.getAsOpaquePointer())); +} + +std::optional DynamicSliceOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "slice_sizes") + return prop.slice_sizes; + return std::nullopt; +} + +void DynamicSliceOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "slice_sizes") { + prop.slice_sizes = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void DynamicSliceOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.slice_sizes) attrs.append("slice_sizes", prop.slice_sizes); +} + +::llvm::LogicalResult DynamicSliceOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getSliceSizesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "slice_sizes", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicSliceOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.slice_sizes))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DynamicSliceOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.slice_sizes); +} + +::mlir::Attribute DynamicSliceOpV1::getSliceSizes() { + auto attr = getSliceSizesAttr(); + return attr; +} + +void DynamicSliceOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::mlir::Attribute slice_sizes) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().slice_sizes = slice_sizes; + odsState.addTypes(result); +} + +void DynamicSliceOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::mlir::Attribute slice_sizes) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().slice_sizes = slice_sizes; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicSliceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void DynamicSliceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicSliceOpV1::verifyInvariantsImpl() { + auto tblgen_slice_sizes = getProperties().slice_sizes; (void)tblgen_slice_sizes; + if (!tblgen_slice_sizes) return emitOpError("requires attribute 'slice_sizes'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_slice_sizes, "slice_sizes"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicSliceOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DynamicSliceOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version DynamicSliceOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicSliceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicUpdateSliceOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DynamicUpdateSliceOpV1GenericAdaptorBase::DynamicUpdateSliceOpV1GenericAdaptorBase(DynamicUpdateSliceOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair DynamicUpdateSliceOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +} // namespace detail +DynamicUpdateSliceOpV1Adaptor::DynamicUpdateSliceOpV1Adaptor(DynamicUpdateSliceOpV1 op) : DynamicUpdateSliceOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult DynamicUpdateSliceOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair DynamicUpdateSliceOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange DynamicUpdateSliceOpV1::getStartIndicesMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult DynamicUpdateSliceOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute DynamicUpdateSliceOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code DynamicUpdateSliceOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional DynamicUpdateSliceOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void DynamicUpdateSliceOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void DynamicUpdateSliceOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult DynamicUpdateSliceOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void DynamicUpdateSliceOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value update, ::mlir::ValueRange start_indices) { + odsState.addOperands(operand); + odsState.addOperands(update); + odsState.addOperands(start_indices); + odsState.addTypes(result); +} + +void DynamicUpdateSliceOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value update, ::mlir::ValueRange start_indices) { + odsState.addOperands(operand); + odsState.addOperands(update); + odsState.addOperands(start_indices); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DynamicUpdateSliceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DynamicUpdateSliceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult DynamicUpdateSliceOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult DynamicUpdateSliceOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version DynamicUpdateSliceOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version DynamicUpdateSliceOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicUpdateSliceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::EinsumOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +EinsumOpV1GenericAdaptorBase::EinsumOpV1GenericAdaptorBase(EinsumOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute EinsumOpV1GenericAdaptorBase::getEinsumConfig() { + auto attr = getEinsumConfigAttr(); + return attr; +} + +} // namespace detail +EinsumOpV1Adaptor::EinsumOpV1Adaptor(EinsumOpV1 op) : EinsumOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult EinsumOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_einsum_config = getProperties().einsum_config; (void)tblgen_einsum_config; + if (!tblgen_einsum_config) return emitError(loc, "'vhlo.einsum_v1' op ""requires attribute 'einsum_config'"); + + if (tblgen_einsum_config && !((true))) + return emitError(loc, "'vhlo.einsum_v1' op ""attribute 'einsum_config' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult EinsumOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.einsum_config; + auto attr = dict.get("einsum_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `einsum_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute EinsumOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.einsum_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("einsum_config", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code EinsumOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.einsum_config.getAsOpaquePointer())); +} + +std::optional EinsumOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "einsum_config") + return prop.einsum_config; + return std::nullopt; +} + +void EinsumOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "einsum_config") { + prop.einsum_config = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void EinsumOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.einsum_config) attrs.append("einsum_config", prop.einsum_config); +} + +::llvm::LogicalResult EinsumOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getEinsumConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "einsum_config", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult EinsumOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.einsum_config))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void EinsumOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.einsum_config); +} + +::mlir::Attribute EinsumOpV1::getEinsumConfig() { + auto attr = getEinsumConfigAttr(); + return attr; +} + +void EinsumOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute einsum_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().einsum_config = einsum_config; + odsState.addTypes(result); +} + +void EinsumOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute einsum_config) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().einsum_config = einsum_config; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void EinsumOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void EinsumOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult EinsumOpV1::verifyInvariantsImpl() { + auto tblgen_einsum_config = getProperties().einsum_config; (void)tblgen_einsum_config; + if (!tblgen_einsum_config) return emitOpError("requires attribute 'einsum_config'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_einsum_config, "einsum_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult EinsumOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version EinsumOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version EinsumOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::EinsumOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ExpOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ExpOpV1GenericAdaptorBase::ExpOpV1GenericAdaptorBase(ExpOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ExpOpV1Adaptor::ExpOpV1Adaptor(ExpOpV1 op) : ExpOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ExpOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ExpOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ExpOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ExpOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ExpOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ExpOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ExpOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ExpOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ExpOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void ExpOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ExpOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ExpOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ExpOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ExpOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ExpOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ExpOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 8, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ExpOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ExpOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ExpOpV2GenericAdaptorBase::ExpOpV2GenericAdaptorBase(ExpOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute ExpOpV2GenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +} // namespace detail +ExpOpV2Adaptor::ExpOpV2Adaptor(ExpOpV2 op) : ExpOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ExpOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitError(loc, "'vhlo.exponential_v2' op ""requires attribute 'result_accuracy'"); + + if (tblgen_result_accuracy && !((true))) + return emitError(loc, "'vhlo.exponential_v2' op ""attribute 'result_accuracy' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult ExpOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ExpOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ExpOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional ExpOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void ExpOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ExpOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult ExpOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ExpOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExpOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_accuracy); +} + +::mlir::Attribute ExpOpV2::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +void ExpOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + odsState.addTypes(result); +} + +void ExpOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ExpOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ExpOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ExpOpV2::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitOpError("requires attribute 'result_accuracy'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ExpOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ExpOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 9, 0); +} +mlir::vhlo::Version ExpOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ExpOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::Expm1OpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +Expm1OpV1GenericAdaptorBase::Expm1OpV1GenericAdaptorBase(Expm1OpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +Expm1OpV1Adaptor::Expm1OpV1Adaptor(Expm1OpV1 op) : Expm1OpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult Expm1OpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult Expm1OpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute Expm1OpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code Expm1OpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional Expm1OpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void Expm1OpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void Expm1OpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult Expm1OpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void Expm1OpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void Expm1OpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void Expm1OpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void Expm1OpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult Expm1OpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult Expm1OpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version Expm1OpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version Expm1OpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 9, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::Expm1OpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::Expm1OpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +Expm1OpV2GenericAdaptorBase::Expm1OpV2GenericAdaptorBase(Expm1OpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute Expm1OpV2GenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +} // namespace detail +Expm1OpV2Adaptor::Expm1OpV2Adaptor(Expm1OpV2 op) : Expm1OpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult Expm1OpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitError(loc, "'vhlo.exponential_minus_one_v2' op ""requires attribute 'result_accuracy'"); + + if (tblgen_result_accuracy && !((true))) + return emitError(loc, "'vhlo.exponential_minus_one_v2' op ""attribute 'result_accuracy' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult Expm1OpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute Expm1OpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code Expm1OpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional Expm1OpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void Expm1OpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void Expm1OpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult Expm1OpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult Expm1OpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void Expm1OpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_accuracy); +} + +::mlir::Attribute Expm1OpV2::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +void Expm1OpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + odsState.addTypes(result); +} + +void Expm1OpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void Expm1OpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void Expm1OpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult Expm1OpV2::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitOpError("requires attribute 'result_accuracy'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult Expm1OpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version Expm1OpV2::getMinVersion() { + return mlir::vhlo::Version(1, 10, 0); +} +mlir::vhlo::Version Expm1OpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::Expm1OpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::FftOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +FftOpV1GenericAdaptorBase::FftOpV1GenericAdaptorBase(FftOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute FftOpV1GenericAdaptorBase::getFftType() { + auto attr = getFftTypeAttr(); + return attr; +} + +::mlir::Attribute FftOpV1GenericAdaptorBase::getFftLength() { + auto attr = getFftLengthAttr(); + return attr; +} + +} // namespace detail +FftOpV1Adaptor::FftOpV1Adaptor(FftOpV1 op) : FftOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult FftOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_fft_length = getProperties().fft_length; (void)tblgen_fft_length; + if (!tblgen_fft_length) return emitError(loc, "'vhlo.fft_v1' op ""requires attribute 'fft_length'"); + auto tblgen_fft_type = getProperties().fft_type; (void)tblgen_fft_type; + if (!tblgen_fft_type) return emitError(loc, "'vhlo.fft_v1' op ""requires attribute 'fft_type'"); + + if (tblgen_fft_type && !((true))) + return emitError(loc, "'vhlo.fft_v1' op ""attribute 'fft_type' failed to satisfy constraint: any attribute"); + + if (tblgen_fft_length && !((true))) + return emitError(loc, "'vhlo.fft_v1' op ""attribute 'fft_length' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult FftOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.fft_length; + auto attr = dict.get("fft_length"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `fft_length` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.fft_type; + auto attr = dict.get("fft_type"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `fft_type` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute FftOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.fft_length; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("fft_length", + propStorage)); + } + + { + const auto &propStorage = prop.fft_type; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("fft_type", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code FftOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.fft_length.getAsOpaquePointer()), + llvm::hash_value(prop.fft_type.getAsOpaquePointer())); +} + +std::optional FftOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "fft_length") + return prop.fft_length; + + if (name == "fft_type") + return prop.fft_type; + return std::nullopt; +} + +void FftOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "fft_length") { + prop.fft_length = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "fft_type") { + prop.fft_type = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void FftOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.fft_length) attrs.append("fft_length", prop.fft_length); + + if (prop.fft_type) attrs.append("fft_type", prop.fft_type); +} + +::llvm::LogicalResult FftOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getFftLengthAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "fft_length", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFftTypeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "fft_type", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult FftOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.fft_length))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.fft_type))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void FftOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.fft_length); + writer.writeAttribute(prop.fft_type); +} + +::mlir::Attribute FftOpV1::getFftType() { + auto attr = getFftTypeAttr(); + return attr; +} + +::mlir::Attribute FftOpV1::getFftLength() { + auto attr = getFftLengthAttr(); + return attr; +} + +void FftOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute fft_type, ::mlir::Attribute fft_length) { + odsState.addOperands(operand); + odsState.getOrAddProperties().fft_type = fft_type; + odsState.getOrAddProperties().fft_length = fft_length; + odsState.addTypes(result); +} + +void FftOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute fft_type, ::mlir::Attribute fft_length) { + odsState.addOperands(operand); + odsState.getOrAddProperties().fft_type = fft_type; + odsState.getOrAddProperties().fft_length = fft_length; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void FftOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void FftOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult FftOpV1::verifyInvariantsImpl() { + auto tblgen_fft_length = getProperties().fft_length; (void)tblgen_fft_length; + if (!tblgen_fft_length) return emitOpError("requires attribute 'fft_length'"); + auto tblgen_fft_type = getProperties().fft_type; (void)tblgen_fft_type; + if (!tblgen_fft_type) return emitOpError("requires attribute 'fft_type'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_fft_type, "fft_type"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_fft_length, "fft_length"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult FftOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version FftOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version FftOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FftOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::FloorOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +FloorOpV1GenericAdaptorBase::FloorOpV1GenericAdaptorBase(FloorOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +FloorOpV1Adaptor::FloorOpV1Adaptor(FloorOpV1 op) : FloorOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult FloorOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult FloorOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute FloorOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code FloorOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional FloorOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void FloorOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void FloorOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult FloorOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void FloorOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void FloorOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void FloorOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void FloorOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult FloorOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult FloorOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version FloorOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version FloorOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloorOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::FuncOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +FuncOpV1GenericAdaptorBase::FuncOpV1GenericAdaptorBase(FuncOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute FuncOpV1GenericAdaptorBase::getSymName() { + auto attr = getSymNameAttr(); + return attr; +} + +::mlir::Attribute FuncOpV1GenericAdaptorBase::getFunctionType() { + auto attr = getFunctionTypeAttr(); + return attr; +} + +::mlir::Attribute FuncOpV1GenericAdaptorBase::getSymVisibility() { + auto attr = getSymVisibilityAttr(); + return attr; +} + +::mlir::Attribute FuncOpV1GenericAdaptorBase::getArgAttrs() { + auto attr = getArgAttrsAttr(); + return attr; +} + +::mlir::Attribute FuncOpV1GenericAdaptorBase::getResAttrs() { + auto attr = getResAttrsAttr(); + return attr; +} + +} // namespace detail +FuncOpV1Adaptor::FuncOpV1Adaptor(FuncOpV1 op) : FuncOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult FuncOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_arg_attrs = getProperties().arg_attrs; (void)tblgen_arg_attrs; + if (!tblgen_arg_attrs) return emitError(loc, "'vhlo.func_v1' op ""requires attribute 'arg_attrs'"); + auto tblgen_function_type = getProperties().function_type; (void)tblgen_function_type; + if (!tblgen_function_type) return emitError(loc, "'vhlo.func_v1' op ""requires attribute 'function_type'"); + auto tblgen_res_attrs = getProperties().res_attrs; (void)tblgen_res_attrs; + if (!tblgen_res_attrs) return emitError(loc, "'vhlo.func_v1' op ""requires attribute 'res_attrs'"); + auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; + if (!tblgen_sym_name) return emitError(loc, "'vhlo.func_v1' op ""requires attribute 'sym_name'"); + auto tblgen_sym_visibility = getProperties().sym_visibility; (void)tblgen_sym_visibility; + if (!tblgen_sym_visibility) return emitError(loc, "'vhlo.func_v1' op ""requires attribute 'sym_visibility'"); + + if (tblgen_sym_name && !((true))) + return emitError(loc, "'vhlo.func_v1' op ""attribute 'sym_name' failed to satisfy constraint: any attribute"); + + if (tblgen_function_type && !((true))) + return emitError(loc, "'vhlo.func_v1' op ""attribute 'function_type' failed to satisfy constraint: any attribute"); + + if (tblgen_sym_visibility && !((true))) + return emitError(loc, "'vhlo.func_v1' op ""attribute 'sym_visibility' failed to satisfy constraint: any attribute"); + + if (tblgen_arg_attrs && !((true))) + return emitError(loc, "'vhlo.func_v1' op ""attribute 'arg_attrs' failed to satisfy constraint: any attribute"); + + if (tblgen_res_attrs && !((true))) + return emitError(loc, "'vhlo.func_v1' op ""attribute 'res_attrs' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult FuncOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.arg_attrs; + auto attr = dict.get("arg_attrs"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `arg_attrs` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.function_type; + auto attr = dict.get("function_type"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `function_type` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.res_attrs; + auto attr = dict.get("res_attrs"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `res_attrs` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.sym_name; + auto attr = dict.get("sym_name"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `sym_name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.sym_visibility; + auto attr = dict.get("sym_visibility"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `sym_visibility` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute FuncOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.arg_attrs; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("arg_attrs", + propStorage)); + } + + { + const auto &propStorage = prop.function_type; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("function_type", + propStorage)); + } + + { + const auto &propStorage = prop.res_attrs; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("res_attrs", + propStorage)); + } + + { + const auto &propStorage = prop.sym_name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("sym_name", + propStorage)); + } + + { + const auto &propStorage = prop.sym_visibility; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("sym_visibility", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code FuncOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.arg_attrs.getAsOpaquePointer()), + llvm::hash_value(prop.function_type.getAsOpaquePointer()), + llvm::hash_value(prop.res_attrs.getAsOpaquePointer()), + llvm::hash_value(prop.sym_name.getAsOpaquePointer()), + llvm::hash_value(prop.sym_visibility.getAsOpaquePointer())); +} + +std::optional FuncOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "arg_attrs") + return prop.arg_attrs; + + if (name == "function_type") + return prop.function_type; + + if (name == "res_attrs") + return prop.res_attrs; + + if (name == "sym_name") + return prop.sym_name; + + if (name == "sym_visibility") + return prop.sym_visibility; + return std::nullopt; +} + +void FuncOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "arg_attrs") { + prop.arg_attrs = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "function_type") { + prop.function_type = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "res_attrs") { + prop.res_attrs = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "sym_name") { + prop.sym_name = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "sym_visibility") { + prop.sym_visibility = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void FuncOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.arg_attrs) attrs.append("arg_attrs", prop.arg_attrs); + + if (prop.function_type) attrs.append("function_type", prop.function_type); + + if (prop.res_attrs) attrs.append("res_attrs", prop.res_attrs); + + if (prop.sym_name) attrs.append("sym_name", prop.sym_name); + + if (prop.sym_visibility) attrs.append("sym_visibility", prop.sym_visibility); +} + +::llvm::LogicalResult FuncOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getArgAttrsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "arg_attrs", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFunctionTypeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "function_type", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getResAttrsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "res_attrs", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "sym_name", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSymVisibilityAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "sym_visibility", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult FuncOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.arg_attrs))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.function_type))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.res_attrs))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.sym_name))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.sym_visibility))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void FuncOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.arg_attrs); + writer.writeAttribute(prop.function_type); + writer.writeAttribute(prop.res_attrs); + writer.writeAttribute(prop.sym_name); + writer.writeAttribute(prop.sym_visibility); +} + +::mlir::Attribute FuncOpV1::getSymName() { + auto attr = getSymNameAttr(); + return attr; +} + +::mlir::Attribute FuncOpV1::getFunctionType() { + auto attr = getFunctionTypeAttr(); + return attr; +} + +::mlir::Attribute FuncOpV1::getSymVisibility() { + auto attr = getSymVisibilityAttr(); + return attr; +} + +::mlir::Attribute FuncOpV1::getArgAttrs() { + auto attr = getArgAttrsAttr(); + return attr; +} + +::mlir::Attribute FuncOpV1::getResAttrs() { + auto attr = getResAttrsAttr(); + return attr; +} + +void FuncOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Attribute sym_name, ::mlir::Attribute function_type, ::mlir::Attribute sym_visibility, ::mlir::Attribute arg_attrs, ::mlir::Attribute res_attrs) { + odsState.getOrAddProperties().sym_name = sym_name; + odsState.getOrAddProperties().function_type = function_type; + odsState.getOrAddProperties().sym_visibility = sym_visibility; + odsState.getOrAddProperties().arg_attrs = arg_attrs; + odsState.getOrAddProperties().res_attrs = res_attrs; + (void)odsState.addRegion(); +} + +void FuncOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Attribute sym_name, ::mlir::Attribute function_type, ::mlir::Attribute sym_visibility, ::mlir::Attribute arg_attrs, ::mlir::Attribute res_attrs) { + odsState.getOrAddProperties().sym_name = sym_name; + odsState.getOrAddProperties().function_type = function_type; + odsState.getOrAddProperties().sym_visibility = sym_visibility; + odsState.getOrAddProperties().arg_attrs = arg_attrs; + odsState.getOrAddProperties().res_attrs = res_attrs; + (void)odsState.addRegion(); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void FuncOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void FuncOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult FuncOpV1::verifyInvariantsImpl() { + auto tblgen_arg_attrs = getProperties().arg_attrs; (void)tblgen_arg_attrs; + if (!tblgen_arg_attrs) return emitOpError("requires attribute 'arg_attrs'"); + auto tblgen_function_type = getProperties().function_type; (void)tblgen_function_type; + if (!tblgen_function_type) return emitOpError("requires attribute 'function_type'"); + auto tblgen_res_attrs = getProperties().res_attrs; (void)tblgen_res_attrs; + if (!tblgen_res_attrs) return emitOpError("requires attribute 'res_attrs'"); + auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; + if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'"); + auto tblgen_sym_visibility = getProperties().sym_visibility; (void)tblgen_sym_visibility; + if (!tblgen_sym_visibility) return emitOpError("requires attribute 'sym_visibility'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_sym_name, "sym_name"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_function_type, "function_type"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_sym_visibility, "sym_visibility"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_arg_attrs, "arg_attrs"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_res_attrs, "res_attrs"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "body", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult FuncOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult FuncOpV1::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::Attribute sym_nameAttr; + std::unique_ptr<::mlir::Region> bodyRegion = std::make_unique<::mlir::Region>(); + ::mlir::Attribute function_typeAttr; + { + auto odsResult = parseFunctionBody(parser, sym_nameAttr, *bodyRegion, function_typeAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().sym_name = sym_nameAttr; + result.getOrAddProperties().function_type = function_typeAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + result.addRegion(std::move(bodyRegion)); + return ::mlir::success(); +} + +void FuncOpV1::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + printFunctionBody(_odsPrinter, *this, getSymNameAttr(), getBody(), getFunctionTypeAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("sym_name"); + elidedAttrs.push_back("function_type"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); +} + +mlir::vhlo::Version FuncOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version FuncOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FuncOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::GatherOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GatherOpV1GenericAdaptorBase::GatherOpV1GenericAdaptorBase(GatherOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute GatherOpV1GenericAdaptorBase::getOffsetDims() { + auto attr = getOffsetDimsAttr(); + return attr; +} + +::mlir::Attribute GatherOpV1GenericAdaptorBase::getCollapsedSliceDims() { + auto attr = getCollapsedSliceDimsAttr(); + return attr; +} + +::mlir::Attribute GatherOpV1GenericAdaptorBase::getStartIndexMap() { + auto attr = getStartIndexMapAttr(); + return attr; +} + +::mlir::Attribute GatherOpV1GenericAdaptorBase::getIndexVectorDim() { + auto attr = getIndexVectorDimAttr(); + return attr; +} + +::mlir::Attribute GatherOpV1GenericAdaptorBase::getSliceSizes() { + auto attr = getSliceSizesAttr(); + return attr; +} + +::mlir::Attribute GatherOpV1GenericAdaptorBase::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + return attr; +} + +} // namespace detail +GatherOpV1Adaptor::GatherOpV1Adaptor(GatherOpV1 op) : GatherOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult GatherOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_collapsed_slice_dims = getProperties().collapsed_slice_dims; (void)tblgen_collapsed_slice_dims; + if (!tblgen_collapsed_slice_dims) return emitError(loc, "'vhlo.gather_v1' op ""requires attribute 'collapsed_slice_dims'"); + auto tblgen_index_vector_dim = getProperties().index_vector_dim; (void)tblgen_index_vector_dim; + if (!tblgen_index_vector_dim) return emitError(loc, "'vhlo.gather_v1' op ""requires attribute 'index_vector_dim'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + if (!tblgen_indices_are_sorted) return emitError(loc, "'vhlo.gather_v1' op ""requires attribute 'indices_are_sorted'"); + auto tblgen_offset_dims = getProperties().offset_dims; (void)tblgen_offset_dims; + if (!tblgen_offset_dims) return emitError(loc, "'vhlo.gather_v1' op ""requires attribute 'offset_dims'"); + auto tblgen_slice_sizes = getProperties().slice_sizes; (void)tblgen_slice_sizes; + if (!tblgen_slice_sizes) return emitError(loc, "'vhlo.gather_v1' op ""requires attribute 'slice_sizes'"); + auto tblgen_start_index_map = getProperties().start_index_map; (void)tblgen_start_index_map; + if (!tblgen_start_index_map) return emitError(loc, "'vhlo.gather_v1' op ""requires attribute 'start_index_map'"); + + if (tblgen_offset_dims && !((true))) + return emitError(loc, "'vhlo.gather_v1' op ""attribute 'offset_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_collapsed_slice_dims && !((true))) + return emitError(loc, "'vhlo.gather_v1' op ""attribute 'collapsed_slice_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_start_index_map && !((true))) + return emitError(loc, "'vhlo.gather_v1' op ""attribute 'start_index_map' failed to satisfy constraint: any attribute"); + + if (tblgen_index_vector_dim && !((true))) + return emitError(loc, "'vhlo.gather_v1' op ""attribute 'index_vector_dim' failed to satisfy constraint: any attribute"); + + if (tblgen_slice_sizes && !((true))) + return emitError(loc, "'vhlo.gather_v1' op ""attribute 'slice_sizes' failed to satisfy constraint: any attribute"); + + if (tblgen_indices_are_sorted && !((true))) + return emitError(loc, "'vhlo.gather_v1' op ""attribute 'indices_are_sorted' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult GatherOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.collapsed_slice_dims; + auto attr = dict.get("collapsed_slice_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `collapsed_slice_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.index_vector_dim; + auto attr = dict.get("index_vector_dim"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `index_vector_dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.indices_are_sorted; + auto attr = dict.get("indices_are_sorted"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `indices_are_sorted` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.offset_dims; + auto attr = dict.get("offset_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `offset_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.slice_sizes; + auto attr = dict.get("slice_sizes"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `slice_sizes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.start_index_map; + auto attr = dict.get("start_index_map"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `start_index_map` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GatherOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.collapsed_slice_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("collapsed_slice_dims", + propStorage)); + } + + { + const auto &propStorage = prop.index_vector_dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("index_vector_dim", + propStorage)); + } + + { + const auto &propStorage = prop.indices_are_sorted; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("indices_are_sorted", + propStorage)); + } + + { + const auto &propStorage = prop.offset_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("offset_dims", + propStorage)); + } + + { + const auto &propStorage = prop.slice_sizes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("slice_sizes", + propStorage)); + } + + { + const auto &propStorage = prop.start_index_map; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("start_index_map", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GatherOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.collapsed_slice_dims.getAsOpaquePointer()), + llvm::hash_value(prop.index_vector_dim.getAsOpaquePointer()), + llvm::hash_value(prop.indices_are_sorted.getAsOpaquePointer()), + llvm::hash_value(prop.offset_dims.getAsOpaquePointer()), + llvm::hash_value(prop.slice_sizes.getAsOpaquePointer()), + llvm::hash_value(prop.start_index_map.getAsOpaquePointer())); +} + +std::optional GatherOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "collapsed_slice_dims") + return prop.collapsed_slice_dims; + + if (name == "index_vector_dim") + return prop.index_vector_dim; + + if (name == "indices_are_sorted") + return prop.indices_are_sorted; + + if (name == "offset_dims") + return prop.offset_dims; + + if (name == "slice_sizes") + return prop.slice_sizes; + + if (name == "start_index_map") + return prop.start_index_map; + return std::nullopt; +} + +void GatherOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "collapsed_slice_dims") { + prop.collapsed_slice_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "index_vector_dim") { + prop.index_vector_dim = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "indices_are_sorted") { + prop.indices_are_sorted = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "offset_dims") { + prop.offset_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "slice_sizes") { + prop.slice_sizes = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "start_index_map") { + prop.start_index_map = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GatherOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.collapsed_slice_dims) attrs.append("collapsed_slice_dims", prop.collapsed_slice_dims); + + if (prop.index_vector_dim) attrs.append("index_vector_dim", prop.index_vector_dim); + + if (prop.indices_are_sorted) attrs.append("indices_are_sorted", prop.indices_are_sorted); + + if (prop.offset_dims) attrs.append("offset_dims", prop.offset_dims); + + if (prop.slice_sizes) attrs.append("slice_sizes", prop.slice_sizes); + + if (prop.start_index_map) attrs.append("start_index_map", prop.start_index_map); +} + +::llvm::LogicalResult GatherOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getCollapsedSliceDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "collapsed_slice_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIndexVectorDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "index_vector_dim", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIndicesAreSortedAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "indices_are_sorted", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOffsetDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "offset_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSliceSizesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "slice_sizes", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStartIndexMapAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "start_index_map", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult GatherOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.collapsed_slice_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.index_vector_dim))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.indices_are_sorted))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.offset_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.slice_sizes))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.start_index_map))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GatherOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.collapsed_slice_dims); + writer.writeAttribute(prop.index_vector_dim); + writer.writeAttribute(prop.indices_are_sorted); + writer.writeAttribute(prop.offset_dims); + writer.writeAttribute(prop.slice_sizes); + writer.writeAttribute(prop.start_index_map); +} + +::mlir::Attribute GatherOpV1::getOffsetDims() { + auto attr = getOffsetDimsAttr(); + return attr; +} + +::mlir::Attribute GatherOpV1::getCollapsedSliceDims() { + auto attr = getCollapsedSliceDimsAttr(); + return attr; +} + +::mlir::Attribute GatherOpV1::getStartIndexMap() { + auto attr = getStartIndexMapAttr(); + return attr; +} + +::mlir::Attribute GatherOpV1::getIndexVectorDim() { + auto attr = getIndexVectorDimAttr(); + return attr; +} + +::mlir::Attribute GatherOpV1::getSliceSizes() { + auto attr = getSliceSizesAttr(); + return attr; +} + +::mlir::Attribute GatherOpV1::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + return attr; +} + +void GatherOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute slice_sizes, ::mlir::Attribute indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().offset_dims = offset_dims; + odsState.getOrAddProperties().collapsed_slice_dims = collapsed_slice_dims; + odsState.getOrAddProperties().start_index_map = start_index_map; + odsState.getOrAddProperties().index_vector_dim = index_vector_dim; + odsState.getOrAddProperties().slice_sizes = slice_sizes; + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + odsState.addTypes(result); +} + +void GatherOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute slice_sizes, ::mlir::Attribute indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().offset_dims = offset_dims; + odsState.getOrAddProperties().collapsed_slice_dims = collapsed_slice_dims; + odsState.getOrAddProperties().start_index_map = start_index_map; + odsState.getOrAddProperties().index_vector_dim = index_vector_dim; + odsState.getOrAddProperties().slice_sizes = slice_sizes; + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GatherOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void GatherOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult GatherOpV1::verifyInvariantsImpl() { + auto tblgen_collapsed_slice_dims = getProperties().collapsed_slice_dims; (void)tblgen_collapsed_slice_dims; + if (!tblgen_collapsed_slice_dims) return emitOpError("requires attribute 'collapsed_slice_dims'"); + auto tblgen_index_vector_dim = getProperties().index_vector_dim; (void)tblgen_index_vector_dim; + if (!tblgen_index_vector_dim) return emitOpError("requires attribute 'index_vector_dim'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + if (!tblgen_indices_are_sorted) return emitOpError("requires attribute 'indices_are_sorted'"); + auto tblgen_offset_dims = getProperties().offset_dims; (void)tblgen_offset_dims; + if (!tblgen_offset_dims) return emitOpError("requires attribute 'offset_dims'"); + auto tblgen_slice_sizes = getProperties().slice_sizes; (void)tblgen_slice_sizes; + if (!tblgen_slice_sizes) return emitOpError("requires attribute 'slice_sizes'"); + auto tblgen_start_index_map = getProperties().start_index_map; (void)tblgen_start_index_map; + if (!tblgen_start_index_map) return emitOpError("requires attribute 'start_index_map'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_offset_dims, "offset_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_collapsed_slice_dims, "collapsed_slice_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_start_index_map, "start_index_map"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_index_vector_dim, "index_vector_dim"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_slice_sizes, "slice_sizes"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_indices_are_sorted, "indices_are_sorted"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult GatherOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version GatherOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version GatherOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 0, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::GatherOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::GatherOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GatherOpV2GenericAdaptorBase::GatherOpV2GenericAdaptorBase(GatherOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute GatherOpV2GenericAdaptorBase::getOffsetDims() { + auto attr = getOffsetDimsAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2GenericAdaptorBase::getCollapsedSliceDims() { + auto attr = getCollapsedSliceDimsAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2GenericAdaptorBase::getOperandBatchingDims() { + auto attr = getOperandBatchingDimsAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2GenericAdaptorBase::getStartIndicesBatchingDims() { + auto attr = getStartIndicesBatchingDimsAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2GenericAdaptorBase::getStartIndexMap() { + auto attr = getStartIndexMapAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2GenericAdaptorBase::getIndexVectorDim() { + auto attr = getIndexVectorDimAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2GenericAdaptorBase::getSliceSizes() { + auto attr = getSliceSizesAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2GenericAdaptorBase::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + return attr; +} + +} // namespace detail +GatherOpV2Adaptor::GatherOpV2Adaptor(GatherOpV2 op) : GatherOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult GatherOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_collapsed_slice_dims = getProperties().collapsed_slice_dims; (void)tblgen_collapsed_slice_dims; + if (!tblgen_collapsed_slice_dims) return emitError(loc, "'vhlo.gather_v2' op ""requires attribute 'collapsed_slice_dims'"); + auto tblgen_index_vector_dim = getProperties().index_vector_dim; (void)tblgen_index_vector_dim; + if (!tblgen_index_vector_dim) return emitError(loc, "'vhlo.gather_v2' op ""requires attribute 'index_vector_dim'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + if (!tblgen_indices_are_sorted) return emitError(loc, "'vhlo.gather_v2' op ""requires attribute 'indices_are_sorted'"); + auto tblgen_offset_dims = getProperties().offset_dims; (void)tblgen_offset_dims; + if (!tblgen_offset_dims) return emitError(loc, "'vhlo.gather_v2' op ""requires attribute 'offset_dims'"); + auto tblgen_operand_batching_dims = getProperties().operand_batching_dims; (void)tblgen_operand_batching_dims; + if (!tblgen_operand_batching_dims) return emitError(loc, "'vhlo.gather_v2' op ""requires attribute 'operand_batching_dims'"); + auto tblgen_slice_sizes = getProperties().slice_sizes; (void)tblgen_slice_sizes; + if (!tblgen_slice_sizes) return emitError(loc, "'vhlo.gather_v2' op ""requires attribute 'slice_sizes'"); + auto tblgen_start_index_map = getProperties().start_index_map; (void)tblgen_start_index_map; + if (!tblgen_start_index_map) return emitError(loc, "'vhlo.gather_v2' op ""requires attribute 'start_index_map'"); + auto tblgen_start_indices_batching_dims = getProperties().start_indices_batching_dims; (void)tblgen_start_indices_batching_dims; + if (!tblgen_start_indices_batching_dims) return emitError(loc, "'vhlo.gather_v2' op ""requires attribute 'start_indices_batching_dims'"); + + if (tblgen_offset_dims && !((true))) + return emitError(loc, "'vhlo.gather_v2' op ""attribute 'offset_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_collapsed_slice_dims && !((true))) + return emitError(loc, "'vhlo.gather_v2' op ""attribute 'collapsed_slice_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_operand_batching_dims && !((true))) + return emitError(loc, "'vhlo.gather_v2' op ""attribute 'operand_batching_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_start_indices_batching_dims && !((true))) + return emitError(loc, "'vhlo.gather_v2' op ""attribute 'start_indices_batching_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_start_index_map && !((true))) + return emitError(loc, "'vhlo.gather_v2' op ""attribute 'start_index_map' failed to satisfy constraint: any attribute"); + + if (tblgen_index_vector_dim && !((true))) + return emitError(loc, "'vhlo.gather_v2' op ""attribute 'index_vector_dim' failed to satisfy constraint: any attribute"); + + if (tblgen_slice_sizes && !((true))) + return emitError(loc, "'vhlo.gather_v2' op ""attribute 'slice_sizes' failed to satisfy constraint: any attribute"); + + if (tblgen_indices_are_sorted && !((true))) + return emitError(loc, "'vhlo.gather_v2' op ""attribute 'indices_are_sorted' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult GatherOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.collapsed_slice_dims; + auto attr = dict.get("collapsed_slice_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `collapsed_slice_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.index_vector_dim; + auto attr = dict.get("index_vector_dim"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `index_vector_dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.indices_are_sorted; + auto attr = dict.get("indices_are_sorted"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `indices_are_sorted` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.offset_dims; + auto attr = dict.get("offset_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `offset_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.operand_batching_dims; + auto attr = dict.get("operand_batching_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `operand_batching_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.slice_sizes; + auto attr = dict.get("slice_sizes"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `slice_sizes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.start_index_map; + auto attr = dict.get("start_index_map"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `start_index_map` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.start_indices_batching_dims; + auto attr = dict.get("start_indices_batching_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `start_indices_batching_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GatherOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.collapsed_slice_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("collapsed_slice_dims", + propStorage)); + } + + { + const auto &propStorage = prop.index_vector_dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("index_vector_dim", + propStorage)); + } + + { + const auto &propStorage = prop.indices_are_sorted; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("indices_are_sorted", + propStorage)); + } + + { + const auto &propStorage = prop.offset_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("offset_dims", + propStorage)); + } + + { + const auto &propStorage = prop.operand_batching_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("operand_batching_dims", + propStorage)); + } + + { + const auto &propStorage = prop.slice_sizes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("slice_sizes", + propStorage)); + } + + { + const auto &propStorage = prop.start_index_map; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("start_index_map", + propStorage)); + } + + { + const auto &propStorage = prop.start_indices_batching_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("start_indices_batching_dims", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GatherOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.collapsed_slice_dims.getAsOpaquePointer()), + llvm::hash_value(prop.index_vector_dim.getAsOpaquePointer()), + llvm::hash_value(prop.indices_are_sorted.getAsOpaquePointer()), + llvm::hash_value(prop.offset_dims.getAsOpaquePointer()), + llvm::hash_value(prop.operand_batching_dims.getAsOpaquePointer()), + llvm::hash_value(prop.slice_sizes.getAsOpaquePointer()), + llvm::hash_value(prop.start_index_map.getAsOpaquePointer()), + llvm::hash_value(prop.start_indices_batching_dims.getAsOpaquePointer())); +} + +std::optional GatherOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "collapsed_slice_dims") + return prop.collapsed_slice_dims; + + if (name == "index_vector_dim") + return prop.index_vector_dim; + + if (name == "indices_are_sorted") + return prop.indices_are_sorted; + + if (name == "offset_dims") + return prop.offset_dims; + + if (name == "operand_batching_dims") + return prop.operand_batching_dims; + + if (name == "slice_sizes") + return prop.slice_sizes; + + if (name == "start_index_map") + return prop.start_index_map; + + if (name == "start_indices_batching_dims") + return prop.start_indices_batching_dims; + return std::nullopt; +} + +void GatherOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "collapsed_slice_dims") { + prop.collapsed_slice_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "index_vector_dim") { + prop.index_vector_dim = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "indices_are_sorted") { + prop.indices_are_sorted = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "offset_dims") { + prop.offset_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "operand_batching_dims") { + prop.operand_batching_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "slice_sizes") { + prop.slice_sizes = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "start_index_map") { + prop.start_index_map = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "start_indices_batching_dims") { + prop.start_indices_batching_dims = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GatherOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.collapsed_slice_dims) attrs.append("collapsed_slice_dims", prop.collapsed_slice_dims); + + if (prop.index_vector_dim) attrs.append("index_vector_dim", prop.index_vector_dim); + + if (prop.indices_are_sorted) attrs.append("indices_are_sorted", prop.indices_are_sorted); + + if (prop.offset_dims) attrs.append("offset_dims", prop.offset_dims); + + if (prop.operand_batching_dims) attrs.append("operand_batching_dims", prop.operand_batching_dims); + + if (prop.slice_sizes) attrs.append("slice_sizes", prop.slice_sizes); + + if (prop.start_index_map) attrs.append("start_index_map", prop.start_index_map); + + if (prop.start_indices_batching_dims) attrs.append("start_indices_batching_dims", prop.start_indices_batching_dims); +} + +::llvm::LogicalResult GatherOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getCollapsedSliceDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "collapsed_slice_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIndexVectorDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "index_vector_dim", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIndicesAreSortedAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "indices_are_sorted", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOffsetDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "offset_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOperandBatchingDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "operand_batching_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSliceSizesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "slice_sizes", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStartIndexMapAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "start_index_map", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStartIndicesBatchingDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "start_indices_batching_dims", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult GatherOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.collapsed_slice_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.index_vector_dim))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.indices_are_sorted))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.offset_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.operand_batching_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.slice_sizes))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.start_index_map))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.start_indices_batching_dims))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GatherOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.collapsed_slice_dims); + writer.writeAttribute(prop.index_vector_dim); + writer.writeAttribute(prop.indices_are_sorted); + writer.writeAttribute(prop.offset_dims); + writer.writeAttribute(prop.operand_batching_dims); + writer.writeAttribute(prop.slice_sizes); + writer.writeAttribute(prop.start_index_map); + writer.writeAttribute(prop.start_indices_batching_dims); +} + +::mlir::Attribute GatherOpV2::getOffsetDims() { + auto attr = getOffsetDimsAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2::getCollapsedSliceDims() { + auto attr = getCollapsedSliceDimsAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2::getOperandBatchingDims() { + auto attr = getOperandBatchingDimsAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2::getStartIndicesBatchingDims() { + auto attr = getStartIndicesBatchingDimsAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2::getStartIndexMap() { + auto attr = getStartIndexMapAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2::getIndexVectorDim() { + auto attr = getIndexVectorDimAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2::getSliceSizes() { + auto attr = getSliceSizesAttr(); + return attr; +} + +::mlir::Attribute GatherOpV2::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + return attr; +} + +void GatherOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute operand_batching_dims, ::mlir::Attribute start_indices_batching_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute slice_sizes, ::mlir::Attribute indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().offset_dims = offset_dims; + odsState.getOrAddProperties().collapsed_slice_dims = collapsed_slice_dims; + odsState.getOrAddProperties().operand_batching_dims = operand_batching_dims; + odsState.getOrAddProperties().start_indices_batching_dims = start_indices_batching_dims; + odsState.getOrAddProperties().start_index_map = start_index_map; + odsState.getOrAddProperties().index_vector_dim = index_vector_dim; + odsState.getOrAddProperties().slice_sizes = slice_sizes; + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + odsState.addTypes(result); +} + +void GatherOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute operand_batching_dims, ::mlir::Attribute start_indices_batching_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute slice_sizes, ::mlir::Attribute indices_are_sorted) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.getOrAddProperties().offset_dims = offset_dims; + odsState.getOrAddProperties().collapsed_slice_dims = collapsed_slice_dims; + odsState.getOrAddProperties().operand_batching_dims = operand_batching_dims; + odsState.getOrAddProperties().start_indices_batching_dims = start_indices_batching_dims; + odsState.getOrAddProperties().start_index_map = start_index_map; + odsState.getOrAddProperties().index_vector_dim = index_vector_dim; + odsState.getOrAddProperties().slice_sizes = slice_sizes; + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GatherOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void GatherOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult GatherOpV2::verifyInvariantsImpl() { + auto tblgen_collapsed_slice_dims = getProperties().collapsed_slice_dims; (void)tblgen_collapsed_slice_dims; + if (!tblgen_collapsed_slice_dims) return emitOpError("requires attribute 'collapsed_slice_dims'"); + auto tblgen_index_vector_dim = getProperties().index_vector_dim; (void)tblgen_index_vector_dim; + if (!tblgen_index_vector_dim) return emitOpError("requires attribute 'index_vector_dim'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + if (!tblgen_indices_are_sorted) return emitOpError("requires attribute 'indices_are_sorted'"); + auto tblgen_offset_dims = getProperties().offset_dims; (void)tblgen_offset_dims; + if (!tblgen_offset_dims) return emitOpError("requires attribute 'offset_dims'"); + auto tblgen_operand_batching_dims = getProperties().operand_batching_dims; (void)tblgen_operand_batching_dims; + if (!tblgen_operand_batching_dims) return emitOpError("requires attribute 'operand_batching_dims'"); + auto tblgen_slice_sizes = getProperties().slice_sizes; (void)tblgen_slice_sizes; + if (!tblgen_slice_sizes) return emitOpError("requires attribute 'slice_sizes'"); + auto tblgen_start_index_map = getProperties().start_index_map; (void)tblgen_start_index_map; + if (!tblgen_start_index_map) return emitOpError("requires attribute 'start_index_map'"); + auto tblgen_start_indices_batching_dims = getProperties().start_indices_batching_dims; (void)tblgen_start_indices_batching_dims; + if (!tblgen_start_indices_batching_dims) return emitOpError("requires attribute 'start_indices_batching_dims'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_offset_dims, "offset_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_collapsed_slice_dims, "collapsed_slice_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_operand_batching_dims, "operand_batching_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_start_indices_batching_dims, "start_indices_batching_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_start_index_map, "start_index_map"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_index_vector_dim, "index_vector_dim"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_slice_sizes, "slice_sizes"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_indices_are_sorted, "indices_are_sorted"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult GatherOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version GatherOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 1, 0); +} +mlir::vhlo::Version GatherOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::GatherOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::GetDimensionSizeOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GetDimensionSizeOpV1GenericAdaptorBase::GetDimensionSizeOpV1GenericAdaptorBase(GetDimensionSizeOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute GetDimensionSizeOpV1GenericAdaptorBase::getDimension() { + auto attr = getDimensionAttr(); + return attr; +} + +} // namespace detail +GetDimensionSizeOpV1Adaptor::GetDimensionSizeOpV1Adaptor(GetDimensionSizeOpV1 op) : GetDimensionSizeOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult GetDimensionSizeOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitError(loc, "'vhlo.get_dimension_size_v1' op ""requires attribute 'dimension'"); + + if (tblgen_dimension && !((true))) + return emitError(loc, "'vhlo.get_dimension_size_v1' op ""attribute 'dimension' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult GetDimensionSizeOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimension; + auto attr = dict.get("dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GetDimensionSizeOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GetDimensionSizeOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimension.getAsOpaquePointer())); +} + +std::optional GetDimensionSizeOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimension") + return prop.dimension; + return std::nullopt; +} + +void GetDimensionSizeOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimension") { + prop.dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GetDimensionSizeOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimension) attrs.append("dimension", prop.dimension); +} + +::llvm::LogicalResult GetDimensionSizeOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult GetDimensionSizeOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetDimensionSizeOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimension); +} + +::mlir::Attribute GetDimensionSizeOpV1::getDimension() { + auto attr = getDimensionAttr(); + return attr; +} + +void GetDimensionSizeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute dimension) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimension = dimension; + odsState.addTypes(result); +} + +void GetDimensionSizeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute dimension) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimension = dimension; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetDimensionSizeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void GetDimensionSizeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult GetDimensionSizeOpV1::verifyInvariantsImpl() { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitOpError("requires attribute 'dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_dimension, "dimension"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult GetDimensionSizeOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version GetDimensionSizeOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version GetDimensionSizeOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::GetDimensionSizeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::GetTupleElementOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GetTupleElementOpV1GenericAdaptorBase::GetTupleElementOpV1GenericAdaptorBase(GetTupleElementOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute GetTupleElementOpV1GenericAdaptorBase::getIndex() { + auto attr = getIndexAttr(); + return attr; +} + +} // namespace detail +GetTupleElementOpV1Adaptor::GetTupleElementOpV1Adaptor(GetTupleElementOpV1 op) : GetTupleElementOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult GetTupleElementOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_index = getProperties().index; (void)tblgen_index; + if (!tblgen_index) return emitError(loc, "'vhlo.get_tuple_element_v1' op ""requires attribute 'index'"); + + if (tblgen_index && !((true))) + return emitError(loc, "'vhlo.get_tuple_element_v1' op ""attribute 'index' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult GetTupleElementOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.index; + auto attr = dict.get("index"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `index` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GetTupleElementOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.index; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("index", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GetTupleElementOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.index.getAsOpaquePointer())); +} + +std::optional GetTupleElementOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "index") + return prop.index; + return std::nullopt; +} + +void GetTupleElementOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "index") { + prop.index = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GetTupleElementOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.index) attrs.append("index", prop.index); +} + +::llvm::LogicalResult GetTupleElementOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getIndexAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "index", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult GetTupleElementOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.index))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetTupleElementOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.index); +} + +::mlir::Attribute GetTupleElementOpV1::getIndex() { + auto attr = getIndexAttr(); + return attr; +} + +void GetTupleElementOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute index) { + odsState.addOperands(operand); + odsState.getOrAddProperties().index = index; + odsState.addTypes(result); +} + +void GetTupleElementOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute index) { + odsState.addOperands(operand); + odsState.getOrAddProperties().index = index; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetTupleElementOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void GetTupleElementOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult GetTupleElementOpV1::verifyInvariantsImpl() { + auto tblgen_index = getProperties().index; (void)tblgen_index; + if (!tblgen_index) return emitOpError("requires attribute 'index'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_index, "index"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult GetTupleElementOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version GetTupleElementOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version GetTupleElementOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::GetTupleElementOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::IfOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IfOpV1GenericAdaptorBase::IfOpV1GenericAdaptorBase(IfOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +IfOpV1Adaptor::IfOpV1Adaptor(IfOpV1 op) : IfOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult IfOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair IfOpV1::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult IfOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute IfOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code IfOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional IfOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void IfOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void IfOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult IfOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void IfOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value pred) { + odsState.addOperands(pred); + (void)odsState.addRegion(); + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void IfOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void IfOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult IfOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "true_branch", index++))) + return ::mlir::failure(); + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "false_branch", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult IfOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version IfOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version IfOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IfOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ImagOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ImagOpV1GenericAdaptorBase::ImagOpV1GenericAdaptorBase(ImagOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ImagOpV1Adaptor::ImagOpV1Adaptor(ImagOpV1 op) : ImagOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ImagOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ImagOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ImagOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ImagOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ImagOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ImagOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ImagOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ImagOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ImagOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void ImagOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ImagOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ImagOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ImagOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ImagOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ImagOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ImagOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ImagOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::InfeedOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +InfeedOpV1GenericAdaptorBase::InfeedOpV1GenericAdaptorBase(InfeedOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute InfeedOpV1GenericAdaptorBase::getInfeedConfig() { + auto attr = getInfeedConfigAttr(); + return attr; +} + +::mlir::Attribute InfeedOpV1GenericAdaptorBase::getLayout() { + auto attr = getLayoutAttr(); + return attr; +} + +} // namespace detail +InfeedOpV1Adaptor::InfeedOpV1Adaptor(InfeedOpV1 op) : InfeedOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult InfeedOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_infeed_config = getProperties().infeed_config; (void)tblgen_infeed_config; + if (!tblgen_infeed_config) return emitError(loc, "'vhlo.infeed_v1' op ""requires attribute 'infeed_config'"); + auto tblgen_layout = getProperties().layout; (void)tblgen_layout; + if (!tblgen_layout) return emitError(loc, "'vhlo.infeed_v1' op ""requires attribute 'layout'"); + + if (tblgen_infeed_config && !((true))) + return emitError(loc, "'vhlo.infeed_v1' op ""attribute 'infeed_config' failed to satisfy constraint: any attribute"); + + if (tblgen_layout && !((true))) + return emitError(loc, "'vhlo.infeed_v1' op ""attribute 'layout' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair InfeedOpV1::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult InfeedOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.infeed_config; + auto attr = dict.get("infeed_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `infeed_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.layout; + auto attr = dict.get("layout"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `layout` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute InfeedOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.infeed_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("infeed_config", + propStorage)); + } + + { + const auto &propStorage = prop.layout; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("layout", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code InfeedOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.infeed_config.getAsOpaquePointer()), + llvm::hash_value(prop.layout.getAsOpaquePointer())); +} + +std::optional InfeedOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "infeed_config") + return prop.infeed_config; + + if (name == "layout") + return prop.layout; + return std::nullopt; +} + +void InfeedOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "infeed_config") { + prop.infeed_config = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "layout") { + prop.layout = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void InfeedOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.infeed_config) attrs.append("infeed_config", prop.infeed_config); + + if (prop.layout) attrs.append("layout", prop.layout); +} + +::llvm::LogicalResult InfeedOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getInfeedConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "infeed_config", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLayoutAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "layout", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult InfeedOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.infeed_config))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.layout))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void InfeedOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.infeed_config); + writer.writeAttribute(prop.layout); +} + +::mlir::Attribute InfeedOpV1::getInfeedConfig() { + auto attr = getInfeedConfigAttr(); + return attr; +} + +::mlir::Attribute InfeedOpV1::getLayout() { + auto attr = getLayoutAttr(); + return attr; +} + +void InfeedOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value token, ::mlir::Attribute infeed_config, ::mlir::Attribute layout) { + odsState.addOperands(token); + odsState.getOrAddProperties().infeed_config = infeed_config; + odsState.getOrAddProperties().layout = layout; + odsState.addTypes(results); +} + +void InfeedOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void InfeedOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult InfeedOpV1::verifyInvariantsImpl() { + auto tblgen_infeed_config = getProperties().infeed_config; (void)tblgen_infeed_config; + if (!tblgen_infeed_config) return emitOpError("requires attribute 'infeed_config'"); + auto tblgen_layout = getProperties().layout; (void)tblgen_layout; + if (!tblgen_layout) return emitOpError("requires attribute 'layout'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_infeed_config, "infeed_config"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_layout, "layout"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult InfeedOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version InfeedOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version InfeedOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::InfeedOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::IotaOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IotaOpV1GenericAdaptorBase::IotaOpV1GenericAdaptorBase(IotaOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute IotaOpV1GenericAdaptorBase::getIotaDimension() { + auto attr = getIotaDimensionAttr(); + return attr; +} + +} // namespace detail +IotaOpV1Adaptor::IotaOpV1Adaptor(IotaOpV1 op) : IotaOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult IotaOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_iota_dimension = getProperties().iota_dimension; (void)tblgen_iota_dimension; + if (!tblgen_iota_dimension) return emitError(loc, "'vhlo.iota_v1' op ""requires attribute 'iota_dimension'"); + + if (tblgen_iota_dimension && !((true))) + return emitError(loc, "'vhlo.iota_v1' op ""attribute 'iota_dimension' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult IotaOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.iota_dimension; + auto attr = dict.get("iota_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `iota_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute IotaOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.iota_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("iota_dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code IotaOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.iota_dimension.getAsOpaquePointer())); +} + +std::optional IotaOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "iota_dimension") + return prop.iota_dimension; + return std::nullopt; +} + +void IotaOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "iota_dimension") { + prop.iota_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void IotaOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.iota_dimension) attrs.append("iota_dimension", prop.iota_dimension); +} + +::llvm::LogicalResult IotaOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getIotaDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "iota_dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult IotaOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.iota_dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void IotaOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.iota_dimension); +} + +::mlir::Attribute IotaOpV1::getIotaDimension() { + auto attr = getIotaDimensionAttr(); + return attr; +} + +void IotaOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Attribute iota_dimension) { + odsState.getOrAddProperties().iota_dimension = iota_dimension; + odsState.addTypes(output); +} + +void IotaOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Attribute iota_dimension) { + odsState.getOrAddProperties().iota_dimension = iota_dimension; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void IotaOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void IotaOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult IotaOpV1::verifyInvariantsImpl() { + auto tblgen_iota_dimension = getProperties().iota_dimension; (void)tblgen_iota_dimension; + if (!tblgen_iota_dimension) return emitOpError("requires attribute 'iota_dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_iota_dimension, "iota_dimension"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult IotaOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version IotaOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version IotaOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IotaOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::IsFiniteOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IsFiniteOpV1GenericAdaptorBase::IsFiniteOpV1GenericAdaptorBase(IsFiniteOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +IsFiniteOpV1Adaptor::IsFiniteOpV1Adaptor(IsFiniteOpV1 op) : IsFiniteOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult IsFiniteOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult IsFiniteOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute IsFiniteOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code IsFiniteOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional IsFiniteOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void IsFiniteOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void IsFiniteOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult IsFiniteOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void IsFiniteOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type y, ::mlir::Value x) { + odsState.addOperands(x); + odsState.addTypes(y); +} + +void IsFiniteOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x) { + odsState.addOperands(x); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void IsFiniteOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void IsFiniteOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult IsFiniteOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult IsFiniteOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version IsFiniteOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version IsFiniteOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IsFiniteOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::Log1pOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +Log1pOpV1GenericAdaptorBase::Log1pOpV1GenericAdaptorBase(Log1pOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +Log1pOpV1Adaptor::Log1pOpV1Adaptor(Log1pOpV1 op) : Log1pOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult Log1pOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult Log1pOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute Log1pOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code Log1pOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional Log1pOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void Log1pOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void Log1pOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult Log1pOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void Log1pOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void Log1pOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void Log1pOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void Log1pOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult Log1pOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult Log1pOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version Log1pOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version Log1pOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 9, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::Log1pOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::Log1pOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +Log1pOpV2GenericAdaptorBase::Log1pOpV2GenericAdaptorBase(Log1pOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute Log1pOpV2GenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +} // namespace detail +Log1pOpV2Adaptor::Log1pOpV2Adaptor(Log1pOpV2 op) : Log1pOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult Log1pOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitError(loc, "'vhlo.log_plus_one_v2' op ""requires attribute 'result_accuracy'"); + + if (tblgen_result_accuracy && !((true))) + return emitError(loc, "'vhlo.log_plus_one_v2' op ""attribute 'result_accuracy' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult Log1pOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute Log1pOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code Log1pOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional Log1pOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void Log1pOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void Log1pOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult Log1pOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult Log1pOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void Log1pOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_accuracy); +} + +::mlir::Attribute Log1pOpV2::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +void Log1pOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + odsState.addTypes(result); +} + +void Log1pOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void Log1pOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void Log1pOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult Log1pOpV2::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitOpError("requires attribute 'result_accuracy'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult Log1pOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version Log1pOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 10, 0); +} +mlir::vhlo::Version Log1pOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::Log1pOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::LogOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +LogOpV1GenericAdaptorBase::LogOpV1GenericAdaptorBase(LogOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +LogOpV1Adaptor::LogOpV1Adaptor(LogOpV1 op) : LogOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult LogOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult LogOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute LogOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code LogOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional LogOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void LogOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void LogOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult LogOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void LogOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void LogOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void LogOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void LogOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult LogOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult LogOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version LogOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version LogOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 9, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::LogOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::LogOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +LogOpV2GenericAdaptorBase::LogOpV2GenericAdaptorBase(LogOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute LogOpV2GenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +} // namespace detail +LogOpV2Adaptor::LogOpV2Adaptor(LogOpV2 op) : LogOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult LogOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitError(loc, "'vhlo.log_v2' op ""requires attribute 'result_accuracy'"); + + if (tblgen_result_accuracy && !((true))) + return emitError(loc, "'vhlo.log_v2' op ""attribute 'result_accuracy' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult LogOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute LogOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code LogOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional LogOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void LogOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void LogOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult LogOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult LogOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void LogOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_accuracy); +} + +::mlir::Attribute LogOpV2::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +void LogOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + odsState.addTypes(result); +} + +void LogOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void LogOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void LogOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult LogOpV2::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitOpError("requires attribute 'result_accuracy'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult LogOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version LogOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 10, 0); +} +mlir::vhlo::Version LogOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::LogOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::LogisticOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +LogisticOpV1GenericAdaptorBase::LogisticOpV1GenericAdaptorBase(LogisticOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +LogisticOpV1Adaptor::LogisticOpV1Adaptor(LogisticOpV1 op) : LogisticOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult LogisticOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult LogisticOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute LogisticOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code LogisticOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional LogisticOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void LogisticOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void LogisticOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult LogisticOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void LogisticOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void LogisticOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void LogisticOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void LogisticOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult LogisticOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult LogisticOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version LogisticOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version LogisticOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 9, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::LogisticOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::LogisticOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +LogisticOpV2GenericAdaptorBase::LogisticOpV2GenericAdaptorBase(LogisticOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute LogisticOpV2GenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +} // namespace detail +LogisticOpV2Adaptor::LogisticOpV2Adaptor(LogisticOpV2 op) : LogisticOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult LogisticOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitError(loc, "'vhlo.logistic_v2' op ""requires attribute 'result_accuracy'"); + + if (tblgen_result_accuracy && !((true))) + return emitError(loc, "'vhlo.logistic_v2' op ""attribute 'result_accuracy' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult LogisticOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute LogisticOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code LogisticOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional LogisticOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void LogisticOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void LogisticOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult LogisticOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult LogisticOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void LogisticOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_accuracy); +} + +::mlir::Attribute LogisticOpV2::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +void LogisticOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + odsState.addTypes(result); +} + +void LogisticOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void LogisticOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void LogisticOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult LogisticOpV2::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitOpError("requires attribute 'result_accuracy'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult LogisticOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version LogisticOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 10, 0); +} +mlir::vhlo::Version LogisticOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::LogisticOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::MapOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MapOpV1GenericAdaptorBase::MapOpV1GenericAdaptorBase(MapOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair MapOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute MapOpV1GenericAdaptorBase::getDimensions() { + auto attr = getDimensionsAttr(); + return attr; +} + +} // namespace detail +MapOpV1Adaptor::MapOpV1Adaptor(MapOpV1 op) : MapOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult MapOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_dimensions = getProperties().dimensions; (void)tblgen_dimensions; + if (!tblgen_dimensions) return emitError(loc, "'vhlo.map_v1' op ""requires attribute 'dimensions'"); + + if (tblgen_dimensions && !((true))) + return emitError(loc, "'vhlo.map_v1' op ""attribute 'dimensions' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair MapOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange MapOpV1::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult MapOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimensions; + auto attr = dict.get("dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute MapOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MapOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimensions.getAsOpaquePointer())); +} + +std::optional MapOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimensions") + return prop.dimensions; + return std::nullopt; +} + +void MapOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimensions") { + prop.dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void MapOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimensions) attrs.append("dimensions", prop.dimensions); +} + +::llvm::LogicalResult MapOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult MapOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MapOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimensions); +} + +::mlir::Attribute MapOpV1::getDimensions() { + auto attr = getDimensionsAttr(); + return attr; +} + +void MapOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs, ::mlir::Attribute dimensions) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimensions = dimensions; + (void)odsState.addRegion(); + odsState.addTypes(result); +} + +void MapOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Attribute dimensions) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimensions = dimensions; + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MapOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void MapOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult MapOpV1::verifyInvariantsImpl() { + auto tblgen_dimensions = getProperties().dimensions; (void)tblgen_dimensions; + if (!tblgen_dimensions) return emitOpError("requires attribute 'dimensions'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_dimensions, "dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "computation", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult MapOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version MapOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version MapOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::MapOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::MaxOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaxOpV1GenericAdaptorBase::MaxOpV1GenericAdaptorBase(MaxOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +MaxOpV1Adaptor::MaxOpV1Adaptor(MaxOpV1 op) : MaxOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult MaxOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult MaxOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute MaxOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MaxOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional MaxOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void MaxOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void MaxOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult MaxOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void MaxOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void MaxOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MaxOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MaxOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult MaxOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult MaxOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version MaxOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version MaxOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::MaxOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::MinOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MinOpV1GenericAdaptorBase::MinOpV1GenericAdaptorBase(MinOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +MinOpV1Adaptor::MinOpV1Adaptor(MinOpV1 op) : MinOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult MinOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult MinOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute MinOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MinOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional MinOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void MinOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void MinOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult MinOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void MinOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void MinOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MinOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MinOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult MinOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult MinOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version MinOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version MinOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::MinOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::MulOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MulOpV1GenericAdaptorBase::MulOpV1GenericAdaptorBase(MulOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +MulOpV1Adaptor::MulOpV1Adaptor(MulOpV1 op) : MulOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult MulOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult MulOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute MulOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MulOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional MulOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void MulOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void MulOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult MulOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void MulOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void MulOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MulOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MulOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult MulOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult MulOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version MulOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version MulOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::MulOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::NegOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +NegOpV1GenericAdaptorBase::NegOpV1GenericAdaptorBase(NegOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +NegOpV1Adaptor::NegOpV1Adaptor(NegOpV1 op) : NegOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult NegOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult NegOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute NegOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code NegOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional NegOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void NegOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void NegOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult NegOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void NegOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void NegOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void NegOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void NegOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult NegOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult NegOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version NegOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version NegOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::NegOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::NotOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +NotOpV1GenericAdaptorBase::NotOpV1GenericAdaptorBase(NotOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +NotOpV1Adaptor::NotOpV1Adaptor(NotOpV1 op) : NotOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult NotOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult NotOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute NotOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code NotOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional NotOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void NotOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void NotOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult NotOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void NotOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void NotOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void NotOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void NotOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult NotOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult NotOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version NotOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version NotOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::NotOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::OptimizationBarrierOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +OptimizationBarrierOpV1GenericAdaptorBase::OptimizationBarrierOpV1GenericAdaptorBase(OptimizationBarrierOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair OptimizationBarrierOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +} // namespace detail +OptimizationBarrierOpV1Adaptor::OptimizationBarrierOpV1Adaptor(OptimizationBarrierOpV1 op) : OptimizationBarrierOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult OptimizationBarrierOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair OptimizationBarrierOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange OptimizationBarrierOpV1::getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair OptimizationBarrierOpV1::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult OptimizationBarrierOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute OptimizationBarrierOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code OptimizationBarrierOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional OptimizationBarrierOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void OptimizationBarrierOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void OptimizationBarrierOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult OptimizationBarrierOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void OptimizationBarrierOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); +} + +void OptimizationBarrierOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult OptimizationBarrierOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult OptimizationBarrierOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version OptimizationBarrierOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version OptimizationBarrierOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::OptimizationBarrierOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::OrOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +OrOpV1GenericAdaptorBase::OrOpV1GenericAdaptorBase(OrOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +OrOpV1Adaptor::OrOpV1Adaptor(OrOpV1 op) : OrOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult OrOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult OrOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute OrOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code OrOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional OrOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void OrOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void OrOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult OrOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void OrOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void OrOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void OrOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void OrOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult OrOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult OrOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version OrOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version OrOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::OrOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::OutfeedOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +OutfeedOpV1GenericAdaptorBase::OutfeedOpV1GenericAdaptorBase(OutfeedOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair OutfeedOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute OutfeedOpV1GenericAdaptorBase::getOutfeedConfig() { + auto attr = getOutfeedConfigAttr(); + return attr; +} + +} // namespace detail +OutfeedOpV1Adaptor::OutfeedOpV1Adaptor(OutfeedOpV1 op) : OutfeedOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult OutfeedOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_outfeed_config = getProperties().outfeed_config; (void)tblgen_outfeed_config; + if (!tblgen_outfeed_config) return emitError(loc, "'vhlo.outfeed_v1' op ""requires attribute 'outfeed_config'"); + + if (tblgen_outfeed_config && !((true))) + return emitError(loc, "'vhlo.outfeed_v1' op ""attribute 'outfeed_config' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair OutfeedOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange OutfeedOpV1::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult OutfeedOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.outfeed_config; + auto attr = dict.get("outfeed_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `outfeed_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute OutfeedOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.outfeed_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("outfeed_config", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code OutfeedOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.outfeed_config.getAsOpaquePointer())); +} + +std::optional OutfeedOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "outfeed_config") + return prop.outfeed_config; + return std::nullopt; +} + +void OutfeedOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "outfeed_config") { + prop.outfeed_config = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void OutfeedOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.outfeed_config) attrs.append("outfeed_config", prop.outfeed_config); +} + +::llvm::LogicalResult OutfeedOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getOutfeedConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "outfeed_config", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult OutfeedOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.outfeed_config))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void OutfeedOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.outfeed_config); +} + +::mlir::Attribute OutfeedOpV1::getOutfeedConfig() { + auto attr = getOutfeedConfigAttr(); + return attr; +} + +void OutfeedOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::Attribute outfeed_config) { + odsState.addOperands(inputs); + odsState.addOperands(token); + odsState.getOrAddProperties().outfeed_config = outfeed_config; + odsState.addTypes(result); +} + +void OutfeedOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::Attribute outfeed_config) { + odsState.addOperands(inputs); + odsState.addOperands(token); + odsState.getOrAddProperties().outfeed_config = outfeed_config; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void OutfeedOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void OutfeedOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult OutfeedOpV1::verifyInvariantsImpl() { + auto tblgen_outfeed_config = getProperties().outfeed_config; (void)tblgen_outfeed_config; + if (!tblgen_outfeed_config) return emitOpError("requires attribute 'outfeed_config'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_outfeed_config, "outfeed_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult OutfeedOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version OutfeedOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version OutfeedOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::OutfeedOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::PadOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PadOpV1GenericAdaptorBase::PadOpV1GenericAdaptorBase(PadOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute PadOpV1GenericAdaptorBase::getEdgePaddingLow() { + auto attr = getEdgePaddingLowAttr(); + return attr; +} + +::mlir::Attribute PadOpV1GenericAdaptorBase::getEdgePaddingHigh() { + auto attr = getEdgePaddingHighAttr(); + return attr; +} + +::mlir::Attribute PadOpV1GenericAdaptorBase::getInteriorPadding() { + auto attr = getInteriorPaddingAttr(); + return attr; +} + +} // namespace detail +PadOpV1Adaptor::PadOpV1Adaptor(PadOpV1 op) : PadOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult PadOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_edge_padding_high = getProperties().edge_padding_high; (void)tblgen_edge_padding_high; + if (!tblgen_edge_padding_high) return emitError(loc, "'vhlo.pad_v1' op ""requires attribute 'edge_padding_high'"); + auto tblgen_edge_padding_low = getProperties().edge_padding_low; (void)tblgen_edge_padding_low; + if (!tblgen_edge_padding_low) return emitError(loc, "'vhlo.pad_v1' op ""requires attribute 'edge_padding_low'"); + auto tblgen_interior_padding = getProperties().interior_padding; (void)tblgen_interior_padding; + if (!tblgen_interior_padding) return emitError(loc, "'vhlo.pad_v1' op ""requires attribute 'interior_padding'"); + + if (tblgen_edge_padding_low && !((true))) + return emitError(loc, "'vhlo.pad_v1' op ""attribute 'edge_padding_low' failed to satisfy constraint: any attribute"); + + if (tblgen_edge_padding_high && !((true))) + return emitError(loc, "'vhlo.pad_v1' op ""attribute 'edge_padding_high' failed to satisfy constraint: any attribute"); + + if (tblgen_interior_padding && !((true))) + return emitError(loc, "'vhlo.pad_v1' op ""attribute 'interior_padding' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult PadOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.edge_padding_high; + auto attr = dict.get("edge_padding_high"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `edge_padding_high` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.edge_padding_low; + auto attr = dict.get("edge_padding_low"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `edge_padding_low` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.interior_padding; + auto attr = dict.get("interior_padding"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `interior_padding` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute PadOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.edge_padding_high; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("edge_padding_high", + propStorage)); + } + + { + const auto &propStorage = prop.edge_padding_low; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("edge_padding_low", + propStorage)); + } + + { + const auto &propStorage = prop.interior_padding; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("interior_padding", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PadOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.edge_padding_high.getAsOpaquePointer()), + llvm::hash_value(prop.edge_padding_low.getAsOpaquePointer()), + llvm::hash_value(prop.interior_padding.getAsOpaquePointer())); +} + +std::optional PadOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "edge_padding_high") + return prop.edge_padding_high; + + if (name == "edge_padding_low") + return prop.edge_padding_low; + + if (name == "interior_padding") + return prop.interior_padding; + return std::nullopt; +} + +void PadOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "edge_padding_high") { + prop.edge_padding_high = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "edge_padding_low") { + prop.edge_padding_low = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "interior_padding") { + prop.interior_padding = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void PadOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.edge_padding_high) attrs.append("edge_padding_high", prop.edge_padding_high); + + if (prop.edge_padding_low) attrs.append("edge_padding_low", prop.edge_padding_low); + + if (prop.interior_padding) attrs.append("interior_padding", prop.interior_padding); +} + +::llvm::LogicalResult PadOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getEdgePaddingHighAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "edge_padding_high", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getEdgePaddingLowAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "edge_padding_low", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInteriorPaddingAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "interior_padding", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult PadOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.edge_padding_high))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.edge_padding_low))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.interior_padding))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PadOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.edge_padding_high); + writer.writeAttribute(prop.edge_padding_low); + writer.writeAttribute(prop.interior_padding); +} + +::mlir::Attribute PadOpV1::getEdgePaddingLow() { + auto attr = getEdgePaddingLowAttr(); + return attr; +} + +::mlir::Attribute PadOpV1::getEdgePaddingHigh() { + auto attr = getEdgePaddingHighAttr(); + return attr; +} + +::mlir::Attribute PadOpV1::getInteriorPadding() { + auto attr = getInteriorPaddingAttr(); + return attr; +} + +void PadOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::Attribute edge_padding_low, ::mlir::Attribute edge_padding_high, ::mlir::Attribute interior_padding) { + odsState.addOperands(operand); + odsState.addOperands(padding_value); + odsState.getOrAddProperties().edge_padding_low = edge_padding_low; + odsState.getOrAddProperties().edge_padding_high = edge_padding_high; + odsState.getOrAddProperties().interior_padding = interior_padding; + odsState.addTypes(result); +} + +void PadOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::Attribute edge_padding_low, ::mlir::Attribute edge_padding_high, ::mlir::Attribute interior_padding) { + odsState.addOperands(operand); + odsState.addOperands(padding_value); + odsState.getOrAddProperties().edge_padding_low = edge_padding_low; + odsState.getOrAddProperties().edge_padding_high = edge_padding_high; + odsState.getOrAddProperties().interior_padding = interior_padding; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PadOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void PadOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult PadOpV1::verifyInvariantsImpl() { + auto tblgen_edge_padding_high = getProperties().edge_padding_high; (void)tblgen_edge_padding_high; + if (!tblgen_edge_padding_high) return emitOpError("requires attribute 'edge_padding_high'"); + auto tblgen_edge_padding_low = getProperties().edge_padding_low; (void)tblgen_edge_padding_low; + if (!tblgen_edge_padding_low) return emitOpError("requires attribute 'edge_padding_low'"); + auto tblgen_interior_padding = getProperties().interior_padding; (void)tblgen_interior_padding; + if (!tblgen_interior_padding) return emitOpError("requires attribute 'interior_padding'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_edge_padding_low, "edge_padding_low"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_edge_padding_high, "edge_padding_high"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_interior_padding, "interior_padding"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult PadOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version PadOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version PadOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::PadOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::PartitionIdOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PartitionIdOpV1GenericAdaptorBase::PartitionIdOpV1GenericAdaptorBase(PartitionIdOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +PartitionIdOpV1Adaptor::PartitionIdOpV1Adaptor(PartitionIdOpV1 op) : PartitionIdOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult PartitionIdOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult PartitionIdOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute PartitionIdOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PartitionIdOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional PartitionIdOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void PartitionIdOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void PartitionIdOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult PartitionIdOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void PartitionIdOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result) { + odsState.addTypes(result); +} + +void PartitionIdOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PartitionIdOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PartitionIdOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult PartitionIdOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult PartitionIdOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version PartitionIdOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version PartitionIdOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::PartitionIdOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::PopulationCountOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PopulationCountOpV1GenericAdaptorBase::PopulationCountOpV1GenericAdaptorBase(PopulationCountOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +PopulationCountOpV1Adaptor::PopulationCountOpV1Adaptor(PopulationCountOpV1 op) : PopulationCountOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult PopulationCountOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult PopulationCountOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute PopulationCountOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PopulationCountOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional PopulationCountOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void PopulationCountOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void PopulationCountOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult PopulationCountOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void PopulationCountOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void PopulationCountOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PopulationCountOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PopulationCountOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult PopulationCountOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult PopulationCountOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version PopulationCountOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version PopulationCountOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::PopulationCountOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::PowOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PowOpV1GenericAdaptorBase::PowOpV1GenericAdaptorBase(PowOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +PowOpV1Adaptor::PowOpV1Adaptor(PowOpV1 op) : PowOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult PowOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult PowOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute PowOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PowOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional PowOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void PowOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void PowOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult PowOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void PowOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void PowOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PowOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PowOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult PowOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult PowOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version PowOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version PowOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::PowOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RealDynamicSliceOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RealDynamicSliceOpV1GenericAdaptorBase::RealDynamicSliceOpV1GenericAdaptorBase(RealDynamicSliceOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +RealDynamicSliceOpV1Adaptor::RealDynamicSliceOpV1Adaptor(RealDynamicSliceOpV1 op) : RealDynamicSliceOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RealDynamicSliceOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult RealDynamicSliceOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute RealDynamicSliceOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RealDynamicSliceOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional RealDynamicSliceOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void RealDynamicSliceOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void RealDynamicSliceOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult RealDynamicSliceOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void RealDynamicSliceOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value limit_indices, ::mlir::Value strides) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(limit_indices); + odsState.addOperands(strides); + odsState.addTypes(result); +} + +void RealDynamicSliceOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value limit_indices, ::mlir::Value strides) { + odsState.addOperands(operand); + odsState.addOperands(start_indices); + odsState.addOperands(limit_indices); + odsState.addOperands(strides); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RealDynamicSliceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 4u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RealDynamicSliceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 4u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RealDynamicSliceOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RealDynamicSliceOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version RealDynamicSliceOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version RealDynamicSliceOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::RealDynamicSliceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RealOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RealOpV1GenericAdaptorBase::RealOpV1GenericAdaptorBase(RealOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +RealOpV1Adaptor::RealOpV1Adaptor(RealOpV1 op) : RealOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RealOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult RealOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute RealOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RealOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional RealOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void RealOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void RealOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult RealOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void RealOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void RealOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RealOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RealOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RealOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RealOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version RealOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version RealOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::RealOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RecvOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RecvOpV1GenericAdaptorBase::RecvOpV1GenericAdaptorBase(RecvOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute RecvOpV1GenericAdaptorBase::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute RecvOpV1GenericAdaptorBase::getChannelType() { + auto attr = getChannelTypeAttr(); + return attr; +} + +::mlir::Attribute RecvOpV1GenericAdaptorBase::getIsHostTransfer() { + auto attr = getIsHostTransferAttr(); + return attr; +} + +} // namespace detail +RecvOpV1Adaptor::RecvOpV1Adaptor(RecvOpV1 op) : RecvOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RecvOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitError(loc, "'vhlo.recv_v1' op ""requires attribute 'channel_id'"); + auto tblgen_channel_type = getProperties().channel_type; (void)tblgen_channel_type; + if (!tblgen_channel_type) return emitError(loc, "'vhlo.recv_v1' op ""requires attribute 'channel_type'"); + auto tblgen_is_host_transfer = getProperties().is_host_transfer; (void)tblgen_is_host_transfer; + if (!tblgen_is_host_transfer) return emitError(loc, "'vhlo.recv_v1' op ""requires attribute 'is_host_transfer'"); + + if (tblgen_channel_id && !((true))) + return emitError(loc, "'vhlo.recv_v1' op ""attribute 'channel_id' failed to satisfy constraint: any attribute"); + + if (tblgen_channel_type && !((true))) + return emitError(loc, "'vhlo.recv_v1' op ""attribute 'channel_type' failed to satisfy constraint: any attribute"); + + if (tblgen_is_host_transfer && !((true))) + return emitError(loc, "'vhlo.recv_v1' op ""attribute 'is_host_transfer' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair RecvOpV1::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult RecvOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_id; + auto attr = dict.get("channel_id"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_id` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.channel_type; + auto attr = dict.get("channel_type"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_type` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.is_host_transfer; + auto attr = dict.get("is_host_transfer"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `is_host_transfer` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute RecvOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_id; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_id", + propStorage)); + } + + { + const auto &propStorage = prop.channel_type; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_type", + propStorage)); + } + + { + const auto &propStorage = prop.is_host_transfer; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("is_host_transfer", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RecvOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_id.getAsOpaquePointer()), + llvm::hash_value(prop.channel_type.getAsOpaquePointer()), + llvm::hash_value(prop.is_host_transfer.getAsOpaquePointer())); +} + +std::optional RecvOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_id") + return prop.channel_id; + + if (name == "channel_type") + return prop.channel_type; + + if (name == "is_host_transfer") + return prop.is_host_transfer; + return std::nullopt; +} + +void RecvOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_id") { + prop.channel_id = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "channel_type") { + prop.channel_type = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "is_host_transfer") { + prop.is_host_transfer = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void RecvOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_id) attrs.append("channel_id", prop.channel_id); + + if (prop.channel_type) attrs.append("channel_type", prop.channel_type); + + if (prop.is_host_transfer) attrs.append("is_host_transfer", prop.is_host_transfer); +} + +::llvm::LogicalResult RecvOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelIdAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "channel_id", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getChannelTypeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "channel_type", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIsHostTransferAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "is_host_transfer", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult RecvOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.channel_id))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.channel_type))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.is_host_transfer))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RecvOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.channel_id); + writer.writeAttribute(prop.channel_type); + writer.writeAttribute(prop.is_host_transfer); +} + +::mlir::Attribute RecvOpV1::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute RecvOpV1::getChannelType() { + auto attr = getChannelTypeAttr(); + return attr; +} + +::mlir::Attribute RecvOpV1::getIsHostTransfer() { + auto attr = getIsHostTransferAttr(); + return attr; +} + +void RecvOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value token, ::mlir::Attribute channel_id, ::mlir::Attribute channel_type, ::mlir::Attribute is_host_transfer) { + odsState.addOperands(token); + odsState.getOrAddProperties().channel_id = channel_id; + odsState.getOrAddProperties().channel_type = channel_type; + odsState.getOrAddProperties().is_host_transfer = is_host_transfer; + odsState.addTypes(results); +} + +void RecvOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void RecvOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RecvOpV1::verifyInvariantsImpl() { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitOpError("requires attribute 'channel_id'"); + auto tblgen_channel_type = getProperties().channel_type; (void)tblgen_channel_type; + if (!tblgen_channel_type) return emitOpError("requires attribute 'channel_type'"); + auto tblgen_is_host_transfer = getProperties().is_host_transfer; (void)tblgen_is_host_transfer; + if (!tblgen_is_host_transfer) return emitOpError("requires attribute 'is_host_transfer'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_channel_id, "channel_id"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_channel_type, "channel_type"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_is_host_transfer, "is_host_transfer"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RecvOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version RecvOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version RecvOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::RecvOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReduceOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReduceOpV1GenericAdaptorBase::ReduceOpV1GenericAdaptorBase(ReduceOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair ReduceOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute ReduceOpV1GenericAdaptorBase::getDimensions() { + auto attr = getDimensionsAttr(); + return attr; +} + +} // namespace detail +ReduceOpV1Adaptor::ReduceOpV1Adaptor(ReduceOpV1 op) : ReduceOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReduceOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_dimensions = getProperties().dimensions; (void)tblgen_dimensions; + if (!tblgen_dimensions) return emitError(loc, "'vhlo.reduce_v1' op ""requires attribute 'dimensions'"); + + if (tblgen_dimensions && !((true))) + return emitError(loc, "'vhlo.reduce_v1' op ""attribute 'dimensions' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair ReduceOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange ReduceOpV1::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::mlir::MutableOperandRange ReduceOpV1::getInitValuesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ReduceOpV1::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult ReduceOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimensions; + auto attr = dict.get("dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ReduceOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReduceOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimensions.getAsOpaquePointer())); +} + +std::optional ReduceOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimensions") + return prop.dimensions; + return std::nullopt; +} + +void ReduceOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimensions") { + prop.dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ReduceOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimensions) attrs.append("dimensions", prop.dimensions); +} + +::llvm::LogicalResult ReduceOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReduceOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimensions); +} + +::mlir::Attribute ReduceOpV1::getDimensions() { + auto attr = getDimensionsAttr(); + return attr; +} + +void ReduceOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::mlir::Attribute dimensions) { + odsState.addOperands(inputs); + odsState.addOperands(init_values); + odsState.getOrAddProperties().dimensions = dimensions; + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void ReduceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ReduceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ReduceOpV1::verifyInvariantsImpl() { + auto tblgen_dimensions = getProperties().dimensions; (void)tblgen_dimensions; + if (!tblgen_dimensions) return emitOpError("requires attribute 'dimensions'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_dimensions, "dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "body", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ReduceOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ReduceOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReduceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReducePrecisionOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReducePrecisionOpV1GenericAdaptorBase::ReducePrecisionOpV1GenericAdaptorBase(ReducePrecisionOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute ReducePrecisionOpV1GenericAdaptorBase::getExponentBits() { + auto attr = getExponentBitsAttr(); + return attr; +} + +::mlir::Attribute ReducePrecisionOpV1GenericAdaptorBase::getMantissaBits() { + auto attr = getMantissaBitsAttr(); + return attr; +} + +} // namespace detail +ReducePrecisionOpV1Adaptor::ReducePrecisionOpV1Adaptor(ReducePrecisionOpV1 op) : ReducePrecisionOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReducePrecisionOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_exponent_bits = getProperties().exponent_bits; (void)tblgen_exponent_bits; + if (!tblgen_exponent_bits) return emitError(loc, "'vhlo.reduce_precision_v1' op ""requires attribute 'exponent_bits'"); + auto tblgen_mantissa_bits = getProperties().mantissa_bits; (void)tblgen_mantissa_bits; + if (!tblgen_mantissa_bits) return emitError(loc, "'vhlo.reduce_precision_v1' op ""requires attribute 'mantissa_bits'"); + + if (tblgen_exponent_bits && !((true))) + return emitError(loc, "'vhlo.reduce_precision_v1' op ""attribute 'exponent_bits' failed to satisfy constraint: any attribute"); + + if (tblgen_mantissa_bits && !((true))) + return emitError(loc, "'vhlo.reduce_precision_v1' op ""attribute 'mantissa_bits' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult ReducePrecisionOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.exponent_bits; + auto attr = dict.get("exponent_bits"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `exponent_bits` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.mantissa_bits; + auto attr = dict.get("mantissa_bits"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `mantissa_bits` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ReducePrecisionOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.exponent_bits; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("exponent_bits", + propStorage)); + } + + { + const auto &propStorage = prop.mantissa_bits; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("mantissa_bits", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReducePrecisionOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.exponent_bits.getAsOpaquePointer()), + llvm::hash_value(prop.mantissa_bits.getAsOpaquePointer())); +} + +std::optional ReducePrecisionOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "exponent_bits") + return prop.exponent_bits; + + if (name == "mantissa_bits") + return prop.mantissa_bits; + return std::nullopt; +} + +void ReducePrecisionOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "exponent_bits") { + prop.exponent_bits = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "mantissa_bits") { + prop.mantissa_bits = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ReducePrecisionOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.exponent_bits) attrs.append("exponent_bits", prop.exponent_bits); + + if (prop.mantissa_bits) attrs.append("mantissa_bits", prop.mantissa_bits); +} + +::llvm::LogicalResult ReducePrecisionOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getExponentBitsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "exponent_bits", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getMantissaBitsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "mantissa_bits", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReducePrecisionOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.exponent_bits))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.mantissa_bits))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReducePrecisionOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.exponent_bits); + writer.writeAttribute(prop.mantissa_bits); +} + +::mlir::Attribute ReducePrecisionOpV1::getExponentBits() { + auto attr = getExponentBitsAttr(); + return attr; +} + +::mlir::Attribute ReducePrecisionOpV1::getMantissaBits() { + auto attr = getMantissaBitsAttr(); + return attr; +} + +void ReducePrecisionOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value operand, ::mlir::Attribute exponent_bits, ::mlir::Attribute mantissa_bits) { + odsState.addOperands(operand); + odsState.getOrAddProperties().exponent_bits = exponent_bits; + odsState.getOrAddProperties().mantissa_bits = mantissa_bits; + odsState.addTypes(output); +} + +void ReducePrecisionOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute exponent_bits, ::mlir::Attribute mantissa_bits) { + odsState.addOperands(operand); + odsState.getOrAddProperties().exponent_bits = exponent_bits; + odsState.getOrAddProperties().mantissa_bits = mantissa_bits; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReducePrecisionOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ReducePrecisionOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ReducePrecisionOpV1::verifyInvariantsImpl() { + auto tblgen_exponent_bits = getProperties().exponent_bits; (void)tblgen_exponent_bits; + if (!tblgen_exponent_bits) return emitOpError("requires attribute 'exponent_bits'"); + auto tblgen_mantissa_bits = getProperties().mantissa_bits; (void)tblgen_mantissa_bits; + if (!tblgen_mantissa_bits) return emitOpError("requires attribute 'mantissa_bits'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_exponent_bits, "exponent_bits"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_mantissa_bits, "mantissa_bits"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReducePrecisionOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ReducePrecisionOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ReducePrecisionOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReducePrecisionOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReduceScatterOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReduceScatterOpV1GenericAdaptorBase::ReduceScatterOpV1GenericAdaptorBase(ReduceScatterOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute ReduceScatterOpV1GenericAdaptorBase::getScatterDimension() { + auto attr = getScatterDimensionAttr(); + return attr; +} + +::mlir::Attribute ReduceScatterOpV1GenericAdaptorBase::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute ReduceScatterOpV1GenericAdaptorBase::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute ReduceScatterOpV1GenericAdaptorBase::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + return attr; +} + +} // namespace detail +ReduceScatterOpV1Adaptor::ReduceScatterOpV1Adaptor(ReduceScatterOpV1 op) : ReduceScatterOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReduceScatterOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitError(loc, "'vhlo.reduce_scatter_v1' op ""requires attribute 'channel_id'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitError(loc, "'vhlo.reduce_scatter_v1' op ""requires attribute 'replica_groups'"); + auto tblgen_scatter_dimension = getProperties().scatter_dimension; (void)tblgen_scatter_dimension; + if (!tblgen_scatter_dimension) return emitError(loc, "'vhlo.reduce_scatter_v1' op ""requires attribute 'scatter_dimension'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + if (!tblgen_use_global_device_ids) return emitError(loc, "'vhlo.reduce_scatter_v1' op ""requires attribute 'use_global_device_ids'"); + + if (tblgen_scatter_dimension && !((true))) + return emitError(loc, "'vhlo.reduce_scatter_v1' op ""attribute 'scatter_dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_replica_groups && !((true))) + return emitError(loc, "'vhlo.reduce_scatter_v1' op ""attribute 'replica_groups' failed to satisfy constraint: any attribute"); + + if (tblgen_channel_id && !((true))) + return emitError(loc, "'vhlo.reduce_scatter_v1' op ""attribute 'channel_id' failed to satisfy constraint: any attribute"); + + if (tblgen_use_global_device_ids && !((true))) + return emitError(loc, "'vhlo.reduce_scatter_v1' op ""attribute 'use_global_device_ids' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceScatterOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_id; + auto attr = dict.get("channel_id"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_id` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.replica_groups; + auto attr = dict.get("replica_groups"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `replica_groups` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.scatter_dimension; + auto attr = dict.get("scatter_dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `scatter_dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.use_global_device_ids; + auto attr = dict.get("use_global_device_ids"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `use_global_device_ids` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ReduceScatterOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_id; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_id", + propStorage)); + } + + { + const auto &propStorage = prop.replica_groups; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("replica_groups", + propStorage)); + } + + { + const auto &propStorage = prop.scatter_dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("scatter_dimension", + propStorage)); + } + + { + const auto &propStorage = prop.use_global_device_ids; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("use_global_device_ids", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReduceScatterOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_id.getAsOpaquePointer()), + llvm::hash_value(prop.replica_groups.getAsOpaquePointer()), + llvm::hash_value(prop.scatter_dimension.getAsOpaquePointer()), + llvm::hash_value(prop.use_global_device_ids.getAsOpaquePointer())); +} + +std::optional ReduceScatterOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_id") + return prop.channel_id; + + if (name == "replica_groups") + return prop.replica_groups; + + if (name == "scatter_dimension") + return prop.scatter_dimension; + + if (name == "use_global_device_ids") + return prop.use_global_device_ids; + return std::nullopt; +} + +void ReduceScatterOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_id") { + prop.channel_id = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "replica_groups") { + prop.replica_groups = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "scatter_dimension") { + prop.scatter_dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "use_global_device_ids") { + prop.use_global_device_ids = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ReduceScatterOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_id) attrs.append("channel_id", prop.channel_id); + + if (prop.replica_groups) attrs.append("replica_groups", prop.replica_groups); + + if (prop.scatter_dimension) attrs.append("scatter_dimension", prop.scatter_dimension); + + if (prop.use_global_device_ids) attrs.append("use_global_device_ids", prop.use_global_device_ids); +} + +::llvm::LogicalResult ReduceScatterOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelIdAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "channel_id", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReplicaGroupsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "replica_groups", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getScatterDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "scatter_dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUseGlobalDeviceIdsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "use_global_device_ids", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceScatterOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.channel_id))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.replica_groups))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.scatter_dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.use_global_device_ids))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReduceScatterOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.channel_id); + writer.writeAttribute(prop.replica_groups); + writer.writeAttribute(prop.scatter_dimension); + writer.writeAttribute(prop.use_global_device_ids); +} + +::mlir::Attribute ReduceScatterOpV1::getScatterDimension() { + auto attr = getScatterDimensionAttr(); + return attr; +} + +::mlir::Attribute ReduceScatterOpV1::getReplicaGroups() { + auto attr = getReplicaGroupsAttr(); + return attr; +} + +::mlir::Attribute ReduceScatterOpV1::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute ReduceScatterOpV1::getUseGlobalDeviceIds() { + auto attr = getUseGlobalDeviceIdsAttr(); + return attr; +} + +void ReduceScatterOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute scatter_dimension, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids) { + odsState.addOperands(operand); + odsState.getOrAddProperties().scatter_dimension = scatter_dimension; + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.getOrAddProperties().channel_id = channel_id; + odsState.getOrAddProperties().use_global_device_ids = use_global_device_ids; + (void)odsState.addRegion(); + odsState.addTypes(result); +} + +void ReduceScatterOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute scatter_dimension, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids) { + odsState.addOperands(operand); + odsState.getOrAddProperties().scatter_dimension = scatter_dimension; + odsState.getOrAddProperties().replica_groups = replica_groups; + odsState.getOrAddProperties().channel_id = channel_id; + odsState.getOrAddProperties().use_global_device_ids = use_global_device_ids; + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReduceScatterOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ReduceScatterOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ReduceScatterOpV1::verifyInvariantsImpl() { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitOpError("requires attribute 'channel_id'"); + auto tblgen_replica_groups = getProperties().replica_groups; (void)tblgen_replica_groups; + if (!tblgen_replica_groups) return emitOpError("requires attribute 'replica_groups'"); + auto tblgen_scatter_dimension = getProperties().scatter_dimension; (void)tblgen_scatter_dimension; + if (!tblgen_scatter_dimension) return emitOpError("requires attribute 'scatter_dimension'"); + auto tblgen_use_global_device_ids = getProperties().use_global_device_ids; (void)tblgen_use_global_device_ids; + if (!tblgen_use_global_device_ids) return emitOpError("requires attribute 'use_global_device_ids'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_scatter_dimension, "scatter_dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_replica_groups, "replica_groups"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_channel_id, "channel_id"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_use_global_device_ids, "use_global_device_ids"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "computation", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceScatterOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ReduceScatterOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ReduceScatterOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReduceScatterOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReduceWindowOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReduceWindowOpV1GenericAdaptorBase::ReduceWindowOpV1GenericAdaptorBase(ReduceWindowOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair ReduceWindowOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute ReduceWindowOpV1GenericAdaptorBase::getWindowDimensions() { + auto attr = getWindowDimensionsAttr(); + return attr; +} + +::mlir::Attribute ReduceWindowOpV1GenericAdaptorBase::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr; +} + +::mlir::Attribute ReduceWindowOpV1GenericAdaptorBase::getBaseDilations() { + auto attr = getBaseDilationsAttr(); + return attr; +} + +::mlir::Attribute ReduceWindowOpV1GenericAdaptorBase::getWindowDilations() { + auto attr = getWindowDilationsAttr(); + return attr; +} + +::mlir::Attribute ReduceWindowOpV1GenericAdaptorBase::getPadding() { + auto attr = getPaddingAttr(); + return attr; +} + +} // namespace detail +ReduceWindowOpV1Adaptor::ReduceWindowOpV1Adaptor(ReduceWindowOpV1 op) : ReduceWindowOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReduceWindowOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_base_dilations = getProperties().base_dilations; (void)tblgen_base_dilations; + if (!tblgen_base_dilations) return emitError(loc, "'vhlo.reduce_window_v1' op ""requires attribute 'base_dilations'"); + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + if (!tblgen_padding) return emitError(loc, "'vhlo.reduce_window_v1' op ""requires attribute 'padding'"); + auto tblgen_window_dilations = getProperties().window_dilations; (void)tblgen_window_dilations; + if (!tblgen_window_dilations) return emitError(loc, "'vhlo.reduce_window_v1' op ""requires attribute 'window_dilations'"); + auto tblgen_window_dimensions = getProperties().window_dimensions; (void)tblgen_window_dimensions; + if (!tblgen_window_dimensions) return emitError(loc, "'vhlo.reduce_window_v1' op ""requires attribute 'window_dimensions'"); + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + if (!tblgen_window_strides) return emitError(loc, "'vhlo.reduce_window_v1' op ""requires attribute 'window_strides'"); + + if (tblgen_window_dimensions && !((true))) + return emitError(loc, "'vhlo.reduce_window_v1' op ""attribute 'window_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_window_strides && !((true))) + return emitError(loc, "'vhlo.reduce_window_v1' op ""attribute 'window_strides' failed to satisfy constraint: any attribute"); + + if (tblgen_base_dilations && !((true))) + return emitError(loc, "'vhlo.reduce_window_v1' op ""attribute 'base_dilations' failed to satisfy constraint: any attribute"); + + if (tblgen_window_dilations && !((true))) + return emitError(loc, "'vhlo.reduce_window_v1' op ""attribute 'window_dilations' failed to satisfy constraint: any attribute"); + + if (tblgen_padding && !((true))) + return emitError(loc, "'vhlo.reduce_window_v1' op ""attribute 'padding' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair ReduceWindowOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange ReduceWindowOpV1::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::mlir::MutableOperandRange ReduceWindowOpV1::getInitValuesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ReduceWindowOpV1::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult ReduceWindowOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.base_dilations; + auto attr = dict.get("base_dilations"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `base_dilations` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.padding; + auto attr = dict.get("padding"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `padding` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_dilations; + auto attr = dict.get("window_dilations"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_dilations` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_dimensions; + auto attr = dict.get("window_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_strides; + auto attr = dict.get("window_strides"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ReduceWindowOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.base_dilations; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("base_dilations", + propStorage)); + } + + { + const auto &propStorage = prop.padding; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("padding", + propStorage)); + } + + { + const auto &propStorage = prop.window_dilations; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_dilations", + propStorage)); + } + + { + const auto &propStorage = prop.window_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.window_strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_strides", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReduceWindowOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.base_dilations.getAsOpaquePointer()), + llvm::hash_value(prop.padding.getAsOpaquePointer()), + llvm::hash_value(prop.window_dilations.getAsOpaquePointer()), + llvm::hash_value(prop.window_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.window_strides.getAsOpaquePointer())); +} + +std::optional ReduceWindowOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "base_dilations") + return prop.base_dilations; + + if (name == "padding") + return prop.padding; + + if (name == "window_dilations") + return prop.window_dilations; + + if (name == "window_dimensions") + return prop.window_dimensions; + + if (name == "window_strides") + return prop.window_strides; + return std::nullopt; +} + +void ReduceWindowOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "base_dilations") { + prop.base_dilations = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "padding") { + prop.padding = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_dilations") { + prop.window_dilations = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_dimensions") { + prop.window_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_strides") { + prop.window_strides = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ReduceWindowOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.base_dilations) attrs.append("base_dilations", prop.base_dilations); + + if (prop.padding) attrs.append("padding", prop.padding); + + if (prop.window_dilations) attrs.append("window_dilations", prop.window_dilations); + + if (prop.window_dimensions) attrs.append("window_dimensions", prop.window_dimensions); + + if (prop.window_strides) attrs.append("window_strides", prop.window_strides); +} + +::llvm::LogicalResult ReduceWindowOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBaseDilationsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "base_dilations", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPaddingAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "padding", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowDilationsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "window_dilations", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "window_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "window_strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceWindowOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.base_dilations))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.padding))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.window_dilations))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.window_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.window_strides))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReduceWindowOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.base_dilations); + writer.writeAttribute(prop.padding); + writer.writeAttribute(prop.window_dilations); + writer.writeAttribute(prop.window_dimensions); + writer.writeAttribute(prop.window_strides); +} + +::mlir::Attribute ReduceWindowOpV1::getWindowDimensions() { + auto attr = getWindowDimensionsAttr(); + return attr; +} + +::mlir::Attribute ReduceWindowOpV1::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr; +} + +::mlir::Attribute ReduceWindowOpV1::getBaseDilations() { + auto attr = getBaseDilationsAttr(); + return attr; +} + +::mlir::Attribute ReduceWindowOpV1::getWindowDilations() { + auto attr = getWindowDilationsAttr(); + return attr; +} + +::mlir::Attribute ReduceWindowOpV1::getPadding() { + auto attr = getPaddingAttr(); + return attr; +} + +void ReduceWindowOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::mlir::Attribute window_dimensions, ::mlir::Attribute window_strides, ::mlir::Attribute base_dilations, ::mlir::Attribute window_dilations, ::mlir::Attribute padding) { + odsState.addOperands(inputs); + odsState.addOperands(init_values); + odsState.getOrAddProperties().window_dimensions = window_dimensions; + odsState.getOrAddProperties().window_strides = window_strides; + odsState.getOrAddProperties().base_dilations = base_dilations; + odsState.getOrAddProperties().window_dilations = window_dilations; + odsState.getOrAddProperties().padding = padding; + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void ReduceWindowOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ReduceWindowOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ReduceWindowOpV1::verifyInvariantsImpl() { + auto tblgen_base_dilations = getProperties().base_dilations; (void)tblgen_base_dilations; + if (!tblgen_base_dilations) return emitOpError("requires attribute 'base_dilations'"); + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + if (!tblgen_padding) return emitOpError("requires attribute 'padding'"); + auto tblgen_window_dilations = getProperties().window_dilations; (void)tblgen_window_dilations; + if (!tblgen_window_dilations) return emitOpError("requires attribute 'window_dilations'"); + auto tblgen_window_dimensions = getProperties().window_dimensions; (void)tblgen_window_dimensions; + if (!tblgen_window_dimensions) return emitOpError("requires attribute 'window_dimensions'"); + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + if (!tblgen_window_strides) return emitOpError("requires attribute 'window_strides'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_window_dimensions, "window_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_window_strides, "window_strides"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_base_dilations, "base_dilations"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_window_dilations, "window_dilations"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_padding, "padding"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "body", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReduceWindowOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ReduceWindowOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ReduceWindowOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReduceWindowOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RemOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RemOpV1GenericAdaptorBase::RemOpV1GenericAdaptorBase(RemOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +RemOpV1Adaptor::RemOpV1Adaptor(RemOpV1 op) : RemOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RemOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult RemOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute RemOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RemOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional RemOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void RemOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void RemOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult RemOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void RemOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void RemOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RemOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RemOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RemOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RemOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version RemOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version RemOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::RemOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReplicaIdOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReplicaIdOpV1GenericAdaptorBase::ReplicaIdOpV1GenericAdaptorBase(ReplicaIdOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ReplicaIdOpV1Adaptor::ReplicaIdOpV1Adaptor(ReplicaIdOpV1 op) : ReplicaIdOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReplicaIdOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ReplicaIdOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ReplicaIdOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReplicaIdOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ReplicaIdOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ReplicaIdOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ReplicaIdOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ReplicaIdOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ReplicaIdOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result) { + odsState.addTypes(result); +} + +void ReplicaIdOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReplicaIdOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ReplicaIdOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ReplicaIdOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReplicaIdOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ReplicaIdOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ReplicaIdOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReplicaIdOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReshapeOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReshapeOpV1GenericAdaptorBase::ReshapeOpV1GenericAdaptorBase(ReshapeOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ReshapeOpV1Adaptor::ReshapeOpV1Adaptor(ReshapeOpV1 op) : ReshapeOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReshapeOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ReshapeOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ReshapeOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReshapeOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ReshapeOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ReshapeOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ReshapeOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ReshapeOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ReshapeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void ReshapeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReshapeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ReshapeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ReshapeOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReshapeOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ReshapeOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ReshapeOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReshapeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReturnOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReturnOpV1GenericAdaptorBase::ReturnOpV1GenericAdaptorBase(ReturnOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair ReturnOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +} // namespace detail +ReturnOpV1Adaptor::ReturnOpV1Adaptor(ReturnOpV1 op) : ReturnOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReturnOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ReturnOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange ReturnOpV1::getResultsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult ReturnOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ReturnOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReturnOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ReturnOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ReturnOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ReturnOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ReturnOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ReturnOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange results) { + odsState.addOperands(results); +} + +void ReturnOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ReturnOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ReturnOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReturnOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ReturnOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ReturnOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReturnOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReverseOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReverseOpV1GenericAdaptorBase::ReverseOpV1GenericAdaptorBase(ReverseOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute ReverseOpV1GenericAdaptorBase::getDimensions() { + auto attr = getDimensionsAttr(); + return attr; +} + +} // namespace detail +ReverseOpV1Adaptor::ReverseOpV1Adaptor(ReverseOpV1 op) : ReverseOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ReverseOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_dimensions = getProperties().dimensions; (void)tblgen_dimensions; + if (!tblgen_dimensions) return emitError(loc, "'vhlo.reverse_v1' op ""requires attribute 'dimensions'"); + + if (tblgen_dimensions && !((true))) + return emitError(loc, "'vhlo.reverse_v1' op ""attribute 'dimensions' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult ReverseOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimensions; + auto attr = dict.get("dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ReverseOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimensions", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReverseOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimensions.getAsOpaquePointer())); +} + +std::optional ReverseOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimensions") + return prop.dimensions; + return std::nullopt; +} + +void ReverseOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimensions") { + prop.dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ReverseOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimensions) attrs.append("dimensions", prop.dimensions); +} + +::llvm::LogicalResult ReverseOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "dimensions", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReverseOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimensions))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReverseOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimensions); +} + +::mlir::Attribute ReverseOpV1::getDimensions() { + auto attr = getDimensionsAttr(); + return attr; +} + +void ReverseOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimensions = dimensions; + odsState.addTypes(result); +} + +void ReverseOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute dimensions) { + odsState.addOperands(operand); + odsState.getOrAddProperties().dimensions = dimensions; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReverseOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ReverseOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ReverseOpV1::verifyInvariantsImpl() { + auto tblgen_dimensions = getProperties().dimensions; (void)tblgen_dimensions; + if (!tblgen_dimensions) return emitOpError("requires attribute 'dimensions'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_dimensions, "dimensions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ReverseOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ReverseOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ReverseOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReverseOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RngBitGeneratorOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RngBitGeneratorOpV1GenericAdaptorBase::RngBitGeneratorOpV1GenericAdaptorBase(RngBitGeneratorOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute RngBitGeneratorOpV1GenericAdaptorBase::getRngAlgorithm() { + auto attr = getRngAlgorithmAttr(); + return attr; +} + +} // namespace detail +RngBitGeneratorOpV1Adaptor::RngBitGeneratorOpV1Adaptor(RngBitGeneratorOpV1 op) : RngBitGeneratorOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RngBitGeneratorOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_rng_algorithm = getProperties().rng_algorithm; (void)tblgen_rng_algorithm; + if (!tblgen_rng_algorithm) return emitError(loc, "'vhlo.rng_bit_generator_v1' op ""requires attribute 'rng_algorithm'"); + + if (tblgen_rng_algorithm && !((true))) + return emitError(loc, "'vhlo.rng_bit_generator_v1' op ""attribute 'rng_algorithm' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +void RngBitGeneratorOpV1::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { + auto resultGroup0 = getODSResults(0); + if (!resultGroup0.empty()) + setNameFn(*resultGroup0.begin(), "output_state"); + auto resultGroup1 = getODSResults(1); + if (!resultGroup1.empty()) + setNameFn(*resultGroup1.begin(), "output"); +} + +::llvm::LogicalResult RngBitGeneratorOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.rng_algorithm; + auto attr = dict.get("rng_algorithm"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rng_algorithm` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute RngBitGeneratorOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.rng_algorithm; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rng_algorithm", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RngBitGeneratorOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.rng_algorithm.getAsOpaquePointer())); +} + +std::optional RngBitGeneratorOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "rng_algorithm") + return prop.rng_algorithm; + return std::nullopt; +} + +void RngBitGeneratorOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "rng_algorithm") { + prop.rng_algorithm = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void RngBitGeneratorOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.rng_algorithm) attrs.append("rng_algorithm", prop.rng_algorithm); +} + +::llvm::LogicalResult RngBitGeneratorOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getRngAlgorithmAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "rng_algorithm", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult RngBitGeneratorOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.rng_algorithm))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RngBitGeneratorOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.rng_algorithm); +} + +::mlir::Attribute RngBitGeneratorOpV1::getRngAlgorithm() { + auto attr = getRngAlgorithmAttr(); + return attr; +} + +void RngBitGeneratorOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_state, ::mlir::Type output, ::mlir::Attribute rng_algorithm, ::mlir::Value initial_state) { + odsState.addOperands(initial_state); + odsState.getOrAddProperties().rng_algorithm = rng_algorithm; + odsState.addTypes(output_state); + odsState.addTypes(output); +} + +void RngBitGeneratorOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Attribute rng_algorithm, ::mlir::Value initial_state) { + odsState.addOperands(initial_state); + odsState.getOrAddProperties().rng_algorithm = rng_algorithm; + assert(resultTypes.size() == 2u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RngBitGeneratorOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void RngBitGeneratorOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RngBitGeneratorOpV1::verifyInvariantsImpl() { + auto tblgen_rng_algorithm = getProperties().rng_algorithm; (void)tblgen_rng_algorithm; + if (!tblgen_rng_algorithm) return emitOpError("requires attribute 'rng_algorithm'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_rng_algorithm, "rng_algorithm"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSResults(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RngBitGeneratorOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version RngBitGeneratorOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version RngBitGeneratorOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::RngBitGeneratorOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RngOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RngOpV1GenericAdaptorBase::RngOpV1GenericAdaptorBase(RngOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute RngOpV1GenericAdaptorBase::getRngDistribution() { + auto attr = getRngDistributionAttr(); + return attr; +} + +} // namespace detail +RngOpV1Adaptor::RngOpV1Adaptor(RngOpV1 op) : RngOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RngOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_rng_distribution = getProperties().rng_distribution; (void)tblgen_rng_distribution; + if (!tblgen_rng_distribution) return emitError(loc, "'vhlo.rng_v1' op ""requires attribute 'rng_distribution'"); + + if (tblgen_rng_distribution && !((true))) + return emitError(loc, "'vhlo.rng_v1' op ""attribute 'rng_distribution' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult RngOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.rng_distribution; + auto attr = dict.get("rng_distribution"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rng_distribution` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute RngOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.rng_distribution; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rng_distribution", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RngOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.rng_distribution.getAsOpaquePointer())); +} + +std::optional RngOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "rng_distribution") + return prop.rng_distribution; + return std::nullopt; +} + +void RngOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "rng_distribution") { + prop.rng_distribution = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void RngOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.rng_distribution) attrs.append("rng_distribution", prop.rng_distribution); +} + +::llvm::LogicalResult RngOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getRngDistributionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "rng_distribution", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult RngOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.rng_distribution))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RngOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.rng_distribution); +} + +::mlir::Attribute RngOpV1::getRngDistribution() { + auto attr = getRngDistributionAttr(); + return attr; +} + +void RngOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::Attribute rng_distribution) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(shape); + odsState.getOrAddProperties().rng_distribution = rng_distribution; + odsState.addTypes(result); +} + +void RngOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::Attribute rng_distribution) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(shape); + odsState.getOrAddProperties().rng_distribution = rng_distribution; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RngOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void RngOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RngOpV1::verifyInvariantsImpl() { + auto tblgen_rng_distribution = getProperties().rng_distribution; (void)tblgen_rng_distribution; + if (!tblgen_rng_distribution) return emitOpError("requires attribute 'rng_distribution'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_rng_distribution, "rng_distribution"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RngOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version RngOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version RngOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::RngOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RoundNearestEvenOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RoundNearestEvenOpV1GenericAdaptorBase::RoundNearestEvenOpV1GenericAdaptorBase(RoundNearestEvenOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +RoundNearestEvenOpV1Adaptor::RoundNearestEvenOpV1Adaptor(RoundNearestEvenOpV1 op) : RoundNearestEvenOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RoundNearestEvenOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult RoundNearestEvenOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute RoundNearestEvenOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RoundNearestEvenOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional RoundNearestEvenOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void RoundNearestEvenOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void RoundNearestEvenOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult RoundNearestEvenOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void RoundNearestEvenOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void RoundNearestEvenOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RoundNearestEvenOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RoundNearestEvenOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RoundNearestEvenOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RoundNearestEvenOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version RoundNearestEvenOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version RoundNearestEvenOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::RoundNearestEvenOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RoundOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RoundOpV1GenericAdaptorBase::RoundOpV1GenericAdaptorBase(RoundOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +RoundOpV1Adaptor::RoundOpV1Adaptor(RoundOpV1 op) : RoundOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RoundOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult RoundOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute RoundOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RoundOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional RoundOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void RoundOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void RoundOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult RoundOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void RoundOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void RoundOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RoundOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RoundOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RoundOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RoundOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version RoundOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version RoundOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::RoundOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RsqrtOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RsqrtOpV1GenericAdaptorBase::RsqrtOpV1GenericAdaptorBase(RsqrtOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +RsqrtOpV1Adaptor::RsqrtOpV1Adaptor(RsqrtOpV1 op) : RsqrtOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RsqrtOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult RsqrtOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute RsqrtOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RsqrtOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional RsqrtOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void RsqrtOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void RsqrtOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult RsqrtOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void RsqrtOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void RsqrtOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RsqrtOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RsqrtOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RsqrtOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RsqrtOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version RsqrtOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version RsqrtOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 9, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::RsqrtOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RsqrtOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RsqrtOpV2GenericAdaptorBase::RsqrtOpV2GenericAdaptorBase(RsqrtOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute RsqrtOpV2GenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +} // namespace detail +RsqrtOpV2Adaptor::RsqrtOpV2Adaptor(RsqrtOpV2 op) : RsqrtOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult RsqrtOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitError(loc, "'vhlo.rsqrt_v2' op ""requires attribute 'result_accuracy'"); + + if (tblgen_result_accuracy && !((true))) + return emitError(loc, "'vhlo.rsqrt_v2' op ""attribute 'result_accuracy' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult RsqrtOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute RsqrtOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code RsqrtOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional RsqrtOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void RsqrtOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void RsqrtOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult RsqrtOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult RsqrtOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RsqrtOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_accuracy); +} + +::mlir::Attribute RsqrtOpV2::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +void RsqrtOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + odsState.addTypes(result); +} + +void RsqrtOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RsqrtOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void RsqrtOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult RsqrtOpV2::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitOpError("requires attribute 'result_accuracy'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult RsqrtOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version RsqrtOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 10, 0); +} +mlir::vhlo::Version RsqrtOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::RsqrtOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ScatterOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ScatterOpV1GenericAdaptorBase::ScatterOpV1GenericAdaptorBase(ScatterOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair ScatterOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute ScatterOpV1GenericAdaptorBase::getUpdateWindowDims() { + auto attr = getUpdateWindowDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV1GenericAdaptorBase::getInsertedWindowDims() { + auto attr = getInsertedWindowDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV1GenericAdaptorBase::getScatterDimsToOperandDims() { + auto attr = getScatterDimsToOperandDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV1GenericAdaptorBase::getIndexVectorDim() { + auto attr = getIndexVectorDimAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV1GenericAdaptorBase::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV1GenericAdaptorBase::getUniqueIndices() { + auto attr = getUniqueIndicesAttr(); + return attr; +} + +} // namespace detail +ScatterOpV1Adaptor::ScatterOpV1Adaptor(ScatterOpV1 op) : ScatterOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ScatterOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_index_vector_dim = getProperties().index_vector_dim; (void)tblgen_index_vector_dim; + if (!tblgen_index_vector_dim) return emitError(loc, "'vhlo.scatter_v1' op ""requires attribute 'index_vector_dim'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + if (!tblgen_indices_are_sorted) return emitError(loc, "'vhlo.scatter_v1' op ""requires attribute 'indices_are_sorted'"); + auto tblgen_inserted_window_dims = getProperties().inserted_window_dims; (void)tblgen_inserted_window_dims; + if (!tblgen_inserted_window_dims) return emitError(loc, "'vhlo.scatter_v1' op ""requires attribute 'inserted_window_dims'"); + auto tblgen_scatter_dims_to_operand_dims = getProperties().scatter_dims_to_operand_dims; (void)tblgen_scatter_dims_to_operand_dims; + if (!tblgen_scatter_dims_to_operand_dims) return emitError(loc, "'vhlo.scatter_v1' op ""requires attribute 'scatter_dims_to_operand_dims'"); + auto tblgen_unique_indices = getProperties().unique_indices; (void)tblgen_unique_indices; + if (!tblgen_unique_indices) return emitError(loc, "'vhlo.scatter_v1' op ""requires attribute 'unique_indices'"); + auto tblgen_update_window_dims = getProperties().update_window_dims; (void)tblgen_update_window_dims; + if (!tblgen_update_window_dims) return emitError(loc, "'vhlo.scatter_v1' op ""requires attribute 'update_window_dims'"); + + if (tblgen_update_window_dims && !((true))) + return emitError(loc, "'vhlo.scatter_v1' op ""attribute 'update_window_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_inserted_window_dims && !((true))) + return emitError(loc, "'vhlo.scatter_v1' op ""attribute 'inserted_window_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_scatter_dims_to_operand_dims && !((true))) + return emitError(loc, "'vhlo.scatter_v1' op ""attribute 'scatter_dims_to_operand_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_index_vector_dim && !((true))) + return emitError(loc, "'vhlo.scatter_v1' op ""attribute 'index_vector_dim' failed to satisfy constraint: any attribute"); + + if (tblgen_indices_are_sorted && !((true))) + return emitError(loc, "'vhlo.scatter_v1' op ""attribute 'indices_are_sorted' failed to satisfy constraint: any attribute"); + + if (tblgen_unique_indices && !((true))) + return emitError(loc, "'vhlo.scatter_v1' op ""attribute 'unique_indices' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair ScatterOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange ScatterOpV1::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::mlir::MutableOperandRange ScatterOpV1::getUpdatesMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ScatterOpV1::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult ScatterOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.index_vector_dim; + auto attr = dict.get("index_vector_dim"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `index_vector_dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.indices_are_sorted; + auto attr = dict.get("indices_are_sorted"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `indices_are_sorted` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.inserted_window_dims; + auto attr = dict.get("inserted_window_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `inserted_window_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.scatter_dims_to_operand_dims; + auto attr = dict.get("scatter_dims_to_operand_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `scatter_dims_to_operand_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.unique_indices; + auto attr = dict.get("unique_indices"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `unique_indices` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.update_window_dims; + auto attr = dict.get("update_window_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `update_window_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ScatterOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.index_vector_dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("index_vector_dim", + propStorage)); + } + + { + const auto &propStorage = prop.indices_are_sorted; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("indices_are_sorted", + propStorage)); + } + + { + const auto &propStorage = prop.inserted_window_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("inserted_window_dims", + propStorage)); + } + + { + const auto &propStorage = prop.scatter_dims_to_operand_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("scatter_dims_to_operand_dims", + propStorage)); + } + + { + const auto &propStorage = prop.unique_indices; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("unique_indices", + propStorage)); + } + + { + const auto &propStorage = prop.update_window_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("update_window_dims", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ScatterOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.index_vector_dim.getAsOpaquePointer()), + llvm::hash_value(prop.indices_are_sorted.getAsOpaquePointer()), + llvm::hash_value(prop.inserted_window_dims.getAsOpaquePointer()), + llvm::hash_value(prop.scatter_dims_to_operand_dims.getAsOpaquePointer()), + llvm::hash_value(prop.unique_indices.getAsOpaquePointer()), + llvm::hash_value(prop.update_window_dims.getAsOpaquePointer())); +} + +std::optional ScatterOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "index_vector_dim") + return prop.index_vector_dim; + + if (name == "indices_are_sorted") + return prop.indices_are_sorted; + + if (name == "inserted_window_dims") + return prop.inserted_window_dims; + + if (name == "scatter_dims_to_operand_dims") + return prop.scatter_dims_to_operand_dims; + + if (name == "unique_indices") + return prop.unique_indices; + + if (name == "update_window_dims") + return prop.update_window_dims; + return std::nullopt; +} + +void ScatterOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "index_vector_dim") { + prop.index_vector_dim = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "indices_are_sorted") { + prop.indices_are_sorted = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "inserted_window_dims") { + prop.inserted_window_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "scatter_dims_to_operand_dims") { + prop.scatter_dims_to_operand_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "unique_indices") { + prop.unique_indices = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "update_window_dims") { + prop.update_window_dims = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ScatterOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.index_vector_dim) attrs.append("index_vector_dim", prop.index_vector_dim); + + if (prop.indices_are_sorted) attrs.append("indices_are_sorted", prop.indices_are_sorted); + + if (prop.inserted_window_dims) attrs.append("inserted_window_dims", prop.inserted_window_dims); + + if (prop.scatter_dims_to_operand_dims) attrs.append("scatter_dims_to_operand_dims", prop.scatter_dims_to_operand_dims); + + if (prop.unique_indices) attrs.append("unique_indices", prop.unique_indices); + + if (prop.update_window_dims) attrs.append("update_window_dims", prop.update_window_dims); +} + +::llvm::LogicalResult ScatterOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getIndexVectorDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "index_vector_dim", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIndicesAreSortedAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "indices_are_sorted", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInsertedWindowDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "inserted_window_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getScatterDimsToOperandDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "scatter_dims_to_operand_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUniqueIndicesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "unique_indices", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUpdateWindowDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "update_window_dims", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ScatterOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.index_vector_dim))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.indices_are_sorted))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.inserted_window_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.scatter_dims_to_operand_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.unique_indices))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.update_window_dims))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ScatterOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.index_vector_dim); + writer.writeAttribute(prop.indices_are_sorted); + writer.writeAttribute(prop.inserted_window_dims); + writer.writeAttribute(prop.scatter_dims_to_operand_dims); + writer.writeAttribute(prop.unique_indices); + writer.writeAttribute(prop.update_window_dims); +} + +::mlir::Attribute ScatterOpV1::getUpdateWindowDims() { + auto attr = getUpdateWindowDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV1::getInsertedWindowDims() { + auto attr = getInsertedWindowDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV1::getScatterDimsToOperandDims() { + auto attr = getScatterDimsToOperandDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV1::getIndexVectorDim() { + auto attr = getIndexVectorDimAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV1::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV1::getUniqueIndices() { + auto attr = getUniqueIndicesAttr(); + return attr; +} + +void ScatterOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::Value scatter_indices, ::mlir::ValueRange updates, ::mlir::Attribute update_window_dims, ::mlir::Attribute inserted_window_dims, ::mlir::Attribute scatter_dims_to_operand_dims, ::mlir::Attribute index_vector_dim, ::mlir::Attribute indices_are_sorted, ::mlir::Attribute unique_indices) { + odsState.addOperands(inputs); + odsState.addOperands(scatter_indices); + odsState.addOperands(updates); + odsState.getOrAddProperties().update_window_dims = update_window_dims; + odsState.getOrAddProperties().inserted_window_dims = inserted_window_dims; + odsState.getOrAddProperties().scatter_dims_to_operand_dims = scatter_dims_to_operand_dims; + odsState.getOrAddProperties().index_vector_dim = index_vector_dim; + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + odsState.getOrAddProperties().unique_indices = unique_indices; + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void ScatterOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ScatterOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ScatterOpV1::verifyInvariantsImpl() { + auto tblgen_index_vector_dim = getProperties().index_vector_dim; (void)tblgen_index_vector_dim; + if (!tblgen_index_vector_dim) return emitOpError("requires attribute 'index_vector_dim'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + if (!tblgen_indices_are_sorted) return emitOpError("requires attribute 'indices_are_sorted'"); + auto tblgen_inserted_window_dims = getProperties().inserted_window_dims; (void)tblgen_inserted_window_dims; + if (!tblgen_inserted_window_dims) return emitOpError("requires attribute 'inserted_window_dims'"); + auto tblgen_scatter_dims_to_operand_dims = getProperties().scatter_dims_to_operand_dims; (void)tblgen_scatter_dims_to_operand_dims; + if (!tblgen_scatter_dims_to_operand_dims) return emitOpError("requires attribute 'scatter_dims_to_operand_dims'"); + auto tblgen_unique_indices = getProperties().unique_indices; (void)tblgen_unique_indices; + if (!tblgen_unique_indices) return emitOpError("requires attribute 'unique_indices'"); + auto tblgen_update_window_dims = getProperties().update_window_dims; (void)tblgen_update_window_dims; + if (!tblgen_update_window_dims) return emitOpError("requires attribute 'update_window_dims'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_update_window_dims, "update_window_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_inserted_window_dims, "inserted_window_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_scatter_dims_to_operand_dims, "scatter_dims_to_operand_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_index_vector_dim, "index_vector_dim"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_indices_are_sorted, "indices_are_sorted"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_unique_indices, "unique_indices"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "update_computation", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ScatterOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ScatterOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ScatterOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 0, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ScatterOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ScatterOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ScatterOpV2GenericAdaptorBase::ScatterOpV2GenericAdaptorBase(ScatterOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair ScatterOpV2GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute ScatterOpV2GenericAdaptorBase::getUpdateWindowDims() { + auto attr = getUpdateWindowDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2GenericAdaptorBase::getInsertedWindowDims() { + auto attr = getInsertedWindowDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2GenericAdaptorBase::getInputBatchingDims() { + auto attr = getInputBatchingDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2GenericAdaptorBase::getScatterIndicesBatchingDims() { + auto attr = getScatterIndicesBatchingDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2GenericAdaptorBase::getScatterDimsToOperandDims() { + auto attr = getScatterDimsToOperandDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2GenericAdaptorBase::getIndexVectorDim() { + auto attr = getIndexVectorDimAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2GenericAdaptorBase::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2GenericAdaptorBase::getUniqueIndices() { + auto attr = getUniqueIndicesAttr(); + return attr; +} + +} // namespace detail +ScatterOpV2Adaptor::ScatterOpV2Adaptor(ScatterOpV2 op) : ScatterOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ScatterOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_index_vector_dim = getProperties().index_vector_dim; (void)tblgen_index_vector_dim; + if (!tblgen_index_vector_dim) return emitError(loc, "'vhlo.scatter_v2' op ""requires attribute 'index_vector_dim'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + if (!tblgen_indices_are_sorted) return emitError(loc, "'vhlo.scatter_v2' op ""requires attribute 'indices_are_sorted'"); + auto tblgen_input_batching_dims = getProperties().input_batching_dims; (void)tblgen_input_batching_dims; + if (!tblgen_input_batching_dims) return emitError(loc, "'vhlo.scatter_v2' op ""requires attribute 'input_batching_dims'"); + auto tblgen_inserted_window_dims = getProperties().inserted_window_dims; (void)tblgen_inserted_window_dims; + if (!tblgen_inserted_window_dims) return emitError(loc, "'vhlo.scatter_v2' op ""requires attribute 'inserted_window_dims'"); + auto tblgen_scatter_dims_to_operand_dims = getProperties().scatter_dims_to_operand_dims; (void)tblgen_scatter_dims_to_operand_dims; + if (!tblgen_scatter_dims_to_operand_dims) return emitError(loc, "'vhlo.scatter_v2' op ""requires attribute 'scatter_dims_to_operand_dims'"); + auto tblgen_scatter_indices_batching_dims = getProperties().scatter_indices_batching_dims; (void)tblgen_scatter_indices_batching_dims; + if (!tblgen_scatter_indices_batching_dims) return emitError(loc, "'vhlo.scatter_v2' op ""requires attribute 'scatter_indices_batching_dims'"); + auto tblgen_unique_indices = getProperties().unique_indices; (void)tblgen_unique_indices; + if (!tblgen_unique_indices) return emitError(loc, "'vhlo.scatter_v2' op ""requires attribute 'unique_indices'"); + auto tblgen_update_window_dims = getProperties().update_window_dims; (void)tblgen_update_window_dims; + if (!tblgen_update_window_dims) return emitError(loc, "'vhlo.scatter_v2' op ""requires attribute 'update_window_dims'"); + + if (tblgen_update_window_dims && !((true))) + return emitError(loc, "'vhlo.scatter_v2' op ""attribute 'update_window_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_inserted_window_dims && !((true))) + return emitError(loc, "'vhlo.scatter_v2' op ""attribute 'inserted_window_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_input_batching_dims && !((true))) + return emitError(loc, "'vhlo.scatter_v2' op ""attribute 'input_batching_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_scatter_indices_batching_dims && !((true))) + return emitError(loc, "'vhlo.scatter_v2' op ""attribute 'scatter_indices_batching_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_scatter_dims_to_operand_dims && !((true))) + return emitError(loc, "'vhlo.scatter_v2' op ""attribute 'scatter_dims_to_operand_dims' failed to satisfy constraint: any attribute"); + + if (tblgen_index_vector_dim && !((true))) + return emitError(loc, "'vhlo.scatter_v2' op ""attribute 'index_vector_dim' failed to satisfy constraint: any attribute"); + + if (tblgen_indices_are_sorted && !((true))) + return emitError(loc, "'vhlo.scatter_v2' op ""attribute 'indices_are_sorted' failed to satisfy constraint: any attribute"); + + if (tblgen_unique_indices && !((true))) + return emitError(loc, "'vhlo.scatter_v2' op ""attribute 'unique_indices' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair ScatterOpV2::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange ScatterOpV2::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::mlir::MutableOperandRange ScatterOpV2::getUpdatesMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ScatterOpV2::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult ScatterOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.index_vector_dim; + auto attr = dict.get("index_vector_dim"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `index_vector_dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.indices_are_sorted; + auto attr = dict.get("indices_are_sorted"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `indices_are_sorted` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.input_batching_dims; + auto attr = dict.get("input_batching_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `input_batching_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.inserted_window_dims; + auto attr = dict.get("inserted_window_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `inserted_window_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.scatter_dims_to_operand_dims; + auto attr = dict.get("scatter_dims_to_operand_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `scatter_dims_to_operand_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.scatter_indices_batching_dims; + auto attr = dict.get("scatter_indices_batching_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `scatter_indices_batching_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.unique_indices; + auto attr = dict.get("unique_indices"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `unique_indices` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.update_window_dims; + auto attr = dict.get("update_window_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `update_window_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ScatterOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.index_vector_dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("index_vector_dim", + propStorage)); + } + + { + const auto &propStorage = prop.indices_are_sorted; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("indices_are_sorted", + propStorage)); + } + + { + const auto &propStorage = prop.input_batching_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("input_batching_dims", + propStorage)); + } + + { + const auto &propStorage = prop.inserted_window_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("inserted_window_dims", + propStorage)); + } + + { + const auto &propStorage = prop.scatter_dims_to_operand_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("scatter_dims_to_operand_dims", + propStorage)); + } + + { + const auto &propStorage = prop.scatter_indices_batching_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("scatter_indices_batching_dims", + propStorage)); + } + + { + const auto &propStorage = prop.unique_indices; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("unique_indices", + propStorage)); + } + + { + const auto &propStorage = prop.update_window_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("update_window_dims", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ScatterOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.index_vector_dim.getAsOpaquePointer()), + llvm::hash_value(prop.indices_are_sorted.getAsOpaquePointer()), + llvm::hash_value(prop.input_batching_dims.getAsOpaquePointer()), + llvm::hash_value(prop.inserted_window_dims.getAsOpaquePointer()), + llvm::hash_value(prop.scatter_dims_to_operand_dims.getAsOpaquePointer()), + llvm::hash_value(prop.scatter_indices_batching_dims.getAsOpaquePointer()), + llvm::hash_value(prop.unique_indices.getAsOpaquePointer()), + llvm::hash_value(prop.update_window_dims.getAsOpaquePointer())); +} + +std::optional ScatterOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "index_vector_dim") + return prop.index_vector_dim; + + if (name == "indices_are_sorted") + return prop.indices_are_sorted; + + if (name == "input_batching_dims") + return prop.input_batching_dims; + + if (name == "inserted_window_dims") + return prop.inserted_window_dims; + + if (name == "scatter_dims_to_operand_dims") + return prop.scatter_dims_to_operand_dims; + + if (name == "scatter_indices_batching_dims") + return prop.scatter_indices_batching_dims; + + if (name == "unique_indices") + return prop.unique_indices; + + if (name == "update_window_dims") + return prop.update_window_dims; + return std::nullopt; +} + +void ScatterOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "index_vector_dim") { + prop.index_vector_dim = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "indices_are_sorted") { + prop.indices_are_sorted = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "input_batching_dims") { + prop.input_batching_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "inserted_window_dims") { + prop.inserted_window_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "scatter_dims_to_operand_dims") { + prop.scatter_dims_to_operand_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "scatter_indices_batching_dims") { + prop.scatter_indices_batching_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "unique_indices") { + prop.unique_indices = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "update_window_dims") { + prop.update_window_dims = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ScatterOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.index_vector_dim) attrs.append("index_vector_dim", prop.index_vector_dim); + + if (prop.indices_are_sorted) attrs.append("indices_are_sorted", prop.indices_are_sorted); + + if (prop.input_batching_dims) attrs.append("input_batching_dims", prop.input_batching_dims); + + if (prop.inserted_window_dims) attrs.append("inserted_window_dims", prop.inserted_window_dims); + + if (prop.scatter_dims_to_operand_dims) attrs.append("scatter_dims_to_operand_dims", prop.scatter_dims_to_operand_dims); + + if (prop.scatter_indices_batching_dims) attrs.append("scatter_indices_batching_dims", prop.scatter_indices_batching_dims); + + if (prop.unique_indices) attrs.append("unique_indices", prop.unique_indices); + + if (prop.update_window_dims) attrs.append("update_window_dims", prop.update_window_dims); +} + +::llvm::LogicalResult ScatterOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getIndexVectorDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "index_vector_dim", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIndicesAreSortedAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "indices_are_sorted", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInputBatchingDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "input_batching_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getInsertedWindowDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "inserted_window_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getScatterDimsToOperandDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "scatter_dims_to_operand_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getScatterIndicesBatchingDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "scatter_indices_batching_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUniqueIndicesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "unique_indices", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUpdateWindowDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "update_window_dims", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ScatterOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.index_vector_dim))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.indices_are_sorted))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.input_batching_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.inserted_window_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.scatter_dims_to_operand_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.scatter_indices_batching_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.unique_indices))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.update_window_dims))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ScatterOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.index_vector_dim); + writer.writeAttribute(prop.indices_are_sorted); + writer.writeAttribute(prop.input_batching_dims); + writer.writeAttribute(prop.inserted_window_dims); + writer.writeAttribute(prop.scatter_dims_to_operand_dims); + writer.writeAttribute(prop.scatter_indices_batching_dims); + writer.writeAttribute(prop.unique_indices); + writer.writeAttribute(prop.update_window_dims); +} + +::mlir::Attribute ScatterOpV2::getUpdateWindowDims() { + auto attr = getUpdateWindowDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2::getInsertedWindowDims() { + auto attr = getInsertedWindowDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2::getInputBatchingDims() { + auto attr = getInputBatchingDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2::getScatterIndicesBatchingDims() { + auto attr = getScatterIndicesBatchingDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2::getScatterDimsToOperandDims() { + auto attr = getScatterDimsToOperandDimsAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2::getIndexVectorDim() { + auto attr = getIndexVectorDimAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2::getIndicesAreSorted() { + auto attr = getIndicesAreSortedAttr(); + return attr; +} + +::mlir::Attribute ScatterOpV2::getUniqueIndices() { + auto attr = getUniqueIndicesAttr(); + return attr; +} + +void ScatterOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::Value scatter_indices, ::mlir::ValueRange updates, ::mlir::Attribute update_window_dims, ::mlir::Attribute inserted_window_dims, ::mlir::Attribute input_batching_dims, ::mlir::Attribute scatter_indices_batching_dims, ::mlir::Attribute scatter_dims_to_operand_dims, ::mlir::Attribute index_vector_dim, ::mlir::Attribute indices_are_sorted, ::mlir::Attribute unique_indices) { + odsState.addOperands(inputs); + odsState.addOperands(scatter_indices); + odsState.addOperands(updates); + odsState.getOrAddProperties().update_window_dims = update_window_dims; + odsState.getOrAddProperties().inserted_window_dims = inserted_window_dims; + odsState.getOrAddProperties().input_batching_dims = input_batching_dims; + odsState.getOrAddProperties().scatter_indices_batching_dims = scatter_indices_batching_dims; + odsState.getOrAddProperties().scatter_dims_to_operand_dims = scatter_dims_to_operand_dims; + odsState.getOrAddProperties().index_vector_dim = index_vector_dim; + odsState.getOrAddProperties().indices_are_sorted = indices_are_sorted; + odsState.getOrAddProperties().unique_indices = unique_indices; + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void ScatterOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void ScatterOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ScatterOpV2::verifyInvariantsImpl() { + auto tblgen_index_vector_dim = getProperties().index_vector_dim; (void)tblgen_index_vector_dim; + if (!tblgen_index_vector_dim) return emitOpError("requires attribute 'index_vector_dim'"); + auto tblgen_indices_are_sorted = getProperties().indices_are_sorted; (void)tblgen_indices_are_sorted; + if (!tblgen_indices_are_sorted) return emitOpError("requires attribute 'indices_are_sorted'"); + auto tblgen_input_batching_dims = getProperties().input_batching_dims; (void)tblgen_input_batching_dims; + if (!tblgen_input_batching_dims) return emitOpError("requires attribute 'input_batching_dims'"); + auto tblgen_inserted_window_dims = getProperties().inserted_window_dims; (void)tblgen_inserted_window_dims; + if (!tblgen_inserted_window_dims) return emitOpError("requires attribute 'inserted_window_dims'"); + auto tblgen_scatter_dims_to_operand_dims = getProperties().scatter_dims_to_operand_dims; (void)tblgen_scatter_dims_to_operand_dims; + if (!tblgen_scatter_dims_to_operand_dims) return emitOpError("requires attribute 'scatter_dims_to_operand_dims'"); + auto tblgen_scatter_indices_batching_dims = getProperties().scatter_indices_batching_dims; (void)tblgen_scatter_indices_batching_dims; + if (!tblgen_scatter_indices_batching_dims) return emitOpError("requires attribute 'scatter_indices_batching_dims'"); + auto tblgen_unique_indices = getProperties().unique_indices; (void)tblgen_unique_indices; + if (!tblgen_unique_indices) return emitOpError("requires attribute 'unique_indices'"); + auto tblgen_update_window_dims = getProperties().update_window_dims; (void)tblgen_update_window_dims; + if (!tblgen_update_window_dims) return emitOpError("requires attribute 'update_window_dims'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_update_window_dims, "update_window_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_inserted_window_dims, "inserted_window_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_input_batching_dims, "input_batching_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_scatter_indices_batching_dims, "scatter_indices_batching_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_scatter_dims_to_operand_dims, "scatter_dims_to_operand_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_index_vector_dim, "index_vector_dim"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_indices_are_sorted, "indices_are_sorted"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_unique_indices, "unique_indices"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "update_computation", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult ScatterOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ScatterOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 1, 0); +} +mlir::vhlo::Version ScatterOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ScatterOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SelectAndScatterOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SelectAndScatterOpV1GenericAdaptorBase::SelectAndScatterOpV1GenericAdaptorBase(SelectAndScatterOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute SelectAndScatterOpV1GenericAdaptorBase::getWindowDimensions() { + auto attr = getWindowDimensionsAttr(); + return attr; +} + +::mlir::Attribute SelectAndScatterOpV1GenericAdaptorBase::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr; +} + +::mlir::Attribute SelectAndScatterOpV1GenericAdaptorBase::getPadding() { + auto attr = getPaddingAttr(); + return attr; +} + +} // namespace detail +SelectAndScatterOpV1Adaptor::SelectAndScatterOpV1Adaptor(SelectAndScatterOpV1 op) : SelectAndScatterOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SelectAndScatterOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + if (!tblgen_padding) return emitError(loc, "'vhlo.select_and_scatter_v1' op ""requires attribute 'padding'"); + auto tblgen_window_dimensions = getProperties().window_dimensions; (void)tblgen_window_dimensions; + if (!tblgen_window_dimensions) return emitError(loc, "'vhlo.select_and_scatter_v1' op ""requires attribute 'window_dimensions'"); + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + if (!tblgen_window_strides) return emitError(loc, "'vhlo.select_and_scatter_v1' op ""requires attribute 'window_strides'"); + + if (tblgen_window_dimensions && !((true))) + return emitError(loc, "'vhlo.select_and_scatter_v1' op ""attribute 'window_dimensions' failed to satisfy constraint: any attribute"); + + if (tblgen_window_strides && !((true))) + return emitError(loc, "'vhlo.select_and_scatter_v1' op ""attribute 'window_strides' failed to satisfy constraint: any attribute"); + + if (tblgen_padding && !((true))) + return emitError(loc, "'vhlo.select_and_scatter_v1' op ""attribute 'padding' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult SelectAndScatterOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.padding; + auto attr = dict.get("padding"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `padding` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_dimensions; + auto attr = dict.get("window_dimensions"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_dimensions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.window_strides; + auto attr = dict.get("window_strides"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `window_strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SelectAndScatterOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.padding; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("padding", + propStorage)); + } + + { + const auto &propStorage = prop.window_dimensions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_dimensions", + propStorage)); + } + + { + const auto &propStorage = prop.window_strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("window_strides", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SelectAndScatterOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.padding.getAsOpaquePointer()), + llvm::hash_value(prop.window_dimensions.getAsOpaquePointer()), + llvm::hash_value(prop.window_strides.getAsOpaquePointer())); +} + +std::optional SelectAndScatterOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "padding") + return prop.padding; + + if (name == "window_dimensions") + return prop.window_dimensions; + + if (name == "window_strides") + return prop.window_strides; + return std::nullopt; +} + +void SelectAndScatterOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "padding") { + prop.padding = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_dimensions") { + prop.window_dimensions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "window_strides") { + prop.window_strides = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SelectAndScatterOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.padding) attrs.append("padding", prop.padding); + + if (prop.window_dimensions) attrs.append("window_dimensions", prop.window_dimensions); + + if (prop.window_strides) attrs.append("window_strides", prop.window_strides); +} + +::llvm::LogicalResult SelectAndScatterOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getPaddingAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "padding", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowDimensionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "window_dimensions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getWindowStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "window_strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SelectAndScatterOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.padding))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.window_dimensions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.window_strides))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SelectAndScatterOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.padding); + writer.writeAttribute(prop.window_dimensions); + writer.writeAttribute(prop.window_strides); +} + +::mlir::Attribute SelectAndScatterOpV1::getWindowDimensions() { + auto attr = getWindowDimensionsAttr(); + return attr; +} + +::mlir::Attribute SelectAndScatterOpV1::getWindowStrides() { + auto attr = getWindowStridesAttr(); + return attr; +} + +::mlir::Attribute SelectAndScatterOpV1::getPadding() { + auto attr = getPaddingAttr(); + return attr; +} + +void SelectAndScatterOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value source, ::mlir::Value init_value, ::mlir::Attribute window_dimensions, ::mlir::Attribute window_strides, ::mlir::Attribute padding) { + odsState.addOperands(operand); + odsState.addOperands(source); + odsState.addOperands(init_value); + odsState.getOrAddProperties().window_dimensions = window_dimensions; + odsState.getOrAddProperties().window_strides = window_strides; + odsState.getOrAddProperties().padding = padding; + (void)odsState.addRegion(); + (void)odsState.addRegion(); + odsState.addTypes(result); +} + +void SelectAndScatterOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value source, ::mlir::Value init_value, ::mlir::Attribute window_dimensions, ::mlir::Attribute window_strides, ::mlir::Attribute padding) { + odsState.addOperands(operand); + odsState.addOperands(source); + odsState.addOperands(init_value); + odsState.getOrAddProperties().window_dimensions = window_dimensions; + odsState.getOrAddProperties().window_strides = window_strides; + odsState.getOrAddProperties().padding = padding; + (void)odsState.addRegion(); + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SelectAndScatterOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SelectAndScatterOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult SelectAndScatterOpV1::verifyInvariantsImpl() { + auto tblgen_padding = getProperties().padding; (void)tblgen_padding; + if (!tblgen_padding) return emitOpError("requires attribute 'padding'"); + auto tblgen_window_dimensions = getProperties().window_dimensions; (void)tblgen_window_dimensions; + if (!tblgen_window_dimensions) return emitOpError("requires attribute 'window_dimensions'"); + auto tblgen_window_strides = getProperties().window_strides; (void)tblgen_window_strides; + if (!tblgen_window_strides) return emitOpError("requires attribute 'window_strides'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_window_dimensions, "window_dimensions"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_window_strides, "window_strides"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_padding, "padding"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "select", index++))) + return ::mlir::failure(); + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "scatter", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SelectAndScatterOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version SelectAndScatterOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version SelectAndScatterOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::SelectAndScatterOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SelectOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SelectOpV1GenericAdaptorBase::SelectOpV1GenericAdaptorBase(SelectOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +SelectOpV1Adaptor::SelectOpV1Adaptor(SelectOpV1 op) : SelectOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SelectOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult SelectOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute SelectOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SelectOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional SelectOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void SelectOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void SelectOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult SelectOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void SelectOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false) { + odsState.addOperands(pred); + odsState.addOperands(on_true); + odsState.addOperands(on_false); + odsState.addTypes(result); +} + +void SelectOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false) { + odsState.addOperands(pred); + odsState.addOperands(on_true); + odsState.addOperands(on_false); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SelectOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SelectOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult SelectOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SelectOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version SelectOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version SelectOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::SelectOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SendOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SendOpV1GenericAdaptorBase::SendOpV1GenericAdaptorBase(SendOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair SendOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute SendOpV1GenericAdaptorBase::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute SendOpV1GenericAdaptorBase::getChannelType() { + auto attr = getChannelTypeAttr(); + return attr; +} + +::mlir::Attribute SendOpV1GenericAdaptorBase::getIsHostTransfer() { + auto attr = getIsHostTransferAttr(); + return attr; +} + +} // namespace detail +SendOpV1Adaptor::SendOpV1Adaptor(SendOpV1 op) : SendOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SendOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitError(loc, "'vhlo.send_v1' op ""requires attribute 'channel_id'"); + auto tblgen_channel_type = getProperties().channel_type; (void)tblgen_channel_type; + if (!tblgen_channel_type) return emitError(loc, "'vhlo.send_v1' op ""requires attribute 'channel_type'"); + auto tblgen_is_host_transfer = getProperties().is_host_transfer; (void)tblgen_is_host_transfer; + if (!tblgen_is_host_transfer) return emitError(loc, "'vhlo.send_v1' op ""requires attribute 'is_host_transfer'"); + + if (tblgen_channel_id && !((true))) + return emitError(loc, "'vhlo.send_v1' op ""attribute 'channel_id' failed to satisfy constraint: any attribute"); + + if (tblgen_channel_type && !((true))) + return emitError(loc, "'vhlo.send_v1' op ""attribute 'channel_type' failed to satisfy constraint: any attribute"); + + if (tblgen_is_host_transfer && !((true))) + return emitError(loc, "'vhlo.send_v1' op ""attribute 'is_host_transfer' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair SendOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange SendOpV1::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult SendOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.channel_id; + auto attr = dict.get("channel_id"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_id` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.channel_type; + auto attr = dict.get("channel_type"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `channel_type` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.is_host_transfer; + auto attr = dict.get("is_host_transfer"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `is_host_transfer` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SendOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.channel_id; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_id", + propStorage)); + } + + { + const auto &propStorage = prop.channel_type; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("channel_type", + propStorage)); + } + + { + const auto &propStorage = prop.is_host_transfer; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("is_host_transfer", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SendOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.channel_id.getAsOpaquePointer()), + llvm::hash_value(prop.channel_type.getAsOpaquePointer()), + llvm::hash_value(prop.is_host_transfer.getAsOpaquePointer())); +} + +std::optional SendOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "channel_id") + return prop.channel_id; + + if (name == "channel_type") + return prop.channel_type; + + if (name == "is_host_transfer") + return prop.is_host_transfer; + return std::nullopt; +} + +void SendOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "channel_id") { + prop.channel_id = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "channel_type") { + prop.channel_type = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "is_host_transfer") { + prop.is_host_transfer = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SendOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.channel_id) attrs.append("channel_id", prop.channel_id); + + if (prop.channel_type) attrs.append("channel_type", prop.channel_type); + + if (prop.is_host_transfer) attrs.append("is_host_transfer", prop.is_host_transfer); +} + +::llvm::LogicalResult SendOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getChannelIdAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "channel_id", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getChannelTypeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "channel_type", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIsHostTransferAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "is_host_transfer", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SendOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.channel_id))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.channel_type))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.is_host_transfer))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SendOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.channel_id); + writer.writeAttribute(prop.channel_type); + writer.writeAttribute(prop.is_host_transfer); +} + +::mlir::Attribute SendOpV1::getChannelId() { + auto attr = getChannelIdAttr(); + return attr; +} + +::mlir::Attribute SendOpV1::getChannelType() { + auto attr = getChannelTypeAttr(); + return attr; +} + +::mlir::Attribute SendOpV1::getIsHostTransfer() { + auto attr = getIsHostTransferAttr(); + return attr; +} + +void SendOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::Attribute channel_id, ::mlir::Attribute channel_type, ::mlir::Attribute is_host_transfer) { + odsState.addOperands(inputs); + odsState.addOperands(token); + odsState.getOrAddProperties().channel_id = channel_id; + odsState.getOrAddProperties().channel_type = channel_type; + odsState.getOrAddProperties().is_host_transfer = is_host_transfer; + odsState.addTypes(result); +} + +void SendOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::Attribute channel_id, ::mlir::Attribute channel_type, ::mlir::Attribute is_host_transfer) { + odsState.addOperands(inputs); + odsState.addOperands(token); + odsState.getOrAddProperties().channel_id = channel_id; + odsState.getOrAddProperties().channel_type = channel_type; + odsState.getOrAddProperties().is_host_transfer = is_host_transfer; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SendOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SendOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult SendOpV1::verifyInvariantsImpl() { + auto tblgen_channel_id = getProperties().channel_id; (void)tblgen_channel_id; + if (!tblgen_channel_id) return emitOpError("requires attribute 'channel_id'"); + auto tblgen_channel_type = getProperties().channel_type; (void)tblgen_channel_type; + if (!tblgen_channel_type) return emitOpError("requires attribute 'channel_type'"); + auto tblgen_is_host_transfer = getProperties().is_host_transfer; (void)tblgen_is_host_transfer; + if (!tblgen_is_host_transfer) return emitOpError("requires attribute 'is_host_transfer'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_channel_id, "channel_id"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_channel_type, "channel_type"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_is_host_transfer, "is_host_transfer"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SendOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version SendOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version SendOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::SendOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SetDimensionSizeOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SetDimensionSizeOpV1GenericAdaptorBase::SetDimensionSizeOpV1GenericAdaptorBase(SetDimensionSizeOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute SetDimensionSizeOpV1GenericAdaptorBase::getDimension() { + auto attr = getDimensionAttr(); + return attr; +} + +} // namespace detail +SetDimensionSizeOpV1Adaptor::SetDimensionSizeOpV1Adaptor(SetDimensionSizeOpV1 op) : SetDimensionSizeOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SetDimensionSizeOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitError(loc, "'vhlo.set_dimension_size_v1' op ""requires attribute 'dimension'"); + + if (tblgen_dimension && !((true))) + return emitError(loc, "'vhlo.set_dimension_size_v1' op ""attribute 'dimension' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult SetDimensionSizeOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimension; + auto attr = dict.get("dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SetDimensionSizeOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SetDimensionSizeOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimension.getAsOpaquePointer())); +} + +std::optional SetDimensionSizeOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimension") + return prop.dimension; + return std::nullopt; +} + +void SetDimensionSizeOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimension") { + prop.dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SetDimensionSizeOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimension) attrs.append("dimension", prop.dimension); +} + +::llvm::LogicalResult SetDimensionSizeOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SetDimensionSizeOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SetDimensionSizeOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimension); +} + +::mlir::Attribute SetDimensionSizeOpV1::getDimension() { + auto attr = getDimensionAttr(); + return attr; +} + +void SetDimensionSizeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value size, ::mlir::Attribute dimension) { + odsState.addOperands(operand); + odsState.addOperands(size); + odsState.getOrAddProperties().dimension = dimension; + odsState.addTypes(result); +} + +void SetDimensionSizeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value size, ::mlir::Attribute dimension) { + odsState.addOperands(operand); + odsState.addOperands(size); + odsState.getOrAddProperties().dimension = dimension; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SetDimensionSizeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SetDimensionSizeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult SetDimensionSizeOpV1::verifyInvariantsImpl() { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitOpError("requires attribute 'dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_dimension, "dimension"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SetDimensionSizeOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version SetDimensionSizeOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version SetDimensionSizeOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::SetDimensionSizeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ShiftLeftOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ShiftLeftOpV1GenericAdaptorBase::ShiftLeftOpV1GenericAdaptorBase(ShiftLeftOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ShiftLeftOpV1Adaptor::ShiftLeftOpV1Adaptor(ShiftLeftOpV1 op) : ShiftLeftOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ShiftLeftOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ShiftLeftOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ShiftLeftOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ShiftLeftOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ShiftLeftOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ShiftLeftOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ShiftLeftOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ShiftLeftOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ShiftLeftOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void ShiftLeftOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ShiftLeftOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ShiftLeftOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ShiftLeftOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ShiftLeftOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ShiftLeftOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ShiftLeftOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ShiftLeftOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ShiftRightArithmeticOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ShiftRightArithmeticOpV1GenericAdaptorBase::ShiftRightArithmeticOpV1GenericAdaptorBase(ShiftRightArithmeticOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ShiftRightArithmeticOpV1Adaptor::ShiftRightArithmeticOpV1Adaptor(ShiftRightArithmeticOpV1 op) : ShiftRightArithmeticOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ShiftRightArithmeticOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ShiftRightArithmeticOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ShiftRightArithmeticOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ShiftRightArithmeticOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ShiftRightArithmeticOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ShiftRightArithmeticOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ShiftRightArithmeticOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ShiftRightArithmeticOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ShiftRightArithmeticOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void ShiftRightArithmeticOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ShiftRightArithmeticOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ShiftRightArithmeticOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ShiftRightArithmeticOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ShiftRightArithmeticOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ShiftRightArithmeticOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ShiftRightArithmeticOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ShiftRightArithmeticOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ShiftRightLogicalOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ShiftRightLogicalOpV1GenericAdaptorBase::ShiftRightLogicalOpV1GenericAdaptorBase(ShiftRightLogicalOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +ShiftRightLogicalOpV1Adaptor::ShiftRightLogicalOpV1Adaptor(ShiftRightLogicalOpV1 op) : ShiftRightLogicalOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult ShiftRightLogicalOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult ShiftRightLogicalOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ShiftRightLogicalOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ShiftRightLogicalOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional ShiftRightLogicalOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void ShiftRightLogicalOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void ShiftRightLogicalOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult ShiftRightLogicalOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void ShiftRightLogicalOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void ShiftRightLogicalOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ShiftRightLogicalOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ShiftRightLogicalOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult ShiftRightLogicalOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult ShiftRightLogicalOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version ShiftRightLogicalOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version ShiftRightLogicalOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ShiftRightLogicalOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SignOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SignOpV1GenericAdaptorBase::SignOpV1GenericAdaptorBase(SignOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +SignOpV1Adaptor::SignOpV1Adaptor(SignOpV1 op) : SignOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SignOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult SignOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute SignOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SignOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional SignOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void SignOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void SignOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult SignOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void SignOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void SignOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SignOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SignOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult SignOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SignOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version SignOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version SignOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::SignOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SineOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SineOpV1GenericAdaptorBase::SineOpV1GenericAdaptorBase(SineOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +SineOpV1Adaptor::SineOpV1Adaptor(SineOpV1 op) : SineOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SineOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult SineOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute SineOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SineOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional SineOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void SineOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void SineOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult SineOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void SineOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void SineOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SineOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SineOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult SineOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SineOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version SineOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version SineOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 9, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::SineOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SineOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SineOpV2GenericAdaptorBase::SineOpV2GenericAdaptorBase(SineOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute SineOpV2GenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +} // namespace detail +SineOpV2Adaptor::SineOpV2Adaptor(SineOpV2 op) : SineOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SineOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitError(loc, "'vhlo.sine_v2' op ""requires attribute 'result_accuracy'"); + + if (tblgen_result_accuracy && !((true))) + return emitError(loc, "'vhlo.sine_v2' op ""attribute 'result_accuracy' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult SineOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SineOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SineOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional SineOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void SineOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SineOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult SineOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SineOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SineOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_accuracy); +} + +::mlir::Attribute SineOpV2::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +void SineOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + odsState.addTypes(result); +} + +void SineOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SineOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SineOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult SineOpV2::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitOpError("requires attribute 'result_accuracy'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SineOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version SineOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 10, 0); +} +mlir::vhlo::Version SineOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::SineOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SliceOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SliceOpV1GenericAdaptorBase::SliceOpV1GenericAdaptorBase(SliceOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute SliceOpV1GenericAdaptorBase::getStartIndices() { + auto attr = getStartIndicesAttr(); + return attr; +} + +::mlir::Attribute SliceOpV1GenericAdaptorBase::getLimitIndices() { + auto attr = getLimitIndicesAttr(); + return attr; +} + +::mlir::Attribute SliceOpV1GenericAdaptorBase::getStrides() { + auto attr = getStridesAttr(); + return attr; +} + +} // namespace detail +SliceOpV1Adaptor::SliceOpV1Adaptor(SliceOpV1 op) : SliceOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SliceOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_limit_indices = getProperties().limit_indices; (void)tblgen_limit_indices; + if (!tblgen_limit_indices) return emitError(loc, "'vhlo.slice_v1' op ""requires attribute 'limit_indices'"); + auto tblgen_start_indices = getProperties().start_indices; (void)tblgen_start_indices; + if (!tblgen_start_indices) return emitError(loc, "'vhlo.slice_v1' op ""requires attribute 'start_indices'"); + auto tblgen_strides = getProperties().strides; (void)tblgen_strides; + if (!tblgen_strides) return emitError(loc, "'vhlo.slice_v1' op ""requires attribute 'strides'"); + + if (tblgen_start_indices && !((true))) + return emitError(loc, "'vhlo.slice_v1' op ""attribute 'start_indices' failed to satisfy constraint: any attribute"); + + if (tblgen_limit_indices && !((true))) + return emitError(loc, "'vhlo.slice_v1' op ""attribute 'limit_indices' failed to satisfy constraint: any attribute"); + + if (tblgen_strides && !((true))) + return emitError(loc, "'vhlo.slice_v1' op ""attribute 'strides' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult SliceOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.limit_indices; + auto attr = dict.get("limit_indices"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `limit_indices` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.start_indices; + auto attr = dict.get("start_indices"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `start_indices` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.strides; + auto attr = dict.get("strides"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SliceOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.limit_indices; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("limit_indices", + propStorage)); + } + + { + const auto &propStorage = prop.start_indices; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("start_indices", + propStorage)); + } + + { + const auto &propStorage = prop.strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("strides", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SliceOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.limit_indices.getAsOpaquePointer()), + llvm::hash_value(prop.start_indices.getAsOpaquePointer()), + llvm::hash_value(prop.strides.getAsOpaquePointer())); +} + +std::optional SliceOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "limit_indices") + return prop.limit_indices; + + if (name == "start_indices") + return prop.start_indices; + + if (name == "strides") + return prop.strides; + return std::nullopt; +} + +void SliceOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "limit_indices") { + prop.limit_indices = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "start_indices") { + prop.start_indices = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "strides") { + prop.strides = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SliceOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.limit_indices) attrs.append("limit_indices", prop.limit_indices); + + if (prop.start_indices) attrs.append("start_indices", prop.start_indices); + + if (prop.strides) attrs.append("strides", prop.strides); +} + +::llvm::LogicalResult SliceOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getLimitIndicesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "limit_indices", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStartIndicesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "start_indices", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SliceOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.limit_indices))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.start_indices))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.strides))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SliceOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.limit_indices); + writer.writeAttribute(prop.start_indices); + writer.writeAttribute(prop.strides); +} + +::mlir::Attribute SliceOpV1::getStartIndices() { + auto attr = getStartIndicesAttr(); + return attr; +} + +::mlir::Attribute SliceOpV1::getLimitIndices() { + auto attr = getLimitIndicesAttr(); + return attr; +} + +::mlir::Attribute SliceOpV1::getStrides() { + auto attr = getStridesAttr(); + return attr; +} + +void SliceOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute start_indices, ::mlir::Attribute limit_indices, ::mlir::Attribute strides) { + odsState.addOperands(operand); + odsState.getOrAddProperties().start_indices = start_indices; + odsState.getOrAddProperties().limit_indices = limit_indices; + odsState.getOrAddProperties().strides = strides; + odsState.addTypes(result); +} + +void SliceOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute start_indices, ::mlir::Attribute limit_indices, ::mlir::Attribute strides) { + odsState.addOperands(operand); + odsState.getOrAddProperties().start_indices = start_indices; + odsState.getOrAddProperties().limit_indices = limit_indices; + odsState.getOrAddProperties().strides = strides; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SliceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SliceOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult SliceOpV1::verifyInvariantsImpl() { + auto tblgen_limit_indices = getProperties().limit_indices; (void)tblgen_limit_indices; + if (!tblgen_limit_indices) return emitOpError("requires attribute 'limit_indices'"); + auto tblgen_start_indices = getProperties().start_indices; (void)tblgen_start_indices; + if (!tblgen_start_indices) return emitOpError("requires attribute 'start_indices'"); + auto tblgen_strides = getProperties().strides; (void)tblgen_strides; + if (!tblgen_strides) return emitOpError("requires attribute 'strides'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_start_indices, "start_indices"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_limit_indices, "limit_indices"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_strides, "strides"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SliceOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version SliceOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version SliceOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::SliceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SortOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SortOpV1GenericAdaptorBase::SortOpV1GenericAdaptorBase(SortOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair SortOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Attribute SortOpV1GenericAdaptorBase::getDimension() { + auto attr = getDimensionAttr(); + return attr; +} + +::mlir::Attribute SortOpV1GenericAdaptorBase::getIsStable() { + auto attr = getIsStableAttr(); + return attr; +} + +} // namespace detail +SortOpV1Adaptor::SortOpV1Adaptor(SortOpV1 op) : SortOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SortOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitError(loc, "'vhlo.sort_v1' op ""requires attribute 'dimension'"); + auto tblgen_is_stable = getProperties().is_stable; (void)tblgen_is_stable; + if (!tblgen_is_stable) return emitError(loc, "'vhlo.sort_v1' op ""requires attribute 'is_stable'"); + + if (tblgen_dimension && !((true))) + return emitError(loc, "'vhlo.sort_v1' op ""attribute 'dimension' failed to satisfy constraint: any attribute"); + + if (tblgen_is_stable && !((true))) + return emitError(loc, "'vhlo.sort_v1' op ""attribute 'is_stable' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair SortOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange SortOpV1::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair SortOpV1::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult SortOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimension; + auto attr = dict.get("dimension"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.is_stable; + auto attr = dict.get("is_stable"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `is_stable` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SortOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimension", + propStorage)); + } + + { + const auto &propStorage = prop.is_stable; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("is_stable", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SortOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.dimension.getAsOpaquePointer()), + llvm::hash_value(prop.is_stable.getAsOpaquePointer())); +} + +std::optional SortOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimension") + return prop.dimension; + + if (name == "is_stable") + return prop.is_stable; + return std::nullopt; +} + +void SortOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimension") { + prop.dimension = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "is_stable") { + prop.is_stable = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SortOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimension) attrs.append("dimension", prop.dimension); + + if (prop.is_stable) attrs.append("is_stable", prop.is_stable); +} + +::llvm::LogicalResult SortOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "dimension", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIsStableAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "is_stable", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SortOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimension))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.is_stable))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SortOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimension); + writer.writeAttribute(prop.is_stable); +} + +::mlir::Attribute SortOpV1::getDimension() { + auto attr = getDimensionAttr(); + return attr; +} + +::mlir::Attribute SortOpV1::getIsStable() { + auto attr = getIsStableAttr(); + return attr; +} + +void SortOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::Attribute dimension, ::mlir::Attribute is_stable) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = dimension; + odsState.getOrAddProperties().is_stable = is_stable; + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void SortOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SortOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult SortOpV1::verifyInvariantsImpl() { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitOpError("requires attribute 'dimension'"); + auto tblgen_is_stable = getProperties().is_stable; (void)tblgen_is_stable; + if (!tblgen_is_stable) return emitOpError("requires attribute 'is_stable'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_dimension, "dimension"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_is_stable, "is_stable"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "comparator", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SortOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version SortOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version SortOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::SortOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SqrtOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SqrtOpV1GenericAdaptorBase::SqrtOpV1GenericAdaptorBase(SqrtOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +SqrtOpV1Adaptor::SqrtOpV1Adaptor(SqrtOpV1 op) : SqrtOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SqrtOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult SqrtOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute SqrtOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SqrtOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional SqrtOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void SqrtOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void SqrtOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult SqrtOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void SqrtOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void SqrtOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SqrtOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SqrtOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult SqrtOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SqrtOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version SqrtOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version SqrtOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 9, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::SqrtOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SqrtOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SqrtOpV2GenericAdaptorBase::SqrtOpV2GenericAdaptorBase(SqrtOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute SqrtOpV2GenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +} // namespace detail +SqrtOpV2Adaptor::SqrtOpV2Adaptor(SqrtOpV2 op) : SqrtOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SqrtOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitError(loc, "'vhlo.sqrt_v2' op ""requires attribute 'result_accuracy'"); + + if (tblgen_result_accuracy && !((true))) + return emitError(loc, "'vhlo.sqrt_v2' op ""attribute 'result_accuracy' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult SqrtOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SqrtOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SqrtOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional SqrtOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void SqrtOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SqrtOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult SqrtOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult SqrtOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SqrtOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_accuracy); +} + +::mlir::Attribute SqrtOpV2::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +void SqrtOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + odsState.addTypes(result); +} + +void SqrtOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SqrtOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void SqrtOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult SqrtOpV2::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitOpError("requires attribute 'result_accuracy'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SqrtOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version SqrtOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 10, 0); +} +mlir::vhlo::Version SqrtOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::SqrtOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SubtractOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SubtractOpV1GenericAdaptorBase::SubtractOpV1GenericAdaptorBase(SubtractOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +SubtractOpV1Adaptor::SubtractOpV1Adaptor(SubtractOpV1 op) : SubtractOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult SubtractOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult SubtractOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute SubtractOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SubtractOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional SubtractOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void SubtractOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void SubtractOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult SubtractOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void SubtractOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void SubtractOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SubtractOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SubtractOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult SubtractOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult SubtractOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version SubtractOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version SubtractOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::SubtractOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TanOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TanOpV1GenericAdaptorBase::TanOpV1GenericAdaptorBase(TanOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +TanOpV1Adaptor::TanOpV1Adaptor(TanOpV1 op) : TanOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TanOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult TanOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute TanOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TanOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional TanOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void TanOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void TanOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult TanOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void TanOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void TanOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TanOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void TanOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult TanOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TanOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version TanOpV1::getMinVersion() { + return mlir::vhlo::Version(1, 4, 0); +} +mlir::vhlo::Version TanOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 9, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TanOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TanOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TanOpV2GenericAdaptorBase::TanOpV2GenericAdaptorBase(TanOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute TanOpV2GenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +} // namespace detail +TanOpV2Adaptor::TanOpV2Adaptor(TanOpV2 op) : TanOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TanOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitError(loc, "'vhlo.tan_v2' op ""requires attribute 'result_accuracy'"); + + if (tblgen_result_accuracy && !((true))) + return emitError(loc, "'vhlo.tan_v2' op ""attribute 'result_accuracy' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult TanOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute TanOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TanOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional TanOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void TanOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void TanOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult TanOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult TanOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TanOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_accuracy); +} + +::mlir::Attribute TanOpV2::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +void TanOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + odsState.addTypes(result); +} + +void TanOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TanOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void TanOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult TanOpV2::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitOpError("requires attribute 'result_accuracy'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TanOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version TanOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 10, 0); +} +mlir::vhlo::Version TanOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TanOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TanhOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TanhOpV1GenericAdaptorBase::TanhOpV1GenericAdaptorBase(TanhOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +TanhOpV1Adaptor::TanhOpV1Adaptor(TanhOpV1 op) : TanhOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TanhOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult TanhOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute TanhOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TanhOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional TanhOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void TanhOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void TanhOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult TanhOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void TanhOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void TanhOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TanhOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void TanhOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult TanhOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TanhOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version TanhOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version TanhOpV1::getMaxVersion() { + return mlir::vhlo::Version(1, 9, 0); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TanhOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TanhOpV2 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TanhOpV2GenericAdaptorBase::TanhOpV2GenericAdaptorBase(TanhOpV2 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute TanhOpV2GenericAdaptorBase::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +} // namespace detail +TanhOpV2Adaptor::TanhOpV2Adaptor(TanhOpV2 op) : TanhOpV2GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TanhOpV2Adaptor::verify(::mlir::Location loc) { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitError(loc, "'vhlo.tanh_v2' op ""requires attribute 'result_accuracy'"); + + if (tblgen_result_accuracy && !((true))) + return emitError(loc, "'vhlo.tanh_v2' op ""attribute 'result_accuracy' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult TanhOpV2::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_accuracy; + auto attr = dict.get("result_accuracy"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_accuracy` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute TanhOpV2::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_accuracy; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_accuracy", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TanhOpV2::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.result_accuracy.getAsOpaquePointer())); +} + +std::optional TanhOpV2::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_accuracy") + return prop.result_accuracy; + return std::nullopt; +} + +void TanhOpV2::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_accuracy") { + prop.result_accuracy = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void TanhOpV2::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_accuracy) attrs.append("result_accuracy", prop.result_accuracy); +} + +::llvm::LogicalResult TanhOpV2::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultAccuracyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "result_accuracy", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult TanhOpV2::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_accuracy))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TanhOpV2::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_accuracy); +} + +::mlir::Attribute TanhOpV2::getResultAccuracy() { + auto attr = getResultAccuracyAttr(); + return attr; +} + +void TanhOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + odsState.addTypes(result); +} + +void TanhOpV2::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy) { + odsState.addOperands(operand); + odsState.getOrAddProperties().result_accuracy = result_accuracy; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TanhOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void TanhOpV2::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult TanhOpV2::verifyInvariantsImpl() { + auto tblgen_result_accuracy = getProperties().result_accuracy; (void)tblgen_result_accuracy; + if (!tblgen_result_accuracy) return emitOpError("requires attribute 'result_accuracy'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_result_accuracy, "result_accuracy"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TanhOpV2::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version TanhOpV2::getMinVersion() { + return mlir::vhlo::Version(1, 10, 0); +} +mlir::vhlo::Version TanhOpV2::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TanhOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TorchIndexSelectOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TorchIndexSelectOpV1GenericAdaptorBase::TorchIndexSelectOpV1GenericAdaptorBase(TorchIndexSelectOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute TorchIndexSelectOpV1GenericAdaptorBase::getDim() { + auto attr = getDimAttr(); + return attr; +} + +::mlir::Attribute TorchIndexSelectOpV1GenericAdaptorBase::getBatchDims() { + auto attr = getBatchDimsAttr(); + return attr; +} + +} // namespace detail +TorchIndexSelectOpV1Adaptor::TorchIndexSelectOpV1Adaptor(TorchIndexSelectOpV1 op) : TorchIndexSelectOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TorchIndexSelectOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_batch_dims = getProperties().batch_dims; (void)tblgen_batch_dims; + if (!tblgen_batch_dims) return emitError(loc, "'vhlo.torch_index_select_v1' op ""requires attribute 'batch_dims'"); + auto tblgen_dim = getProperties().dim; (void)tblgen_dim; + if (!tblgen_dim) return emitError(loc, "'vhlo.torch_index_select_v1' op ""requires attribute 'dim'"); + + if (tblgen_dim && !((true))) + return emitError(loc, "'vhlo.torch_index_select_v1' op ""attribute 'dim' failed to satisfy constraint: any attribute"); + + if (tblgen_batch_dims && !((true))) + return emitError(loc, "'vhlo.torch_index_select_v1' op ""attribute 'batch_dims' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult TorchIndexSelectOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.batch_dims; + auto attr = dict.get("batch_dims"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `batch_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.dim; + auto attr = dict.get("dim"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute TorchIndexSelectOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.batch_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("batch_dims", + propStorage)); + } + + { + const auto &propStorage = prop.dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dim", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TorchIndexSelectOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.batch_dims.getAsOpaquePointer()), + llvm::hash_value(prop.dim.getAsOpaquePointer())); +} + +std::optional TorchIndexSelectOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "batch_dims") + return prop.batch_dims; + + if (name == "dim") + return prop.dim; + return std::nullopt; +} + +void TorchIndexSelectOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "batch_dims") { + prop.batch_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "dim") { + prop.dim = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void TorchIndexSelectOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.batch_dims) attrs.append("batch_dims", prop.batch_dims); + + if (prop.dim) attrs.append("dim", prop.dim); +} + +::llvm::LogicalResult TorchIndexSelectOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getBatchDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "batch_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "dim", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult TorchIndexSelectOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.batch_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.dim))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TorchIndexSelectOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.batch_dims); + writer.writeAttribute(prop.dim); +} + +::mlir::Attribute TorchIndexSelectOpV1::getDim() { + auto attr = getDimAttr(); + return attr; +} + +::mlir::Attribute TorchIndexSelectOpV1::getBatchDims() { + auto attr = getBatchDimsAttr(); + return attr; +} + +void TorchIndexSelectOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value index, ::mlir::Attribute dim, ::mlir::Attribute batch_dims) { + odsState.addOperands(operand); + odsState.addOperands(index); + odsState.getOrAddProperties().dim = dim; + odsState.getOrAddProperties().batch_dims = batch_dims; + odsState.addTypes(result); +} + +void TorchIndexSelectOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value index, ::mlir::Attribute dim, ::mlir::Attribute batch_dims) { + odsState.addOperands(operand); + odsState.addOperands(index); + odsState.getOrAddProperties().dim = dim; + odsState.getOrAddProperties().batch_dims = batch_dims; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TorchIndexSelectOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void TorchIndexSelectOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult TorchIndexSelectOpV1::verifyInvariantsImpl() { + auto tblgen_batch_dims = getProperties().batch_dims; (void)tblgen_batch_dims; + if (!tblgen_batch_dims) return emitOpError("requires attribute 'batch_dims'"); + auto tblgen_dim = getProperties().dim; (void)tblgen_dim; + if (!tblgen_dim) return emitOpError("requires attribute 'dim'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_dim, "dim"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_batch_dims, "batch_dims"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TorchIndexSelectOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version TorchIndexSelectOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version TorchIndexSelectOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TorchIndexSelectOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TransposeOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TransposeOpV1GenericAdaptorBase::TransposeOpV1GenericAdaptorBase(TransposeOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute TransposeOpV1GenericAdaptorBase::getPermutation() { + auto attr = getPermutationAttr(); + return attr; +} + +} // namespace detail +TransposeOpV1Adaptor::TransposeOpV1Adaptor(TransposeOpV1 op) : TransposeOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TransposeOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_permutation = getProperties().permutation; (void)tblgen_permutation; + if (!tblgen_permutation) return emitError(loc, "'vhlo.transpose_v1' op ""requires attribute 'permutation'"); + + if (tblgen_permutation && !((true))) + return emitError(loc, "'vhlo.transpose_v1' op ""attribute 'permutation' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult TransposeOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.permutation; + auto attr = dict.get("permutation"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `permutation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute TransposeOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.permutation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("permutation", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TransposeOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.permutation.getAsOpaquePointer())); +} + +std::optional TransposeOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "permutation") + return prop.permutation; + return std::nullopt; +} + +void TransposeOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "permutation") { + prop.permutation = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void TransposeOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.permutation) attrs.append("permutation", prop.permutation); +} + +::llvm::LogicalResult TransposeOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getPermutationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "permutation", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult TransposeOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.permutation))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TransposeOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.permutation); +} + +::mlir::Attribute TransposeOpV1::getPermutation() { + auto attr = getPermutationAttr(); + return attr; +} + +void TransposeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute permutation) { + odsState.addOperands(operand); + odsState.getOrAddProperties().permutation = permutation; + odsState.addTypes(result); +} + +void TransposeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute permutation) { + odsState.addOperands(operand); + odsState.getOrAddProperties().permutation = permutation; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TransposeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void TransposeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult TransposeOpV1::verifyInvariantsImpl() { + auto tblgen_permutation = getProperties().permutation; (void)tblgen_permutation; + if (!tblgen_permutation) return emitOpError("requires attribute 'permutation'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_permutation, "permutation"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TransposeOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version TransposeOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version TransposeOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TransposeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TriangularSolveOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TriangularSolveOpV1GenericAdaptorBase::TriangularSolveOpV1GenericAdaptorBase(TriangularSolveOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute TriangularSolveOpV1GenericAdaptorBase::getLeftSide() { + auto attr = getLeftSideAttr(); + return attr; +} + +::mlir::Attribute TriangularSolveOpV1GenericAdaptorBase::getLower() { + auto attr = getLowerAttr(); + return attr; +} + +::mlir::Attribute TriangularSolveOpV1GenericAdaptorBase::getUnitDiagonal() { + auto attr = getUnitDiagonalAttr(); + return attr; +} + +::mlir::Attribute TriangularSolveOpV1GenericAdaptorBase::getTransposeA() { + auto attr = getTransposeAAttr(); + return attr; +} + +} // namespace detail +TriangularSolveOpV1Adaptor::TriangularSolveOpV1Adaptor(TriangularSolveOpV1 op) : TriangularSolveOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TriangularSolveOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_left_side = getProperties().left_side; (void)tblgen_left_side; + if (!tblgen_left_side) return emitError(loc, "'vhlo.triangular_solve_v1' op ""requires attribute 'left_side'"); + auto tblgen_lower = getProperties().lower; (void)tblgen_lower; + if (!tblgen_lower) return emitError(loc, "'vhlo.triangular_solve_v1' op ""requires attribute 'lower'"); + auto tblgen_transpose_a = getProperties().transpose_a; (void)tblgen_transpose_a; + if (!tblgen_transpose_a) return emitError(loc, "'vhlo.triangular_solve_v1' op ""requires attribute 'transpose_a'"); + auto tblgen_unit_diagonal = getProperties().unit_diagonal; (void)tblgen_unit_diagonal; + if (!tblgen_unit_diagonal) return emitError(loc, "'vhlo.triangular_solve_v1' op ""requires attribute 'unit_diagonal'"); + + if (tblgen_left_side && !((true))) + return emitError(loc, "'vhlo.triangular_solve_v1' op ""attribute 'left_side' failed to satisfy constraint: any attribute"); + + if (tblgen_lower && !((true))) + return emitError(loc, "'vhlo.triangular_solve_v1' op ""attribute 'lower' failed to satisfy constraint: any attribute"); + + if (tblgen_unit_diagonal && !((true))) + return emitError(loc, "'vhlo.triangular_solve_v1' op ""attribute 'unit_diagonal' failed to satisfy constraint: any attribute"); + + if (tblgen_transpose_a && !((true))) + return emitError(loc, "'vhlo.triangular_solve_v1' op ""attribute 'transpose_a' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult TriangularSolveOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.left_side; + auto attr = dict.get("left_side"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `left_side` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.lower; + auto attr = dict.get("lower"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lower` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.transpose_a; + auto attr = dict.get("transpose_a"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `transpose_a` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.unit_diagonal; + auto attr = dict.get("unit_diagonal"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `unit_diagonal` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute TriangularSolveOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.left_side; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("left_side", + propStorage)); + } + + { + const auto &propStorage = prop.lower; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lower", + propStorage)); + } + + { + const auto &propStorage = prop.transpose_a; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("transpose_a", + propStorage)); + } + + { + const auto &propStorage = prop.unit_diagonal; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("unit_diagonal", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TriangularSolveOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.left_side.getAsOpaquePointer()), + llvm::hash_value(prop.lower.getAsOpaquePointer()), + llvm::hash_value(prop.transpose_a.getAsOpaquePointer()), + llvm::hash_value(prop.unit_diagonal.getAsOpaquePointer())); +} + +std::optional TriangularSolveOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "left_side") + return prop.left_side; + + if (name == "lower") + return prop.lower; + + if (name == "transpose_a") + return prop.transpose_a; + + if (name == "unit_diagonal") + return prop.unit_diagonal; + return std::nullopt; +} + +void TriangularSolveOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "left_side") { + prop.left_side = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "lower") { + prop.lower = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "transpose_a") { + prop.transpose_a = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "unit_diagonal") { + prop.unit_diagonal = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void TriangularSolveOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.left_side) attrs.append("left_side", prop.left_side); + + if (prop.lower) attrs.append("lower", prop.lower); + + if (prop.transpose_a) attrs.append("transpose_a", prop.transpose_a); + + if (prop.unit_diagonal) attrs.append("unit_diagonal", prop.unit_diagonal); +} + +::llvm::LogicalResult TriangularSolveOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getLeftSideAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "left_side", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLowerAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "lower", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getTransposeAAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "transpose_a", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUnitDiagonalAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "unit_diagonal", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult TriangularSolveOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.left_side))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.lower))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.transpose_a))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.unit_diagonal))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TriangularSolveOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.left_side); + writer.writeAttribute(prop.lower); + writer.writeAttribute(prop.transpose_a); + writer.writeAttribute(prop.unit_diagonal); +} + +::mlir::Attribute TriangularSolveOpV1::getLeftSide() { + auto attr = getLeftSideAttr(); + return attr; +} + +::mlir::Attribute TriangularSolveOpV1::getLower() { + auto attr = getLowerAttr(); + return attr; +} + +::mlir::Attribute TriangularSolveOpV1::getUnitDiagonal() { + auto attr = getUnitDiagonalAttr(); + return attr; +} + +::mlir::Attribute TriangularSolveOpV1::getTransposeA() { + auto attr = getTransposeAAttr(); + return attr; +} + +void TriangularSolveOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, ::mlir::Value b, ::mlir::Attribute left_side, ::mlir::Attribute lower, ::mlir::Attribute unit_diagonal, ::mlir::Attribute transpose_a) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.getOrAddProperties().left_side = left_side; + odsState.getOrAddProperties().lower = lower; + odsState.getOrAddProperties().unit_diagonal = unit_diagonal; + odsState.getOrAddProperties().transpose_a = transpose_a; + odsState.addTypes(result); +} + +void TriangularSolveOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Attribute left_side, ::mlir::Attribute lower, ::mlir::Attribute unit_diagonal, ::mlir::Attribute transpose_a) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.getOrAddProperties().left_side = left_side; + odsState.getOrAddProperties().lower = lower; + odsState.getOrAddProperties().unit_diagonal = unit_diagonal; + odsState.getOrAddProperties().transpose_a = transpose_a; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TriangularSolveOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void TriangularSolveOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult TriangularSolveOpV1::verifyInvariantsImpl() { + auto tblgen_left_side = getProperties().left_side; (void)tblgen_left_side; + if (!tblgen_left_side) return emitOpError("requires attribute 'left_side'"); + auto tblgen_lower = getProperties().lower; (void)tblgen_lower; + if (!tblgen_lower) return emitOpError("requires attribute 'lower'"); + auto tblgen_transpose_a = getProperties().transpose_a; (void)tblgen_transpose_a; + if (!tblgen_transpose_a) return emitOpError("requires attribute 'transpose_a'"); + auto tblgen_unit_diagonal = getProperties().unit_diagonal; (void)tblgen_unit_diagonal; + if (!tblgen_unit_diagonal) return emitOpError("requires attribute 'unit_diagonal'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_left_side, "left_side"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_lower, "lower"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_unit_diagonal, "unit_diagonal"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_transpose_a, "transpose_a"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TriangularSolveOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version TriangularSolveOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version TriangularSolveOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TriangularSolveOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TupleOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TupleOpV1GenericAdaptorBase::TupleOpV1GenericAdaptorBase(TupleOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair TupleOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +} // namespace detail +TupleOpV1Adaptor::TupleOpV1Adaptor(TupleOpV1 op) : TupleOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult TupleOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair TupleOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange TupleOpV1::getValMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::llvm::LogicalResult TupleOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute TupleOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TupleOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional TupleOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void TupleOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void TupleOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult TupleOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void TupleOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange val) { + odsState.addOperands(val); + odsState.addTypes(result); +} + +void TupleOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void TupleOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult TupleOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult TupleOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version TupleOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version TupleOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TupleOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::UnaryEinsumOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +UnaryEinsumOpV1GenericAdaptorBase::UnaryEinsumOpV1GenericAdaptorBase(UnaryEinsumOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +::mlir::Attribute UnaryEinsumOpV1GenericAdaptorBase::getEinsumConfig() { + auto attr = getEinsumConfigAttr(); + return attr; +} + +} // namespace detail +UnaryEinsumOpV1Adaptor::UnaryEinsumOpV1Adaptor(UnaryEinsumOpV1 op) : UnaryEinsumOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult UnaryEinsumOpV1Adaptor::verify(::mlir::Location loc) { + auto tblgen_einsum_config = getProperties().einsum_config; (void)tblgen_einsum_config; + if (!tblgen_einsum_config) return emitError(loc, "'vhlo.unary_einsum_v1' op ""requires attribute 'einsum_config'"); + + if (tblgen_einsum_config && !((true))) + return emitError(loc, "'vhlo.unary_einsum_v1' op ""attribute 'einsum_config' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +::llvm::LogicalResult UnaryEinsumOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.einsum_config; + auto attr = dict.get("einsum_config"); + if (attr) { + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `einsum_config` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute UnaryEinsumOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.einsum_config; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("einsum_config", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code UnaryEinsumOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine( + llvm::hash_value(prop.einsum_config.getAsOpaquePointer())); +} + +std::optional UnaryEinsumOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "einsum_config") + return prop.einsum_config; + return std::nullopt; +} + +void UnaryEinsumOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "einsum_config") { + prop.einsum_config = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void UnaryEinsumOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.einsum_config) attrs.append("einsum_config", prop.einsum_config); +} + +::llvm::LogicalResult UnaryEinsumOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getEinsumConfigAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(attr, "einsum_config", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult UnaryEinsumOpV1::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.einsum_config))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void UnaryEinsumOpV1::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.einsum_config); +} + +::mlir::Attribute UnaryEinsumOpV1::getEinsumConfig() { + auto attr = getEinsumConfigAttr(); + return attr; +} + +void UnaryEinsumOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute einsum_config) { + odsState.addOperands(operand); + odsState.getOrAddProperties().einsum_config = einsum_config; + odsState.addTypes(result); +} + +void UnaryEinsumOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute einsum_config) { + odsState.addOperands(operand); + odsState.getOrAddProperties().einsum_config = einsum_config; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void UnaryEinsumOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); + + if (!attributes.empty()) { + ::mlir::OpaqueProperties properties = + &odsState.getOrAddProperties(); + std::optional<::mlir::RegisteredOperationName> info = + odsState.name.getRegisteredInfo(); + if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties, + odsState.attributes.getDictionary(odsState.getContext()), nullptr))) + ::llvm::report_fatal_error("Property conversion failed."); + } +} + +void UnaryEinsumOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult UnaryEinsumOpV1::verifyInvariantsImpl() { + auto tblgen_einsum_config = getProperties().einsum_config; (void)tblgen_einsum_config; + if (!tblgen_einsum_config) return emitOpError("requires attribute 'einsum_config'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VhloOps1(*this, tblgen_einsum_config, "einsum_config"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult UnaryEinsumOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version UnaryEinsumOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version UnaryEinsumOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::UnaryEinsumOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::UniformDequantizeOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +UniformDequantizeOpV1GenericAdaptorBase::UniformDequantizeOpV1GenericAdaptorBase(UniformDequantizeOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +UniformDequantizeOpV1Adaptor::UniformDequantizeOpV1Adaptor(UniformDequantizeOpV1 op) : UniformDequantizeOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult UniformDequantizeOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult UniformDequantizeOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute UniformDequantizeOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code UniformDequantizeOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional UniformDequantizeOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void UniformDequantizeOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void UniformDequantizeOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult UniformDequantizeOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void UniformDequantizeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void UniformDequantizeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void UniformDequantizeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void UniformDequantizeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult UniformDequantizeOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult UniformDequantizeOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version UniformDequantizeOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version UniformDequantizeOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::UniformDequantizeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::UniformQuantizeOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +UniformQuantizeOpV1GenericAdaptorBase::UniformQuantizeOpV1GenericAdaptorBase(UniformQuantizeOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +UniformQuantizeOpV1Adaptor::UniformQuantizeOpV1Adaptor(UniformQuantizeOpV1 op) : UniformQuantizeOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult UniformQuantizeOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult UniformQuantizeOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute UniformQuantizeOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code UniformQuantizeOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional UniformQuantizeOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void UniformQuantizeOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void UniformQuantizeOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult UniformQuantizeOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void UniformQuantizeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand) { + odsState.addOperands(operand); + odsState.addTypes(result); +} + +void UniformQuantizeOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand) { + odsState.addOperands(operand); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void UniformQuantizeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void UniformQuantizeOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult UniformQuantizeOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult UniformQuantizeOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version UniformQuantizeOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version UniformQuantizeOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::UniformQuantizeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::WhileOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +WhileOpV1GenericAdaptorBase::WhileOpV1GenericAdaptorBase(WhileOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +std::pair WhileOpV1GenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +} // namespace detail +WhileOpV1Adaptor::WhileOpV1Adaptor(WhileOpV1 op) : WhileOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult WhileOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair WhileOpV1::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::MutableOperandRange WhileOpV1::getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair WhileOpV1::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::llvm::LogicalResult WhileOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute WhileOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code WhileOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional WhileOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void WhileOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void WhileOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult WhileOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void WhileOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +void WhileOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult WhileOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "cond", index++))) + return ::mlir::failure(); + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VhloOps1(*this, region, "body", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::llvm::LogicalResult WhileOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version WhileOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version WhileOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::WhileOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::XorOpV1 definitions +//===----------------------------------------------------------------------===// + +namespace detail { +XorOpV1GenericAdaptorBase::XorOpV1GenericAdaptorBase(XorOpV1 op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {} + +} // namespace detail +XorOpV1Adaptor::XorOpV1Adaptor(XorOpV1 op) : XorOpV1GenericAdaptor(op->getOperands(), op) {} + +::llvm::LogicalResult XorOpV1Adaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +::llvm::LogicalResult XorOpV1::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute XorOpV1::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code XorOpV1::computePropertiesHash(const Properties &prop) { + using llvm::hash_value; + return llvm::hash_combine(); +} + +std::optional XorOpV1::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + return std::nullopt; +} + +void XorOpV1::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { +} + +void XorOpV1::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { +} + +::llvm::LogicalResult XorOpV1::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +void XorOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void XorOpV1::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void XorOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void XorOpV1::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.useProperties(const_cast(properties)); + odsState.addAttributes(discardableAttributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::llvm::LogicalResult XorOpV1::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VhloOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::llvm::LogicalResult XorOpV1::verifyInvariants() { + return verifyInvariantsImpl(); +} + +mlir::vhlo::Version XorOpV1::getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); +} +mlir::vhlo::Version XorOpV1::getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); +} +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::XorOpV1) + + +#endif // GET_OP_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOps.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOps.h new file mode 100644 index 0000000000000000000000000000000000000000..2f639a7282788fc00b2e820f560b62b5217c3c0b --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOps.h @@ -0,0 +1,76 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + Copyright 2022 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_VHLO_OPS_H +#define STABLEHLO_DIALECT_VHLO_OPS_H + +#include "mlir/IR/Attributes.h" +#include "mlir/IR/Dialect.h" +#include "mlir/IR/DialectImplementation.h" +#include "mlir/IR/Location.h" +#include "mlir/IR/MLIRContext.h" +#include "mlir/Interfaces/FunctionInterfaces.h" +#include "stablehlo/dialect/Version.h" +#include "stablehlo/dialect/VhloTypes.h" + +namespace mlir { +namespace vhlo { + +class VhloDialect : public Dialect { + public: + explicit VhloDialect(MLIRContext *context); + static StringRef getDialectNamespace() { return "vhlo"; } + + // Parses a type registered to this dialect. + Type parseType(DialectAsmParser &parser) const override; + + // Prints a type registered to this dialect. + void printType(Type type, DialectAsmPrinter &os) const override; + + // Parses an attribute registered to this dialect. + Attribute parseAttribute(DialectAsmParser &parser, Type type) const override; + + // Prints an attribute registered to this dialect. + void printAttribute(Attribute attr, DialectAsmPrinter &os) const override; + + private: + // Adds VHLO types to this dialect. + // See implementation comments for additional details. + void addVhloTypes(); + + // Does the same this as Dialect::addTypes but without calling registerType. + // See comments for `addVhloTypes` for additional details. + template + void addTypesWithoutRegistering() { + (addType(Types::getTypeID(), AbstractType::get(*this)), ...); + } +}; + +} // namespace vhlo +} // namespace mlir + +// Attrs and Enums +#include "stablehlo/dialect/VhloAttrInterfaces.h.inc" +#include "stablehlo/dialect/VhloEnums.h.inc" +#define GET_ATTRDEF_CLASSES +#include "stablehlo/dialect/VhloAttrs.h.inc" + +// Ops +#include "stablehlo/dialect/VhloOpInterfaces.h.inc" +#define GET_OP_CLASSES +#include "stablehlo/dialect/VhloOps.h.inc" + +#endif // STABLEHLO_DIALECT_VHLO_OPS_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOps.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOps.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..ea410d12ca5d95c93e7fcab9259300d9cd5e60be --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloOps.h.inc @@ -0,0 +1,32123 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: VhloOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace vhlo { +class AbsOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class AddOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class AfterAllOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class AllGatherOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class AllGatherOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class AllReduceOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class AllReduceOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class AllToAllOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class AllToAllOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class AndOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class Atan2OpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class BatchNormGradOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class BatchNormInferenceOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class BatchNormTrainingOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class BitcastConvertOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class BroadcastInDimOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class BroadcastOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CallOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CaseOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CbrtOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CbrtOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CeilOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CholeskyOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ClampOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ClzOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CollectiveBroadcastOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CollectivePermuteOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CompareOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ComplexOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CompositeOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ConcatenateOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ConstantOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ConvertOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ConvolutionOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CosineOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CosineOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CreateTokenOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CrossReplicaSumOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class CustomCallOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DivOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DotGeneralOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DotGeneralOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DotOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DynamicBroadcastInDimOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DynamicConvOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DynamicConvOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DynamicGatherOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DynamicGatherOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DynamicIotaOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DynamicPadOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DynamicReshapeOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DynamicSliceOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class DynamicUpdateSliceOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class EinsumOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ExpOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ExpOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class Expm1OpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class Expm1OpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class FftOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class FloorOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class FuncOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class GatherOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class GatherOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class GetDimensionSizeOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class GetTupleElementOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class IfOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ImagOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class InfeedOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class IotaOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class IsFiniteOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class Log1pOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class Log1pOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class LogOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class LogOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class LogisticOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class LogisticOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class MapOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class MaxOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class MinOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class MulOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class NegOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class NotOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class OptimizationBarrierOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class OrOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class OutfeedOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class PadOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class PartitionIdOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class PopulationCountOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class PowOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class RealDynamicSliceOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class RealOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class RecvOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ReduceOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ReducePrecisionOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ReduceScatterOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ReduceWindowOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class RemOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ReplicaIdOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ReshapeOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ReturnOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ReverseOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class RngBitGeneratorOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class RngOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class RoundNearestEvenOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class RoundOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class RsqrtOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class RsqrtOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ScatterOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ScatterOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class SelectAndScatterOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class SelectOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class SendOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class SetDimensionSizeOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ShiftLeftOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ShiftRightArithmeticOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class ShiftRightLogicalOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class SignOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class SineOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class SineOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class SliceOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class SortOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class SqrtOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class SqrtOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class SubtractOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class TanOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class TanOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class TanhOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class TanhOpV2; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class TorchIndexSelectOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class TransposeOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class TriangularSolveOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class TupleOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class UnaryEinsumOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class UniformDequantizeOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class UniformQuantizeOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class WhileOpV1; +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +class XorOpV1; +} // namespace vhlo +} // namespace mlir +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AbsOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AbsOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AbsOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.abs_v1", odsAttrs.getContext()); + } + + AbsOpV1GenericAdaptorBase(AbsOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AbsOpV1GenericAdaptor : public detail::AbsOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AbsOpV1GenericAdaptorBase; +public: + AbsOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AbsOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AbsOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AbsOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AbsOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + AbsOpV1GenericAdaptor(RangeT values, const AbsOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AbsOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AbsOpV1Adaptor : public AbsOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using AbsOpV1GenericAdaptor::AbsOpV1GenericAdaptor; + AbsOpV1Adaptor(AbsOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AbsOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AbsOpV1Adaptor; + template + using GenericAdaptor = AbsOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.abs_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::AbsOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AddOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AddOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AddOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.add_v1", odsAttrs.getContext()); + } + + AddOpV1GenericAdaptorBase(AddOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AddOpV1GenericAdaptor : public detail::AddOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AddOpV1GenericAdaptorBase; +public: + AddOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AddOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AddOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AddOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AddOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + AddOpV1GenericAdaptor(RangeT values, const AddOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AddOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AddOpV1Adaptor : public AddOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using AddOpV1GenericAdaptor::AddOpV1GenericAdaptor; + AddOpV1Adaptor(AddOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AddOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AddOpV1Adaptor; + template + using GenericAdaptor = AddOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.add_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::AddOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AfterAllOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AfterAllOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AfterAllOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.after_all_v1", odsAttrs.getContext()); + } + + AfterAllOpV1GenericAdaptorBase(AfterAllOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AfterAllOpV1GenericAdaptor : public detail::AfterAllOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AfterAllOpV1GenericAdaptorBase; +public: + AfterAllOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AfterAllOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AfterAllOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AfterAllOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AfterAllOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + AfterAllOpV1GenericAdaptor(RangeT values, const AfterAllOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AfterAllOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AfterAllOpV1Adaptor : public AfterAllOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using AfterAllOpV1GenericAdaptor::AfterAllOpV1GenericAdaptor; + AfterAllOpV1Adaptor(AfterAllOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AfterAllOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AfterAllOpV1Adaptor; + template + using GenericAdaptor = AfterAllOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.after_all_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::AfterAllOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AllGatherOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AllGatherOpV1GenericAdaptorBase { +public: + struct Properties { + using all_gather_dimTy = ::mlir::Attribute; + all_gather_dimTy all_gather_dim; + + auto getAllGatherDim() const { + auto &propStorage = this->all_gather_dim; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setAllGatherDim(const ::mlir::Attribute &propValue) { + this->all_gather_dim = propValue; + } + using channel_idTy = ::mlir::Attribute; + channel_idTy channel_id; + + auto getChannelId() const { + auto &propStorage = this->channel_id; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setChannelId(const ::mlir::Attribute &propValue) { + this->channel_id = propValue; + } + using replica_groupsTy = ::mlir::Attribute; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setReplicaGroups(const ::mlir::Attribute &propValue) { + this->replica_groups = propValue; + } + using use_global_device_idsTy = ::mlir::Attribute; + use_global_device_idsTy use_global_device_ids; + + auto getUseGlobalDeviceIds() const { + auto &propStorage = this->use_global_device_ids; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setUseGlobalDeviceIds(const ::mlir::Attribute &propValue) { + this->use_global_device_ids = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.all_gather_dim == this->all_gather_dim && + rhs.channel_id == this->channel_id && + rhs.replica_groups == this->replica_groups && + rhs.use_global_device_ids == this->use_global_device_ids && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AllGatherOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.all_gather_v1", odsAttrs.getContext()); + } + + AllGatherOpV1GenericAdaptorBase(AllGatherOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getAllGatherDimAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().all_gather_dim); + return attr; + } + + ::mlir::Attribute getAllGatherDim(); + ::mlir::Attribute getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + return attr; + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + return attr; + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getUseGlobalDeviceIdsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().use_global_device_ids); + return attr; + } + + ::mlir::Attribute getUseGlobalDeviceIds(); +}; +} // namespace detail +template +class AllGatherOpV1GenericAdaptor : public detail::AllGatherOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AllGatherOpV1GenericAdaptorBase; +public: + AllGatherOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AllGatherOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AllGatherOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AllGatherOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AllGatherOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + AllGatherOpV1GenericAdaptor(RangeT values, const AllGatherOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AllGatherOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AllGatherOpV1Adaptor : public AllGatherOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using AllGatherOpV1GenericAdaptor::AllGatherOpV1GenericAdaptor; + AllGatherOpV1Adaptor(AllGatherOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AllGatherOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AllGatherOpV1Adaptor; + template + using GenericAdaptor = AllGatherOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("all_gather_dim"), ::llvm::StringRef("channel_id"), ::llvm::StringRef("replica_groups"), ::llvm::StringRef("use_global_device_ids")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getAllGatherDimAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getAllGatherDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getChannelIdAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getChannelIdAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getUseGlobalDeviceIdsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getUseGlobalDeviceIdsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.all_gather_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getAllGatherDimAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().all_gather_dim); + } + + ::mlir::Attribute getAllGatherDim(); + ::mlir::Attribute getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getUseGlobalDeviceIdsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().use_global_device_ids); + } + + ::mlir::Attribute getUseGlobalDeviceIds(); + void setAllGatherDimAttr(::mlir::Attribute attr) { + getProperties().all_gather_dim = attr; + } + + void setReplicaGroupsAttr(::mlir::Attribute attr) { + getProperties().replica_groups = attr; + } + + void setChannelIdAttr(::mlir::Attribute attr) { + getProperties().channel_id = attr; + } + + void setUseGlobalDeviceIdsAttr(::mlir::Attribute attr) { + getProperties().use_global_device_ids = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute all_gather_dim, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute all_gather_dim, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 4 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::AllGatherOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AllGatherOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AllGatherOpV2GenericAdaptorBase { +public: + struct Properties { + using all_gather_dimTy = ::mlir::Attribute; + all_gather_dimTy all_gather_dim; + + auto getAllGatherDim() const { + auto &propStorage = this->all_gather_dim; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setAllGatherDim(const ::mlir::Attribute &propValue) { + this->all_gather_dim = propValue; + } + using channel_idTy = ::mlir::Attribute; + channel_idTy channel_id; + + auto getChannelId() const { + auto &propStorage = this->channel_id; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setChannelId(const ::mlir::Attribute &propValue) { + this->channel_id = propValue; + } + using replica_groupsTy = ::mlir::Attribute; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setReplicaGroups(const ::mlir::Attribute &propValue) { + this->replica_groups = propValue; + } + using use_global_device_idsTy = ::mlir::Attribute; + use_global_device_idsTy use_global_device_ids; + + auto getUseGlobalDeviceIds() const { + auto &propStorage = this->use_global_device_ids; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setUseGlobalDeviceIds(const ::mlir::Attribute &propValue) { + this->use_global_device_ids = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.all_gather_dim == this->all_gather_dim && + rhs.channel_id == this->channel_id && + rhs.replica_groups == this->replica_groups && + rhs.use_global_device_ids == this->use_global_device_ids && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AllGatherOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.all_gather_v2", odsAttrs.getContext()); + } + + AllGatherOpV2GenericAdaptorBase(AllGatherOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getAllGatherDimAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().all_gather_dim); + return attr; + } + + ::mlir::Attribute getAllGatherDim(); + ::mlir::Attribute getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + return attr; + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + return attr; + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getUseGlobalDeviceIdsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().use_global_device_ids); + return attr; + } + + ::mlir::Attribute getUseGlobalDeviceIds(); +}; +} // namespace detail +template +class AllGatherOpV2GenericAdaptor : public detail::AllGatherOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AllGatherOpV2GenericAdaptorBase; +public: + AllGatherOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AllGatherOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AllGatherOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AllGatherOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AllGatherOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + AllGatherOpV2GenericAdaptor(RangeT values, const AllGatherOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AllGatherOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class AllGatherOpV2Adaptor : public AllGatherOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using AllGatherOpV2GenericAdaptor::AllGatherOpV2GenericAdaptor; + AllGatherOpV2Adaptor(AllGatherOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AllGatherOpV2 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = AllGatherOpV2Adaptor; + template + using GenericAdaptor = AllGatherOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("all_gather_dim"), ::llvm::StringRef("channel_id"), ::llvm::StringRef("replica_groups"), ::llvm::StringRef("use_global_device_ids")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getAllGatherDimAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getAllGatherDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getChannelIdAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getChannelIdAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getUseGlobalDeviceIdsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getUseGlobalDeviceIdsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.all_gather_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getOperands() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getAllGatherDimAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().all_gather_dim); + } + + ::mlir::Attribute getAllGatherDim(); + ::mlir::Attribute getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getUseGlobalDeviceIdsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().use_global_device_ids); + } + + ::mlir::Attribute getUseGlobalDeviceIds(); + void setAllGatherDimAttr(::mlir::Attribute attr) { + getProperties().all_gather_dim = attr; + } + + void setReplicaGroupsAttr(::mlir::Attribute attr) { + getProperties().replica_groups = attr; + } + + void setChannelIdAttr(::mlir::Attribute attr) { + getProperties().channel_id = attr; + } + + void setUseGlobalDeviceIdsAttr(::mlir::Attribute attr) { + getProperties().use_global_device_ids = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange operands, ::mlir::Attribute all_gather_dim, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 4 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::AllGatherOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AllReduceOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AllReduceOpV1GenericAdaptorBase { +public: + struct Properties { + using channel_idTy = ::mlir::Attribute; + channel_idTy channel_id; + + auto getChannelId() const { + auto &propStorage = this->channel_id; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setChannelId(const ::mlir::Attribute &propValue) { + this->channel_id = propValue; + } + using replica_groupsTy = ::mlir::Attribute; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setReplicaGroups(const ::mlir::Attribute &propValue) { + this->replica_groups = propValue; + } + using use_global_device_idsTy = ::mlir::Attribute; + use_global_device_idsTy use_global_device_ids; + + auto getUseGlobalDeviceIds() const { + auto &propStorage = this->use_global_device_ids; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setUseGlobalDeviceIds(const ::mlir::Attribute &propValue) { + this->use_global_device_ids = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_id == this->channel_id && + rhs.replica_groups == this->replica_groups && + rhs.use_global_device_ids == this->use_global_device_ids && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AllReduceOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.all_reduce_v1", odsAttrs.getContext()); + } + + AllReduceOpV1GenericAdaptorBase(AllReduceOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + return attr; + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + return attr; + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getUseGlobalDeviceIdsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().use_global_device_ids); + return attr; + } + + ::mlir::Attribute getUseGlobalDeviceIds(); + ::mlir::Region &getComputation() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class AllReduceOpV1GenericAdaptor : public detail::AllReduceOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AllReduceOpV1GenericAdaptorBase; +public: + AllReduceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AllReduceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AllReduceOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AllReduceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AllReduceOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + AllReduceOpV1GenericAdaptor(RangeT values, const AllReduceOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AllReduceOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AllReduceOpV1Adaptor : public AllReduceOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using AllReduceOpV1GenericAdaptor::AllReduceOpV1GenericAdaptor; + AllReduceOpV1Adaptor(AllReduceOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AllReduceOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait, ::mlir::vhlo::VersionedOpConstraintInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AllReduceOpV1Adaptor; + template + using GenericAdaptor = AllReduceOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_id"), ::llvm::StringRef("replica_groups"), ::llvm::StringRef("use_global_device_ids")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelIdAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelIdAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getUseGlobalDeviceIdsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getUseGlobalDeviceIdsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.all_reduce_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + ::mlir::Region &getComputation() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getUseGlobalDeviceIdsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().use_global_device_ids); + } + + ::mlir::Attribute getUseGlobalDeviceIds(); + void setReplicaGroupsAttr(::mlir::Attribute attr) { + getProperties().replica_groups = attr; + } + + void setChannelIdAttr(::mlir::Attribute attr) { + getProperties().channel_id = attr; + } + + void setUseGlobalDeviceIdsAttr(::mlir::Attribute attr) { + getProperties().use_global_device_ids = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); + mlir::LogicalResult validateConstraint(mlir::Operation*op, mlir::vhlo::Version targetVersion); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::AllReduceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AllReduceOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AllReduceOpV2GenericAdaptorBase { +public: + struct Properties { + using channel_idTy = ::mlir::Attribute; + channel_idTy channel_id; + + auto getChannelId() const { + auto &propStorage = this->channel_id; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setChannelId(const ::mlir::Attribute &propValue) { + this->channel_id = propValue; + } + using replica_groupsTy = ::mlir::Attribute; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setReplicaGroups(const ::mlir::Attribute &propValue) { + this->replica_groups = propValue; + } + using use_global_device_idsTy = ::mlir::Attribute; + use_global_device_idsTy use_global_device_ids; + + auto getUseGlobalDeviceIds() const { + auto &propStorage = this->use_global_device_ids; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setUseGlobalDeviceIds(const ::mlir::Attribute &propValue) { + this->use_global_device_ids = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_id == this->channel_id && + rhs.replica_groups == this->replica_groups && + rhs.use_global_device_ids == this->use_global_device_ids && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AllReduceOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.all_reduce_v2", odsAttrs.getContext()); + } + + AllReduceOpV2GenericAdaptorBase(AllReduceOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + return attr; + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + return attr; + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getUseGlobalDeviceIdsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().use_global_device_ids); + return attr; + } + + ::mlir::Attribute getUseGlobalDeviceIds(); + ::mlir::Region &getComputation() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class AllReduceOpV2GenericAdaptor : public detail::AllReduceOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AllReduceOpV2GenericAdaptorBase; +public: + AllReduceOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AllReduceOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AllReduceOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AllReduceOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AllReduceOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + AllReduceOpV2GenericAdaptor(RangeT values, const AllReduceOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AllReduceOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class AllReduceOpV2Adaptor : public AllReduceOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using AllReduceOpV2GenericAdaptor::AllReduceOpV2GenericAdaptor; + AllReduceOpV2Adaptor(AllReduceOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AllReduceOpV2 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = AllReduceOpV2Adaptor; + template + using GenericAdaptor = AllReduceOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_id"), ::llvm::StringRef("replica_groups"), ::llvm::StringRef("use_global_device_ids")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelIdAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelIdAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getUseGlobalDeviceIdsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getUseGlobalDeviceIdsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.all_reduce_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getOperands() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + ::mlir::Region &getComputation() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getUseGlobalDeviceIdsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().use_global_device_ids); + } + + ::mlir::Attribute getUseGlobalDeviceIds(); + void setReplicaGroupsAttr(::mlir::Attribute attr) { + getProperties().replica_groups = attr; + } + + void setChannelIdAttr(::mlir::Attribute attr) { + getProperties().channel_id = attr; + } + + void setUseGlobalDeviceIdsAttr(::mlir::Attribute attr) { + getProperties().use_global_device_ids = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange operands, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::AllReduceOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AllToAllOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AllToAllOpV1GenericAdaptorBase { +public: + struct Properties { + using channel_idTy = ::mlir::Attribute; + channel_idTy channel_id; + + auto getChannelId() const { + auto &propStorage = this->channel_id; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setChannelId(const ::mlir::Attribute &propValue) { + this->channel_id = propValue; + } + using concat_dimensionTy = ::mlir::Attribute; + concat_dimensionTy concat_dimension; + + auto getConcatDimension() const { + auto &propStorage = this->concat_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setConcatDimension(const ::mlir::Attribute &propValue) { + this->concat_dimension = propValue; + } + using replica_groupsTy = ::mlir::Attribute; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setReplicaGroups(const ::mlir::Attribute &propValue) { + this->replica_groups = propValue; + } + using split_countTy = ::mlir::Attribute; + split_countTy split_count; + + auto getSplitCount() const { + auto &propStorage = this->split_count; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setSplitCount(const ::mlir::Attribute &propValue) { + this->split_count = propValue; + } + using split_dimensionTy = ::mlir::Attribute; + split_dimensionTy split_dimension; + + auto getSplitDimension() const { + auto &propStorage = this->split_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setSplitDimension(const ::mlir::Attribute &propValue) { + this->split_dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_id == this->channel_id && + rhs.concat_dimension == this->concat_dimension && + rhs.replica_groups == this->replica_groups && + rhs.split_count == this->split_count && + rhs.split_dimension == this->split_dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AllToAllOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.all_to_all_v1", odsAttrs.getContext()); + } + + AllToAllOpV1GenericAdaptorBase(AllToAllOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getSplitDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().split_dimension); + return attr; + } + + ::mlir::Attribute getSplitDimension(); + ::mlir::Attribute getConcatDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().concat_dimension); + return attr; + } + + ::mlir::Attribute getConcatDimension(); + ::mlir::Attribute getSplitCountAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().split_count); + return attr; + } + + ::mlir::Attribute getSplitCount(); + ::mlir::Attribute getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + return attr; + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + return attr; + } + + ::mlir::Attribute getChannelId(); +}; +} // namespace detail +template +class AllToAllOpV1GenericAdaptor : public detail::AllToAllOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AllToAllOpV1GenericAdaptorBase; +public: + AllToAllOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AllToAllOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AllToAllOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AllToAllOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AllToAllOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + AllToAllOpV1GenericAdaptor(RangeT values, const AllToAllOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AllToAllOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AllToAllOpV1Adaptor : public AllToAllOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using AllToAllOpV1GenericAdaptor::AllToAllOpV1GenericAdaptor; + AllToAllOpV1Adaptor(AllToAllOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AllToAllOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AllToAllOpV1Adaptor; + template + using GenericAdaptor = AllToAllOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_id"), ::llvm::StringRef("concat_dimension"), ::llvm::StringRef("replica_groups"), ::llvm::StringRef("split_count"), ::llvm::StringRef("split_dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelIdAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelIdAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getConcatDimensionAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getConcatDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getSplitCountAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getSplitCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getSplitDimensionAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getSplitDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.all_to_all_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getSplitDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().split_dimension); + } + + ::mlir::Attribute getSplitDimension(); + ::mlir::Attribute getConcatDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().concat_dimension); + } + + ::mlir::Attribute getConcatDimension(); + ::mlir::Attribute getSplitCountAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().split_count); + } + + ::mlir::Attribute getSplitCount(); + ::mlir::Attribute getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + } + + ::mlir::Attribute getChannelId(); + void setSplitDimensionAttr(::mlir::Attribute attr) { + getProperties().split_dimension = attr; + } + + void setConcatDimensionAttr(::mlir::Attribute attr) { + getProperties().concat_dimension = attr; + } + + void setSplitCountAttr(::mlir::Attribute attr) { + getProperties().split_count = attr; + } + + void setReplicaGroupsAttr(::mlir::Attribute attr) { + getProperties().replica_groups = attr; + } + + void setChannelIdAttr(::mlir::Attribute attr) { + getProperties().channel_id = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute split_dimension, ::mlir::Attribute concat_dimension, ::mlir::Attribute split_count, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute split_dimension, ::mlir::Attribute concat_dimension, ::mlir::Attribute split_count, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 5 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::AllToAllOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AllToAllOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AllToAllOpV2GenericAdaptorBase { +public: + struct Properties { + using channel_idTy = ::mlir::Attribute; + channel_idTy channel_id; + + auto getChannelId() const { + auto &propStorage = this->channel_id; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setChannelId(const ::mlir::Attribute &propValue) { + this->channel_id = propValue; + } + using concat_dimensionTy = ::mlir::Attribute; + concat_dimensionTy concat_dimension; + + auto getConcatDimension() const { + auto &propStorage = this->concat_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setConcatDimension(const ::mlir::Attribute &propValue) { + this->concat_dimension = propValue; + } + using replica_groupsTy = ::mlir::Attribute; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setReplicaGroups(const ::mlir::Attribute &propValue) { + this->replica_groups = propValue; + } + using split_countTy = ::mlir::Attribute; + split_countTy split_count; + + auto getSplitCount() const { + auto &propStorage = this->split_count; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setSplitCount(const ::mlir::Attribute &propValue) { + this->split_count = propValue; + } + using split_dimensionTy = ::mlir::Attribute; + split_dimensionTy split_dimension; + + auto getSplitDimension() const { + auto &propStorage = this->split_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setSplitDimension(const ::mlir::Attribute &propValue) { + this->split_dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_id == this->channel_id && + rhs.concat_dimension == this->concat_dimension && + rhs.replica_groups == this->replica_groups && + rhs.split_count == this->split_count && + rhs.split_dimension == this->split_dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AllToAllOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.all_to_all_v2", odsAttrs.getContext()); + } + + AllToAllOpV2GenericAdaptorBase(AllToAllOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getSplitDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().split_dimension); + return attr; + } + + ::mlir::Attribute getSplitDimension(); + ::mlir::Attribute getConcatDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().concat_dimension); + return attr; + } + + ::mlir::Attribute getConcatDimension(); + ::mlir::Attribute getSplitCountAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().split_count); + return attr; + } + + ::mlir::Attribute getSplitCount(); + ::mlir::Attribute getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + return attr; + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + return attr; + } + + ::mlir::Attribute getChannelId(); +}; +} // namespace detail +template +class AllToAllOpV2GenericAdaptor : public detail::AllToAllOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AllToAllOpV2GenericAdaptorBase; +public: + AllToAllOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AllToAllOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AllToAllOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AllToAllOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AllToAllOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + AllToAllOpV2GenericAdaptor(RangeT values, const AllToAllOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AllToAllOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class AllToAllOpV2Adaptor : public AllToAllOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using AllToAllOpV2GenericAdaptor::AllToAllOpV2GenericAdaptor; + AllToAllOpV2Adaptor(AllToAllOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AllToAllOpV2 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = AllToAllOpV2Adaptor; + template + using GenericAdaptor = AllToAllOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_id"), ::llvm::StringRef("concat_dimension"), ::llvm::StringRef("replica_groups"), ::llvm::StringRef("split_count"), ::llvm::StringRef("split_dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelIdAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelIdAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getConcatDimensionAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getConcatDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getSplitCountAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getSplitCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getSplitDimensionAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getSplitDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.all_to_all_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getOperands() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getSplitDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().split_dimension); + } + + ::mlir::Attribute getSplitDimension(); + ::mlir::Attribute getConcatDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().concat_dimension); + } + + ::mlir::Attribute getConcatDimension(); + ::mlir::Attribute getSplitCountAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().split_count); + } + + ::mlir::Attribute getSplitCount(); + ::mlir::Attribute getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + } + + ::mlir::Attribute getChannelId(); + void setSplitDimensionAttr(::mlir::Attribute attr) { + getProperties().split_dimension = attr; + } + + void setConcatDimensionAttr(::mlir::Attribute attr) { + getProperties().concat_dimension = attr; + } + + void setSplitCountAttr(::mlir::Attribute attr) { + getProperties().split_count = attr; + } + + void setReplicaGroupsAttr(::mlir::Attribute attr) { + getProperties().replica_groups = attr; + } + + void setChannelIdAttr(::mlir::Attribute attr) { + getProperties().channel_id = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange operands, ::mlir::Attribute split_dimension, ::mlir::Attribute concat_dimension, ::mlir::Attribute split_count, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 5 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::AllToAllOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::AndOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AndOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AndOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.and_v1", odsAttrs.getContext()); + } + + AndOpV1GenericAdaptorBase(AndOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class AndOpV1GenericAdaptor : public detail::AndOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AndOpV1GenericAdaptorBase; +public: + AndOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AndOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AndOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + AndOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : AndOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + AndOpV1GenericAdaptor(RangeT values, const AndOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + AndOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AndOpV1Adaptor : public AndOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using AndOpV1GenericAdaptor::AndOpV1GenericAdaptor; + AndOpV1Adaptor(AndOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class AndOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AndOpV1Adaptor; + template + using GenericAdaptor = AndOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.and_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::AndOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::Atan2OpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class Atan2OpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + Atan2OpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.atan2_v1", odsAttrs.getContext()); + } + + Atan2OpV1GenericAdaptorBase(Atan2OpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class Atan2OpV1GenericAdaptor : public detail::Atan2OpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::Atan2OpV1GenericAdaptorBase; +public: + Atan2OpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + Atan2OpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : Atan2OpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + Atan2OpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : Atan2OpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + Atan2OpV1GenericAdaptor(RangeT values, const Atan2OpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + Atan2OpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class Atan2OpV1Adaptor : public Atan2OpV1GenericAdaptor<::mlir::ValueRange> { +public: + using Atan2OpV1GenericAdaptor::Atan2OpV1GenericAdaptor; + Atan2OpV1Adaptor(Atan2OpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class Atan2OpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = Atan2OpV1Adaptor; + template + using GenericAdaptor = Atan2OpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.atan2_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::Atan2OpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::BatchNormGradOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BatchNormGradOpV1GenericAdaptorBase { +public: + struct Properties { + using epsilonTy = ::mlir::Attribute; + epsilonTy epsilon; + + auto getEpsilon() const { + auto &propStorage = this->epsilon; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setEpsilon(const ::mlir::Attribute &propValue) { + this->epsilon = propValue; + } + using feature_indexTy = ::mlir::Attribute; + feature_indexTy feature_index; + + auto getFeatureIndex() const { + auto &propStorage = this->feature_index; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setFeatureIndex(const ::mlir::Attribute &propValue) { + this->feature_index = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.epsilon == this->epsilon && + rhs.feature_index == this->feature_index && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BatchNormGradOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.batch_norm_grad_v1", odsAttrs.getContext()); + } + + BatchNormGradOpV1GenericAdaptorBase(BatchNormGradOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getEpsilonAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().epsilon); + return attr; + } + + ::mlir::Attribute getEpsilon(); + ::mlir::Attribute getFeatureIndexAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().feature_index); + return attr; + } + + ::mlir::Attribute getFeatureIndex(); +}; +} // namespace detail +template +class BatchNormGradOpV1GenericAdaptor : public detail::BatchNormGradOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BatchNormGradOpV1GenericAdaptorBase; +public: + BatchNormGradOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BatchNormGradOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BatchNormGradOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BatchNormGradOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BatchNormGradOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + BatchNormGradOpV1GenericAdaptor(RangeT values, const BatchNormGradOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BatchNormGradOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getScale() { + return (*getODSOperands(1).begin()); + } + + ValueT getMean() { + return (*getODSOperands(2).begin()); + } + + ValueT getVariance() { + return (*getODSOperands(3).begin()); + } + + ValueT getGradOutput() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BatchNormGradOpV1Adaptor : public BatchNormGradOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using BatchNormGradOpV1GenericAdaptor::BatchNormGradOpV1GenericAdaptor; + BatchNormGradOpV1Adaptor(BatchNormGradOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BatchNormGradOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<5>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BatchNormGradOpV1Adaptor; + template + using GenericAdaptor = BatchNormGradOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("epsilon"), ::llvm::StringRef("feature_index")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getEpsilonAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getEpsilonAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFeatureIndexAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFeatureIndexAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.batch_norm_grad_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getScale() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getMean() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(2).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getVariance() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(3).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getGradOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(4).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getScaleMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getMeanMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getVarianceMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getGradOutputMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getGradOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getGradScale() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getGradOffset() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(2).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getEpsilonAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().epsilon); + } + + ::mlir::Attribute getEpsilon(); + ::mlir::Attribute getFeatureIndexAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().feature_index); + } + + ::mlir::Attribute getFeatureIndex(); + void setEpsilonAttr(::mlir::Attribute attr) { + getProperties().epsilon = attr; + } + + void setFeatureIndexAttr(::mlir::Attribute attr) { + getProperties().feature_index = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type grad_operand, ::mlir::Type grad_scale, ::mlir::Type grad_offset, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::mlir::Attribute epsilon, ::mlir::Attribute feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Value grad_output, ::mlir::Attribute epsilon, ::mlir::Attribute feature_index); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::BatchNormGradOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::BatchNormInferenceOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BatchNormInferenceOpV1GenericAdaptorBase { +public: + struct Properties { + using epsilonTy = ::mlir::Attribute; + epsilonTy epsilon; + + auto getEpsilon() const { + auto &propStorage = this->epsilon; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setEpsilon(const ::mlir::Attribute &propValue) { + this->epsilon = propValue; + } + using feature_indexTy = ::mlir::Attribute; + feature_indexTy feature_index; + + auto getFeatureIndex() const { + auto &propStorage = this->feature_index; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setFeatureIndex(const ::mlir::Attribute &propValue) { + this->feature_index = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.epsilon == this->epsilon && + rhs.feature_index == this->feature_index && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BatchNormInferenceOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.batch_norm_inference_v1", odsAttrs.getContext()); + } + + BatchNormInferenceOpV1GenericAdaptorBase(BatchNormInferenceOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getEpsilonAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().epsilon); + return attr; + } + + ::mlir::Attribute getEpsilon(); + ::mlir::Attribute getFeatureIndexAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().feature_index); + return attr; + } + + ::mlir::Attribute getFeatureIndex(); +}; +} // namespace detail +template +class BatchNormInferenceOpV1GenericAdaptor : public detail::BatchNormInferenceOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BatchNormInferenceOpV1GenericAdaptorBase; +public: + BatchNormInferenceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BatchNormInferenceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BatchNormInferenceOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BatchNormInferenceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BatchNormInferenceOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + BatchNormInferenceOpV1GenericAdaptor(RangeT values, const BatchNormInferenceOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BatchNormInferenceOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getScale() { + return (*getODSOperands(1).begin()); + } + + ValueT getOffset() { + return (*getODSOperands(2).begin()); + } + + ValueT getMean() { + return (*getODSOperands(3).begin()); + } + + ValueT getVariance() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BatchNormInferenceOpV1Adaptor : public BatchNormInferenceOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using BatchNormInferenceOpV1GenericAdaptor::BatchNormInferenceOpV1GenericAdaptor; + BatchNormInferenceOpV1Adaptor(BatchNormInferenceOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BatchNormInferenceOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<5>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BatchNormInferenceOpV1Adaptor; + template + using GenericAdaptor = BatchNormInferenceOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("epsilon"), ::llvm::StringRef("feature_index")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getEpsilonAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getEpsilonAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFeatureIndexAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFeatureIndexAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.batch_norm_inference_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getScale() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getOffset() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(2).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getMean() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(3).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getVariance() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(4).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getScaleMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOffsetMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getMeanMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getVarianceMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getEpsilonAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().epsilon); + } + + ::mlir::Attribute getEpsilon(); + ::mlir::Attribute getFeatureIndexAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().feature_index); + } + + ::mlir::Attribute getFeatureIndex(); + void setEpsilonAttr(::mlir::Attribute attr) { + getProperties().epsilon = attr; + } + + void setFeatureIndexAttr(::mlir::Attribute attr) { + getProperties().feature_index = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Attribute epsilon, ::mlir::Attribute feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value mean, ::mlir::Value variance, ::mlir::Attribute epsilon, ::mlir::Attribute feature_index); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::BatchNormInferenceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::BatchNormTrainingOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BatchNormTrainingOpV1GenericAdaptorBase { +public: + struct Properties { + using epsilonTy = ::mlir::Attribute; + epsilonTy epsilon; + + auto getEpsilon() const { + auto &propStorage = this->epsilon; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setEpsilon(const ::mlir::Attribute &propValue) { + this->epsilon = propValue; + } + using feature_indexTy = ::mlir::Attribute; + feature_indexTy feature_index; + + auto getFeatureIndex() const { + auto &propStorage = this->feature_index; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setFeatureIndex(const ::mlir::Attribute &propValue) { + this->feature_index = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.epsilon == this->epsilon && + rhs.feature_index == this->feature_index && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BatchNormTrainingOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.batch_norm_training_v1", odsAttrs.getContext()); + } + + BatchNormTrainingOpV1GenericAdaptorBase(BatchNormTrainingOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getEpsilonAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().epsilon); + return attr; + } + + ::mlir::Attribute getEpsilon(); + ::mlir::Attribute getFeatureIndexAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().feature_index); + return attr; + } + + ::mlir::Attribute getFeatureIndex(); +}; +} // namespace detail +template +class BatchNormTrainingOpV1GenericAdaptor : public detail::BatchNormTrainingOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BatchNormTrainingOpV1GenericAdaptorBase; +public: + BatchNormTrainingOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BatchNormTrainingOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BatchNormTrainingOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BatchNormTrainingOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BatchNormTrainingOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + BatchNormTrainingOpV1GenericAdaptor(RangeT values, const BatchNormTrainingOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BatchNormTrainingOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getScale() { + return (*getODSOperands(1).begin()); + } + + ValueT getOffset() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BatchNormTrainingOpV1Adaptor : public BatchNormTrainingOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using BatchNormTrainingOpV1GenericAdaptor::BatchNormTrainingOpV1GenericAdaptor; + BatchNormTrainingOpV1Adaptor(BatchNormTrainingOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BatchNormTrainingOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BatchNormTrainingOpV1Adaptor; + template + using GenericAdaptor = BatchNormTrainingOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("epsilon"), ::llvm::StringRef("feature_index")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getEpsilonAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getEpsilonAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFeatureIndexAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFeatureIndexAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.batch_norm_training_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getScale() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getOffset() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getScaleMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOffsetMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getBatchMean() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getBatchVar() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(2).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getEpsilonAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().epsilon); + } + + ::mlir::Attribute getEpsilon(); + ::mlir::Attribute getFeatureIndexAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().feature_index); + } + + ::mlir::Attribute getFeatureIndex(); + void setEpsilonAttr(::mlir::Attribute attr) { + getProperties().epsilon = attr; + } + + void setFeatureIndexAttr(::mlir::Attribute attr) { + getProperties().feature_index = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Type batch_mean, ::mlir::Type batch_var, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Attribute epsilon, ::mlir::Attribute feature_index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Attribute epsilon, ::mlir::Attribute feature_index); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::BatchNormTrainingOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::BitcastConvertOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BitcastConvertOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BitcastConvertOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.bitcast_convert_v1", odsAttrs.getContext()); + } + + BitcastConvertOpV1GenericAdaptorBase(BitcastConvertOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class BitcastConvertOpV1GenericAdaptor : public detail::BitcastConvertOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BitcastConvertOpV1GenericAdaptorBase; +public: + BitcastConvertOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BitcastConvertOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BitcastConvertOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BitcastConvertOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BitcastConvertOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + BitcastConvertOpV1GenericAdaptor(RangeT values, const BitcastConvertOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BitcastConvertOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BitcastConvertOpV1Adaptor : public BitcastConvertOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using BitcastConvertOpV1GenericAdaptor::BitcastConvertOpV1GenericAdaptor; + BitcastConvertOpV1Adaptor(BitcastConvertOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BitcastConvertOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BitcastConvertOpV1Adaptor; + template + using GenericAdaptor = BitcastConvertOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.bitcast_convert_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::BitcastConvertOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::BroadcastInDimOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastInDimOpV1GenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::Attribute; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setBroadcastDimensions(const ::mlir::Attribute &propValue) { + this->broadcast_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastInDimOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.broadcast_in_dim_v1", odsAttrs.getContext()); + } + + BroadcastInDimOpV1GenericAdaptorBase(BroadcastInDimOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getBroadcastDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().broadcast_dimensions); + return attr; + } + + ::mlir::Attribute getBroadcastDimensions(); +}; +} // namespace detail +template +class BroadcastInDimOpV1GenericAdaptor : public detail::BroadcastInDimOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastInDimOpV1GenericAdaptorBase; +public: + BroadcastInDimOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastInDimOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastInDimOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastInDimOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastInDimOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastInDimOpV1GenericAdaptor(RangeT values, const BroadcastInDimOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastInDimOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastInDimOpV1Adaptor : public BroadcastInDimOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastInDimOpV1GenericAdaptor::BroadcastInDimOpV1GenericAdaptor; + BroadcastInDimOpV1Adaptor(BroadcastInDimOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastInDimOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastInDimOpV1Adaptor; + template + using GenericAdaptor = BroadcastInDimOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.broadcast_in_dim_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getBroadcastDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().broadcast_dimensions); + } + + ::mlir::Attribute getBroadcastDimensions(); + void setBroadcastDimensionsAttr(::mlir::Attribute attr) { + getProperties().broadcast_dimensions = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute broadcast_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute broadcast_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::BroadcastInDimOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::BroadcastOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastOpV1GenericAdaptorBase { +public: + struct Properties { + using broadcast_sizesTy = ::mlir::Attribute; + broadcast_sizesTy broadcast_sizes; + + auto getBroadcastSizes() const { + auto &propStorage = this->broadcast_sizes; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setBroadcastSizes(const ::mlir::Attribute &propValue) { + this->broadcast_sizes = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_sizes == this->broadcast_sizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.broadcast_v1", odsAttrs.getContext()); + } + + BroadcastOpV1GenericAdaptorBase(BroadcastOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getBroadcastSizesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().broadcast_sizes); + return attr; + } + + ::mlir::Attribute getBroadcastSizes(); +}; +} // namespace detail +template +class BroadcastOpV1GenericAdaptor : public detail::BroadcastOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastOpV1GenericAdaptorBase; +public: + BroadcastOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + BroadcastOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : BroadcastOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + BroadcastOpV1GenericAdaptor(RangeT values, const BroadcastOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + BroadcastOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastOpV1Adaptor : public BroadcastOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastOpV1GenericAdaptor::BroadcastOpV1GenericAdaptor; + BroadcastOpV1Adaptor(BroadcastOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastOpV1Adaptor; + template + using GenericAdaptor = BroadcastOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_sizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastSizesAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastSizesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.broadcast_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getBroadcastSizesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().broadcast_sizes); + } + + ::mlir::Attribute getBroadcastSizes(); + void setBroadcastSizesAttr(::mlir::Attribute attr) { + getProperties().broadcast_sizes = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute broadcast_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute broadcast_sizes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::BroadcastOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CallOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CallOpV1GenericAdaptorBase { +public: + struct Properties { + using calleeTy = ::mlir::Attribute; + calleeTy callee; + + auto getCallee() const { + auto &propStorage = this->callee; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setCallee(const ::mlir::Attribute &propValue) { + this->callee = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.callee == this->callee && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CallOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.call_v1", odsAttrs.getContext()); + } + + CallOpV1GenericAdaptorBase(CallOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getCalleeAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().callee); + return attr; + } + + ::mlir::Attribute getCallee(); +}; +} // namespace detail +template +class CallOpV1GenericAdaptor : public detail::CallOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CallOpV1GenericAdaptorBase; +public: + CallOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CallOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CallOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CallOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CallOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + CallOpV1GenericAdaptor(RangeT values, const CallOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CallOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class CallOpV1Adaptor : public CallOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using CallOpV1GenericAdaptor::CallOpV1GenericAdaptor; + CallOpV1Adaptor(CallOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CallOpV1 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = CallOpV1Adaptor; + template + using GenericAdaptor = CallOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("callee")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getCalleeAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getCalleeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.call_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getOperands() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getCalleeAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().callee); + } + + ::mlir::Attribute getCallee(); + void setCalleeAttr(::mlir::Attribute attr) { + getProperties().callee = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Attribute callee, ::mlir::ValueRange operands); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CallOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CaseOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CaseOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CaseOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.case_v1", odsAttrs.getContext()); + } + + CaseOpV1GenericAdaptorBase(CaseOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::RegionRange getBranches() { + return odsRegions.drop_front(0); + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class CaseOpV1GenericAdaptor : public detail::CaseOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CaseOpV1GenericAdaptorBase; +public: + CaseOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CaseOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CaseOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CaseOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CaseOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + CaseOpV1GenericAdaptor(RangeT values, const CaseOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CaseOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getIndex() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CaseOpV1Adaptor : public CaseOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using CaseOpV1GenericAdaptor::CaseOpV1GenericAdaptor; + CaseOpV1Adaptor(CaseOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CaseOpV1 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = CaseOpV1Adaptor; + template + using GenericAdaptor = CaseOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.case_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getIndex() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getIndexMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + ::mlir::MutableArrayRef<::mlir::Region> getBranches() { + return (*this)->getRegions().drop_front(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value index, unsigned branchesCount); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes, unsigned numRegions); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CaseOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CbrtOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CbrtOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CbrtOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.cbrt_v1", odsAttrs.getContext()); + } + + CbrtOpV1GenericAdaptorBase(CbrtOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class CbrtOpV1GenericAdaptor : public detail::CbrtOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CbrtOpV1GenericAdaptorBase; +public: + CbrtOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CbrtOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CbrtOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CbrtOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CbrtOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + CbrtOpV1GenericAdaptor(RangeT values, const CbrtOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CbrtOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CbrtOpV1Adaptor : public CbrtOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using CbrtOpV1GenericAdaptor::CbrtOpV1GenericAdaptor; + CbrtOpV1Adaptor(CbrtOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CbrtOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CbrtOpV1Adaptor; + template + using GenericAdaptor = CbrtOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.cbrt_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CbrtOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CbrtOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CbrtOpV2GenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::Attribute; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResultAccuracy(const ::mlir::Attribute &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CbrtOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.cbrt_v2", odsAttrs.getContext()); + } + + CbrtOpV2GenericAdaptorBase(CbrtOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getResultAccuracyAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + return attr; + } + + ::mlir::Attribute getResultAccuracy(); +}; +} // namespace detail +template +class CbrtOpV2GenericAdaptor : public detail::CbrtOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CbrtOpV2GenericAdaptorBase; +public: + CbrtOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CbrtOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CbrtOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CbrtOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CbrtOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + CbrtOpV2GenericAdaptor(RangeT values, const CbrtOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CbrtOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CbrtOpV2Adaptor : public CbrtOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using CbrtOpV2GenericAdaptor::CbrtOpV2GenericAdaptor; + CbrtOpV2Adaptor(CbrtOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CbrtOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CbrtOpV2Adaptor; + template + using GenericAdaptor = CbrtOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.cbrt_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getResultAccuracyAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + } + + ::mlir::Attribute getResultAccuracy(); + void setResultAccuracyAttr(::mlir::Attribute attr) { + getProperties().result_accuracy = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CbrtOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CeilOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CeilOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CeilOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.ceil_v1", odsAttrs.getContext()); + } + + CeilOpV1GenericAdaptorBase(CeilOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class CeilOpV1GenericAdaptor : public detail::CeilOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CeilOpV1GenericAdaptorBase; +public: + CeilOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CeilOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CeilOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CeilOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CeilOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + CeilOpV1GenericAdaptor(RangeT values, const CeilOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CeilOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CeilOpV1Adaptor : public CeilOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using CeilOpV1GenericAdaptor::CeilOpV1GenericAdaptor; + CeilOpV1Adaptor(CeilOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CeilOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CeilOpV1Adaptor; + template + using GenericAdaptor = CeilOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.ceil_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CeilOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CholeskyOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CholeskyOpV1GenericAdaptorBase { +public: + struct Properties { + using lowerTy = ::mlir::Attribute; + lowerTy lower; + + auto getLower() const { + auto &propStorage = this->lower; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLower(const ::mlir::Attribute &propValue) { + this->lower = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.lower == this->lower && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CholeskyOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.cholesky_v1", odsAttrs.getContext()); + } + + CholeskyOpV1GenericAdaptorBase(CholeskyOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getLowerAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().lower); + return attr; + } + + ::mlir::Attribute getLower(); +}; +} // namespace detail +template +class CholeskyOpV1GenericAdaptor : public detail::CholeskyOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CholeskyOpV1GenericAdaptorBase; +public: + CholeskyOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CholeskyOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CholeskyOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CholeskyOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CholeskyOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + CholeskyOpV1GenericAdaptor(RangeT values, const CholeskyOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CholeskyOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CholeskyOpV1Adaptor : public CholeskyOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using CholeskyOpV1GenericAdaptor::CholeskyOpV1GenericAdaptor; + CholeskyOpV1Adaptor(CholeskyOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CholeskyOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CholeskyOpV1Adaptor; + template + using GenericAdaptor = CholeskyOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("lower")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getLowerAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getLowerAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.cholesky_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getLowerAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().lower); + } + + ::mlir::Attribute getLower(); + void setLowerAttr(::mlir::Attribute attr) { + getProperties().lower = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, ::mlir::Attribute lower); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Attribute lower); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CholeskyOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ClampOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ClampOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ClampOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.clamp_v1", odsAttrs.getContext()); + } + + ClampOpV1GenericAdaptorBase(ClampOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ClampOpV1GenericAdaptor : public detail::ClampOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ClampOpV1GenericAdaptorBase; +public: + ClampOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ClampOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ClampOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ClampOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ClampOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ClampOpV1GenericAdaptor(RangeT values, const ClampOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ClampOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getMin() { + return (*getODSOperands(0).begin()); + } + + ValueT getOperand() { + return (*getODSOperands(1).begin()); + } + + ValueT getMax() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ClampOpV1Adaptor : public ClampOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ClampOpV1GenericAdaptor::ClampOpV1GenericAdaptor; + ClampOpV1Adaptor(ClampOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ClampOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ClampOpV1Adaptor; + template + using GenericAdaptor = ClampOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.clamp_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getMin() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getMax() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getMinMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getMaxMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value min, ::mlir::Value operand, ::mlir::Value max); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value min, ::mlir::Value operand, ::mlir::Value max); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ClampOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ClzOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ClzOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ClzOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.count_leading_zeros_v1", odsAttrs.getContext()); + } + + ClzOpV1GenericAdaptorBase(ClzOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ClzOpV1GenericAdaptor : public detail::ClzOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ClzOpV1GenericAdaptorBase; +public: + ClzOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ClzOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ClzOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ClzOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ClzOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ClzOpV1GenericAdaptor(RangeT values, const ClzOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ClzOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ClzOpV1Adaptor : public ClzOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ClzOpV1GenericAdaptor::ClzOpV1GenericAdaptor; + ClzOpV1Adaptor(ClzOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ClzOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ClzOpV1Adaptor; + template + using GenericAdaptor = ClzOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.count_leading_zeros_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ClzOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CollectiveBroadcastOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CollectiveBroadcastOpV1GenericAdaptorBase { +public: + struct Properties { + using channel_idTy = ::mlir::Attribute; + channel_idTy channel_id; + + auto getChannelId() const { + auto &propStorage = this->channel_id; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setChannelId(const ::mlir::Attribute &propValue) { + this->channel_id = propValue; + } + using replica_groupsTy = ::mlir::Attribute; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setReplicaGroups(const ::mlir::Attribute &propValue) { + this->replica_groups = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_id == this->channel_id && + rhs.replica_groups == this->replica_groups && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CollectiveBroadcastOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.collective_broadcast_v1", odsAttrs.getContext()); + } + + CollectiveBroadcastOpV1GenericAdaptorBase(CollectiveBroadcastOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + return attr; + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + return attr; + } + + ::mlir::Attribute getChannelId(); +}; +} // namespace detail +template +class CollectiveBroadcastOpV1GenericAdaptor : public detail::CollectiveBroadcastOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CollectiveBroadcastOpV1GenericAdaptorBase; +public: + CollectiveBroadcastOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CollectiveBroadcastOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CollectiveBroadcastOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CollectiveBroadcastOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CollectiveBroadcastOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + CollectiveBroadcastOpV1GenericAdaptor(RangeT values, const CollectiveBroadcastOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CollectiveBroadcastOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CollectiveBroadcastOpV1Adaptor : public CollectiveBroadcastOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using CollectiveBroadcastOpV1GenericAdaptor::CollectiveBroadcastOpV1GenericAdaptor; + CollectiveBroadcastOpV1Adaptor(CollectiveBroadcastOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CollectiveBroadcastOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CollectiveBroadcastOpV1Adaptor; + template + using GenericAdaptor = CollectiveBroadcastOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_id"), ::llvm::StringRef("replica_groups")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelIdAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelIdAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.collective_broadcast_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + } + + ::mlir::Attribute getChannelId(); + void setReplicaGroupsAttr(::mlir::Attribute attr) { + getProperties().replica_groups = attr; + } + + void setChannelIdAttr(::mlir::Attribute attr) { + getProperties().channel_id = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CollectiveBroadcastOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CollectivePermuteOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CollectivePermuteOpV1GenericAdaptorBase { +public: + struct Properties { + using channel_idTy = ::mlir::Attribute; + channel_idTy channel_id; + + auto getChannelId() const { + auto &propStorage = this->channel_id; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setChannelId(const ::mlir::Attribute &propValue) { + this->channel_id = propValue; + } + using source_target_pairsTy = ::mlir::Attribute; + source_target_pairsTy source_target_pairs; + + auto getSourceTargetPairs() const { + auto &propStorage = this->source_target_pairs; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setSourceTargetPairs(const ::mlir::Attribute &propValue) { + this->source_target_pairs = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_id == this->channel_id && + rhs.source_target_pairs == this->source_target_pairs && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CollectivePermuteOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.collective_permute_v1", odsAttrs.getContext()); + } + + CollectivePermuteOpV1GenericAdaptorBase(CollectivePermuteOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getSourceTargetPairsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().source_target_pairs); + return attr; + } + + ::mlir::Attribute getSourceTargetPairs(); + ::mlir::Attribute getChannelIdAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + return attr; + } + + ::mlir::Attribute getChannelId(); +}; +} // namespace detail +template +class CollectivePermuteOpV1GenericAdaptor : public detail::CollectivePermuteOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CollectivePermuteOpV1GenericAdaptorBase; +public: + CollectivePermuteOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CollectivePermuteOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CollectivePermuteOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CollectivePermuteOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CollectivePermuteOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + CollectivePermuteOpV1GenericAdaptor(RangeT values, const CollectivePermuteOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CollectivePermuteOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CollectivePermuteOpV1Adaptor : public CollectivePermuteOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using CollectivePermuteOpV1GenericAdaptor::CollectivePermuteOpV1GenericAdaptor; + CollectivePermuteOpV1Adaptor(CollectivePermuteOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CollectivePermuteOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CollectivePermuteOpV1Adaptor; + template + using GenericAdaptor = CollectivePermuteOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_id"), ::llvm::StringRef("source_target_pairs")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelIdAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelIdAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getSourceTargetPairsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getSourceTargetPairsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.collective_permute_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getSourceTargetPairsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().source_target_pairs); + } + + ::mlir::Attribute getSourceTargetPairs(); + ::mlir::Attribute getChannelIdAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + } + + ::mlir::Attribute getChannelId(); + void setSourceTargetPairsAttr(::mlir::Attribute attr) { + getProperties().source_target_pairs = attr; + } + + void setChannelIdAttr(::mlir::Attribute attr) { + getProperties().channel_id = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute source_target_pairs, ::mlir::Attribute channel_id); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute source_target_pairs, ::mlir::Attribute channel_id); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CollectivePermuteOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CompareOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CompareOpV1GenericAdaptorBase { +public: + struct Properties { + using compare_typeTy = ::mlir::Attribute; + compare_typeTy compare_type; + + auto getCompareType() const { + auto &propStorage = this->compare_type; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setCompareType(const ::mlir::Attribute &propValue) { + this->compare_type = propValue; + } + using comparison_directionTy = ::mlir::Attribute; + comparison_directionTy comparison_direction; + + auto getComparisonDirection() const { + auto &propStorage = this->comparison_direction; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setComparisonDirection(const ::mlir::Attribute &propValue) { + this->comparison_direction = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.compare_type == this->compare_type && + rhs.comparison_direction == this->comparison_direction && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CompareOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.compare_v1", odsAttrs.getContext()); + } + + CompareOpV1GenericAdaptorBase(CompareOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getComparisonDirectionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().comparison_direction); + return attr; + } + + ::mlir::Attribute getComparisonDirection(); + ::mlir::Attribute getCompareTypeAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().compare_type); + return attr; + } + + ::mlir::Attribute getCompareType(); +}; +} // namespace detail +template +class CompareOpV1GenericAdaptor : public detail::CompareOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CompareOpV1GenericAdaptorBase; +public: + CompareOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CompareOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CompareOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CompareOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CompareOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + CompareOpV1GenericAdaptor(RangeT values, const CompareOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CompareOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CompareOpV1Adaptor : public CompareOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using CompareOpV1GenericAdaptor::CompareOpV1GenericAdaptor; + CompareOpV1Adaptor(CompareOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CompareOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CompareOpV1Adaptor; + template + using GenericAdaptor = CompareOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("compare_type"), ::llvm::StringRef("comparison_direction")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getCompareTypeAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getCompareTypeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getComparisonDirectionAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getComparisonDirectionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.compare_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getComparisonDirectionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().comparison_direction); + } + + ::mlir::Attribute getComparisonDirection(); + ::mlir::Attribute getCompareTypeAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().compare_type); + } + + ::mlir::Attribute getCompareType(); + void setComparisonDirectionAttr(::mlir::Attribute attr) { + getProperties().comparison_direction = attr; + } + + void setCompareTypeAttr(::mlir::Attribute attr) { + getProperties().compare_type = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute comparison_direction, ::mlir::Attribute compare_type); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute comparison_direction, ::mlir::Attribute compare_type); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CompareOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ComplexOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ComplexOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ComplexOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.complex_v1", odsAttrs.getContext()); + } + + ComplexOpV1GenericAdaptorBase(ComplexOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ComplexOpV1GenericAdaptor : public detail::ComplexOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ComplexOpV1GenericAdaptorBase; +public: + ComplexOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ComplexOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ComplexOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ComplexOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ComplexOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ComplexOpV1GenericAdaptor(RangeT values, const ComplexOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ComplexOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ComplexOpV1Adaptor : public ComplexOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ComplexOpV1GenericAdaptor::ComplexOpV1GenericAdaptor; + ComplexOpV1Adaptor(ComplexOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ComplexOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ComplexOpV1Adaptor; + template + using GenericAdaptor = ComplexOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.complex_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ComplexOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CompositeOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CompositeOpV1GenericAdaptorBase { +public: + struct Properties { + using composite_attributesTy = ::mlir::Attribute; + composite_attributesTy composite_attributes; + + auto getCompositeAttributes() const { + auto &propStorage = this->composite_attributes; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setCompositeAttributes(const ::mlir::Attribute &propValue) { + this->composite_attributes = propValue; + } + using decompositionTy = ::mlir::Attribute; + decompositionTy decomposition; + + auto getDecomposition() const { + auto &propStorage = this->decomposition; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setDecomposition(const ::mlir::Attribute &propValue) { + this->decomposition = propValue; + } + using nameTy = ::mlir::Attribute; + nameTy name; + + auto getName() const { + auto &propStorage = this->name; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setName(const ::mlir::Attribute &propValue) { + this->name = propValue; + } + using versionTy = ::mlir::Attribute; + versionTy version; + + auto getVersion() const { + auto &propStorage = this->version; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setVersion(const ::mlir::Attribute &propValue) { + this->version = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.composite_attributes == this->composite_attributes && + rhs.decomposition == this->decomposition && + rhs.name == this->name && + rhs.version == this->version && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CompositeOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.composite_v1", odsAttrs.getContext()); + } + + CompositeOpV1GenericAdaptorBase(CompositeOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getNameAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().name); + return attr; + } + + ::mlir::Attribute getName(); + ::mlir::Attribute getCompositeAttributesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().composite_attributes); + return attr; + } + + ::mlir::Attribute getCompositeAttributes(); + ::mlir::Attribute getDecompositionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().decomposition); + return attr; + } + + ::mlir::Attribute getDecomposition(); + ::mlir::Attribute getVersionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().version); + return attr; + } + + ::mlir::Attribute getVersion(); +}; +} // namespace detail +template +class CompositeOpV1GenericAdaptor : public detail::CompositeOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CompositeOpV1GenericAdaptorBase; +public: + CompositeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CompositeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CompositeOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CompositeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CompositeOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + CompositeOpV1GenericAdaptor(RangeT values, const CompositeOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CompositeOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CompositeOpV1Adaptor : public CompositeOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using CompositeOpV1GenericAdaptor::CompositeOpV1GenericAdaptor; + CompositeOpV1Adaptor(CompositeOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CompositeOpV1 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = CompositeOpV1Adaptor; + template + using GenericAdaptor = CompositeOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("composite_attributes"), ::llvm::StringRef("decomposition"), ::llvm::StringRef("name"), ::llvm::StringRef("version")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getCompositeAttributesAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getCompositeAttributesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getDecompositionAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getDecompositionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getNameAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getVersionAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getVersionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.composite_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getNameAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().name); + } + + ::mlir::Attribute getName(); + ::mlir::Attribute getCompositeAttributesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().composite_attributes); + } + + ::mlir::Attribute getCompositeAttributes(); + ::mlir::Attribute getDecompositionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().decomposition); + } + + ::mlir::Attribute getDecomposition(); + ::mlir::Attribute getVersionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().version); + } + + ::mlir::Attribute getVersion(); + void setNameAttr(::mlir::Attribute attr) { + getProperties().name = attr; + } + + void setCompositeAttributesAttr(::mlir::Attribute attr) { + getProperties().composite_attributes = attr; + } + + void setDecompositionAttr(::mlir::Attribute attr) { + getProperties().decomposition = attr; + } + + void setVersionAttr(::mlir::Attribute attr) { + getProperties().version = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::Attribute name, ::mlir::Attribute composite_attributes, ::mlir::Attribute decomposition, ::mlir::Attribute version); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 4 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CompositeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ConcatenateOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConcatenateOpV1GenericAdaptorBase { +public: + struct Properties { + using dimensionTy = ::mlir::Attribute; + dimensionTy dimension; + + auto getDimension() const { + auto &propStorage = this->dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setDimension(const ::mlir::Attribute &propValue) { + this->dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimension == this->dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConcatenateOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.concatenate_v1", odsAttrs.getContext()); + } + + ConcatenateOpV1GenericAdaptorBase(ConcatenateOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().dimension); + return attr; + } + + ::mlir::Attribute getDimension(); +}; +} // namespace detail +template +class ConcatenateOpV1GenericAdaptor : public detail::ConcatenateOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConcatenateOpV1GenericAdaptorBase; +public: + ConcatenateOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConcatenateOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConcatenateOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ConcatenateOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ConcatenateOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ConcatenateOpV1GenericAdaptor(RangeT values, const ConcatenateOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ConcatenateOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConcatenateOpV1Adaptor : public ConcatenateOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ConcatenateOpV1GenericAdaptor::ConcatenateOpV1GenericAdaptor; + ConcatenateOpV1Adaptor(ConcatenateOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ConcatenateOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConcatenateOpV1Adaptor; + template + using GenericAdaptor = ConcatenateOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.concatenate_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().dimension); + } + + ::mlir::Attribute getDimension(); + void setDimensionAttr(::mlir::Attribute attr) { + getProperties().dimension = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs, ::mlir::Attribute dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Attribute dimension); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ConcatenateOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ConstantOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConstantOpV1GenericAdaptorBase { +public: + struct Properties { + using valueTy = ::mlir::Attribute; + valueTy value; + + auto getValue() const { + auto &propStorage = this->value; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setValue(const ::mlir::Attribute &propValue) { + this->value = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.value == this->value && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConstantOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.constant_v1", odsAttrs.getContext()); + } + + ConstantOpV1GenericAdaptorBase(ConstantOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getValueAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().value); + return attr; + } + + ::mlir::Attribute getValue(); +}; +} // namespace detail +template +class ConstantOpV1GenericAdaptor : public detail::ConstantOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConstantOpV1GenericAdaptorBase; +public: + ConstantOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConstantOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConstantOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ConstantOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ConstantOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ConstantOpV1GenericAdaptor(RangeT values, const ConstantOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ConstantOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConstantOpV1Adaptor : public ConstantOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ConstantOpV1GenericAdaptor::ConstantOpV1GenericAdaptor; + ConstantOpV1Adaptor(ConstantOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ConstantOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConstantOpV1Adaptor; + template + using GenericAdaptor = ConstantOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("value")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getValueAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getValueAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.constant_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getValueAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().value); + } + + ::mlir::Attribute getValue(); + void setValueAttr(::mlir::Attribute attr) { + getProperties().value = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Attribute value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Attribute value); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ConstantOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ConvertOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConvertOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConvertOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.convert_v1", odsAttrs.getContext()); + } + + ConvertOpV1GenericAdaptorBase(ConvertOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ConvertOpV1GenericAdaptor : public detail::ConvertOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConvertOpV1GenericAdaptorBase; +public: + ConvertOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConvertOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConvertOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ConvertOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ConvertOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ConvertOpV1GenericAdaptor(RangeT values, const ConvertOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ConvertOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConvertOpV1Adaptor : public ConvertOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ConvertOpV1GenericAdaptor::ConvertOpV1GenericAdaptor; + ConvertOpV1Adaptor(ConvertOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ConvertOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConvertOpV1Adaptor; + template + using GenericAdaptor = ConvertOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.convert_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ConvertOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ConvolutionOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConvolutionOpV1GenericAdaptorBase { +public: + struct Properties { + using batch_group_countTy = ::mlir::Attribute; + batch_group_countTy batch_group_count; + + auto getBatchGroupCount() const { + auto &propStorage = this->batch_group_count; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setBatchGroupCount(const ::mlir::Attribute &propValue) { + this->batch_group_count = propValue; + } + using feature_group_countTy = ::mlir::Attribute; + feature_group_countTy feature_group_count; + + auto getFeatureGroupCount() const { + auto &propStorage = this->feature_group_count; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setFeatureGroupCount(const ::mlir::Attribute &propValue) { + this->feature_group_count = propValue; + } + using input_batch_dimensionTy = ::mlir::Attribute; + input_batch_dimensionTy input_batch_dimension; + + auto getInputBatchDimension() const { + auto &propStorage = this->input_batch_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInputBatchDimension(const ::mlir::Attribute &propValue) { + this->input_batch_dimension = propValue; + } + using input_feature_dimensionTy = ::mlir::Attribute; + input_feature_dimensionTy input_feature_dimension; + + auto getInputFeatureDimension() const { + auto &propStorage = this->input_feature_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInputFeatureDimension(const ::mlir::Attribute &propValue) { + this->input_feature_dimension = propValue; + } + using input_spatial_dimensionsTy = ::mlir::Attribute; + input_spatial_dimensionsTy input_spatial_dimensions; + + auto getInputSpatialDimensions() const { + auto &propStorage = this->input_spatial_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInputSpatialDimensions(const ::mlir::Attribute &propValue) { + this->input_spatial_dimensions = propValue; + } + using kernel_input_feature_dimensionTy = ::mlir::Attribute; + kernel_input_feature_dimensionTy kernel_input_feature_dimension; + + auto getKernelInputFeatureDimension() const { + auto &propStorage = this->kernel_input_feature_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setKernelInputFeatureDimension(const ::mlir::Attribute &propValue) { + this->kernel_input_feature_dimension = propValue; + } + using kernel_output_feature_dimensionTy = ::mlir::Attribute; + kernel_output_feature_dimensionTy kernel_output_feature_dimension; + + auto getKernelOutputFeatureDimension() const { + auto &propStorage = this->kernel_output_feature_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setKernelOutputFeatureDimension(const ::mlir::Attribute &propValue) { + this->kernel_output_feature_dimension = propValue; + } + using kernel_spatial_dimensionsTy = ::mlir::Attribute; + kernel_spatial_dimensionsTy kernel_spatial_dimensions; + + auto getKernelSpatialDimensions() const { + auto &propStorage = this->kernel_spatial_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setKernelSpatialDimensions(const ::mlir::Attribute &propValue) { + this->kernel_spatial_dimensions = propValue; + } + using lhs_dilationTy = ::mlir::Attribute; + lhs_dilationTy lhs_dilation; + + auto getLhsDilation() const { + auto &propStorage = this->lhs_dilation; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLhsDilation(const ::mlir::Attribute &propValue) { + this->lhs_dilation = propValue; + } + using output_batch_dimensionTy = ::mlir::Attribute; + output_batch_dimensionTy output_batch_dimension; + + auto getOutputBatchDimension() const { + auto &propStorage = this->output_batch_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOutputBatchDimension(const ::mlir::Attribute &propValue) { + this->output_batch_dimension = propValue; + } + using output_feature_dimensionTy = ::mlir::Attribute; + output_feature_dimensionTy output_feature_dimension; + + auto getOutputFeatureDimension() const { + auto &propStorage = this->output_feature_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOutputFeatureDimension(const ::mlir::Attribute &propValue) { + this->output_feature_dimension = propValue; + } + using output_spatial_dimensionsTy = ::mlir::Attribute; + output_spatial_dimensionsTy output_spatial_dimensions; + + auto getOutputSpatialDimensions() const { + auto &propStorage = this->output_spatial_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOutputSpatialDimensions(const ::mlir::Attribute &propValue) { + this->output_spatial_dimensions = propValue; + } + using paddingTy = ::mlir::Attribute; + paddingTy padding; + + auto getPadding() const { + auto &propStorage = this->padding; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setPadding(const ::mlir::Attribute &propValue) { + this->padding = propValue; + } + using precision_configTy = ::mlir::Attribute; + precision_configTy precision_config; + + auto getPrecisionConfig() const { + auto &propStorage = this->precision_config; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setPrecisionConfig(const ::mlir::Attribute &propValue) { + this->precision_config = propValue; + } + using rhs_dilationTy = ::mlir::Attribute; + rhs_dilationTy rhs_dilation; + + auto getRhsDilation() const { + auto &propStorage = this->rhs_dilation; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setRhsDilation(const ::mlir::Attribute &propValue) { + this->rhs_dilation = propValue; + } + using window_reversalTy = ::mlir::Attribute; + window_reversalTy window_reversal; + + auto getWindowReversal() const { + auto &propStorage = this->window_reversal; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setWindowReversal(const ::mlir::Attribute &propValue) { + this->window_reversal = propValue; + } + using window_stridesTy = ::mlir::Attribute; + window_stridesTy window_strides; + + auto getWindowStrides() const { + auto &propStorage = this->window_strides; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setWindowStrides(const ::mlir::Attribute &propValue) { + this->window_strides = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.batch_group_count == this->batch_group_count && + rhs.feature_group_count == this->feature_group_count && + rhs.input_batch_dimension == this->input_batch_dimension && + rhs.input_feature_dimension == this->input_feature_dimension && + rhs.input_spatial_dimensions == this->input_spatial_dimensions && + rhs.kernel_input_feature_dimension == this->kernel_input_feature_dimension && + rhs.kernel_output_feature_dimension == this->kernel_output_feature_dimension && + rhs.kernel_spatial_dimensions == this->kernel_spatial_dimensions && + rhs.lhs_dilation == this->lhs_dilation && + rhs.output_batch_dimension == this->output_batch_dimension && + rhs.output_feature_dimension == this->output_feature_dimension && + rhs.output_spatial_dimensions == this->output_spatial_dimensions && + rhs.padding == this->padding && + rhs.precision_config == this->precision_config && + rhs.rhs_dilation == this->rhs_dilation && + rhs.window_reversal == this->window_reversal && + rhs.window_strides == this->window_strides && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConvolutionOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.convolution_v1", odsAttrs.getContext()); + } + + ConvolutionOpV1GenericAdaptorBase(ConvolutionOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getWindowStridesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().window_strides); + return attr; + } + + ::mlir::Attribute getWindowStrides(); + ::mlir::Attribute getPaddingAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().padding); + return attr; + } + + ::mlir::Attribute getPadding(); + ::mlir::Attribute getLhsDilationAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().lhs_dilation); + return attr; + } + + ::mlir::Attribute getLhsDilation(); + ::mlir::Attribute getRhsDilationAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().rhs_dilation); + return attr; + } + + ::mlir::Attribute getRhsDilation(); + ::mlir::Attribute getWindowReversalAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().window_reversal); + return attr; + } + + ::mlir::Attribute getWindowReversal(); + ::mlir::Attribute getInputBatchDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().input_batch_dimension); + return attr; + } + + ::mlir::Attribute getInputBatchDimension(); + ::mlir::Attribute getInputFeatureDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().input_feature_dimension); + return attr; + } + + ::mlir::Attribute getInputFeatureDimension(); + ::mlir::Attribute getInputSpatialDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().input_spatial_dimensions); + return attr; + } + + ::mlir::Attribute getInputSpatialDimensions(); + ::mlir::Attribute getKernelInputFeatureDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().kernel_input_feature_dimension); + return attr; + } + + ::mlir::Attribute getKernelInputFeatureDimension(); + ::mlir::Attribute getKernelOutputFeatureDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().kernel_output_feature_dimension); + return attr; + } + + ::mlir::Attribute getKernelOutputFeatureDimension(); + ::mlir::Attribute getKernelSpatialDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().kernel_spatial_dimensions); + return attr; + } + + ::mlir::Attribute getKernelSpatialDimensions(); + ::mlir::Attribute getOutputBatchDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().output_batch_dimension); + return attr; + } + + ::mlir::Attribute getOutputBatchDimension(); + ::mlir::Attribute getOutputFeatureDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().output_feature_dimension); + return attr; + } + + ::mlir::Attribute getOutputFeatureDimension(); + ::mlir::Attribute getOutputSpatialDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().output_spatial_dimensions); + return attr; + } + + ::mlir::Attribute getOutputSpatialDimensions(); + ::mlir::Attribute getFeatureGroupCountAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().feature_group_count); + return attr; + } + + ::mlir::Attribute getFeatureGroupCount(); + ::mlir::Attribute getBatchGroupCountAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().batch_group_count); + return attr; + } + + ::mlir::Attribute getBatchGroupCount(); + ::mlir::Attribute getPrecisionConfigAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().precision_config); + return attr; + } + + ::mlir::Attribute getPrecisionConfig(); +}; +} // namespace detail +template +class ConvolutionOpV1GenericAdaptor : public detail::ConvolutionOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConvolutionOpV1GenericAdaptorBase; +public: + ConvolutionOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConvolutionOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConvolutionOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ConvolutionOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ConvolutionOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ConvolutionOpV1GenericAdaptor(RangeT values, const ConvolutionOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ConvolutionOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConvolutionOpV1Adaptor : public ConvolutionOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ConvolutionOpV1GenericAdaptor::ConvolutionOpV1GenericAdaptor; + ConvolutionOpV1Adaptor(ConvolutionOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ConvolutionOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConvolutionOpV1Adaptor; + template + using GenericAdaptor = ConvolutionOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("batch_group_count"), ::llvm::StringRef("feature_group_count"), ::llvm::StringRef("input_batch_dimension"), ::llvm::StringRef("input_feature_dimension"), ::llvm::StringRef("input_spatial_dimensions"), ::llvm::StringRef("kernel_input_feature_dimension"), ::llvm::StringRef("kernel_output_feature_dimension"), ::llvm::StringRef("kernel_spatial_dimensions"), ::llvm::StringRef("lhs_dilation"), ::llvm::StringRef("output_batch_dimension"), ::llvm::StringRef("output_feature_dimension"), ::llvm::StringRef("output_spatial_dimensions"), ::llvm::StringRef("padding"), ::llvm::StringRef("precision_config"), ::llvm::StringRef("rhs_dilation"), ::llvm::StringRef("window_reversal"), ::llvm::StringRef("window_strides")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBatchGroupCountAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBatchGroupCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFeatureGroupCountAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFeatureGroupCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getInputBatchDimensionAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getInputBatchDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getInputFeatureDimensionAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getInputFeatureDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getInputSpatialDimensionsAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getInputSpatialDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + ::mlir::StringAttr getKernelInputFeatureDimensionAttrName() { + return getAttributeNameForIndex(5); + } + + static ::mlir::StringAttr getKernelInputFeatureDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 5); + } + + ::mlir::StringAttr getKernelOutputFeatureDimensionAttrName() { + return getAttributeNameForIndex(6); + } + + static ::mlir::StringAttr getKernelOutputFeatureDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 6); + } + + ::mlir::StringAttr getKernelSpatialDimensionsAttrName() { + return getAttributeNameForIndex(7); + } + + static ::mlir::StringAttr getKernelSpatialDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 7); + } + + ::mlir::StringAttr getLhsDilationAttrName() { + return getAttributeNameForIndex(8); + } + + static ::mlir::StringAttr getLhsDilationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 8); + } + + ::mlir::StringAttr getOutputBatchDimensionAttrName() { + return getAttributeNameForIndex(9); + } + + static ::mlir::StringAttr getOutputBatchDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 9); + } + + ::mlir::StringAttr getOutputFeatureDimensionAttrName() { + return getAttributeNameForIndex(10); + } + + static ::mlir::StringAttr getOutputFeatureDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 10); + } + + ::mlir::StringAttr getOutputSpatialDimensionsAttrName() { + return getAttributeNameForIndex(11); + } + + static ::mlir::StringAttr getOutputSpatialDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 11); + } + + ::mlir::StringAttr getPaddingAttrName() { + return getAttributeNameForIndex(12); + } + + static ::mlir::StringAttr getPaddingAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 12); + } + + ::mlir::StringAttr getPrecisionConfigAttrName() { + return getAttributeNameForIndex(13); + } + + static ::mlir::StringAttr getPrecisionConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 13); + } + + ::mlir::StringAttr getRhsDilationAttrName() { + return getAttributeNameForIndex(14); + } + + static ::mlir::StringAttr getRhsDilationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 14); + } + + ::mlir::StringAttr getWindowReversalAttrName() { + return getAttributeNameForIndex(15); + } + + static ::mlir::StringAttr getWindowReversalAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 15); + } + + ::mlir::StringAttr getWindowStridesAttrName() { + return getAttributeNameForIndex(16); + } + + static ::mlir::StringAttr getWindowStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 16); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.convolution_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getWindowStridesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().window_strides); + } + + ::mlir::Attribute getWindowStrides(); + ::mlir::Attribute getPaddingAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().padding); + } + + ::mlir::Attribute getPadding(); + ::mlir::Attribute getLhsDilationAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().lhs_dilation); + } + + ::mlir::Attribute getLhsDilation(); + ::mlir::Attribute getRhsDilationAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().rhs_dilation); + } + + ::mlir::Attribute getRhsDilation(); + ::mlir::Attribute getWindowReversalAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().window_reversal); + } + + ::mlir::Attribute getWindowReversal(); + ::mlir::Attribute getInputBatchDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().input_batch_dimension); + } + + ::mlir::Attribute getInputBatchDimension(); + ::mlir::Attribute getInputFeatureDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().input_feature_dimension); + } + + ::mlir::Attribute getInputFeatureDimension(); + ::mlir::Attribute getInputSpatialDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().input_spatial_dimensions); + } + + ::mlir::Attribute getInputSpatialDimensions(); + ::mlir::Attribute getKernelInputFeatureDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().kernel_input_feature_dimension); + } + + ::mlir::Attribute getKernelInputFeatureDimension(); + ::mlir::Attribute getKernelOutputFeatureDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().kernel_output_feature_dimension); + } + + ::mlir::Attribute getKernelOutputFeatureDimension(); + ::mlir::Attribute getKernelSpatialDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().kernel_spatial_dimensions); + } + + ::mlir::Attribute getKernelSpatialDimensions(); + ::mlir::Attribute getOutputBatchDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().output_batch_dimension); + } + + ::mlir::Attribute getOutputBatchDimension(); + ::mlir::Attribute getOutputFeatureDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().output_feature_dimension); + } + + ::mlir::Attribute getOutputFeatureDimension(); + ::mlir::Attribute getOutputSpatialDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().output_spatial_dimensions); + } + + ::mlir::Attribute getOutputSpatialDimensions(); + ::mlir::Attribute getFeatureGroupCountAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().feature_group_count); + } + + ::mlir::Attribute getFeatureGroupCount(); + ::mlir::Attribute getBatchGroupCountAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().batch_group_count); + } + + ::mlir::Attribute getBatchGroupCount(); + ::mlir::Attribute getPrecisionConfigAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().precision_config); + } + + ::mlir::Attribute getPrecisionConfig(); + void setWindowStridesAttr(::mlir::Attribute attr) { + getProperties().window_strides = attr; + } + + void setPaddingAttr(::mlir::Attribute attr) { + getProperties().padding = attr; + } + + void setLhsDilationAttr(::mlir::Attribute attr) { + getProperties().lhs_dilation = attr; + } + + void setRhsDilationAttr(::mlir::Attribute attr) { + getProperties().rhs_dilation = attr; + } + + void setWindowReversalAttr(::mlir::Attribute attr) { + getProperties().window_reversal = attr; + } + + void setInputBatchDimensionAttr(::mlir::Attribute attr) { + getProperties().input_batch_dimension = attr; + } + + void setInputFeatureDimensionAttr(::mlir::Attribute attr) { + getProperties().input_feature_dimension = attr; + } + + void setInputSpatialDimensionsAttr(::mlir::Attribute attr) { + getProperties().input_spatial_dimensions = attr; + } + + void setKernelInputFeatureDimensionAttr(::mlir::Attribute attr) { + getProperties().kernel_input_feature_dimension = attr; + } + + void setKernelOutputFeatureDimensionAttr(::mlir::Attribute attr) { + getProperties().kernel_output_feature_dimension = attr; + } + + void setKernelSpatialDimensionsAttr(::mlir::Attribute attr) { + getProperties().kernel_spatial_dimensions = attr; + } + + void setOutputBatchDimensionAttr(::mlir::Attribute attr) { + getProperties().output_batch_dimension = attr; + } + + void setOutputFeatureDimensionAttr(::mlir::Attribute attr) { + getProperties().output_feature_dimension = attr; + } + + void setOutputSpatialDimensionsAttr(::mlir::Attribute attr) { + getProperties().output_spatial_dimensions = attr; + } + + void setFeatureGroupCountAttr(::mlir::Attribute attr) { + getProperties().feature_group_count = attr; + } + + void setBatchGroupCountAttr(::mlir::Attribute attr) { + getProperties().batch_group_count = attr; + } + + void setPrecisionConfigAttr(::mlir::Attribute attr) { + getProperties().precision_config = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute window_strides, ::mlir::Attribute padding, ::mlir::Attribute lhs_dilation, ::mlir::Attribute rhs_dilation, ::mlir::Attribute window_reversal, ::mlir::Attribute input_batch_dimension, ::mlir::Attribute input_feature_dimension, ::mlir::Attribute input_spatial_dimensions, ::mlir::Attribute kernel_input_feature_dimension, ::mlir::Attribute kernel_output_feature_dimension, ::mlir::Attribute kernel_spatial_dimensions, ::mlir::Attribute output_batch_dimension, ::mlir::Attribute output_feature_dimension, ::mlir::Attribute output_spatial_dimensions, ::mlir::Attribute feature_group_count, ::mlir::Attribute batch_group_count, ::mlir::Attribute precision_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute window_strides, ::mlir::Attribute padding, ::mlir::Attribute lhs_dilation, ::mlir::Attribute rhs_dilation, ::mlir::Attribute window_reversal, ::mlir::Attribute input_batch_dimension, ::mlir::Attribute input_feature_dimension, ::mlir::Attribute input_spatial_dimensions, ::mlir::Attribute kernel_input_feature_dimension, ::mlir::Attribute kernel_output_feature_dimension, ::mlir::Attribute kernel_spatial_dimensions, ::mlir::Attribute output_batch_dimension, ::mlir::Attribute output_feature_dimension, ::mlir::Attribute output_spatial_dimensions, ::mlir::Attribute feature_group_count, ::mlir::Attribute batch_group_count, ::mlir::Attribute precision_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 17 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ConvolutionOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CosineOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CosineOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CosineOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.cosine_v1", odsAttrs.getContext()); + } + + CosineOpV1GenericAdaptorBase(CosineOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class CosineOpV1GenericAdaptor : public detail::CosineOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CosineOpV1GenericAdaptorBase; +public: + CosineOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CosineOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CosineOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CosineOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CosineOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + CosineOpV1GenericAdaptor(RangeT values, const CosineOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CosineOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CosineOpV1Adaptor : public CosineOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using CosineOpV1GenericAdaptor::CosineOpV1GenericAdaptor; + CosineOpV1Adaptor(CosineOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CosineOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CosineOpV1Adaptor; + template + using GenericAdaptor = CosineOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.cosine_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CosineOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CosineOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CosineOpV2GenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::Attribute; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResultAccuracy(const ::mlir::Attribute &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CosineOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.cosine_v2", odsAttrs.getContext()); + } + + CosineOpV2GenericAdaptorBase(CosineOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getResultAccuracyAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + return attr; + } + + ::mlir::Attribute getResultAccuracy(); +}; +} // namespace detail +template +class CosineOpV2GenericAdaptor : public detail::CosineOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CosineOpV2GenericAdaptorBase; +public: + CosineOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CosineOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CosineOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CosineOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CosineOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + CosineOpV2GenericAdaptor(RangeT values, const CosineOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CosineOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CosineOpV2Adaptor : public CosineOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using CosineOpV2GenericAdaptor::CosineOpV2GenericAdaptor; + CosineOpV2Adaptor(CosineOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CosineOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CosineOpV2Adaptor; + template + using GenericAdaptor = CosineOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.cosine_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getResultAccuracyAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + } + + ::mlir::Attribute getResultAccuracy(); + void setResultAccuracyAttr(::mlir::Attribute attr) { + getProperties().result_accuracy = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CosineOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CreateTokenOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CreateTokenOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CreateTokenOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.create_token_v1", odsAttrs.getContext()); + } + + CreateTokenOpV1GenericAdaptorBase(CreateTokenOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class CreateTokenOpV1GenericAdaptor : public detail::CreateTokenOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CreateTokenOpV1GenericAdaptorBase; +public: + CreateTokenOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CreateTokenOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CreateTokenOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CreateTokenOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CreateTokenOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + CreateTokenOpV1GenericAdaptor(RangeT values, const CreateTokenOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CreateTokenOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CreateTokenOpV1Adaptor : public CreateTokenOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using CreateTokenOpV1GenericAdaptor::CreateTokenOpV1GenericAdaptor; + CreateTokenOpV1Adaptor(CreateTokenOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CreateTokenOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CreateTokenOpV1Adaptor; + template + using GenericAdaptor = CreateTokenOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.create_token_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CreateTokenOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CrossReplicaSumOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CrossReplicaSumOpV1GenericAdaptorBase { +public: + struct Properties { + using replica_groupsTy = ::mlir::Attribute; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setReplicaGroups(const ::mlir::Attribute &propValue) { + this->replica_groups = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.replica_groups == this->replica_groups && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CrossReplicaSumOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.cross-replica-sum_v1", odsAttrs.getContext()); + } + + CrossReplicaSumOpV1GenericAdaptorBase(CrossReplicaSumOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + return attr; + } + + ::mlir::Attribute getReplicaGroups(); +}; +} // namespace detail +template +class CrossReplicaSumOpV1GenericAdaptor : public detail::CrossReplicaSumOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CrossReplicaSumOpV1GenericAdaptorBase; +public: + CrossReplicaSumOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CrossReplicaSumOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CrossReplicaSumOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CrossReplicaSumOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CrossReplicaSumOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + CrossReplicaSumOpV1GenericAdaptor(RangeT values, const CrossReplicaSumOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CrossReplicaSumOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CrossReplicaSumOpV1Adaptor : public CrossReplicaSumOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using CrossReplicaSumOpV1GenericAdaptor::CrossReplicaSumOpV1GenericAdaptor; + CrossReplicaSumOpV1Adaptor(CrossReplicaSumOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CrossReplicaSumOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CrossReplicaSumOpV1Adaptor; + template + using GenericAdaptor = CrossReplicaSumOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("replica_groups")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.cross-replica-sum_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + } + + ::mlir::Attribute getReplicaGroups(); + void setReplicaGroupsAttr(::mlir::Attribute attr) { + getProperties().replica_groups = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute replica_groups); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute replica_groups); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CrossReplicaSumOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::CustomCallOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CustomCallOpV1GenericAdaptorBase { +public: + struct Properties { + using api_versionTy = ::mlir::Attribute; + api_versionTy api_version; + + auto getApiVersion() const { + auto &propStorage = this->api_version; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setApiVersion(const ::mlir::Attribute &propValue) { + this->api_version = propValue; + } + using backend_configTy = ::mlir::Attribute; + backend_configTy backend_config; + + auto getBackendConfig() const { + auto &propStorage = this->backend_config; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setBackendConfig(const ::mlir::Attribute &propValue) { + this->backend_config = propValue; + } + using call_target_nameTy = ::mlir::Attribute; + call_target_nameTy call_target_name; + + auto getCallTargetName() const { + auto &propStorage = this->call_target_name; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setCallTargetName(const ::mlir::Attribute &propValue) { + this->call_target_name = propValue; + } + using called_computationsTy = ::mlir::Attribute; + called_computationsTy called_computations; + + auto getCalledComputations() const { + auto &propStorage = this->called_computations; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setCalledComputations(const ::mlir::Attribute &propValue) { + this->called_computations = propValue; + } + using has_side_effectTy = ::mlir::Attribute; + has_side_effectTy has_side_effect; + + auto getHasSideEffect() const { + auto &propStorage = this->has_side_effect; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setHasSideEffect(const ::mlir::Attribute &propValue) { + this->has_side_effect = propValue; + } + using operand_layoutsTy = ::mlir::Attribute; + operand_layoutsTy operand_layouts; + + auto getOperandLayouts() const { + auto &propStorage = this->operand_layouts; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOperandLayouts(const ::mlir::Attribute &propValue) { + this->operand_layouts = propValue; + } + using output_operand_aliasesTy = ::mlir::Attribute; + output_operand_aliasesTy output_operand_aliases; + + auto getOutputOperandAliases() const { + auto &propStorage = this->output_operand_aliases; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOutputOperandAliases(const ::mlir::Attribute &propValue) { + this->output_operand_aliases = propValue; + } + using result_layoutsTy = ::mlir::Attribute; + result_layoutsTy result_layouts; + + auto getResultLayouts() const { + auto &propStorage = this->result_layouts; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResultLayouts(const ::mlir::Attribute &propValue) { + this->result_layouts = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.api_version == this->api_version && + rhs.backend_config == this->backend_config && + rhs.call_target_name == this->call_target_name && + rhs.called_computations == this->called_computations && + rhs.has_side_effect == this->has_side_effect && + rhs.operand_layouts == this->operand_layouts && + rhs.output_operand_aliases == this->output_operand_aliases && + rhs.result_layouts == this->result_layouts && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CustomCallOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.custom_call_v1", odsAttrs.getContext()); + } + + CustomCallOpV1GenericAdaptorBase(CustomCallOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getCallTargetNameAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().call_target_name); + return attr; + } + + ::mlir::Attribute getCallTargetName(); + ::mlir::Attribute getHasSideEffectAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().has_side_effect); + return attr; + } + + ::mlir::Attribute getHasSideEffect(); + ::mlir::Attribute getBackendConfigAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().backend_config); + return attr; + } + + ::mlir::Attribute getBackendConfig(); + ::mlir::Attribute getApiVersionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().api_version); + return attr; + } + + ::mlir::Attribute getApiVersion(); + ::mlir::Attribute getCalledComputationsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().called_computations); + return attr; + } + + ::mlir::Attribute getCalledComputations(); + ::mlir::Attribute getOperandLayoutsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().operand_layouts); + return attr; + } + + ::mlir::Attribute getOperandLayouts(); + ::mlir::Attribute getResultLayoutsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().result_layouts); + return attr; + } + + ::mlir::Attribute getResultLayouts(); + ::mlir::Attribute getOutputOperandAliasesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().output_operand_aliases); + return attr; + } + + ::mlir::Attribute getOutputOperandAliases(); +}; +} // namespace detail +template +class CustomCallOpV1GenericAdaptor : public detail::CustomCallOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CustomCallOpV1GenericAdaptorBase; +public: + CustomCallOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CustomCallOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CustomCallOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + CustomCallOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : CustomCallOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + CustomCallOpV1GenericAdaptor(RangeT values, const CustomCallOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + CustomCallOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CustomCallOpV1Adaptor : public CustomCallOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using CustomCallOpV1GenericAdaptor::CustomCallOpV1GenericAdaptor; + CustomCallOpV1Adaptor(CustomCallOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class CustomCallOpV1 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = CustomCallOpV1Adaptor; + template + using GenericAdaptor = CustomCallOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("api_version"), ::llvm::StringRef("backend_config"), ::llvm::StringRef("call_target_name"), ::llvm::StringRef("called_computations"), ::llvm::StringRef("has_side_effect"), ::llvm::StringRef("operand_layouts"), ::llvm::StringRef("output_operand_aliases"), ::llvm::StringRef("result_layouts")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getApiVersionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getApiVersionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getBackendConfigAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getBackendConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getCallTargetNameAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getCallTargetNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getCalledComputationsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getCalledComputationsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getHasSideEffectAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getHasSideEffectAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + ::mlir::StringAttr getOperandLayoutsAttrName() { + return getAttributeNameForIndex(5); + } + + static ::mlir::StringAttr getOperandLayoutsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 5); + } + + ::mlir::StringAttr getOutputOperandAliasesAttrName() { + return getAttributeNameForIndex(6); + } + + static ::mlir::StringAttr getOutputOperandAliasesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 6); + } + + ::mlir::StringAttr getResultLayoutsAttrName() { + return getAttributeNameForIndex(7); + } + + static ::mlir::StringAttr getResultLayoutsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 7); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.custom_call_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getCallTargetNameAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().call_target_name); + } + + ::mlir::Attribute getCallTargetName(); + ::mlir::Attribute getHasSideEffectAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().has_side_effect); + } + + ::mlir::Attribute getHasSideEffect(); + ::mlir::Attribute getBackendConfigAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().backend_config); + } + + ::mlir::Attribute getBackendConfig(); + ::mlir::Attribute getApiVersionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().api_version); + } + + ::mlir::Attribute getApiVersion(); + ::mlir::Attribute getCalledComputationsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().called_computations); + } + + ::mlir::Attribute getCalledComputations(); + ::mlir::Attribute getOperandLayoutsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().operand_layouts); + } + + ::mlir::Attribute getOperandLayouts(); + ::mlir::Attribute getResultLayoutsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().result_layouts); + } + + ::mlir::Attribute getResultLayouts(); + ::mlir::Attribute getOutputOperandAliasesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().output_operand_aliases); + } + + ::mlir::Attribute getOutputOperandAliases(); + void setCallTargetNameAttr(::mlir::Attribute attr) { + getProperties().call_target_name = attr; + } + + void setHasSideEffectAttr(::mlir::Attribute attr) { + getProperties().has_side_effect = attr; + } + + void setBackendConfigAttr(::mlir::Attribute attr) { + getProperties().backend_config = attr; + } + + void setApiVersionAttr(::mlir::Attribute attr) { + getProperties().api_version = attr; + } + + void setCalledComputationsAttr(::mlir::Attribute attr) { + getProperties().called_computations = attr; + } + + void setOperandLayoutsAttr(::mlir::Attribute attr) { + getProperties().operand_layouts = attr; + } + + void setResultLayoutsAttr(::mlir::Attribute attr) { + getProperties().result_layouts = attr; + } + + void setOutputOperandAliasesAttr(::mlir::Attribute attr) { + getProperties().output_operand_aliases = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::Attribute call_target_name, ::mlir::Attribute has_side_effect, ::mlir::Attribute backend_config, ::mlir::Attribute api_version, ::mlir::Attribute called_computations, ::mlir::Attribute operand_layouts, ::mlir::Attribute result_layouts, ::mlir::Attribute output_operand_aliases); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); + mlir::LogicalResult validateConstraint(mlir::Operation*op, mlir::vhlo::Version targetVersion); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 8 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::CustomCallOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DivOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DivOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DivOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.divide_v1", odsAttrs.getContext()); + } + + DivOpV1GenericAdaptorBase(DivOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class DivOpV1GenericAdaptor : public detail::DivOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DivOpV1GenericAdaptorBase; +public: + DivOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DivOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DivOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DivOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DivOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + DivOpV1GenericAdaptor(RangeT values, const DivOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DivOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DivOpV1Adaptor : public DivOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using DivOpV1GenericAdaptor::DivOpV1GenericAdaptor; + DivOpV1Adaptor(DivOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DivOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DivOpV1Adaptor; + template + using GenericAdaptor = DivOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.divide_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DivOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DotGeneralOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DotGeneralOpV1GenericAdaptorBase { +public: + struct Properties { + using lhs_batching_dimensionsTy = ::mlir::Attribute; + lhs_batching_dimensionsTy lhs_batching_dimensions; + + auto getLhsBatchingDimensions() const { + auto &propStorage = this->lhs_batching_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLhsBatchingDimensions(const ::mlir::Attribute &propValue) { + this->lhs_batching_dimensions = propValue; + } + using lhs_contracting_dimensionsTy = ::mlir::Attribute; + lhs_contracting_dimensionsTy lhs_contracting_dimensions; + + auto getLhsContractingDimensions() const { + auto &propStorage = this->lhs_contracting_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLhsContractingDimensions(const ::mlir::Attribute &propValue) { + this->lhs_contracting_dimensions = propValue; + } + using precision_configTy = ::mlir::Attribute; + precision_configTy precision_config; + + auto getPrecisionConfig() const { + auto &propStorage = this->precision_config; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setPrecisionConfig(const ::mlir::Attribute &propValue) { + this->precision_config = propValue; + } + using rhs_batching_dimensionsTy = ::mlir::Attribute; + rhs_batching_dimensionsTy rhs_batching_dimensions; + + auto getRhsBatchingDimensions() const { + auto &propStorage = this->rhs_batching_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setRhsBatchingDimensions(const ::mlir::Attribute &propValue) { + this->rhs_batching_dimensions = propValue; + } + using rhs_contracting_dimensionsTy = ::mlir::Attribute; + rhs_contracting_dimensionsTy rhs_contracting_dimensions; + + auto getRhsContractingDimensions() const { + auto &propStorage = this->rhs_contracting_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setRhsContractingDimensions(const ::mlir::Attribute &propValue) { + this->rhs_contracting_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.lhs_batching_dimensions == this->lhs_batching_dimensions && + rhs.lhs_contracting_dimensions == this->lhs_contracting_dimensions && + rhs.precision_config == this->precision_config && + rhs.rhs_batching_dimensions == this->rhs_batching_dimensions && + rhs.rhs_contracting_dimensions == this->rhs_contracting_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DotGeneralOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.dot_general_v1", odsAttrs.getContext()); + } + + DotGeneralOpV1GenericAdaptorBase(DotGeneralOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getLhsBatchingDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().lhs_batching_dimensions); + return attr; + } + + ::mlir::Attribute getLhsBatchingDimensions(); + ::mlir::Attribute getRhsBatchingDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().rhs_batching_dimensions); + return attr; + } + + ::mlir::Attribute getRhsBatchingDimensions(); + ::mlir::Attribute getLhsContractingDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().lhs_contracting_dimensions); + return attr; + } + + ::mlir::Attribute getLhsContractingDimensions(); + ::mlir::Attribute getRhsContractingDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().rhs_contracting_dimensions); + return attr; + } + + ::mlir::Attribute getRhsContractingDimensions(); + ::mlir::Attribute getPrecisionConfigAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().precision_config); + return attr; + } + + ::mlir::Attribute getPrecisionConfig(); +}; +} // namespace detail +template +class DotGeneralOpV1GenericAdaptor : public detail::DotGeneralOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DotGeneralOpV1GenericAdaptorBase; +public: + DotGeneralOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DotGeneralOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DotGeneralOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DotGeneralOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DotGeneralOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + DotGeneralOpV1GenericAdaptor(RangeT values, const DotGeneralOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DotGeneralOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DotGeneralOpV1Adaptor : public DotGeneralOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using DotGeneralOpV1GenericAdaptor::DotGeneralOpV1GenericAdaptor; + DotGeneralOpV1Adaptor(DotGeneralOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DotGeneralOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DotGeneralOpV1Adaptor; + template + using GenericAdaptor = DotGeneralOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("lhs_batching_dimensions"), ::llvm::StringRef("lhs_contracting_dimensions"), ::llvm::StringRef("precision_config"), ::llvm::StringRef("rhs_batching_dimensions"), ::llvm::StringRef("rhs_contracting_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getLhsBatchingDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getLhsBatchingDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getLhsContractingDimensionsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getLhsContractingDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getPrecisionConfigAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getPrecisionConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getRhsBatchingDimensionsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getRhsBatchingDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getRhsContractingDimensionsAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getRhsContractingDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.dot_general_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getLhsBatchingDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().lhs_batching_dimensions); + } + + ::mlir::Attribute getLhsBatchingDimensions(); + ::mlir::Attribute getRhsBatchingDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().rhs_batching_dimensions); + } + + ::mlir::Attribute getRhsBatchingDimensions(); + ::mlir::Attribute getLhsContractingDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().lhs_contracting_dimensions); + } + + ::mlir::Attribute getLhsContractingDimensions(); + ::mlir::Attribute getRhsContractingDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().rhs_contracting_dimensions); + } + + ::mlir::Attribute getRhsContractingDimensions(); + ::mlir::Attribute getPrecisionConfigAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().precision_config); + } + + ::mlir::Attribute getPrecisionConfig(); + void setLhsBatchingDimensionsAttr(::mlir::Attribute attr) { + getProperties().lhs_batching_dimensions = attr; + } + + void setRhsBatchingDimensionsAttr(::mlir::Attribute attr) { + getProperties().rhs_batching_dimensions = attr; + } + + void setLhsContractingDimensionsAttr(::mlir::Attribute attr) { + getProperties().lhs_contracting_dimensions = attr; + } + + void setRhsContractingDimensionsAttr(::mlir::Attribute attr) { + getProperties().rhs_contracting_dimensions = attr; + } + + void setPrecisionConfigAttr(::mlir::Attribute attr) { + getProperties().precision_config = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute lhs_batching_dimensions, ::mlir::Attribute rhs_batching_dimensions, ::mlir::Attribute lhs_contracting_dimensions, ::mlir::Attribute rhs_contracting_dimensions, ::mlir::Attribute precision_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute lhs_batching_dimensions, ::mlir::Attribute rhs_batching_dimensions, ::mlir::Attribute lhs_contracting_dimensions, ::mlir::Attribute rhs_contracting_dimensions, ::mlir::Attribute precision_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 5 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DotGeneralOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DotGeneralOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DotGeneralOpV2GenericAdaptorBase { +public: + struct Properties { + using accumulation_typeTy = ::mlir::Attribute; + accumulation_typeTy accumulation_type; + + auto getAccumulationType() const { + auto &propStorage = this->accumulation_type; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setAccumulationType(const ::mlir::Attribute &propValue) { + this->accumulation_type = propValue; + } + using allow_imprecise_accumulationTy = ::mlir::Attribute; + allow_imprecise_accumulationTy allow_imprecise_accumulation; + + auto getAllowImpreciseAccumulation() const { + auto &propStorage = this->allow_imprecise_accumulation; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setAllowImpreciseAccumulation(const ::mlir::Attribute &propValue) { + this->allow_imprecise_accumulation = propValue; + } + using lhs_batching_dimensionsTy = ::mlir::Attribute; + lhs_batching_dimensionsTy lhs_batching_dimensions; + + auto getLhsBatchingDimensions() const { + auto &propStorage = this->lhs_batching_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLhsBatchingDimensions(const ::mlir::Attribute &propValue) { + this->lhs_batching_dimensions = propValue; + } + using lhs_component_countTy = ::mlir::Attribute; + lhs_component_countTy lhs_component_count; + + auto getLhsComponentCount() const { + auto &propStorage = this->lhs_component_count; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLhsComponentCount(const ::mlir::Attribute &propValue) { + this->lhs_component_count = propValue; + } + using lhs_contracting_dimensionsTy = ::mlir::Attribute; + lhs_contracting_dimensionsTy lhs_contracting_dimensions; + + auto getLhsContractingDimensions() const { + auto &propStorage = this->lhs_contracting_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLhsContractingDimensions(const ::mlir::Attribute &propValue) { + this->lhs_contracting_dimensions = propValue; + } + using lhs_precision_typeTy = ::mlir::Attribute; + lhs_precision_typeTy lhs_precision_type; + + auto getLhsPrecisionType() const { + auto &propStorage = this->lhs_precision_type; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLhsPrecisionType(const ::mlir::Attribute &propValue) { + this->lhs_precision_type = propValue; + } + using num_primitive_operationsTy = ::mlir::Attribute; + num_primitive_operationsTy num_primitive_operations; + + auto getNumPrimitiveOperations() const { + auto &propStorage = this->num_primitive_operations; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setNumPrimitiveOperations(const ::mlir::Attribute &propValue) { + this->num_primitive_operations = propValue; + } + using precision_configTy = ::mlir::Attribute; + precision_configTy precision_config; + + auto getPrecisionConfig() const { + auto &propStorage = this->precision_config; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setPrecisionConfig(const ::mlir::Attribute &propValue) { + this->precision_config = propValue; + } + using rhs_batching_dimensionsTy = ::mlir::Attribute; + rhs_batching_dimensionsTy rhs_batching_dimensions; + + auto getRhsBatchingDimensions() const { + auto &propStorage = this->rhs_batching_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setRhsBatchingDimensions(const ::mlir::Attribute &propValue) { + this->rhs_batching_dimensions = propValue; + } + using rhs_component_countTy = ::mlir::Attribute; + rhs_component_countTy rhs_component_count; + + auto getRhsComponentCount() const { + auto &propStorage = this->rhs_component_count; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setRhsComponentCount(const ::mlir::Attribute &propValue) { + this->rhs_component_count = propValue; + } + using rhs_contracting_dimensionsTy = ::mlir::Attribute; + rhs_contracting_dimensionsTy rhs_contracting_dimensions; + + auto getRhsContractingDimensions() const { + auto &propStorage = this->rhs_contracting_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setRhsContractingDimensions(const ::mlir::Attribute &propValue) { + this->rhs_contracting_dimensions = propValue; + } + using rhs_precision_typeTy = ::mlir::Attribute; + rhs_precision_typeTy rhs_precision_type; + + auto getRhsPrecisionType() const { + auto &propStorage = this->rhs_precision_type; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setRhsPrecisionType(const ::mlir::Attribute &propValue) { + this->rhs_precision_type = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.accumulation_type == this->accumulation_type && + rhs.allow_imprecise_accumulation == this->allow_imprecise_accumulation && + rhs.lhs_batching_dimensions == this->lhs_batching_dimensions && + rhs.lhs_component_count == this->lhs_component_count && + rhs.lhs_contracting_dimensions == this->lhs_contracting_dimensions && + rhs.lhs_precision_type == this->lhs_precision_type && + rhs.num_primitive_operations == this->num_primitive_operations && + rhs.precision_config == this->precision_config && + rhs.rhs_batching_dimensions == this->rhs_batching_dimensions && + rhs.rhs_component_count == this->rhs_component_count && + rhs.rhs_contracting_dimensions == this->rhs_contracting_dimensions && + rhs.rhs_precision_type == this->rhs_precision_type && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DotGeneralOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.dot_general_v2", odsAttrs.getContext()); + } + + DotGeneralOpV2GenericAdaptorBase(DotGeneralOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getLhsBatchingDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().lhs_batching_dimensions); + return attr; + } + + ::mlir::Attribute getLhsBatchingDimensions(); + ::mlir::Attribute getRhsBatchingDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().rhs_batching_dimensions); + return attr; + } + + ::mlir::Attribute getRhsBatchingDimensions(); + ::mlir::Attribute getLhsContractingDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().lhs_contracting_dimensions); + return attr; + } + + ::mlir::Attribute getLhsContractingDimensions(); + ::mlir::Attribute getRhsContractingDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().rhs_contracting_dimensions); + return attr; + } + + ::mlir::Attribute getRhsContractingDimensions(); + ::mlir::Attribute getPrecisionConfigAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().precision_config); + return attr; + } + + ::mlir::Attribute getPrecisionConfig(); + ::mlir::Attribute getLhsPrecisionTypeAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().lhs_precision_type); + return attr; + } + + ::mlir::Attribute getLhsPrecisionType(); + ::mlir::Attribute getRhsPrecisionTypeAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().rhs_precision_type); + return attr; + } + + ::mlir::Attribute getRhsPrecisionType(); + ::mlir::Attribute getAccumulationTypeAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().accumulation_type); + return attr; + } + + ::mlir::Attribute getAccumulationType(); + ::mlir::Attribute getLhsComponentCountAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().lhs_component_count); + return attr; + } + + ::mlir::Attribute getLhsComponentCount(); + ::mlir::Attribute getRhsComponentCountAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().rhs_component_count); + return attr; + } + + ::mlir::Attribute getRhsComponentCount(); + ::mlir::Attribute getNumPrimitiveOperationsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().num_primitive_operations); + return attr; + } + + ::mlir::Attribute getNumPrimitiveOperations(); + ::mlir::Attribute getAllowImpreciseAccumulationAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().allow_imprecise_accumulation); + return attr; + } + + ::mlir::Attribute getAllowImpreciseAccumulation(); +}; +} // namespace detail +template +class DotGeneralOpV2GenericAdaptor : public detail::DotGeneralOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DotGeneralOpV2GenericAdaptorBase; +public: + DotGeneralOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DotGeneralOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DotGeneralOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DotGeneralOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DotGeneralOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + DotGeneralOpV2GenericAdaptor(RangeT values, const DotGeneralOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DotGeneralOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DotGeneralOpV2Adaptor : public DotGeneralOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using DotGeneralOpV2GenericAdaptor::DotGeneralOpV2GenericAdaptor; + DotGeneralOpV2Adaptor(DotGeneralOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DotGeneralOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DotGeneralOpV2Adaptor; + template + using GenericAdaptor = DotGeneralOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("accumulation_type"), ::llvm::StringRef("allow_imprecise_accumulation"), ::llvm::StringRef("lhs_batching_dimensions"), ::llvm::StringRef("lhs_component_count"), ::llvm::StringRef("lhs_contracting_dimensions"), ::llvm::StringRef("lhs_precision_type"), ::llvm::StringRef("num_primitive_operations"), ::llvm::StringRef("precision_config"), ::llvm::StringRef("rhs_batching_dimensions"), ::llvm::StringRef("rhs_component_count"), ::llvm::StringRef("rhs_contracting_dimensions"), ::llvm::StringRef("rhs_precision_type")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getAccumulationTypeAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getAccumulationTypeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getAllowImpreciseAccumulationAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getAllowImpreciseAccumulationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getLhsBatchingDimensionsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getLhsBatchingDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getLhsComponentCountAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getLhsComponentCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getLhsContractingDimensionsAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getLhsContractingDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + ::mlir::StringAttr getLhsPrecisionTypeAttrName() { + return getAttributeNameForIndex(5); + } + + static ::mlir::StringAttr getLhsPrecisionTypeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 5); + } + + ::mlir::StringAttr getNumPrimitiveOperationsAttrName() { + return getAttributeNameForIndex(6); + } + + static ::mlir::StringAttr getNumPrimitiveOperationsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 6); + } + + ::mlir::StringAttr getPrecisionConfigAttrName() { + return getAttributeNameForIndex(7); + } + + static ::mlir::StringAttr getPrecisionConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 7); + } + + ::mlir::StringAttr getRhsBatchingDimensionsAttrName() { + return getAttributeNameForIndex(8); + } + + static ::mlir::StringAttr getRhsBatchingDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 8); + } + + ::mlir::StringAttr getRhsComponentCountAttrName() { + return getAttributeNameForIndex(9); + } + + static ::mlir::StringAttr getRhsComponentCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 9); + } + + ::mlir::StringAttr getRhsContractingDimensionsAttrName() { + return getAttributeNameForIndex(10); + } + + static ::mlir::StringAttr getRhsContractingDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 10); + } + + ::mlir::StringAttr getRhsPrecisionTypeAttrName() { + return getAttributeNameForIndex(11); + } + + static ::mlir::StringAttr getRhsPrecisionTypeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 11); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.dot_general_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getLhsBatchingDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().lhs_batching_dimensions); + } + + ::mlir::Attribute getLhsBatchingDimensions(); + ::mlir::Attribute getRhsBatchingDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().rhs_batching_dimensions); + } + + ::mlir::Attribute getRhsBatchingDimensions(); + ::mlir::Attribute getLhsContractingDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().lhs_contracting_dimensions); + } + + ::mlir::Attribute getLhsContractingDimensions(); + ::mlir::Attribute getRhsContractingDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().rhs_contracting_dimensions); + } + + ::mlir::Attribute getRhsContractingDimensions(); + ::mlir::Attribute getPrecisionConfigAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().precision_config); + } + + ::mlir::Attribute getPrecisionConfig(); + ::mlir::Attribute getLhsPrecisionTypeAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().lhs_precision_type); + } + + ::mlir::Attribute getLhsPrecisionType(); + ::mlir::Attribute getRhsPrecisionTypeAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().rhs_precision_type); + } + + ::mlir::Attribute getRhsPrecisionType(); + ::mlir::Attribute getAccumulationTypeAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().accumulation_type); + } + + ::mlir::Attribute getAccumulationType(); + ::mlir::Attribute getLhsComponentCountAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().lhs_component_count); + } + + ::mlir::Attribute getLhsComponentCount(); + ::mlir::Attribute getRhsComponentCountAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().rhs_component_count); + } + + ::mlir::Attribute getRhsComponentCount(); + ::mlir::Attribute getNumPrimitiveOperationsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().num_primitive_operations); + } + + ::mlir::Attribute getNumPrimitiveOperations(); + ::mlir::Attribute getAllowImpreciseAccumulationAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().allow_imprecise_accumulation); + } + + ::mlir::Attribute getAllowImpreciseAccumulation(); + void setLhsBatchingDimensionsAttr(::mlir::Attribute attr) { + getProperties().lhs_batching_dimensions = attr; + } + + void setRhsBatchingDimensionsAttr(::mlir::Attribute attr) { + getProperties().rhs_batching_dimensions = attr; + } + + void setLhsContractingDimensionsAttr(::mlir::Attribute attr) { + getProperties().lhs_contracting_dimensions = attr; + } + + void setRhsContractingDimensionsAttr(::mlir::Attribute attr) { + getProperties().rhs_contracting_dimensions = attr; + } + + void setPrecisionConfigAttr(::mlir::Attribute attr) { + getProperties().precision_config = attr; + } + + void setLhsPrecisionTypeAttr(::mlir::Attribute attr) { + getProperties().lhs_precision_type = attr; + } + + void setRhsPrecisionTypeAttr(::mlir::Attribute attr) { + getProperties().rhs_precision_type = attr; + } + + void setAccumulationTypeAttr(::mlir::Attribute attr) { + getProperties().accumulation_type = attr; + } + + void setLhsComponentCountAttr(::mlir::Attribute attr) { + getProperties().lhs_component_count = attr; + } + + void setRhsComponentCountAttr(::mlir::Attribute attr) { + getProperties().rhs_component_count = attr; + } + + void setNumPrimitiveOperationsAttr(::mlir::Attribute attr) { + getProperties().num_primitive_operations = attr; + } + + void setAllowImpreciseAccumulationAttr(::mlir::Attribute attr) { + getProperties().allow_imprecise_accumulation = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute lhs_batching_dimensions, ::mlir::Attribute rhs_batching_dimensions, ::mlir::Attribute lhs_contracting_dimensions, ::mlir::Attribute rhs_contracting_dimensions, ::mlir::Attribute precision_config, ::mlir::Attribute lhs_precision_type, ::mlir::Attribute rhs_precision_type, ::mlir::Attribute accumulation_type, ::mlir::Attribute lhs_component_count, ::mlir::Attribute rhs_component_count, ::mlir::Attribute num_primitive_operations, ::mlir::Attribute allow_imprecise_accumulation); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute lhs_batching_dimensions, ::mlir::Attribute rhs_batching_dimensions, ::mlir::Attribute lhs_contracting_dimensions, ::mlir::Attribute rhs_contracting_dimensions, ::mlir::Attribute precision_config, ::mlir::Attribute lhs_precision_type, ::mlir::Attribute rhs_precision_type, ::mlir::Attribute accumulation_type, ::mlir::Attribute lhs_component_count, ::mlir::Attribute rhs_component_count, ::mlir::Attribute num_primitive_operations, ::mlir::Attribute allow_imprecise_accumulation); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 12 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DotGeneralOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DotOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DotOpV1GenericAdaptorBase { +public: + struct Properties { + using precision_configTy = ::mlir::Attribute; + precision_configTy precision_config; + + auto getPrecisionConfig() const { + auto &propStorage = this->precision_config; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setPrecisionConfig(const ::mlir::Attribute &propValue) { + this->precision_config = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.precision_config == this->precision_config && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DotOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.dot_v1", odsAttrs.getContext()); + } + + DotOpV1GenericAdaptorBase(DotOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getPrecisionConfigAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().precision_config); + return attr; + } + + ::mlir::Attribute getPrecisionConfig(); +}; +} // namespace detail +template +class DotOpV1GenericAdaptor : public detail::DotOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DotOpV1GenericAdaptorBase; +public: + DotOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DotOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DotOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DotOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DotOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + DotOpV1GenericAdaptor(RangeT values, const DotOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DotOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DotOpV1Adaptor : public DotOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using DotOpV1GenericAdaptor::DotOpV1GenericAdaptor; + DotOpV1Adaptor(DotOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DotOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DotOpV1Adaptor; + template + using GenericAdaptor = DotOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("precision_config")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getPrecisionConfigAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getPrecisionConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.dot_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getPrecisionConfigAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().precision_config); + } + + ::mlir::Attribute getPrecisionConfig(); + void setPrecisionConfigAttr(::mlir::Attribute attr) { + getProperties().precision_config = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute precision_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute precision_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DotOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicBroadcastInDimOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicBroadcastInDimOpV1GenericAdaptorBase { +public: + struct Properties { + using broadcast_dimensionsTy = ::mlir::Attribute; + broadcast_dimensionsTy broadcast_dimensions; + + auto getBroadcastDimensions() const { + auto &propStorage = this->broadcast_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setBroadcastDimensions(const ::mlir::Attribute &propValue) { + this->broadcast_dimensions = propValue; + } + using known_expanding_dimensionsTy = ::mlir::Attribute; + known_expanding_dimensionsTy known_expanding_dimensions; + + auto getKnownExpandingDimensions() const { + auto &propStorage = this->known_expanding_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setKnownExpandingDimensions(const ::mlir::Attribute &propValue) { + this->known_expanding_dimensions = propValue; + } + using known_nonexpanding_dimensionsTy = ::mlir::Attribute; + known_nonexpanding_dimensionsTy known_nonexpanding_dimensions; + + auto getKnownNonexpandingDimensions() const { + auto &propStorage = this->known_nonexpanding_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setKnownNonexpandingDimensions(const ::mlir::Attribute &propValue) { + this->known_nonexpanding_dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.broadcast_dimensions == this->broadcast_dimensions && + rhs.known_expanding_dimensions == this->known_expanding_dimensions && + rhs.known_nonexpanding_dimensions == this->known_nonexpanding_dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicBroadcastInDimOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.dynamic_broadcast_in_dim_v1", odsAttrs.getContext()); + } + + DynamicBroadcastInDimOpV1GenericAdaptorBase(DynamicBroadcastInDimOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getBroadcastDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().broadcast_dimensions); + return attr; + } + + ::mlir::Attribute getBroadcastDimensions(); + ::mlir::Attribute getKnownExpandingDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().known_expanding_dimensions); + return attr; + } + + ::mlir::Attribute getKnownExpandingDimensions(); + ::mlir::Attribute getKnownNonexpandingDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().known_nonexpanding_dimensions); + return attr; + } + + ::mlir::Attribute getKnownNonexpandingDimensions(); +}; +} // namespace detail +template +class DynamicBroadcastInDimOpV1GenericAdaptor : public detail::DynamicBroadcastInDimOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicBroadcastInDimOpV1GenericAdaptorBase; +public: + DynamicBroadcastInDimOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicBroadcastInDimOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicBroadcastInDimOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicBroadcastInDimOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicBroadcastInDimOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicBroadcastInDimOpV1GenericAdaptor(RangeT values, const DynamicBroadcastInDimOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicBroadcastInDimOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getOutputDimensions() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicBroadcastInDimOpV1Adaptor : public DynamicBroadcastInDimOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using DynamicBroadcastInDimOpV1GenericAdaptor::DynamicBroadcastInDimOpV1GenericAdaptor; + DynamicBroadcastInDimOpV1Adaptor(DynamicBroadcastInDimOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicBroadcastInDimOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicBroadcastInDimOpV1Adaptor; + template + using GenericAdaptor = DynamicBroadcastInDimOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("broadcast_dimensions"), ::llvm::StringRef("known_expanding_dimensions"), ::llvm::StringRef("known_nonexpanding_dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBroadcastDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBroadcastDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getKnownExpandingDimensionsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getKnownExpandingDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getKnownNonexpandingDimensionsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getKnownNonexpandingDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.dynamic_broadcast_in_dim_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getOutputDimensions() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOutputDimensionsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getBroadcastDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().broadcast_dimensions); + } + + ::mlir::Attribute getBroadcastDimensions(); + ::mlir::Attribute getKnownExpandingDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().known_expanding_dimensions); + } + + ::mlir::Attribute getKnownExpandingDimensions(); + ::mlir::Attribute getKnownNonexpandingDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().known_nonexpanding_dimensions); + } + + ::mlir::Attribute getKnownNonexpandingDimensions(); + void setBroadcastDimensionsAttr(::mlir::Attribute attr) { + getProperties().broadcast_dimensions = attr; + } + + void setKnownExpandingDimensionsAttr(::mlir::Attribute attr) { + getProperties().known_expanding_dimensions = attr; + } + + void setKnownNonexpandingDimensionsAttr(::mlir::Attribute attr) { + getProperties().known_nonexpanding_dimensions = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value output_dimensions, ::mlir::Attribute broadcast_dimensions, ::mlir::Attribute known_expanding_dimensions, ::mlir::Attribute known_nonexpanding_dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value output_dimensions, ::mlir::Attribute broadcast_dimensions, ::mlir::Attribute known_expanding_dimensions, ::mlir::Attribute known_nonexpanding_dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicBroadcastInDimOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicConvOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicConvOpV1GenericAdaptorBase { +public: + struct Properties { + using batch_group_countTy = ::mlir::Attribute; + batch_group_countTy batch_group_count; + + auto getBatchGroupCount() const { + auto &propStorage = this->batch_group_count; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setBatchGroupCount(const ::mlir::Attribute &propValue) { + this->batch_group_count = propValue; + } + using feature_group_countTy = ::mlir::Attribute; + feature_group_countTy feature_group_count; + + auto getFeatureGroupCount() const { + auto &propStorage = this->feature_group_count; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setFeatureGroupCount(const ::mlir::Attribute &propValue) { + this->feature_group_count = propValue; + } + using input_batch_dimensionTy = ::mlir::Attribute; + input_batch_dimensionTy input_batch_dimension; + + auto getInputBatchDimension() const { + auto &propStorage = this->input_batch_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInputBatchDimension(const ::mlir::Attribute &propValue) { + this->input_batch_dimension = propValue; + } + using input_feature_dimensionTy = ::mlir::Attribute; + input_feature_dimensionTy input_feature_dimension; + + auto getInputFeatureDimension() const { + auto &propStorage = this->input_feature_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInputFeatureDimension(const ::mlir::Attribute &propValue) { + this->input_feature_dimension = propValue; + } + using input_spatial_dimensionsTy = ::mlir::Attribute; + input_spatial_dimensionsTy input_spatial_dimensions; + + auto getInputSpatialDimensions() const { + auto &propStorage = this->input_spatial_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInputSpatialDimensions(const ::mlir::Attribute &propValue) { + this->input_spatial_dimensions = propValue; + } + using kernel_input_feature_dimensionTy = ::mlir::Attribute; + kernel_input_feature_dimensionTy kernel_input_feature_dimension; + + auto getKernelInputFeatureDimension() const { + auto &propStorage = this->kernel_input_feature_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setKernelInputFeatureDimension(const ::mlir::Attribute &propValue) { + this->kernel_input_feature_dimension = propValue; + } + using kernel_output_feature_dimensionTy = ::mlir::Attribute; + kernel_output_feature_dimensionTy kernel_output_feature_dimension; + + auto getKernelOutputFeatureDimension() const { + auto &propStorage = this->kernel_output_feature_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setKernelOutputFeatureDimension(const ::mlir::Attribute &propValue) { + this->kernel_output_feature_dimension = propValue; + } + using kernel_spatial_dimensionsTy = ::mlir::Attribute; + kernel_spatial_dimensionsTy kernel_spatial_dimensions; + + auto getKernelSpatialDimensions() const { + auto &propStorage = this->kernel_spatial_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setKernelSpatialDimensions(const ::mlir::Attribute &propValue) { + this->kernel_spatial_dimensions = propValue; + } + using lhs_dilationTy = ::mlir::Attribute; + lhs_dilationTy lhs_dilation; + + auto getLhsDilation() const { + auto &propStorage = this->lhs_dilation; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLhsDilation(const ::mlir::Attribute &propValue) { + this->lhs_dilation = propValue; + } + using output_batch_dimensionTy = ::mlir::Attribute; + output_batch_dimensionTy output_batch_dimension; + + auto getOutputBatchDimension() const { + auto &propStorage = this->output_batch_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOutputBatchDimension(const ::mlir::Attribute &propValue) { + this->output_batch_dimension = propValue; + } + using output_feature_dimensionTy = ::mlir::Attribute; + output_feature_dimensionTy output_feature_dimension; + + auto getOutputFeatureDimension() const { + auto &propStorage = this->output_feature_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOutputFeatureDimension(const ::mlir::Attribute &propValue) { + this->output_feature_dimension = propValue; + } + using output_spatial_dimensionsTy = ::mlir::Attribute; + output_spatial_dimensionsTy output_spatial_dimensions; + + auto getOutputSpatialDimensions() const { + auto &propStorage = this->output_spatial_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOutputSpatialDimensions(const ::mlir::Attribute &propValue) { + this->output_spatial_dimensions = propValue; + } + using paddingTy = ::mlir::Attribute; + paddingTy padding; + + auto getPadding() const { + auto &propStorage = this->padding; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setPadding(const ::mlir::Attribute &propValue) { + this->padding = propValue; + } + using precision_configTy = ::mlir::Attribute; + precision_configTy precision_config; + + auto getPrecisionConfig() const { + auto &propStorage = this->precision_config; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setPrecisionConfig(const ::mlir::Attribute &propValue) { + this->precision_config = propValue; + } + using rhs_dilationTy = ::mlir::Attribute; + rhs_dilationTy rhs_dilation; + + auto getRhsDilation() const { + auto &propStorage = this->rhs_dilation; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setRhsDilation(const ::mlir::Attribute &propValue) { + this->rhs_dilation = propValue; + } + using window_reversalTy = ::mlir::Attribute; + window_reversalTy window_reversal; + + auto getWindowReversal() const { + auto &propStorage = this->window_reversal; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setWindowReversal(const ::mlir::Attribute &propValue) { + this->window_reversal = propValue; + } + using window_stridesTy = ::mlir::Attribute; + window_stridesTy window_strides; + + auto getWindowStrides() const { + auto &propStorage = this->window_strides; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setWindowStrides(const ::mlir::Attribute &propValue) { + this->window_strides = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.batch_group_count == this->batch_group_count && + rhs.feature_group_count == this->feature_group_count && + rhs.input_batch_dimension == this->input_batch_dimension && + rhs.input_feature_dimension == this->input_feature_dimension && + rhs.input_spatial_dimensions == this->input_spatial_dimensions && + rhs.kernel_input_feature_dimension == this->kernel_input_feature_dimension && + rhs.kernel_output_feature_dimension == this->kernel_output_feature_dimension && + rhs.kernel_spatial_dimensions == this->kernel_spatial_dimensions && + rhs.lhs_dilation == this->lhs_dilation && + rhs.output_batch_dimension == this->output_batch_dimension && + rhs.output_feature_dimension == this->output_feature_dimension && + rhs.output_spatial_dimensions == this->output_spatial_dimensions && + rhs.padding == this->padding && + rhs.precision_config == this->precision_config && + rhs.rhs_dilation == this->rhs_dilation && + rhs.window_reversal == this->window_reversal && + rhs.window_strides == this->window_strides && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicConvOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.dynamic_conv_v1", odsAttrs.getContext()); + } + + DynamicConvOpV1GenericAdaptorBase(DynamicConvOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getWindowStridesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().window_strides); + return attr; + } + + ::mlir::Attribute getWindowStrides(); + ::mlir::Attribute getPaddingAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().padding); + return attr; + } + + ::mlir::Attribute getPadding(); + ::mlir::Attribute getLhsDilationAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().lhs_dilation); + return attr; + } + + ::mlir::Attribute getLhsDilation(); + ::mlir::Attribute getRhsDilationAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().rhs_dilation); + return attr; + } + + ::mlir::Attribute getRhsDilation(); + ::mlir::Attribute getWindowReversalAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().window_reversal); + return attr; + } + + ::mlir::Attribute getWindowReversal(); + ::mlir::Attribute getInputBatchDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().input_batch_dimension); + return attr; + } + + ::mlir::Attribute getInputBatchDimension(); + ::mlir::Attribute getInputFeatureDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().input_feature_dimension); + return attr; + } + + ::mlir::Attribute getInputFeatureDimension(); + ::mlir::Attribute getInputSpatialDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().input_spatial_dimensions); + return attr; + } + + ::mlir::Attribute getInputSpatialDimensions(); + ::mlir::Attribute getKernelInputFeatureDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().kernel_input_feature_dimension); + return attr; + } + + ::mlir::Attribute getKernelInputFeatureDimension(); + ::mlir::Attribute getKernelOutputFeatureDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().kernel_output_feature_dimension); + return attr; + } + + ::mlir::Attribute getKernelOutputFeatureDimension(); + ::mlir::Attribute getKernelSpatialDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().kernel_spatial_dimensions); + return attr; + } + + ::mlir::Attribute getKernelSpatialDimensions(); + ::mlir::Attribute getOutputBatchDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().output_batch_dimension); + return attr; + } + + ::mlir::Attribute getOutputBatchDimension(); + ::mlir::Attribute getOutputFeatureDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().output_feature_dimension); + return attr; + } + + ::mlir::Attribute getOutputFeatureDimension(); + ::mlir::Attribute getOutputSpatialDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().output_spatial_dimensions); + return attr; + } + + ::mlir::Attribute getOutputSpatialDimensions(); + ::mlir::Attribute getFeatureGroupCountAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().feature_group_count); + return attr; + } + + ::mlir::Attribute getFeatureGroupCount(); + ::mlir::Attribute getBatchGroupCountAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().batch_group_count); + return attr; + } + + ::mlir::Attribute getBatchGroupCount(); + ::mlir::Attribute getPrecisionConfigAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().precision_config); + return attr; + } + + ::mlir::Attribute getPrecisionConfig(); +}; +} // namespace detail +template +class DynamicConvOpV1GenericAdaptor : public detail::DynamicConvOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicConvOpV1GenericAdaptorBase; +public: + DynamicConvOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicConvOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicConvOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicConvOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicConvOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicConvOpV1GenericAdaptor(RangeT values, const DynamicConvOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicConvOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + ValueT getDPadding() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicConvOpV1Adaptor : public DynamicConvOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using DynamicConvOpV1GenericAdaptor::DynamicConvOpV1GenericAdaptor; + DynamicConvOpV1Adaptor(DynamicConvOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicConvOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicConvOpV1Adaptor; + template + using GenericAdaptor = DynamicConvOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("batch_group_count"), ::llvm::StringRef("feature_group_count"), ::llvm::StringRef("input_batch_dimension"), ::llvm::StringRef("input_feature_dimension"), ::llvm::StringRef("input_spatial_dimensions"), ::llvm::StringRef("kernel_input_feature_dimension"), ::llvm::StringRef("kernel_output_feature_dimension"), ::llvm::StringRef("kernel_spatial_dimensions"), ::llvm::StringRef("lhs_dilation"), ::llvm::StringRef("output_batch_dimension"), ::llvm::StringRef("output_feature_dimension"), ::llvm::StringRef("output_spatial_dimensions"), ::llvm::StringRef("padding"), ::llvm::StringRef("precision_config"), ::llvm::StringRef("rhs_dilation"), ::llvm::StringRef("window_reversal"), ::llvm::StringRef("window_strides")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBatchGroupCountAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBatchGroupCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFeatureGroupCountAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFeatureGroupCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getInputBatchDimensionAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getInputBatchDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getInputFeatureDimensionAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getInputFeatureDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getInputSpatialDimensionsAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getInputSpatialDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + ::mlir::StringAttr getKernelInputFeatureDimensionAttrName() { + return getAttributeNameForIndex(5); + } + + static ::mlir::StringAttr getKernelInputFeatureDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 5); + } + + ::mlir::StringAttr getKernelOutputFeatureDimensionAttrName() { + return getAttributeNameForIndex(6); + } + + static ::mlir::StringAttr getKernelOutputFeatureDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 6); + } + + ::mlir::StringAttr getKernelSpatialDimensionsAttrName() { + return getAttributeNameForIndex(7); + } + + static ::mlir::StringAttr getKernelSpatialDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 7); + } + + ::mlir::StringAttr getLhsDilationAttrName() { + return getAttributeNameForIndex(8); + } + + static ::mlir::StringAttr getLhsDilationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 8); + } + + ::mlir::StringAttr getOutputBatchDimensionAttrName() { + return getAttributeNameForIndex(9); + } + + static ::mlir::StringAttr getOutputBatchDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 9); + } + + ::mlir::StringAttr getOutputFeatureDimensionAttrName() { + return getAttributeNameForIndex(10); + } + + static ::mlir::StringAttr getOutputFeatureDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 10); + } + + ::mlir::StringAttr getOutputSpatialDimensionsAttrName() { + return getAttributeNameForIndex(11); + } + + static ::mlir::StringAttr getOutputSpatialDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 11); + } + + ::mlir::StringAttr getPaddingAttrName() { + return getAttributeNameForIndex(12); + } + + static ::mlir::StringAttr getPaddingAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 12); + } + + ::mlir::StringAttr getPrecisionConfigAttrName() { + return getAttributeNameForIndex(13); + } + + static ::mlir::StringAttr getPrecisionConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 13); + } + + ::mlir::StringAttr getRhsDilationAttrName() { + return getAttributeNameForIndex(14); + } + + static ::mlir::StringAttr getRhsDilationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 14); + } + + ::mlir::StringAttr getWindowReversalAttrName() { + return getAttributeNameForIndex(15); + } + + static ::mlir::StringAttr getWindowReversalAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 15); + } + + ::mlir::StringAttr getWindowStridesAttrName() { + return getAttributeNameForIndex(16); + } + + static ::mlir::StringAttr getWindowStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 16); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.dynamic_conv_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getDPadding() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getDPaddingMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getWindowStridesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().window_strides); + } + + ::mlir::Attribute getWindowStrides(); + ::mlir::Attribute getPaddingAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().padding); + } + + ::mlir::Attribute getPadding(); + ::mlir::Attribute getLhsDilationAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().lhs_dilation); + } + + ::mlir::Attribute getLhsDilation(); + ::mlir::Attribute getRhsDilationAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().rhs_dilation); + } + + ::mlir::Attribute getRhsDilation(); + ::mlir::Attribute getWindowReversalAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().window_reversal); + } + + ::mlir::Attribute getWindowReversal(); + ::mlir::Attribute getInputBatchDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().input_batch_dimension); + } + + ::mlir::Attribute getInputBatchDimension(); + ::mlir::Attribute getInputFeatureDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().input_feature_dimension); + } + + ::mlir::Attribute getInputFeatureDimension(); + ::mlir::Attribute getInputSpatialDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().input_spatial_dimensions); + } + + ::mlir::Attribute getInputSpatialDimensions(); + ::mlir::Attribute getKernelInputFeatureDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().kernel_input_feature_dimension); + } + + ::mlir::Attribute getKernelInputFeatureDimension(); + ::mlir::Attribute getKernelOutputFeatureDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().kernel_output_feature_dimension); + } + + ::mlir::Attribute getKernelOutputFeatureDimension(); + ::mlir::Attribute getKernelSpatialDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().kernel_spatial_dimensions); + } + + ::mlir::Attribute getKernelSpatialDimensions(); + ::mlir::Attribute getOutputBatchDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().output_batch_dimension); + } + + ::mlir::Attribute getOutputBatchDimension(); + ::mlir::Attribute getOutputFeatureDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().output_feature_dimension); + } + + ::mlir::Attribute getOutputFeatureDimension(); + ::mlir::Attribute getOutputSpatialDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().output_spatial_dimensions); + } + + ::mlir::Attribute getOutputSpatialDimensions(); + ::mlir::Attribute getFeatureGroupCountAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().feature_group_count); + } + + ::mlir::Attribute getFeatureGroupCount(); + ::mlir::Attribute getBatchGroupCountAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().batch_group_count); + } + + ::mlir::Attribute getBatchGroupCount(); + ::mlir::Attribute getPrecisionConfigAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().precision_config); + } + + ::mlir::Attribute getPrecisionConfig(); + void setWindowStridesAttr(::mlir::Attribute attr) { + getProperties().window_strides = attr; + } + + void setPaddingAttr(::mlir::Attribute attr) { + getProperties().padding = attr; + } + + void setLhsDilationAttr(::mlir::Attribute attr) { + getProperties().lhs_dilation = attr; + } + + void setRhsDilationAttr(::mlir::Attribute attr) { + getProperties().rhs_dilation = attr; + } + + void setWindowReversalAttr(::mlir::Attribute attr) { + getProperties().window_reversal = attr; + } + + void setInputBatchDimensionAttr(::mlir::Attribute attr) { + getProperties().input_batch_dimension = attr; + } + + void setInputFeatureDimensionAttr(::mlir::Attribute attr) { + getProperties().input_feature_dimension = attr; + } + + void setInputSpatialDimensionsAttr(::mlir::Attribute attr) { + getProperties().input_spatial_dimensions = attr; + } + + void setKernelInputFeatureDimensionAttr(::mlir::Attribute attr) { + getProperties().kernel_input_feature_dimension = attr; + } + + void setKernelOutputFeatureDimensionAttr(::mlir::Attribute attr) { + getProperties().kernel_output_feature_dimension = attr; + } + + void setKernelSpatialDimensionsAttr(::mlir::Attribute attr) { + getProperties().kernel_spatial_dimensions = attr; + } + + void setOutputBatchDimensionAttr(::mlir::Attribute attr) { + getProperties().output_batch_dimension = attr; + } + + void setOutputFeatureDimensionAttr(::mlir::Attribute attr) { + getProperties().output_feature_dimension = attr; + } + + void setOutputSpatialDimensionsAttr(::mlir::Attribute attr) { + getProperties().output_spatial_dimensions = attr; + } + + void setFeatureGroupCountAttr(::mlir::Attribute attr) { + getProperties().feature_group_count = attr; + } + + void setBatchGroupCountAttr(::mlir::Attribute attr) { + getProperties().batch_group_count = attr; + } + + void setPrecisionConfigAttr(::mlir::Attribute attr) { + getProperties().precision_config = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value d_padding, ::mlir::Attribute window_strides, ::mlir::Attribute padding, ::mlir::Attribute lhs_dilation, ::mlir::Attribute rhs_dilation, ::mlir::Attribute window_reversal, ::mlir::Attribute input_batch_dimension, ::mlir::Attribute input_feature_dimension, ::mlir::Attribute input_spatial_dimensions, ::mlir::Attribute kernel_input_feature_dimension, ::mlir::Attribute kernel_output_feature_dimension, ::mlir::Attribute kernel_spatial_dimensions, ::mlir::Attribute output_batch_dimension, ::mlir::Attribute output_feature_dimension, ::mlir::Attribute output_spatial_dimensions, ::mlir::Attribute feature_group_count, ::mlir::Attribute batch_group_count, ::mlir::Attribute precision_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value d_padding, ::mlir::Attribute window_strides, ::mlir::Attribute padding, ::mlir::Attribute lhs_dilation, ::mlir::Attribute rhs_dilation, ::mlir::Attribute window_reversal, ::mlir::Attribute input_batch_dimension, ::mlir::Attribute input_feature_dimension, ::mlir::Attribute input_spatial_dimensions, ::mlir::Attribute kernel_input_feature_dimension, ::mlir::Attribute kernel_output_feature_dimension, ::mlir::Attribute kernel_spatial_dimensions, ::mlir::Attribute output_batch_dimension, ::mlir::Attribute output_feature_dimension, ::mlir::Attribute output_spatial_dimensions, ::mlir::Attribute feature_group_count, ::mlir::Attribute batch_group_count, ::mlir::Attribute precision_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 17 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicConvOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicConvOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicConvOpV2GenericAdaptorBase { +public: + struct Properties { + using batch_group_countTy = ::mlir::Attribute; + batch_group_countTy batch_group_count; + + auto getBatchGroupCount() const { + auto &propStorage = this->batch_group_count; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setBatchGroupCount(const ::mlir::Attribute &propValue) { + this->batch_group_count = propValue; + } + using feature_group_countTy = ::mlir::Attribute; + feature_group_countTy feature_group_count; + + auto getFeatureGroupCount() const { + auto &propStorage = this->feature_group_count; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setFeatureGroupCount(const ::mlir::Attribute &propValue) { + this->feature_group_count = propValue; + } + using input_batch_dimensionTy = ::mlir::Attribute; + input_batch_dimensionTy input_batch_dimension; + + auto getInputBatchDimension() const { + auto &propStorage = this->input_batch_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInputBatchDimension(const ::mlir::Attribute &propValue) { + this->input_batch_dimension = propValue; + } + using input_feature_dimensionTy = ::mlir::Attribute; + input_feature_dimensionTy input_feature_dimension; + + auto getInputFeatureDimension() const { + auto &propStorage = this->input_feature_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInputFeatureDimension(const ::mlir::Attribute &propValue) { + this->input_feature_dimension = propValue; + } + using input_spatial_dimensionsTy = ::mlir::Attribute; + input_spatial_dimensionsTy input_spatial_dimensions; + + auto getInputSpatialDimensions() const { + auto &propStorage = this->input_spatial_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInputSpatialDimensions(const ::mlir::Attribute &propValue) { + this->input_spatial_dimensions = propValue; + } + using kernel_input_feature_dimensionTy = ::mlir::Attribute; + kernel_input_feature_dimensionTy kernel_input_feature_dimension; + + auto getKernelInputFeatureDimension() const { + auto &propStorage = this->kernel_input_feature_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setKernelInputFeatureDimension(const ::mlir::Attribute &propValue) { + this->kernel_input_feature_dimension = propValue; + } + using kernel_output_feature_dimensionTy = ::mlir::Attribute; + kernel_output_feature_dimensionTy kernel_output_feature_dimension; + + auto getKernelOutputFeatureDimension() const { + auto &propStorage = this->kernel_output_feature_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setKernelOutputFeatureDimension(const ::mlir::Attribute &propValue) { + this->kernel_output_feature_dimension = propValue; + } + using kernel_spatial_dimensionsTy = ::mlir::Attribute; + kernel_spatial_dimensionsTy kernel_spatial_dimensions; + + auto getKernelSpatialDimensions() const { + auto &propStorage = this->kernel_spatial_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setKernelSpatialDimensions(const ::mlir::Attribute &propValue) { + this->kernel_spatial_dimensions = propValue; + } + using lhs_dilationTy = ::mlir::Attribute; + lhs_dilationTy lhs_dilation; + + auto getLhsDilation() const { + auto &propStorage = this->lhs_dilation; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLhsDilation(const ::mlir::Attribute &propValue) { + this->lhs_dilation = propValue; + } + using output_batch_dimensionTy = ::mlir::Attribute; + output_batch_dimensionTy output_batch_dimension; + + auto getOutputBatchDimension() const { + auto &propStorage = this->output_batch_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOutputBatchDimension(const ::mlir::Attribute &propValue) { + this->output_batch_dimension = propValue; + } + using output_feature_dimensionTy = ::mlir::Attribute; + output_feature_dimensionTy output_feature_dimension; + + auto getOutputFeatureDimension() const { + auto &propStorage = this->output_feature_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOutputFeatureDimension(const ::mlir::Attribute &propValue) { + this->output_feature_dimension = propValue; + } + using output_spatial_dimensionsTy = ::mlir::Attribute; + output_spatial_dimensionsTy output_spatial_dimensions; + + auto getOutputSpatialDimensions() const { + auto &propStorage = this->output_spatial_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOutputSpatialDimensions(const ::mlir::Attribute &propValue) { + this->output_spatial_dimensions = propValue; + } + using precision_configTy = ::mlir::Attribute; + precision_configTy precision_config; + + auto getPrecisionConfig() const { + auto &propStorage = this->precision_config; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setPrecisionConfig(const ::mlir::Attribute &propValue) { + this->precision_config = propValue; + } + using rhs_dilationTy = ::mlir::Attribute; + rhs_dilationTy rhs_dilation; + + auto getRhsDilation() const { + auto &propStorage = this->rhs_dilation; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setRhsDilation(const ::mlir::Attribute &propValue) { + this->rhs_dilation = propValue; + } + using window_reversalTy = ::mlir::Attribute; + window_reversalTy window_reversal; + + auto getWindowReversal() const { + auto &propStorage = this->window_reversal; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setWindowReversal(const ::mlir::Attribute &propValue) { + this->window_reversal = propValue; + } + using window_stridesTy = ::mlir::Attribute; + window_stridesTy window_strides; + + auto getWindowStrides() const { + auto &propStorage = this->window_strides; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setWindowStrides(const ::mlir::Attribute &propValue) { + this->window_strides = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.batch_group_count == this->batch_group_count && + rhs.feature_group_count == this->feature_group_count && + rhs.input_batch_dimension == this->input_batch_dimension && + rhs.input_feature_dimension == this->input_feature_dimension && + rhs.input_spatial_dimensions == this->input_spatial_dimensions && + rhs.kernel_input_feature_dimension == this->kernel_input_feature_dimension && + rhs.kernel_output_feature_dimension == this->kernel_output_feature_dimension && + rhs.kernel_spatial_dimensions == this->kernel_spatial_dimensions && + rhs.lhs_dilation == this->lhs_dilation && + rhs.output_batch_dimension == this->output_batch_dimension && + rhs.output_feature_dimension == this->output_feature_dimension && + rhs.output_spatial_dimensions == this->output_spatial_dimensions && + rhs.precision_config == this->precision_config && + rhs.rhs_dilation == this->rhs_dilation && + rhs.window_reversal == this->window_reversal && + rhs.window_strides == this->window_strides && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicConvOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.dynamic_conv_v2", odsAttrs.getContext()); + } + + DynamicConvOpV2GenericAdaptorBase(DynamicConvOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getWindowStridesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().window_strides); + return attr; + } + + ::mlir::Attribute getWindowStrides(); + ::mlir::Attribute getLhsDilationAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().lhs_dilation); + return attr; + } + + ::mlir::Attribute getLhsDilation(); + ::mlir::Attribute getRhsDilationAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().rhs_dilation); + return attr; + } + + ::mlir::Attribute getRhsDilation(); + ::mlir::Attribute getWindowReversalAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().window_reversal); + return attr; + } + + ::mlir::Attribute getWindowReversal(); + ::mlir::Attribute getInputBatchDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().input_batch_dimension); + return attr; + } + + ::mlir::Attribute getInputBatchDimension(); + ::mlir::Attribute getInputFeatureDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().input_feature_dimension); + return attr; + } + + ::mlir::Attribute getInputFeatureDimension(); + ::mlir::Attribute getInputSpatialDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().input_spatial_dimensions); + return attr; + } + + ::mlir::Attribute getInputSpatialDimensions(); + ::mlir::Attribute getKernelInputFeatureDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().kernel_input_feature_dimension); + return attr; + } + + ::mlir::Attribute getKernelInputFeatureDimension(); + ::mlir::Attribute getKernelOutputFeatureDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().kernel_output_feature_dimension); + return attr; + } + + ::mlir::Attribute getKernelOutputFeatureDimension(); + ::mlir::Attribute getKernelSpatialDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().kernel_spatial_dimensions); + return attr; + } + + ::mlir::Attribute getKernelSpatialDimensions(); + ::mlir::Attribute getOutputBatchDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().output_batch_dimension); + return attr; + } + + ::mlir::Attribute getOutputBatchDimension(); + ::mlir::Attribute getOutputFeatureDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().output_feature_dimension); + return attr; + } + + ::mlir::Attribute getOutputFeatureDimension(); + ::mlir::Attribute getOutputSpatialDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().output_spatial_dimensions); + return attr; + } + + ::mlir::Attribute getOutputSpatialDimensions(); + ::mlir::Attribute getFeatureGroupCountAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().feature_group_count); + return attr; + } + + ::mlir::Attribute getFeatureGroupCount(); + ::mlir::Attribute getBatchGroupCountAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().batch_group_count); + return attr; + } + + ::mlir::Attribute getBatchGroupCount(); + ::mlir::Attribute getPrecisionConfigAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().precision_config); + return attr; + } + + ::mlir::Attribute getPrecisionConfig(); +}; +} // namespace detail +template +class DynamicConvOpV2GenericAdaptor : public detail::DynamicConvOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicConvOpV2GenericAdaptorBase; +public: + DynamicConvOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicConvOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicConvOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicConvOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicConvOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicConvOpV2GenericAdaptor(RangeT values, const DynamicConvOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicConvOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + ValueT getPadding() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicConvOpV2Adaptor : public DynamicConvOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using DynamicConvOpV2GenericAdaptor::DynamicConvOpV2GenericAdaptor; + DynamicConvOpV2Adaptor(DynamicConvOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicConvOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicConvOpV2Adaptor; + template + using GenericAdaptor = DynamicConvOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("batch_group_count"), ::llvm::StringRef("feature_group_count"), ::llvm::StringRef("input_batch_dimension"), ::llvm::StringRef("input_feature_dimension"), ::llvm::StringRef("input_spatial_dimensions"), ::llvm::StringRef("kernel_input_feature_dimension"), ::llvm::StringRef("kernel_output_feature_dimension"), ::llvm::StringRef("kernel_spatial_dimensions"), ::llvm::StringRef("lhs_dilation"), ::llvm::StringRef("output_batch_dimension"), ::llvm::StringRef("output_feature_dimension"), ::llvm::StringRef("output_spatial_dimensions"), ::llvm::StringRef("precision_config"), ::llvm::StringRef("rhs_dilation"), ::llvm::StringRef("window_reversal"), ::llvm::StringRef("window_strides")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBatchGroupCountAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBatchGroupCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFeatureGroupCountAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFeatureGroupCountAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getInputBatchDimensionAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getInputBatchDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getInputFeatureDimensionAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getInputFeatureDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getInputSpatialDimensionsAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getInputSpatialDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + ::mlir::StringAttr getKernelInputFeatureDimensionAttrName() { + return getAttributeNameForIndex(5); + } + + static ::mlir::StringAttr getKernelInputFeatureDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 5); + } + + ::mlir::StringAttr getKernelOutputFeatureDimensionAttrName() { + return getAttributeNameForIndex(6); + } + + static ::mlir::StringAttr getKernelOutputFeatureDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 6); + } + + ::mlir::StringAttr getKernelSpatialDimensionsAttrName() { + return getAttributeNameForIndex(7); + } + + static ::mlir::StringAttr getKernelSpatialDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 7); + } + + ::mlir::StringAttr getLhsDilationAttrName() { + return getAttributeNameForIndex(8); + } + + static ::mlir::StringAttr getLhsDilationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 8); + } + + ::mlir::StringAttr getOutputBatchDimensionAttrName() { + return getAttributeNameForIndex(9); + } + + static ::mlir::StringAttr getOutputBatchDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 9); + } + + ::mlir::StringAttr getOutputFeatureDimensionAttrName() { + return getAttributeNameForIndex(10); + } + + static ::mlir::StringAttr getOutputFeatureDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 10); + } + + ::mlir::StringAttr getOutputSpatialDimensionsAttrName() { + return getAttributeNameForIndex(11); + } + + static ::mlir::StringAttr getOutputSpatialDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 11); + } + + ::mlir::StringAttr getPrecisionConfigAttrName() { + return getAttributeNameForIndex(12); + } + + static ::mlir::StringAttr getPrecisionConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 12); + } + + ::mlir::StringAttr getRhsDilationAttrName() { + return getAttributeNameForIndex(13); + } + + static ::mlir::StringAttr getRhsDilationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 13); + } + + ::mlir::StringAttr getWindowReversalAttrName() { + return getAttributeNameForIndex(14); + } + + static ::mlir::StringAttr getWindowReversalAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 14); + } + + ::mlir::StringAttr getWindowStridesAttrName() { + return getAttributeNameForIndex(15); + } + + static ::mlir::StringAttr getWindowStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 15); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.dynamic_conv_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getPadding() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getPaddingMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getWindowStridesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().window_strides); + } + + ::mlir::Attribute getWindowStrides(); + ::mlir::Attribute getLhsDilationAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().lhs_dilation); + } + + ::mlir::Attribute getLhsDilation(); + ::mlir::Attribute getRhsDilationAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().rhs_dilation); + } + + ::mlir::Attribute getRhsDilation(); + ::mlir::Attribute getWindowReversalAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().window_reversal); + } + + ::mlir::Attribute getWindowReversal(); + ::mlir::Attribute getInputBatchDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().input_batch_dimension); + } + + ::mlir::Attribute getInputBatchDimension(); + ::mlir::Attribute getInputFeatureDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().input_feature_dimension); + } + + ::mlir::Attribute getInputFeatureDimension(); + ::mlir::Attribute getInputSpatialDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().input_spatial_dimensions); + } + + ::mlir::Attribute getInputSpatialDimensions(); + ::mlir::Attribute getKernelInputFeatureDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().kernel_input_feature_dimension); + } + + ::mlir::Attribute getKernelInputFeatureDimension(); + ::mlir::Attribute getKernelOutputFeatureDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().kernel_output_feature_dimension); + } + + ::mlir::Attribute getKernelOutputFeatureDimension(); + ::mlir::Attribute getKernelSpatialDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().kernel_spatial_dimensions); + } + + ::mlir::Attribute getKernelSpatialDimensions(); + ::mlir::Attribute getOutputBatchDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().output_batch_dimension); + } + + ::mlir::Attribute getOutputBatchDimension(); + ::mlir::Attribute getOutputFeatureDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().output_feature_dimension); + } + + ::mlir::Attribute getOutputFeatureDimension(); + ::mlir::Attribute getOutputSpatialDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().output_spatial_dimensions); + } + + ::mlir::Attribute getOutputSpatialDimensions(); + ::mlir::Attribute getFeatureGroupCountAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().feature_group_count); + } + + ::mlir::Attribute getFeatureGroupCount(); + ::mlir::Attribute getBatchGroupCountAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().batch_group_count); + } + + ::mlir::Attribute getBatchGroupCount(); + ::mlir::Attribute getPrecisionConfigAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().precision_config); + } + + ::mlir::Attribute getPrecisionConfig(); + void setWindowStridesAttr(::mlir::Attribute attr) { + getProperties().window_strides = attr; + } + + void setLhsDilationAttr(::mlir::Attribute attr) { + getProperties().lhs_dilation = attr; + } + + void setRhsDilationAttr(::mlir::Attribute attr) { + getProperties().rhs_dilation = attr; + } + + void setWindowReversalAttr(::mlir::Attribute attr) { + getProperties().window_reversal = attr; + } + + void setInputBatchDimensionAttr(::mlir::Attribute attr) { + getProperties().input_batch_dimension = attr; + } + + void setInputFeatureDimensionAttr(::mlir::Attribute attr) { + getProperties().input_feature_dimension = attr; + } + + void setInputSpatialDimensionsAttr(::mlir::Attribute attr) { + getProperties().input_spatial_dimensions = attr; + } + + void setKernelInputFeatureDimensionAttr(::mlir::Attribute attr) { + getProperties().kernel_input_feature_dimension = attr; + } + + void setKernelOutputFeatureDimensionAttr(::mlir::Attribute attr) { + getProperties().kernel_output_feature_dimension = attr; + } + + void setKernelSpatialDimensionsAttr(::mlir::Attribute attr) { + getProperties().kernel_spatial_dimensions = attr; + } + + void setOutputBatchDimensionAttr(::mlir::Attribute attr) { + getProperties().output_batch_dimension = attr; + } + + void setOutputFeatureDimensionAttr(::mlir::Attribute attr) { + getProperties().output_feature_dimension = attr; + } + + void setOutputSpatialDimensionsAttr(::mlir::Attribute attr) { + getProperties().output_spatial_dimensions = attr; + } + + void setFeatureGroupCountAttr(::mlir::Attribute attr) { + getProperties().feature_group_count = attr; + } + + void setBatchGroupCountAttr(::mlir::Attribute attr) { + getProperties().batch_group_count = attr; + } + + void setPrecisionConfigAttr(::mlir::Attribute attr) { + getProperties().precision_config = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value padding, ::mlir::Attribute window_strides, ::mlir::Attribute lhs_dilation, ::mlir::Attribute rhs_dilation, ::mlir::Attribute window_reversal, ::mlir::Attribute input_batch_dimension, ::mlir::Attribute input_feature_dimension, ::mlir::Attribute input_spatial_dimensions, ::mlir::Attribute kernel_input_feature_dimension, ::mlir::Attribute kernel_output_feature_dimension, ::mlir::Attribute kernel_spatial_dimensions, ::mlir::Attribute output_batch_dimension, ::mlir::Attribute output_feature_dimension, ::mlir::Attribute output_spatial_dimensions, ::mlir::Attribute feature_group_count, ::mlir::Attribute batch_group_count, ::mlir::Attribute precision_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value padding, ::mlir::Attribute window_strides, ::mlir::Attribute lhs_dilation, ::mlir::Attribute rhs_dilation, ::mlir::Attribute window_reversal, ::mlir::Attribute input_batch_dimension, ::mlir::Attribute input_feature_dimension, ::mlir::Attribute input_spatial_dimensions, ::mlir::Attribute kernel_input_feature_dimension, ::mlir::Attribute kernel_output_feature_dimension, ::mlir::Attribute kernel_spatial_dimensions, ::mlir::Attribute output_batch_dimension, ::mlir::Attribute output_feature_dimension, ::mlir::Attribute output_spatial_dimensions, ::mlir::Attribute feature_group_count, ::mlir::Attribute batch_group_count, ::mlir::Attribute precision_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 16 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicConvOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicGatherOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicGatherOpV1GenericAdaptorBase { +public: + struct Properties { + using collapsed_slice_dimsTy = ::mlir::Attribute; + collapsed_slice_dimsTy collapsed_slice_dims; + + auto getCollapsedSliceDims() const { + auto &propStorage = this->collapsed_slice_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setCollapsedSliceDims(const ::mlir::Attribute &propValue) { + this->collapsed_slice_dims = propValue; + } + using index_vector_dimTy = ::mlir::Attribute; + index_vector_dimTy index_vector_dim; + + auto getIndexVectorDim() const { + auto &propStorage = this->index_vector_dim; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIndexVectorDim(const ::mlir::Attribute &propValue) { + this->index_vector_dim = propValue; + } + using indices_are_sortedTy = ::mlir::Attribute; + indices_are_sortedTy indices_are_sorted; + + auto getIndicesAreSorted() const { + auto &propStorage = this->indices_are_sorted; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIndicesAreSorted(const ::mlir::Attribute &propValue) { + this->indices_are_sorted = propValue; + } + using offset_dimsTy = ::mlir::Attribute; + offset_dimsTy offset_dims; + + auto getOffsetDims() const { + auto &propStorage = this->offset_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOffsetDims(const ::mlir::Attribute &propValue) { + this->offset_dims = propValue; + } + using start_index_mapTy = ::mlir::Attribute; + start_index_mapTy start_index_map; + + auto getStartIndexMap() const { + auto &propStorage = this->start_index_map; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setStartIndexMap(const ::mlir::Attribute &propValue) { + this->start_index_map = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.collapsed_slice_dims == this->collapsed_slice_dims && + rhs.index_vector_dim == this->index_vector_dim && + rhs.indices_are_sorted == this->indices_are_sorted && + rhs.offset_dims == this->offset_dims && + rhs.start_index_map == this->start_index_map && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicGatherOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.dynamic_gather_v1", odsAttrs.getContext()); + } + + DynamicGatherOpV1GenericAdaptorBase(DynamicGatherOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getOffsetDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().offset_dims); + return attr; + } + + ::mlir::Attribute getOffsetDims(); + ::mlir::Attribute getCollapsedSliceDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().collapsed_slice_dims); + return attr; + } + + ::mlir::Attribute getCollapsedSliceDims(); + ::mlir::Attribute getStartIndexMapAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().start_index_map); + return attr; + } + + ::mlir::Attribute getStartIndexMap(); + ::mlir::Attribute getIndexVectorDimAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().index_vector_dim); + return attr; + } + + ::mlir::Attribute getIndexVectorDim(); + ::mlir::Attribute getIndicesAreSortedAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().indices_are_sorted); + return attr; + } + + ::mlir::Attribute getIndicesAreSorted(); +}; +} // namespace detail +template +class DynamicGatherOpV1GenericAdaptor : public detail::DynamicGatherOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicGatherOpV1GenericAdaptorBase; +public: + DynamicGatherOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicGatherOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicGatherOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicGatherOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicGatherOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicGatherOpV1GenericAdaptor(RangeT values, const DynamicGatherOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicGatherOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getStartIndices() { + return (*getODSOperands(1).begin()); + } + + ValueT getSliceSizes() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicGatherOpV1Adaptor : public DynamicGatherOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using DynamicGatherOpV1GenericAdaptor::DynamicGatherOpV1GenericAdaptor; + DynamicGatherOpV1Adaptor(DynamicGatherOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicGatherOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicGatherOpV1Adaptor; + template + using GenericAdaptor = DynamicGatherOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("collapsed_slice_dims"), ::llvm::StringRef("index_vector_dim"), ::llvm::StringRef("indices_are_sorted"), ::llvm::StringRef("offset_dims"), ::llvm::StringRef("start_index_map")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getCollapsedSliceDimsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getCollapsedSliceDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIndexVectorDimAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIndexVectorDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getIndicesAreSortedAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getIndicesAreSortedAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getOffsetDimsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getOffsetDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getStartIndexMapAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getStartIndexMapAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.dynamic_gather_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getStartIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getSliceSizes() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getStartIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getSliceSizesMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getOffsetDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().offset_dims); + } + + ::mlir::Attribute getOffsetDims(); + ::mlir::Attribute getCollapsedSliceDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().collapsed_slice_dims); + } + + ::mlir::Attribute getCollapsedSliceDims(); + ::mlir::Attribute getStartIndexMapAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().start_index_map); + } + + ::mlir::Attribute getStartIndexMap(); + ::mlir::Attribute getIndexVectorDimAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().index_vector_dim); + } + + ::mlir::Attribute getIndexVectorDim(); + ::mlir::Attribute getIndicesAreSortedAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().indices_are_sorted); + } + + ::mlir::Attribute getIndicesAreSorted(); + void setOffsetDimsAttr(::mlir::Attribute attr) { + getProperties().offset_dims = attr; + } + + void setCollapsedSliceDimsAttr(::mlir::Attribute attr) { + getProperties().collapsed_slice_dims = attr; + } + + void setStartIndexMapAttr(::mlir::Attribute attr) { + getProperties().start_index_map = attr; + } + + void setIndexVectorDimAttr(::mlir::Attribute attr) { + getProperties().index_vector_dim = attr; + } + + void setIndicesAreSortedAttr(::mlir::Attribute attr) { + getProperties().indices_are_sorted = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute indices_are_sorted); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute indices_are_sorted); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 5 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicGatherOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicGatherOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicGatherOpV2GenericAdaptorBase { +public: + struct Properties { + using collapsed_slice_dimsTy = ::mlir::Attribute; + collapsed_slice_dimsTy collapsed_slice_dims; + + auto getCollapsedSliceDims() const { + auto &propStorage = this->collapsed_slice_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setCollapsedSliceDims(const ::mlir::Attribute &propValue) { + this->collapsed_slice_dims = propValue; + } + using index_vector_dimTy = ::mlir::Attribute; + index_vector_dimTy index_vector_dim; + + auto getIndexVectorDim() const { + auto &propStorage = this->index_vector_dim; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIndexVectorDim(const ::mlir::Attribute &propValue) { + this->index_vector_dim = propValue; + } + using indices_are_sortedTy = ::mlir::Attribute; + indices_are_sortedTy indices_are_sorted; + + auto getIndicesAreSorted() const { + auto &propStorage = this->indices_are_sorted; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIndicesAreSorted(const ::mlir::Attribute &propValue) { + this->indices_are_sorted = propValue; + } + using offset_dimsTy = ::mlir::Attribute; + offset_dimsTy offset_dims; + + auto getOffsetDims() const { + auto &propStorage = this->offset_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOffsetDims(const ::mlir::Attribute &propValue) { + this->offset_dims = propValue; + } + using operand_batching_dimsTy = ::mlir::Attribute; + operand_batching_dimsTy operand_batching_dims; + + auto getOperandBatchingDims() const { + auto &propStorage = this->operand_batching_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOperandBatchingDims(const ::mlir::Attribute &propValue) { + this->operand_batching_dims = propValue; + } + using start_index_mapTy = ::mlir::Attribute; + start_index_mapTy start_index_map; + + auto getStartIndexMap() const { + auto &propStorage = this->start_index_map; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setStartIndexMap(const ::mlir::Attribute &propValue) { + this->start_index_map = propValue; + } + using start_indices_batching_dimsTy = ::mlir::Attribute; + start_indices_batching_dimsTy start_indices_batching_dims; + + auto getStartIndicesBatchingDims() const { + auto &propStorage = this->start_indices_batching_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setStartIndicesBatchingDims(const ::mlir::Attribute &propValue) { + this->start_indices_batching_dims = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.collapsed_slice_dims == this->collapsed_slice_dims && + rhs.index_vector_dim == this->index_vector_dim && + rhs.indices_are_sorted == this->indices_are_sorted && + rhs.offset_dims == this->offset_dims && + rhs.operand_batching_dims == this->operand_batching_dims && + rhs.start_index_map == this->start_index_map && + rhs.start_indices_batching_dims == this->start_indices_batching_dims && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicGatherOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.dynamic_gather_v2", odsAttrs.getContext()); + } + + DynamicGatherOpV2GenericAdaptorBase(DynamicGatherOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getOffsetDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().offset_dims); + return attr; + } + + ::mlir::Attribute getOffsetDims(); + ::mlir::Attribute getCollapsedSliceDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().collapsed_slice_dims); + return attr; + } + + ::mlir::Attribute getCollapsedSliceDims(); + ::mlir::Attribute getOperandBatchingDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().operand_batching_dims); + return attr; + } + + ::mlir::Attribute getOperandBatchingDims(); + ::mlir::Attribute getStartIndicesBatchingDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().start_indices_batching_dims); + return attr; + } + + ::mlir::Attribute getStartIndicesBatchingDims(); + ::mlir::Attribute getStartIndexMapAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().start_index_map); + return attr; + } + + ::mlir::Attribute getStartIndexMap(); + ::mlir::Attribute getIndexVectorDimAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().index_vector_dim); + return attr; + } + + ::mlir::Attribute getIndexVectorDim(); + ::mlir::Attribute getIndicesAreSortedAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().indices_are_sorted); + return attr; + } + + ::mlir::Attribute getIndicesAreSorted(); +}; +} // namespace detail +template +class DynamicGatherOpV2GenericAdaptor : public detail::DynamicGatherOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicGatherOpV2GenericAdaptorBase; +public: + DynamicGatherOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicGatherOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicGatherOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicGatherOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicGatherOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicGatherOpV2GenericAdaptor(RangeT values, const DynamicGatherOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicGatherOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getStartIndices() { + return (*getODSOperands(1).begin()); + } + + ValueT getSliceSizes() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicGatherOpV2Adaptor : public DynamicGatherOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using DynamicGatherOpV2GenericAdaptor::DynamicGatherOpV2GenericAdaptor; + DynamicGatherOpV2Adaptor(DynamicGatherOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicGatherOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicGatherOpV2Adaptor; + template + using GenericAdaptor = DynamicGatherOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("collapsed_slice_dims"), ::llvm::StringRef("index_vector_dim"), ::llvm::StringRef("indices_are_sorted"), ::llvm::StringRef("offset_dims"), ::llvm::StringRef("operand_batching_dims"), ::llvm::StringRef("start_index_map"), ::llvm::StringRef("start_indices_batching_dims")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getCollapsedSliceDimsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getCollapsedSliceDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIndexVectorDimAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIndexVectorDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getIndicesAreSortedAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getIndicesAreSortedAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getOffsetDimsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getOffsetDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getOperandBatchingDimsAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getOperandBatchingDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + ::mlir::StringAttr getStartIndexMapAttrName() { + return getAttributeNameForIndex(5); + } + + static ::mlir::StringAttr getStartIndexMapAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 5); + } + + ::mlir::StringAttr getStartIndicesBatchingDimsAttrName() { + return getAttributeNameForIndex(6); + } + + static ::mlir::StringAttr getStartIndicesBatchingDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 6); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.dynamic_gather_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getStartIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getSliceSizes() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getStartIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getSliceSizesMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getOffsetDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().offset_dims); + } + + ::mlir::Attribute getOffsetDims(); + ::mlir::Attribute getCollapsedSliceDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().collapsed_slice_dims); + } + + ::mlir::Attribute getCollapsedSliceDims(); + ::mlir::Attribute getOperandBatchingDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().operand_batching_dims); + } + + ::mlir::Attribute getOperandBatchingDims(); + ::mlir::Attribute getStartIndicesBatchingDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().start_indices_batching_dims); + } + + ::mlir::Attribute getStartIndicesBatchingDims(); + ::mlir::Attribute getStartIndexMapAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().start_index_map); + } + + ::mlir::Attribute getStartIndexMap(); + ::mlir::Attribute getIndexVectorDimAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().index_vector_dim); + } + + ::mlir::Attribute getIndexVectorDim(); + ::mlir::Attribute getIndicesAreSortedAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().indices_are_sorted); + } + + ::mlir::Attribute getIndicesAreSorted(); + void setOffsetDimsAttr(::mlir::Attribute attr) { + getProperties().offset_dims = attr; + } + + void setCollapsedSliceDimsAttr(::mlir::Attribute attr) { + getProperties().collapsed_slice_dims = attr; + } + + void setOperandBatchingDimsAttr(::mlir::Attribute attr) { + getProperties().operand_batching_dims = attr; + } + + void setStartIndicesBatchingDimsAttr(::mlir::Attribute attr) { + getProperties().start_indices_batching_dims = attr; + } + + void setStartIndexMapAttr(::mlir::Attribute attr) { + getProperties().start_index_map = attr; + } + + void setIndexVectorDimAttr(::mlir::Attribute attr) { + getProperties().index_vector_dim = attr; + } + + void setIndicesAreSortedAttr(::mlir::Attribute attr) { + getProperties().indices_are_sorted = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute operand_batching_dims, ::mlir::Attribute start_indices_batching_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute indices_are_sorted); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value slice_sizes, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute operand_batching_dims, ::mlir::Attribute start_indices_batching_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute indices_are_sorted); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 7 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicGatherOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicIotaOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicIotaOpV1GenericAdaptorBase { +public: + struct Properties { + using iota_dimensionTy = ::mlir::Attribute; + iota_dimensionTy iota_dimension; + + auto getIotaDimension() const { + auto &propStorage = this->iota_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIotaDimension(const ::mlir::Attribute &propValue) { + this->iota_dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.iota_dimension == this->iota_dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicIotaOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.dynamic_iota_v1", odsAttrs.getContext()); + } + + DynamicIotaOpV1GenericAdaptorBase(DynamicIotaOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getIotaDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().iota_dimension); + return attr; + } + + ::mlir::Attribute getIotaDimension(); +}; +} // namespace detail +template +class DynamicIotaOpV1GenericAdaptor : public detail::DynamicIotaOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicIotaOpV1GenericAdaptorBase; +public: + DynamicIotaOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicIotaOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicIotaOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicIotaOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicIotaOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicIotaOpV1GenericAdaptor(RangeT values, const DynamicIotaOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicIotaOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOutputShape() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicIotaOpV1Adaptor : public DynamicIotaOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using DynamicIotaOpV1GenericAdaptor::DynamicIotaOpV1GenericAdaptor; + DynamicIotaOpV1Adaptor(DynamicIotaOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicIotaOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicIotaOpV1Adaptor; + template + using GenericAdaptor = DynamicIotaOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("iota_dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getIotaDimensionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getIotaDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.dynamic_iota_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOutputShape() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOutputShapeMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getIotaDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().iota_dimension); + } + + ::mlir::Attribute getIotaDimension(); + void setIotaDimensionAttr(::mlir::Attribute attr) { + getProperties().iota_dimension = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value output_shape, ::mlir::Attribute iota_dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value output_shape, ::mlir::Attribute iota_dimension); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicIotaOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicPadOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicPadOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicPadOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.dynamic_pad_v1", odsAttrs.getContext()); + } + + DynamicPadOpV1GenericAdaptorBase(DynamicPadOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class DynamicPadOpV1GenericAdaptor : public detail::DynamicPadOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicPadOpV1GenericAdaptorBase; +public: + DynamicPadOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicPadOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicPadOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicPadOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicPadOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicPadOpV1GenericAdaptor(RangeT values, const DynamicPadOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicPadOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getPaddingValue() { + return (*getODSOperands(1).begin()); + } + + ValueT getEdgePaddingLow() { + return (*getODSOperands(2).begin()); + } + + ValueT getEdgePaddingHigh() { + return (*getODSOperands(3).begin()); + } + + ValueT getInteriorPadding() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicPadOpV1Adaptor : public DynamicPadOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using DynamicPadOpV1GenericAdaptor::DynamicPadOpV1GenericAdaptor; + DynamicPadOpV1Adaptor(DynamicPadOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicPadOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<5>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicPadOpV1Adaptor; + template + using GenericAdaptor = DynamicPadOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.dynamic_pad_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getPaddingValue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getEdgePaddingLow() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(2).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getEdgePaddingHigh() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(3).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getInteriorPadding() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(4).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getPaddingValueMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getEdgePaddingLowMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getEdgePaddingHighMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getInteriorPaddingMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::Value edge_padding_low, ::mlir::Value edge_padding_high, ::mlir::Value interior_padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::Value edge_padding_low, ::mlir::Value edge_padding_high, ::mlir::Value interior_padding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicPadOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicReshapeOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicReshapeOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicReshapeOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.dynamic_reshape_v1", odsAttrs.getContext()); + } + + DynamicReshapeOpV1GenericAdaptorBase(DynamicReshapeOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class DynamicReshapeOpV1GenericAdaptor : public detail::DynamicReshapeOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicReshapeOpV1GenericAdaptorBase; +public: + DynamicReshapeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicReshapeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicReshapeOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicReshapeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicReshapeOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicReshapeOpV1GenericAdaptor(RangeT values, const DynamicReshapeOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicReshapeOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getOutputShape() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicReshapeOpV1Adaptor : public DynamicReshapeOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using DynamicReshapeOpV1GenericAdaptor::DynamicReshapeOpV1GenericAdaptor; + DynamicReshapeOpV1Adaptor(DynamicReshapeOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicReshapeOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicReshapeOpV1Adaptor; + template + using GenericAdaptor = DynamicReshapeOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.dynamic_reshape_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getOutputShape() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOutputShapeMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value output_shape); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value output_shape); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicReshapeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicSliceOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicSliceOpV1GenericAdaptorBase { +public: + struct Properties { + using slice_sizesTy = ::mlir::Attribute; + slice_sizesTy slice_sizes; + + auto getSliceSizes() const { + auto &propStorage = this->slice_sizes; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setSliceSizes(const ::mlir::Attribute &propValue) { + this->slice_sizes = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.slice_sizes == this->slice_sizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicSliceOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.dynamic_slice_v1", odsAttrs.getContext()); + } + + DynamicSliceOpV1GenericAdaptorBase(DynamicSliceOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getSliceSizesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().slice_sizes); + return attr; + } + + ::mlir::Attribute getSliceSizes(); +}; +} // namespace detail +template +class DynamicSliceOpV1GenericAdaptor : public detail::DynamicSliceOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicSliceOpV1GenericAdaptorBase; +public: + DynamicSliceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicSliceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicSliceOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicSliceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicSliceOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicSliceOpV1GenericAdaptor(RangeT values, const DynamicSliceOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicSliceOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getStartIndices() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicSliceOpV1Adaptor : public DynamicSliceOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using DynamicSliceOpV1GenericAdaptor::DynamicSliceOpV1GenericAdaptor; + DynamicSliceOpV1Adaptor(DynamicSliceOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicSliceOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicSliceOpV1Adaptor; + template + using GenericAdaptor = DynamicSliceOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("slice_sizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getSliceSizesAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getSliceSizesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.dynamic_slice_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::Operation::operand_range getStartIndices() { + return getODSOperands(1); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::MutableOperandRange getStartIndicesMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getSliceSizesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().slice_sizes); + } + + ::mlir::Attribute getSliceSizes(); + void setSliceSizesAttr(::mlir::Attribute attr) { + getProperties().slice_sizes = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::mlir::Attribute slice_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::ValueRange start_indices, ::mlir::Attribute slice_sizes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicSliceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::DynamicUpdateSliceOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DynamicUpdateSliceOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + DynamicUpdateSliceOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.dynamic_update_slice_v1", odsAttrs.getContext()); + } + + DynamicUpdateSliceOpV1GenericAdaptorBase(DynamicUpdateSliceOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class DynamicUpdateSliceOpV1GenericAdaptor : public detail::DynamicUpdateSliceOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DynamicUpdateSliceOpV1GenericAdaptorBase; +public: + DynamicUpdateSliceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DynamicUpdateSliceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DynamicUpdateSliceOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + DynamicUpdateSliceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : DynamicUpdateSliceOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + DynamicUpdateSliceOpV1GenericAdaptor(RangeT values, const DynamicUpdateSliceOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + DynamicUpdateSliceOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getUpdate() { + return (*getODSOperands(1).begin()); + } + + RangeT getStartIndices() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DynamicUpdateSliceOpV1Adaptor : public DynamicUpdateSliceOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using DynamicUpdateSliceOpV1GenericAdaptor::DynamicUpdateSliceOpV1GenericAdaptor; + DynamicUpdateSliceOpV1Adaptor(DynamicUpdateSliceOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class DynamicUpdateSliceOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DynamicUpdateSliceOpV1Adaptor; + template + using GenericAdaptor = DynamicUpdateSliceOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.dynamic_update_slice_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getUpdate() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::Operation::operand_range getStartIndices() { + return getODSOperands(2); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getUpdateMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::MutableOperandRange getStartIndicesMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value update, ::mlir::ValueRange start_indices); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value update, ::mlir::ValueRange start_indices); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::DynamicUpdateSliceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::EinsumOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class EinsumOpV1GenericAdaptorBase { +public: + struct Properties { + using einsum_configTy = ::mlir::Attribute; + einsum_configTy einsum_config; + + auto getEinsumConfig() const { + auto &propStorage = this->einsum_config; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setEinsumConfig(const ::mlir::Attribute &propValue) { + this->einsum_config = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.einsum_config == this->einsum_config && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + EinsumOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.einsum_v1", odsAttrs.getContext()); + } + + EinsumOpV1GenericAdaptorBase(EinsumOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getEinsumConfigAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().einsum_config); + return attr; + } + + ::mlir::Attribute getEinsumConfig(); +}; +} // namespace detail +template +class EinsumOpV1GenericAdaptor : public detail::EinsumOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::EinsumOpV1GenericAdaptorBase; +public: + EinsumOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + EinsumOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : EinsumOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + EinsumOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : EinsumOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + EinsumOpV1GenericAdaptor(RangeT values, const EinsumOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + EinsumOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class EinsumOpV1Adaptor : public EinsumOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using EinsumOpV1GenericAdaptor::EinsumOpV1GenericAdaptor; + EinsumOpV1Adaptor(EinsumOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class EinsumOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = EinsumOpV1Adaptor; + template + using GenericAdaptor = EinsumOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("einsum_config")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getEinsumConfigAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getEinsumConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.einsum_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getEinsumConfigAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().einsum_config); + } + + ::mlir::Attribute getEinsumConfig(); + void setEinsumConfigAttr(::mlir::Attribute attr) { + getProperties().einsum_config = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute einsum_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Attribute einsum_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::EinsumOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ExpOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ExpOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ExpOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.exponential_v1", odsAttrs.getContext()); + } + + ExpOpV1GenericAdaptorBase(ExpOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ExpOpV1GenericAdaptor : public detail::ExpOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ExpOpV1GenericAdaptorBase; +public: + ExpOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ExpOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ExpOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ExpOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ExpOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ExpOpV1GenericAdaptor(RangeT values, const ExpOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ExpOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ExpOpV1Adaptor : public ExpOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ExpOpV1GenericAdaptor::ExpOpV1GenericAdaptor; + ExpOpV1Adaptor(ExpOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ExpOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ExpOpV1Adaptor; + template + using GenericAdaptor = ExpOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.exponential_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ExpOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ExpOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ExpOpV2GenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::Attribute; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResultAccuracy(const ::mlir::Attribute &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ExpOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.exponential_v2", odsAttrs.getContext()); + } + + ExpOpV2GenericAdaptorBase(ExpOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getResultAccuracyAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + return attr; + } + + ::mlir::Attribute getResultAccuracy(); +}; +} // namespace detail +template +class ExpOpV2GenericAdaptor : public detail::ExpOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ExpOpV2GenericAdaptorBase; +public: + ExpOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ExpOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ExpOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ExpOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ExpOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + ExpOpV2GenericAdaptor(RangeT values, const ExpOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ExpOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ExpOpV2Adaptor : public ExpOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using ExpOpV2GenericAdaptor::ExpOpV2GenericAdaptor; + ExpOpV2Adaptor(ExpOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ExpOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ExpOpV2Adaptor; + template + using GenericAdaptor = ExpOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.exponential_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getResultAccuracyAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + } + + ::mlir::Attribute getResultAccuracy(); + void setResultAccuracyAttr(::mlir::Attribute attr) { + getProperties().result_accuracy = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ExpOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::Expm1OpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class Expm1OpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + Expm1OpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.exponential_minus_one_v1", odsAttrs.getContext()); + } + + Expm1OpV1GenericAdaptorBase(Expm1OpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class Expm1OpV1GenericAdaptor : public detail::Expm1OpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::Expm1OpV1GenericAdaptorBase; +public: + Expm1OpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + Expm1OpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : Expm1OpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + Expm1OpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : Expm1OpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + Expm1OpV1GenericAdaptor(RangeT values, const Expm1OpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + Expm1OpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class Expm1OpV1Adaptor : public Expm1OpV1GenericAdaptor<::mlir::ValueRange> { +public: + using Expm1OpV1GenericAdaptor::Expm1OpV1GenericAdaptor; + Expm1OpV1Adaptor(Expm1OpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class Expm1OpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = Expm1OpV1Adaptor; + template + using GenericAdaptor = Expm1OpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.exponential_minus_one_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::Expm1OpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::Expm1OpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class Expm1OpV2GenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::Attribute; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResultAccuracy(const ::mlir::Attribute &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + Expm1OpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.exponential_minus_one_v2", odsAttrs.getContext()); + } + + Expm1OpV2GenericAdaptorBase(Expm1OpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getResultAccuracyAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + return attr; + } + + ::mlir::Attribute getResultAccuracy(); +}; +} // namespace detail +template +class Expm1OpV2GenericAdaptor : public detail::Expm1OpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::Expm1OpV2GenericAdaptorBase; +public: + Expm1OpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + Expm1OpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : Expm1OpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + Expm1OpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : Expm1OpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + Expm1OpV2GenericAdaptor(RangeT values, const Expm1OpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + Expm1OpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class Expm1OpV2Adaptor : public Expm1OpV2GenericAdaptor<::mlir::ValueRange> { +public: + using Expm1OpV2GenericAdaptor::Expm1OpV2GenericAdaptor; + Expm1OpV2Adaptor(Expm1OpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class Expm1OpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = Expm1OpV2Adaptor; + template + using GenericAdaptor = Expm1OpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.exponential_minus_one_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getResultAccuracyAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + } + + ::mlir::Attribute getResultAccuracy(); + void setResultAccuracyAttr(::mlir::Attribute attr) { + getProperties().result_accuracy = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::Expm1OpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::FftOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class FftOpV1GenericAdaptorBase { +public: + struct Properties { + using fft_lengthTy = ::mlir::Attribute; + fft_lengthTy fft_length; + + auto getFftLength() const { + auto &propStorage = this->fft_length; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setFftLength(const ::mlir::Attribute &propValue) { + this->fft_length = propValue; + } + using fft_typeTy = ::mlir::Attribute; + fft_typeTy fft_type; + + auto getFftType() const { + auto &propStorage = this->fft_type; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setFftType(const ::mlir::Attribute &propValue) { + this->fft_type = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.fft_length == this->fft_length && + rhs.fft_type == this->fft_type && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + FftOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.fft_v1", odsAttrs.getContext()); + } + + FftOpV1GenericAdaptorBase(FftOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getFftTypeAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().fft_type); + return attr; + } + + ::mlir::Attribute getFftType(); + ::mlir::Attribute getFftLengthAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().fft_length); + return attr; + } + + ::mlir::Attribute getFftLength(); +}; +} // namespace detail +template +class FftOpV1GenericAdaptor : public detail::FftOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::FftOpV1GenericAdaptorBase; +public: + FftOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + FftOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : FftOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + FftOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : FftOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + FftOpV1GenericAdaptor(RangeT values, const FftOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + FftOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class FftOpV1Adaptor : public FftOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using FftOpV1GenericAdaptor::FftOpV1GenericAdaptor; + FftOpV1Adaptor(FftOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class FftOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = FftOpV1Adaptor; + template + using GenericAdaptor = FftOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("fft_length"), ::llvm::StringRef("fft_type")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getFftLengthAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getFftLengthAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFftTypeAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFftTypeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.fft_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getFftTypeAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().fft_type); + } + + ::mlir::Attribute getFftType(); + ::mlir::Attribute getFftLengthAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().fft_length); + } + + ::mlir::Attribute getFftLength(); + void setFftTypeAttr(::mlir::Attribute attr) { + getProperties().fft_type = attr; + } + + void setFftLengthAttr(::mlir::Attribute attr) { + getProperties().fft_length = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute fft_type, ::mlir::Attribute fft_length); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute fft_type, ::mlir::Attribute fft_length); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FftOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::FloorOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class FloorOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + FloorOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.floor_v1", odsAttrs.getContext()); + } + + FloorOpV1GenericAdaptorBase(FloorOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class FloorOpV1GenericAdaptor : public detail::FloorOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::FloorOpV1GenericAdaptorBase; +public: + FloorOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + FloorOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : FloorOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + FloorOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : FloorOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + FloorOpV1GenericAdaptor(RangeT values, const FloorOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + FloorOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class FloorOpV1Adaptor : public FloorOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using FloorOpV1GenericAdaptor::FloorOpV1GenericAdaptor; + FloorOpV1Adaptor(FloorOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class FloorOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = FloorOpV1Adaptor; + template + using GenericAdaptor = FloorOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.floor_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloorOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::FuncOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class FuncOpV1GenericAdaptorBase { +public: + struct Properties { + using arg_attrsTy = ::mlir::Attribute; + arg_attrsTy arg_attrs; + + auto getArgAttrs() const { + auto &propStorage = this->arg_attrs; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setArgAttrs(const ::mlir::Attribute &propValue) { + this->arg_attrs = propValue; + } + using function_typeTy = ::mlir::Attribute; + function_typeTy function_type; + + auto getFunctionType() const { + auto &propStorage = this->function_type; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setFunctionType(const ::mlir::Attribute &propValue) { + this->function_type = propValue; + } + using res_attrsTy = ::mlir::Attribute; + res_attrsTy res_attrs; + + auto getResAttrs() const { + auto &propStorage = this->res_attrs; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResAttrs(const ::mlir::Attribute &propValue) { + this->res_attrs = propValue; + } + using sym_nameTy = ::mlir::Attribute; + sym_nameTy sym_name; + + auto getSymName() const { + auto &propStorage = this->sym_name; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setSymName(const ::mlir::Attribute &propValue) { + this->sym_name = propValue; + } + using sym_visibilityTy = ::mlir::Attribute; + sym_visibilityTy sym_visibility; + + auto getSymVisibility() const { + auto &propStorage = this->sym_visibility; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setSymVisibility(const ::mlir::Attribute &propValue) { + this->sym_visibility = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.arg_attrs == this->arg_attrs && + rhs.function_type == this->function_type && + rhs.res_attrs == this->res_attrs && + rhs.sym_name == this->sym_name && + rhs.sym_visibility == this->sym_visibility && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + FuncOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.func_v1", odsAttrs.getContext()); + } + + FuncOpV1GenericAdaptorBase(FuncOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getSymNameAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().sym_name); + return attr; + } + + ::mlir::Attribute getSymName(); + ::mlir::Attribute getFunctionTypeAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().function_type); + return attr; + } + + ::mlir::Attribute getFunctionType(); + ::mlir::Attribute getSymVisibilityAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().sym_visibility); + return attr; + } + + ::mlir::Attribute getSymVisibility(); + ::mlir::Attribute getArgAttrsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().arg_attrs); + return attr; + } + + ::mlir::Attribute getArgAttrs(); + ::mlir::Attribute getResAttrsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().res_attrs); + return attr; + } + + ::mlir::Attribute getResAttrs(); + ::mlir::Region &getBody() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class FuncOpV1GenericAdaptor : public detail::FuncOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::FuncOpV1GenericAdaptorBase; +public: + FuncOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + FuncOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : FuncOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + FuncOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : FuncOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + FuncOpV1GenericAdaptor(RangeT values, const FuncOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + FuncOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class FuncOpV1Adaptor : public FuncOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using FuncOpV1GenericAdaptor::FuncOpV1GenericAdaptor; + FuncOpV1Adaptor(FuncOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class FuncOpV1 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = FuncOpV1Adaptor; + template + using GenericAdaptor = FuncOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("arg_attrs"), ::llvm::StringRef("function_type"), ::llvm::StringRef("res_attrs"), ::llvm::StringRef("sym_name"), ::llvm::StringRef("sym_visibility")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getArgAttrsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getArgAttrsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFunctionTypeAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFunctionTypeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getResAttrsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getResAttrsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getSymNameAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getSymNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getSymVisibilityAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getSymVisibilityAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.func_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Region &getBody() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getSymNameAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().sym_name); + } + + ::mlir::Attribute getSymName(); + ::mlir::Attribute getFunctionTypeAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().function_type); + } + + ::mlir::Attribute getFunctionType(); + ::mlir::Attribute getSymVisibilityAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().sym_visibility); + } + + ::mlir::Attribute getSymVisibility(); + ::mlir::Attribute getArgAttrsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().arg_attrs); + } + + ::mlir::Attribute getArgAttrs(); + ::mlir::Attribute getResAttrsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().res_attrs); + } + + ::mlir::Attribute getResAttrs(); + void setSymNameAttr(::mlir::Attribute attr) { + getProperties().sym_name = attr; + } + + void setFunctionTypeAttr(::mlir::Attribute attr) { + getProperties().function_type = attr; + } + + void setSymVisibilityAttr(::mlir::Attribute attr) { + getProperties().sym_visibility = attr; + } + + void setArgAttrsAttr(::mlir::Attribute attr) { + getProperties().arg_attrs = attr; + } + + void setResAttrsAttr(::mlir::Attribute attr) { + getProperties().res_attrs = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Attribute sym_name, ::mlir::Attribute function_type, ::mlir::Attribute sym_visibility, ::mlir::Attribute arg_attrs, ::mlir::Attribute res_attrs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Attribute sym_name, ::mlir::Attribute function_type, ::mlir::Attribute sym_visibility, ::mlir::Attribute arg_attrs, ::mlir::Attribute res_attrs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 5 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FuncOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::GatherOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GatherOpV1GenericAdaptorBase { +public: + struct Properties { + using collapsed_slice_dimsTy = ::mlir::Attribute; + collapsed_slice_dimsTy collapsed_slice_dims; + + auto getCollapsedSliceDims() const { + auto &propStorage = this->collapsed_slice_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setCollapsedSliceDims(const ::mlir::Attribute &propValue) { + this->collapsed_slice_dims = propValue; + } + using index_vector_dimTy = ::mlir::Attribute; + index_vector_dimTy index_vector_dim; + + auto getIndexVectorDim() const { + auto &propStorage = this->index_vector_dim; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIndexVectorDim(const ::mlir::Attribute &propValue) { + this->index_vector_dim = propValue; + } + using indices_are_sortedTy = ::mlir::Attribute; + indices_are_sortedTy indices_are_sorted; + + auto getIndicesAreSorted() const { + auto &propStorage = this->indices_are_sorted; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIndicesAreSorted(const ::mlir::Attribute &propValue) { + this->indices_are_sorted = propValue; + } + using offset_dimsTy = ::mlir::Attribute; + offset_dimsTy offset_dims; + + auto getOffsetDims() const { + auto &propStorage = this->offset_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOffsetDims(const ::mlir::Attribute &propValue) { + this->offset_dims = propValue; + } + using slice_sizesTy = ::mlir::Attribute; + slice_sizesTy slice_sizes; + + auto getSliceSizes() const { + auto &propStorage = this->slice_sizes; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setSliceSizes(const ::mlir::Attribute &propValue) { + this->slice_sizes = propValue; + } + using start_index_mapTy = ::mlir::Attribute; + start_index_mapTy start_index_map; + + auto getStartIndexMap() const { + auto &propStorage = this->start_index_map; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setStartIndexMap(const ::mlir::Attribute &propValue) { + this->start_index_map = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.collapsed_slice_dims == this->collapsed_slice_dims && + rhs.index_vector_dim == this->index_vector_dim && + rhs.indices_are_sorted == this->indices_are_sorted && + rhs.offset_dims == this->offset_dims && + rhs.slice_sizes == this->slice_sizes && + rhs.start_index_map == this->start_index_map && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GatherOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.gather_v1", odsAttrs.getContext()); + } + + GatherOpV1GenericAdaptorBase(GatherOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getOffsetDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().offset_dims); + return attr; + } + + ::mlir::Attribute getOffsetDims(); + ::mlir::Attribute getCollapsedSliceDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().collapsed_slice_dims); + return attr; + } + + ::mlir::Attribute getCollapsedSliceDims(); + ::mlir::Attribute getStartIndexMapAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().start_index_map); + return attr; + } + + ::mlir::Attribute getStartIndexMap(); + ::mlir::Attribute getIndexVectorDimAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().index_vector_dim); + return attr; + } + + ::mlir::Attribute getIndexVectorDim(); + ::mlir::Attribute getSliceSizesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().slice_sizes); + return attr; + } + + ::mlir::Attribute getSliceSizes(); + ::mlir::Attribute getIndicesAreSortedAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().indices_are_sorted); + return attr; + } + + ::mlir::Attribute getIndicesAreSorted(); +}; +} // namespace detail +template +class GatherOpV1GenericAdaptor : public detail::GatherOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GatherOpV1GenericAdaptorBase; +public: + GatherOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GatherOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GatherOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + GatherOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : GatherOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + GatherOpV1GenericAdaptor(RangeT values, const GatherOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + GatherOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getStartIndices() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GatherOpV1Adaptor : public GatherOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using GatherOpV1GenericAdaptor::GatherOpV1GenericAdaptor; + GatherOpV1Adaptor(GatherOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class GatherOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GatherOpV1Adaptor; + template + using GenericAdaptor = GatherOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("collapsed_slice_dims"), ::llvm::StringRef("index_vector_dim"), ::llvm::StringRef("indices_are_sorted"), ::llvm::StringRef("offset_dims"), ::llvm::StringRef("slice_sizes"), ::llvm::StringRef("start_index_map")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getCollapsedSliceDimsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getCollapsedSliceDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIndexVectorDimAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIndexVectorDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getIndicesAreSortedAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getIndicesAreSortedAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getOffsetDimsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getOffsetDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getSliceSizesAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getSliceSizesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + ::mlir::StringAttr getStartIndexMapAttrName() { + return getAttributeNameForIndex(5); + } + + static ::mlir::StringAttr getStartIndexMapAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 5); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.gather_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getStartIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getStartIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getOffsetDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().offset_dims); + } + + ::mlir::Attribute getOffsetDims(); + ::mlir::Attribute getCollapsedSliceDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().collapsed_slice_dims); + } + + ::mlir::Attribute getCollapsedSliceDims(); + ::mlir::Attribute getStartIndexMapAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().start_index_map); + } + + ::mlir::Attribute getStartIndexMap(); + ::mlir::Attribute getIndexVectorDimAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().index_vector_dim); + } + + ::mlir::Attribute getIndexVectorDim(); + ::mlir::Attribute getSliceSizesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().slice_sizes); + } + + ::mlir::Attribute getSliceSizes(); + ::mlir::Attribute getIndicesAreSortedAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().indices_are_sorted); + } + + ::mlir::Attribute getIndicesAreSorted(); + void setOffsetDimsAttr(::mlir::Attribute attr) { + getProperties().offset_dims = attr; + } + + void setCollapsedSliceDimsAttr(::mlir::Attribute attr) { + getProperties().collapsed_slice_dims = attr; + } + + void setStartIndexMapAttr(::mlir::Attribute attr) { + getProperties().start_index_map = attr; + } + + void setIndexVectorDimAttr(::mlir::Attribute attr) { + getProperties().index_vector_dim = attr; + } + + void setSliceSizesAttr(::mlir::Attribute attr) { + getProperties().slice_sizes = attr; + } + + void setIndicesAreSortedAttr(::mlir::Attribute attr) { + getProperties().indices_are_sorted = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute slice_sizes, ::mlir::Attribute indices_are_sorted); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute slice_sizes, ::mlir::Attribute indices_are_sorted); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 6 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::GatherOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::GatherOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GatherOpV2GenericAdaptorBase { +public: + struct Properties { + using collapsed_slice_dimsTy = ::mlir::Attribute; + collapsed_slice_dimsTy collapsed_slice_dims; + + auto getCollapsedSliceDims() const { + auto &propStorage = this->collapsed_slice_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setCollapsedSliceDims(const ::mlir::Attribute &propValue) { + this->collapsed_slice_dims = propValue; + } + using index_vector_dimTy = ::mlir::Attribute; + index_vector_dimTy index_vector_dim; + + auto getIndexVectorDim() const { + auto &propStorage = this->index_vector_dim; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIndexVectorDim(const ::mlir::Attribute &propValue) { + this->index_vector_dim = propValue; + } + using indices_are_sortedTy = ::mlir::Attribute; + indices_are_sortedTy indices_are_sorted; + + auto getIndicesAreSorted() const { + auto &propStorage = this->indices_are_sorted; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIndicesAreSorted(const ::mlir::Attribute &propValue) { + this->indices_are_sorted = propValue; + } + using offset_dimsTy = ::mlir::Attribute; + offset_dimsTy offset_dims; + + auto getOffsetDims() const { + auto &propStorage = this->offset_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOffsetDims(const ::mlir::Attribute &propValue) { + this->offset_dims = propValue; + } + using operand_batching_dimsTy = ::mlir::Attribute; + operand_batching_dimsTy operand_batching_dims; + + auto getOperandBatchingDims() const { + auto &propStorage = this->operand_batching_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOperandBatchingDims(const ::mlir::Attribute &propValue) { + this->operand_batching_dims = propValue; + } + using slice_sizesTy = ::mlir::Attribute; + slice_sizesTy slice_sizes; + + auto getSliceSizes() const { + auto &propStorage = this->slice_sizes; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setSliceSizes(const ::mlir::Attribute &propValue) { + this->slice_sizes = propValue; + } + using start_index_mapTy = ::mlir::Attribute; + start_index_mapTy start_index_map; + + auto getStartIndexMap() const { + auto &propStorage = this->start_index_map; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setStartIndexMap(const ::mlir::Attribute &propValue) { + this->start_index_map = propValue; + } + using start_indices_batching_dimsTy = ::mlir::Attribute; + start_indices_batching_dimsTy start_indices_batching_dims; + + auto getStartIndicesBatchingDims() const { + auto &propStorage = this->start_indices_batching_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setStartIndicesBatchingDims(const ::mlir::Attribute &propValue) { + this->start_indices_batching_dims = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.collapsed_slice_dims == this->collapsed_slice_dims && + rhs.index_vector_dim == this->index_vector_dim && + rhs.indices_are_sorted == this->indices_are_sorted && + rhs.offset_dims == this->offset_dims && + rhs.operand_batching_dims == this->operand_batching_dims && + rhs.slice_sizes == this->slice_sizes && + rhs.start_index_map == this->start_index_map && + rhs.start_indices_batching_dims == this->start_indices_batching_dims && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GatherOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.gather_v2", odsAttrs.getContext()); + } + + GatherOpV2GenericAdaptorBase(GatherOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getOffsetDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().offset_dims); + return attr; + } + + ::mlir::Attribute getOffsetDims(); + ::mlir::Attribute getCollapsedSliceDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().collapsed_slice_dims); + return attr; + } + + ::mlir::Attribute getCollapsedSliceDims(); + ::mlir::Attribute getOperandBatchingDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().operand_batching_dims); + return attr; + } + + ::mlir::Attribute getOperandBatchingDims(); + ::mlir::Attribute getStartIndicesBatchingDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().start_indices_batching_dims); + return attr; + } + + ::mlir::Attribute getStartIndicesBatchingDims(); + ::mlir::Attribute getStartIndexMapAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().start_index_map); + return attr; + } + + ::mlir::Attribute getStartIndexMap(); + ::mlir::Attribute getIndexVectorDimAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().index_vector_dim); + return attr; + } + + ::mlir::Attribute getIndexVectorDim(); + ::mlir::Attribute getSliceSizesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().slice_sizes); + return attr; + } + + ::mlir::Attribute getSliceSizes(); + ::mlir::Attribute getIndicesAreSortedAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().indices_are_sorted); + return attr; + } + + ::mlir::Attribute getIndicesAreSorted(); +}; +} // namespace detail +template +class GatherOpV2GenericAdaptor : public detail::GatherOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GatherOpV2GenericAdaptorBase; +public: + GatherOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GatherOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GatherOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + GatherOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : GatherOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + GatherOpV2GenericAdaptor(RangeT values, const GatherOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + GatherOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getStartIndices() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GatherOpV2Adaptor : public GatherOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using GatherOpV2GenericAdaptor::GatherOpV2GenericAdaptor; + GatherOpV2Adaptor(GatherOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class GatherOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GatherOpV2Adaptor; + template + using GenericAdaptor = GatherOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("collapsed_slice_dims"), ::llvm::StringRef("index_vector_dim"), ::llvm::StringRef("indices_are_sorted"), ::llvm::StringRef("offset_dims"), ::llvm::StringRef("operand_batching_dims"), ::llvm::StringRef("slice_sizes"), ::llvm::StringRef("start_index_map"), ::llvm::StringRef("start_indices_batching_dims")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getCollapsedSliceDimsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getCollapsedSliceDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIndexVectorDimAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIndexVectorDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getIndicesAreSortedAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getIndicesAreSortedAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getOffsetDimsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getOffsetDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getOperandBatchingDimsAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getOperandBatchingDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + ::mlir::StringAttr getSliceSizesAttrName() { + return getAttributeNameForIndex(5); + } + + static ::mlir::StringAttr getSliceSizesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 5); + } + + ::mlir::StringAttr getStartIndexMapAttrName() { + return getAttributeNameForIndex(6); + } + + static ::mlir::StringAttr getStartIndexMapAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 6); + } + + ::mlir::StringAttr getStartIndicesBatchingDimsAttrName() { + return getAttributeNameForIndex(7); + } + + static ::mlir::StringAttr getStartIndicesBatchingDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 7); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.gather_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getStartIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getStartIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getOffsetDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().offset_dims); + } + + ::mlir::Attribute getOffsetDims(); + ::mlir::Attribute getCollapsedSliceDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().collapsed_slice_dims); + } + + ::mlir::Attribute getCollapsedSliceDims(); + ::mlir::Attribute getOperandBatchingDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().operand_batching_dims); + } + + ::mlir::Attribute getOperandBatchingDims(); + ::mlir::Attribute getStartIndicesBatchingDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().start_indices_batching_dims); + } + + ::mlir::Attribute getStartIndicesBatchingDims(); + ::mlir::Attribute getStartIndexMapAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().start_index_map); + } + + ::mlir::Attribute getStartIndexMap(); + ::mlir::Attribute getIndexVectorDimAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().index_vector_dim); + } + + ::mlir::Attribute getIndexVectorDim(); + ::mlir::Attribute getSliceSizesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().slice_sizes); + } + + ::mlir::Attribute getSliceSizes(); + ::mlir::Attribute getIndicesAreSortedAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().indices_are_sorted); + } + + ::mlir::Attribute getIndicesAreSorted(); + void setOffsetDimsAttr(::mlir::Attribute attr) { + getProperties().offset_dims = attr; + } + + void setCollapsedSliceDimsAttr(::mlir::Attribute attr) { + getProperties().collapsed_slice_dims = attr; + } + + void setOperandBatchingDimsAttr(::mlir::Attribute attr) { + getProperties().operand_batching_dims = attr; + } + + void setStartIndicesBatchingDimsAttr(::mlir::Attribute attr) { + getProperties().start_indices_batching_dims = attr; + } + + void setStartIndexMapAttr(::mlir::Attribute attr) { + getProperties().start_index_map = attr; + } + + void setIndexVectorDimAttr(::mlir::Attribute attr) { + getProperties().index_vector_dim = attr; + } + + void setSliceSizesAttr(::mlir::Attribute attr) { + getProperties().slice_sizes = attr; + } + + void setIndicesAreSortedAttr(::mlir::Attribute attr) { + getProperties().indices_are_sorted = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute operand_batching_dims, ::mlir::Attribute start_indices_batching_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute slice_sizes, ::mlir::Attribute indices_are_sorted); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Attribute offset_dims, ::mlir::Attribute collapsed_slice_dims, ::mlir::Attribute operand_batching_dims, ::mlir::Attribute start_indices_batching_dims, ::mlir::Attribute start_index_map, ::mlir::Attribute index_vector_dim, ::mlir::Attribute slice_sizes, ::mlir::Attribute indices_are_sorted); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 8 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::GatherOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::GetDimensionSizeOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GetDimensionSizeOpV1GenericAdaptorBase { +public: + struct Properties { + using dimensionTy = ::mlir::Attribute; + dimensionTy dimension; + + auto getDimension() const { + auto &propStorage = this->dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setDimension(const ::mlir::Attribute &propValue) { + this->dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimension == this->dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GetDimensionSizeOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.get_dimension_size_v1", odsAttrs.getContext()); + } + + GetDimensionSizeOpV1GenericAdaptorBase(GetDimensionSizeOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().dimension); + return attr; + } + + ::mlir::Attribute getDimension(); +}; +} // namespace detail +template +class GetDimensionSizeOpV1GenericAdaptor : public detail::GetDimensionSizeOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GetDimensionSizeOpV1GenericAdaptorBase; +public: + GetDimensionSizeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GetDimensionSizeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GetDimensionSizeOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + GetDimensionSizeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : GetDimensionSizeOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + GetDimensionSizeOpV1GenericAdaptor(RangeT values, const GetDimensionSizeOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + GetDimensionSizeOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GetDimensionSizeOpV1Adaptor : public GetDimensionSizeOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using GetDimensionSizeOpV1GenericAdaptor::GetDimensionSizeOpV1GenericAdaptor; + GetDimensionSizeOpV1Adaptor(GetDimensionSizeOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class GetDimensionSizeOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GetDimensionSizeOpV1Adaptor; + template + using GenericAdaptor = GetDimensionSizeOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.get_dimension_size_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().dimension); + } + + ::mlir::Attribute getDimension(); + void setDimensionAttr(::mlir::Attribute attr) { + getProperties().dimension = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute dimension); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::GetDimensionSizeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::GetTupleElementOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GetTupleElementOpV1GenericAdaptorBase { +public: + struct Properties { + using indexTy = ::mlir::Attribute; + indexTy index; + + auto getIndex() const { + auto &propStorage = this->index; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIndex(const ::mlir::Attribute &propValue) { + this->index = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.index == this->index && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GetTupleElementOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.get_tuple_element_v1", odsAttrs.getContext()); + } + + GetTupleElementOpV1GenericAdaptorBase(GetTupleElementOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getIndexAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().index); + return attr; + } + + ::mlir::Attribute getIndex(); +}; +} // namespace detail +template +class GetTupleElementOpV1GenericAdaptor : public detail::GetTupleElementOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GetTupleElementOpV1GenericAdaptorBase; +public: + GetTupleElementOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GetTupleElementOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GetTupleElementOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + GetTupleElementOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : GetTupleElementOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + GetTupleElementOpV1GenericAdaptor(RangeT values, const GetTupleElementOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + GetTupleElementOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GetTupleElementOpV1Adaptor : public GetTupleElementOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using GetTupleElementOpV1GenericAdaptor::GetTupleElementOpV1GenericAdaptor; + GetTupleElementOpV1Adaptor(GetTupleElementOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class GetTupleElementOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GetTupleElementOpV1Adaptor; + template + using GenericAdaptor = GetTupleElementOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("index")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getIndexAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getIndexAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.get_tuple_element_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getIndexAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().index); + } + + ::mlir::Attribute getIndex(); + void setIndexAttr(::mlir::Attribute attr) { + getProperties().index = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute index); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::GetTupleElementOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::IfOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IfOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + IfOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.if_v1", odsAttrs.getContext()); + } + + IfOpV1GenericAdaptorBase(IfOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Region &getTrueBranch() { + return *odsRegions[0]; + } + + ::mlir::Region &getFalseBranch() { + return *odsRegions[1]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class IfOpV1GenericAdaptor : public detail::IfOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IfOpV1GenericAdaptorBase; +public: + IfOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IfOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IfOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + IfOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : IfOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + IfOpV1GenericAdaptor(RangeT values, const IfOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + IfOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getPred() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class IfOpV1Adaptor : public IfOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using IfOpV1GenericAdaptor::IfOpV1GenericAdaptor; + IfOpV1Adaptor(IfOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class IfOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = IfOpV1Adaptor; + template + using GenericAdaptor = IfOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.if_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getPred() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getPredMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + ::mlir::Region &getTrueBranch() { + return (*this)->getRegion(0); + } + + ::mlir::Region &getFalseBranch() { + return (*this)->getRegion(1); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value pred); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IfOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ImagOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ImagOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ImagOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.imag_v1", odsAttrs.getContext()); + } + + ImagOpV1GenericAdaptorBase(ImagOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ImagOpV1GenericAdaptor : public detail::ImagOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ImagOpV1GenericAdaptorBase; +public: + ImagOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ImagOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ImagOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ImagOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ImagOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ImagOpV1GenericAdaptor(RangeT values, const ImagOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ImagOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ImagOpV1Adaptor : public ImagOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ImagOpV1GenericAdaptor::ImagOpV1GenericAdaptor; + ImagOpV1Adaptor(ImagOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ImagOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ImagOpV1Adaptor; + template + using GenericAdaptor = ImagOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.imag_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ImagOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::InfeedOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class InfeedOpV1GenericAdaptorBase { +public: + struct Properties { + using infeed_configTy = ::mlir::Attribute; + infeed_configTy infeed_config; + + auto getInfeedConfig() const { + auto &propStorage = this->infeed_config; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInfeedConfig(const ::mlir::Attribute &propValue) { + this->infeed_config = propValue; + } + using layoutTy = ::mlir::Attribute; + layoutTy layout; + + auto getLayout() const { + auto &propStorage = this->layout; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLayout(const ::mlir::Attribute &propValue) { + this->layout = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.infeed_config == this->infeed_config && + rhs.layout == this->layout && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + InfeedOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.infeed_v1", odsAttrs.getContext()); + } + + InfeedOpV1GenericAdaptorBase(InfeedOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getInfeedConfigAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().infeed_config); + return attr; + } + + ::mlir::Attribute getInfeedConfig(); + ::mlir::Attribute getLayoutAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().layout); + return attr; + } + + ::mlir::Attribute getLayout(); +}; +} // namespace detail +template +class InfeedOpV1GenericAdaptor : public detail::InfeedOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::InfeedOpV1GenericAdaptorBase; +public: + InfeedOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + InfeedOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : InfeedOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + InfeedOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : InfeedOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + InfeedOpV1GenericAdaptor(RangeT values, const InfeedOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + InfeedOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getToken() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class InfeedOpV1Adaptor : public InfeedOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using InfeedOpV1GenericAdaptor::InfeedOpV1GenericAdaptor; + InfeedOpV1Adaptor(InfeedOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class InfeedOpV1 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = InfeedOpV1Adaptor; + template + using GenericAdaptor = InfeedOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("infeed_config"), ::llvm::StringRef("layout")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getInfeedConfigAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getInfeedConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getLayoutAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getLayoutAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.infeed_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getToken() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getTokenMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getInfeedConfigAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().infeed_config); + } + + ::mlir::Attribute getInfeedConfig(); + ::mlir::Attribute getLayoutAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().layout); + } + + ::mlir::Attribute getLayout(); + void setInfeedConfigAttr(::mlir::Attribute attr) { + getProperties().infeed_config = attr; + } + + void setLayoutAttr(::mlir::Attribute attr) { + getProperties().layout = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value token, ::mlir::Attribute infeed_config, ::mlir::Attribute layout); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::InfeedOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::IotaOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IotaOpV1GenericAdaptorBase { +public: + struct Properties { + using iota_dimensionTy = ::mlir::Attribute; + iota_dimensionTy iota_dimension; + + auto getIotaDimension() const { + auto &propStorage = this->iota_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIotaDimension(const ::mlir::Attribute &propValue) { + this->iota_dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.iota_dimension == this->iota_dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + IotaOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.iota_v1", odsAttrs.getContext()); + } + + IotaOpV1GenericAdaptorBase(IotaOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getIotaDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().iota_dimension); + return attr; + } + + ::mlir::Attribute getIotaDimension(); +}; +} // namespace detail +template +class IotaOpV1GenericAdaptor : public detail::IotaOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IotaOpV1GenericAdaptorBase; +public: + IotaOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IotaOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IotaOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + IotaOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : IotaOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + IotaOpV1GenericAdaptor(RangeT values, const IotaOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + IotaOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class IotaOpV1Adaptor : public IotaOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using IotaOpV1GenericAdaptor::IotaOpV1GenericAdaptor; + IotaOpV1Adaptor(IotaOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class IotaOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = IotaOpV1Adaptor; + template + using GenericAdaptor = IotaOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("iota_dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getIotaDimensionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getIotaDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.iota_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getIotaDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().iota_dimension); + } + + ::mlir::Attribute getIotaDimension(); + void setIotaDimensionAttr(::mlir::Attribute attr) { + getProperties().iota_dimension = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Attribute iota_dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Attribute iota_dimension); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IotaOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::IsFiniteOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IsFiniteOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + IsFiniteOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.is_finite_v1", odsAttrs.getContext()); + } + + IsFiniteOpV1GenericAdaptorBase(IsFiniteOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class IsFiniteOpV1GenericAdaptor : public detail::IsFiniteOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IsFiniteOpV1GenericAdaptorBase; +public: + IsFiniteOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IsFiniteOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IsFiniteOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + IsFiniteOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : IsFiniteOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + IsFiniteOpV1GenericAdaptor(RangeT values, const IsFiniteOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + IsFiniteOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getX() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class IsFiniteOpV1Adaptor : public IsFiniteOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using IsFiniteOpV1GenericAdaptor::IsFiniteOpV1GenericAdaptor; + IsFiniteOpV1Adaptor(IsFiniteOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class IsFiniteOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = IsFiniteOpV1Adaptor; + template + using GenericAdaptor = IsFiniteOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.is_finite_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getX() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getXMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getY() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type y, ::mlir::Value x); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IsFiniteOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::Log1pOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class Log1pOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + Log1pOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.log_plus_one_v1", odsAttrs.getContext()); + } + + Log1pOpV1GenericAdaptorBase(Log1pOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class Log1pOpV1GenericAdaptor : public detail::Log1pOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::Log1pOpV1GenericAdaptorBase; +public: + Log1pOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + Log1pOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : Log1pOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + Log1pOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : Log1pOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + Log1pOpV1GenericAdaptor(RangeT values, const Log1pOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + Log1pOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class Log1pOpV1Adaptor : public Log1pOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using Log1pOpV1GenericAdaptor::Log1pOpV1GenericAdaptor; + Log1pOpV1Adaptor(Log1pOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class Log1pOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = Log1pOpV1Adaptor; + template + using GenericAdaptor = Log1pOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.log_plus_one_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::Log1pOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::Log1pOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class Log1pOpV2GenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::Attribute; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResultAccuracy(const ::mlir::Attribute &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + Log1pOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.log_plus_one_v2", odsAttrs.getContext()); + } + + Log1pOpV2GenericAdaptorBase(Log1pOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getResultAccuracyAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + return attr; + } + + ::mlir::Attribute getResultAccuracy(); +}; +} // namespace detail +template +class Log1pOpV2GenericAdaptor : public detail::Log1pOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::Log1pOpV2GenericAdaptorBase; +public: + Log1pOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + Log1pOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : Log1pOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + Log1pOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : Log1pOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + Log1pOpV2GenericAdaptor(RangeT values, const Log1pOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + Log1pOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class Log1pOpV2Adaptor : public Log1pOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using Log1pOpV2GenericAdaptor::Log1pOpV2GenericAdaptor; + Log1pOpV2Adaptor(Log1pOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class Log1pOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = Log1pOpV2Adaptor; + template + using GenericAdaptor = Log1pOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.log_plus_one_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getResultAccuracyAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + } + + ::mlir::Attribute getResultAccuracy(); + void setResultAccuracyAttr(::mlir::Attribute attr) { + getProperties().result_accuracy = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::Log1pOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::LogOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class LogOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + LogOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.log_v1", odsAttrs.getContext()); + } + + LogOpV1GenericAdaptorBase(LogOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class LogOpV1GenericAdaptor : public detail::LogOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::LogOpV1GenericAdaptorBase; +public: + LogOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + LogOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : LogOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + LogOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : LogOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + LogOpV1GenericAdaptor(RangeT values, const LogOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + LogOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class LogOpV1Adaptor : public LogOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using LogOpV1GenericAdaptor::LogOpV1GenericAdaptor; + LogOpV1Adaptor(LogOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class LogOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = LogOpV1Adaptor; + template + using GenericAdaptor = LogOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.log_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::LogOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::LogOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class LogOpV2GenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::Attribute; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResultAccuracy(const ::mlir::Attribute &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + LogOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.log_v2", odsAttrs.getContext()); + } + + LogOpV2GenericAdaptorBase(LogOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getResultAccuracyAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + return attr; + } + + ::mlir::Attribute getResultAccuracy(); +}; +} // namespace detail +template +class LogOpV2GenericAdaptor : public detail::LogOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::LogOpV2GenericAdaptorBase; +public: + LogOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + LogOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : LogOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + LogOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : LogOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + LogOpV2GenericAdaptor(RangeT values, const LogOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + LogOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class LogOpV2Adaptor : public LogOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using LogOpV2GenericAdaptor::LogOpV2GenericAdaptor; + LogOpV2Adaptor(LogOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class LogOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = LogOpV2Adaptor; + template + using GenericAdaptor = LogOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.log_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getResultAccuracyAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + } + + ::mlir::Attribute getResultAccuracy(); + void setResultAccuracyAttr(::mlir::Attribute attr) { + getProperties().result_accuracy = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::LogOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::LogisticOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class LogisticOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + LogisticOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.logistic_v1", odsAttrs.getContext()); + } + + LogisticOpV1GenericAdaptorBase(LogisticOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class LogisticOpV1GenericAdaptor : public detail::LogisticOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::LogisticOpV1GenericAdaptorBase; +public: + LogisticOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + LogisticOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : LogisticOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + LogisticOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : LogisticOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + LogisticOpV1GenericAdaptor(RangeT values, const LogisticOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + LogisticOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class LogisticOpV1Adaptor : public LogisticOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using LogisticOpV1GenericAdaptor::LogisticOpV1GenericAdaptor; + LogisticOpV1Adaptor(LogisticOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class LogisticOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = LogisticOpV1Adaptor; + template + using GenericAdaptor = LogisticOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.logistic_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::LogisticOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::LogisticOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class LogisticOpV2GenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::Attribute; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResultAccuracy(const ::mlir::Attribute &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + LogisticOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.logistic_v2", odsAttrs.getContext()); + } + + LogisticOpV2GenericAdaptorBase(LogisticOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getResultAccuracyAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + return attr; + } + + ::mlir::Attribute getResultAccuracy(); +}; +} // namespace detail +template +class LogisticOpV2GenericAdaptor : public detail::LogisticOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::LogisticOpV2GenericAdaptorBase; +public: + LogisticOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + LogisticOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : LogisticOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + LogisticOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : LogisticOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + LogisticOpV2GenericAdaptor(RangeT values, const LogisticOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + LogisticOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class LogisticOpV2Adaptor : public LogisticOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using LogisticOpV2GenericAdaptor::LogisticOpV2GenericAdaptor; + LogisticOpV2Adaptor(LogisticOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class LogisticOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = LogisticOpV2Adaptor; + template + using GenericAdaptor = LogisticOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.logistic_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getResultAccuracyAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + } + + ::mlir::Attribute getResultAccuracy(); + void setResultAccuracyAttr(::mlir::Attribute attr) { + getProperties().result_accuracy = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::LogisticOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::MapOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MapOpV1GenericAdaptorBase { +public: + struct Properties { + using dimensionsTy = ::mlir::Attribute; + dimensionsTy dimensions; + + auto getDimensions() const { + auto &propStorage = this->dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setDimensions(const ::mlir::Attribute &propValue) { + this->dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimensions == this->dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MapOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.map_v1", odsAttrs.getContext()); + } + + MapOpV1GenericAdaptorBase(MapOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().dimensions); + return attr; + } + + ::mlir::Attribute getDimensions(); + ::mlir::Region &getComputation() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class MapOpV1GenericAdaptor : public detail::MapOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MapOpV1GenericAdaptorBase; +public: + MapOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MapOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MapOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + MapOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : MapOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + MapOpV1GenericAdaptor(RangeT values, const MapOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + MapOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MapOpV1Adaptor : public MapOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using MapOpV1GenericAdaptor::MapOpV1GenericAdaptor; + MapOpV1Adaptor(MapOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class MapOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MapOpV1Adaptor; + template + using GenericAdaptor = MapOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.map_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + ::mlir::Region &getComputation() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().dimensions); + } + + ::mlir::Attribute getDimensions(); + void setDimensionsAttr(::mlir::Attribute attr) { + getProperties().dimensions = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs, ::mlir::Attribute dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Attribute dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::MapOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::MaxOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaxOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MaxOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.maximum_v1", odsAttrs.getContext()); + } + + MaxOpV1GenericAdaptorBase(MaxOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class MaxOpV1GenericAdaptor : public detail::MaxOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaxOpV1GenericAdaptorBase; +public: + MaxOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaxOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaxOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + MaxOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : MaxOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + MaxOpV1GenericAdaptor(RangeT values, const MaxOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + MaxOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaxOpV1Adaptor : public MaxOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using MaxOpV1GenericAdaptor::MaxOpV1GenericAdaptor; + MaxOpV1Adaptor(MaxOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class MaxOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaxOpV1Adaptor; + template + using GenericAdaptor = MaxOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.maximum_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::MaxOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::MinOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MinOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MinOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.minimum_v1", odsAttrs.getContext()); + } + + MinOpV1GenericAdaptorBase(MinOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class MinOpV1GenericAdaptor : public detail::MinOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MinOpV1GenericAdaptorBase; +public: + MinOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MinOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MinOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + MinOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : MinOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + MinOpV1GenericAdaptor(RangeT values, const MinOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + MinOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MinOpV1Adaptor : public MinOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using MinOpV1GenericAdaptor::MinOpV1GenericAdaptor; + MinOpV1Adaptor(MinOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class MinOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MinOpV1Adaptor; + template + using GenericAdaptor = MinOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.minimum_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::MinOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::MulOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MulOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MulOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.multiply_v1", odsAttrs.getContext()); + } + + MulOpV1GenericAdaptorBase(MulOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class MulOpV1GenericAdaptor : public detail::MulOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MulOpV1GenericAdaptorBase; +public: + MulOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MulOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MulOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + MulOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : MulOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + MulOpV1GenericAdaptor(RangeT values, const MulOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + MulOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MulOpV1Adaptor : public MulOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using MulOpV1GenericAdaptor::MulOpV1GenericAdaptor; + MulOpV1Adaptor(MulOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class MulOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MulOpV1Adaptor; + template + using GenericAdaptor = MulOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.multiply_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::MulOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::NegOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class NegOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + NegOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.negate_v1", odsAttrs.getContext()); + } + + NegOpV1GenericAdaptorBase(NegOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class NegOpV1GenericAdaptor : public detail::NegOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::NegOpV1GenericAdaptorBase; +public: + NegOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + NegOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : NegOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + NegOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : NegOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + NegOpV1GenericAdaptor(RangeT values, const NegOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + NegOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class NegOpV1Adaptor : public NegOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using NegOpV1GenericAdaptor::NegOpV1GenericAdaptor; + NegOpV1Adaptor(NegOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class NegOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = NegOpV1Adaptor; + template + using GenericAdaptor = NegOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.negate_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::NegOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::NotOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class NotOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + NotOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.not_v1", odsAttrs.getContext()); + } + + NotOpV1GenericAdaptorBase(NotOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class NotOpV1GenericAdaptor : public detail::NotOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::NotOpV1GenericAdaptorBase; +public: + NotOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + NotOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : NotOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + NotOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : NotOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + NotOpV1GenericAdaptor(RangeT values, const NotOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + NotOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class NotOpV1Adaptor : public NotOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using NotOpV1GenericAdaptor::NotOpV1GenericAdaptor; + NotOpV1Adaptor(NotOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class NotOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = NotOpV1Adaptor; + template + using GenericAdaptor = NotOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.not_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::NotOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::OptimizationBarrierOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class OptimizationBarrierOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + OptimizationBarrierOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.optimization_barrier_v1", odsAttrs.getContext()); + } + + OptimizationBarrierOpV1GenericAdaptorBase(OptimizationBarrierOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class OptimizationBarrierOpV1GenericAdaptor : public detail::OptimizationBarrierOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::OptimizationBarrierOpV1GenericAdaptorBase; +public: + OptimizationBarrierOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + OptimizationBarrierOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : OptimizationBarrierOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + OptimizationBarrierOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : OptimizationBarrierOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + OptimizationBarrierOpV1GenericAdaptor(RangeT values, const OptimizationBarrierOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + OptimizationBarrierOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperand() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class OptimizationBarrierOpV1Adaptor : public OptimizationBarrierOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using OptimizationBarrierOpV1GenericAdaptor::OptimizationBarrierOpV1GenericAdaptor; + OptimizationBarrierOpV1Adaptor(OptimizationBarrierOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class OptimizationBarrierOpV1 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = OptimizationBarrierOpV1Adaptor; + template + using GenericAdaptor = OptimizationBarrierOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.optimization_barrier_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getOperand() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getOperandMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResult() { + return getODSResults(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::OptimizationBarrierOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::OrOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class OrOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + OrOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.or_v1", odsAttrs.getContext()); + } + + OrOpV1GenericAdaptorBase(OrOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class OrOpV1GenericAdaptor : public detail::OrOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::OrOpV1GenericAdaptorBase; +public: + OrOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + OrOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : OrOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + OrOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : OrOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + OrOpV1GenericAdaptor(RangeT values, const OrOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + OrOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class OrOpV1Adaptor : public OrOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using OrOpV1GenericAdaptor::OrOpV1GenericAdaptor; + OrOpV1Adaptor(OrOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class OrOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = OrOpV1Adaptor; + template + using GenericAdaptor = OrOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.or_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::OrOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::OutfeedOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class OutfeedOpV1GenericAdaptorBase { +public: + struct Properties { + using outfeed_configTy = ::mlir::Attribute; + outfeed_configTy outfeed_config; + + auto getOutfeedConfig() const { + auto &propStorage = this->outfeed_config; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setOutfeedConfig(const ::mlir::Attribute &propValue) { + this->outfeed_config = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.outfeed_config == this->outfeed_config && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + OutfeedOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.outfeed_v1", odsAttrs.getContext()); + } + + OutfeedOpV1GenericAdaptorBase(OutfeedOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getOutfeedConfigAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().outfeed_config); + return attr; + } + + ::mlir::Attribute getOutfeedConfig(); +}; +} // namespace detail +template +class OutfeedOpV1GenericAdaptor : public detail::OutfeedOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::OutfeedOpV1GenericAdaptorBase; +public: + OutfeedOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + OutfeedOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : OutfeedOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + OutfeedOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : OutfeedOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + OutfeedOpV1GenericAdaptor(RangeT values, const OutfeedOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + OutfeedOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + ValueT getToken() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class OutfeedOpV1Adaptor : public OutfeedOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using OutfeedOpV1GenericAdaptor::OutfeedOpV1GenericAdaptor; + OutfeedOpV1Adaptor(OutfeedOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class OutfeedOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = OutfeedOpV1Adaptor; + template + using GenericAdaptor = OutfeedOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("outfeed_config")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getOutfeedConfigAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getOutfeedConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.outfeed_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::TypedValue<::mlir::Type> getToken() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::MutableOperandRange getInputsMutable(); + ::mlir::OpOperand &getTokenMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getOutfeedConfigAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().outfeed_config); + } + + ::mlir::Attribute getOutfeedConfig(); + void setOutfeedConfigAttr(::mlir::Attribute attr) { + getProperties().outfeed_config = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::Attribute outfeed_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::Attribute outfeed_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::OutfeedOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::PadOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PadOpV1GenericAdaptorBase { +public: + struct Properties { + using edge_padding_highTy = ::mlir::Attribute; + edge_padding_highTy edge_padding_high; + + auto getEdgePaddingHigh() const { + auto &propStorage = this->edge_padding_high; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setEdgePaddingHigh(const ::mlir::Attribute &propValue) { + this->edge_padding_high = propValue; + } + using edge_padding_lowTy = ::mlir::Attribute; + edge_padding_lowTy edge_padding_low; + + auto getEdgePaddingLow() const { + auto &propStorage = this->edge_padding_low; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setEdgePaddingLow(const ::mlir::Attribute &propValue) { + this->edge_padding_low = propValue; + } + using interior_paddingTy = ::mlir::Attribute; + interior_paddingTy interior_padding; + + auto getInteriorPadding() const { + auto &propStorage = this->interior_padding; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInteriorPadding(const ::mlir::Attribute &propValue) { + this->interior_padding = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.edge_padding_high == this->edge_padding_high && + rhs.edge_padding_low == this->edge_padding_low && + rhs.interior_padding == this->interior_padding && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PadOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.pad_v1", odsAttrs.getContext()); + } + + PadOpV1GenericAdaptorBase(PadOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getEdgePaddingLowAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().edge_padding_low); + return attr; + } + + ::mlir::Attribute getEdgePaddingLow(); + ::mlir::Attribute getEdgePaddingHighAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().edge_padding_high); + return attr; + } + + ::mlir::Attribute getEdgePaddingHigh(); + ::mlir::Attribute getInteriorPaddingAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().interior_padding); + return attr; + } + + ::mlir::Attribute getInteriorPadding(); +}; +} // namespace detail +template +class PadOpV1GenericAdaptor : public detail::PadOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PadOpV1GenericAdaptorBase; +public: + PadOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PadOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PadOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + PadOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : PadOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + PadOpV1GenericAdaptor(RangeT values, const PadOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + PadOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getPaddingValue() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PadOpV1Adaptor : public PadOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using PadOpV1GenericAdaptor::PadOpV1GenericAdaptor; + PadOpV1Adaptor(PadOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class PadOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = PadOpV1Adaptor; + template + using GenericAdaptor = PadOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("edge_padding_high"), ::llvm::StringRef("edge_padding_low"), ::llvm::StringRef("interior_padding")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getEdgePaddingHighAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getEdgePaddingHighAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getEdgePaddingLowAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getEdgePaddingLowAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getInteriorPaddingAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getInteriorPaddingAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.pad_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getPaddingValue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getPaddingValueMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getEdgePaddingLowAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().edge_padding_low); + } + + ::mlir::Attribute getEdgePaddingLow(); + ::mlir::Attribute getEdgePaddingHighAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().edge_padding_high); + } + + ::mlir::Attribute getEdgePaddingHigh(); + ::mlir::Attribute getInteriorPaddingAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().interior_padding); + } + + ::mlir::Attribute getInteriorPadding(); + void setEdgePaddingLowAttr(::mlir::Attribute attr) { + getProperties().edge_padding_low = attr; + } + + void setEdgePaddingHighAttr(::mlir::Attribute attr) { + getProperties().edge_padding_high = attr; + } + + void setInteriorPaddingAttr(::mlir::Attribute attr) { + getProperties().interior_padding = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::Attribute edge_padding_low, ::mlir::Attribute edge_padding_high, ::mlir::Attribute interior_padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value padding_value, ::mlir::Attribute edge_padding_low, ::mlir::Attribute edge_padding_high, ::mlir::Attribute interior_padding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::PadOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::PartitionIdOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PartitionIdOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PartitionIdOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.partition_id_v1", odsAttrs.getContext()); + } + + PartitionIdOpV1GenericAdaptorBase(PartitionIdOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class PartitionIdOpV1GenericAdaptor : public detail::PartitionIdOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PartitionIdOpV1GenericAdaptorBase; +public: + PartitionIdOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PartitionIdOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PartitionIdOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + PartitionIdOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : PartitionIdOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + PartitionIdOpV1GenericAdaptor(RangeT values, const PartitionIdOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + PartitionIdOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PartitionIdOpV1Adaptor : public PartitionIdOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using PartitionIdOpV1GenericAdaptor::PartitionIdOpV1GenericAdaptor; + PartitionIdOpV1Adaptor(PartitionIdOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class PartitionIdOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = PartitionIdOpV1Adaptor; + template + using GenericAdaptor = PartitionIdOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.partition_id_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::PartitionIdOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::PopulationCountOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PopulationCountOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PopulationCountOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.popcnt_v1", odsAttrs.getContext()); + } + + PopulationCountOpV1GenericAdaptorBase(PopulationCountOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class PopulationCountOpV1GenericAdaptor : public detail::PopulationCountOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PopulationCountOpV1GenericAdaptorBase; +public: + PopulationCountOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PopulationCountOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PopulationCountOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + PopulationCountOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : PopulationCountOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + PopulationCountOpV1GenericAdaptor(RangeT values, const PopulationCountOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + PopulationCountOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PopulationCountOpV1Adaptor : public PopulationCountOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using PopulationCountOpV1GenericAdaptor::PopulationCountOpV1GenericAdaptor; + PopulationCountOpV1Adaptor(PopulationCountOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class PopulationCountOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = PopulationCountOpV1Adaptor; + template + using GenericAdaptor = PopulationCountOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.popcnt_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::PopulationCountOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::PowOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PowOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PowOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.power_v1", odsAttrs.getContext()); + } + + PowOpV1GenericAdaptorBase(PowOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class PowOpV1GenericAdaptor : public detail::PowOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PowOpV1GenericAdaptorBase; +public: + PowOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PowOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PowOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + PowOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : PowOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + PowOpV1GenericAdaptor(RangeT values, const PowOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + PowOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PowOpV1Adaptor : public PowOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using PowOpV1GenericAdaptor::PowOpV1GenericAdaptor; + PowOpV1Adaptor(PowOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class PowOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = PowOpV1Adaptor; + template + using GenericAdaptor = PowOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.power_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::PowOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RealDynamicSliceOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RealDynamicSliceOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RealDynamicSliceOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.real_dynamic_slice_v1", odsAttrs.getContext()); + } + + RealDynamicSliceOpV1GenericAdaptorBase(RealDynamicSliceOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class RealDynamicSliceOpV1GenericAdaptor : public detail::RealDynamicSliceOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RealDynamicSliceOpV1GenericAdaptorBase; +public: + RealDynamicSliceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RealDynamicSliceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RealDynamicSliceOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RealDynamicSliceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RealDynamicSliceOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + RealDynamicSliceOpV1GenericAdaptor(RangeT values, const RealDynamicSliceOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RealDynamicSliceOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getStartIndices() { + return (*getODSOperands(1).begin()); + } + + ValueT getLimitIndices() { + return (*getODSOperands(2).begin()); + } + + ValueT getStrides() { + return (*getODSOperands(3).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RealDynamicSliceOpV1Adaptor : public RealDynamicSliceOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using RealDynamicSliceOpV1GenericAdaptor::RealDynamicSliceOpV1GenericAdaptor; + RealDynamicSliceOpV1Adaptor(RealDynamicSliceOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RealDynamicSliceOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<4>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RealDynamicSliceOpV1Adaptor; + template + using GenericAdaptor = RealDynamicSliceOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.real_dynamic_slice_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getStartIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getLimitIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(2).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getStrides() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(3).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getStartIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getLimitIndicesMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getStridesMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value limit_indices, ::mlir::Value strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value start_indices, ::mlir::Value limit_indices, ::mlir::Value strides); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::RealDynamicSliceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RealOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RealOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RealOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.real_v1", odsAttrs.getContext()); + } + + RealOpV1GenericAdaptorBase(RealOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class RealOpV1GenericAdaptor : public detail::RealOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RealOpV1GenericAdaptorBase; +public: + RealOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RealOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RealOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RealOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RealOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + RealOpV1GenericAdaptor(RangeT values, const RealOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RealOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RealOpV1Adaptor : public RealOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using RealOpV1GenericAdaptor::RealOpV1GenericAdaptor; + RealOpV1Adaptor(RealOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RealOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RealOpV1Adaptor; + template + using GenericAdaptor = RealOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.real_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::RealOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RecvOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RecvOpV1GenericAdaptorBase { +public: + struct Properties { + using channel_idTy = ::mlir::Attribute; + channel_idTy channel_id; + + auto getChannelId() const { + auto &propStorage = this->channel_id; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setChannelId(const ::mlir::Attribute &propValue) { + this->channel_id = propValue; + } + using channel_typeTy = ::mlir::Attribute; + channel_typeTy channel_type; + + auto getChannelType() const { + auto &propStorage = this->channel_type; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setChannelType(const ::mlir::Attribute &propValue) { + this->channel_type = propValue; + } + using is_host_transferTy = ::mlir::Attribute; + is_host_transferTy is_host_transfer; + + auto getIsHostTransfer() const { + auto &propStorage = this->is_host_transfer; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIsHostTransfer(const ::mlir::Attribute &propValue) { + this->is_host_transfer = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_id == this->channel_id && + rhs.channel_type == this->channel_type && + rhs.is_host_transfer == this->is_host_transfer && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RecvOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.recv_v1", odsAttrs.getContext()); + } + + RecvOpV1GenericAdaptorBase(RecvOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getChannelIdAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + return attr; + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getChannelTypeAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().channel_type); + return attr; + } + + ::mlir::Attribute getChannelType(); + ::mlir::Attribute getIsHostTransferAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().is_host_transfer); + return attr; + } + + ::mlir::Attribute getIsHostTransfer(); +}; +} // namespace detail +template +class RecvOpV1GenericAdaptor : public detail::RecvOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RecvOpV1GenericAdaptorBase; +public: + RecvOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RecvOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RecvOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RecvOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RecvOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + RecvOpV1GenericAdaptor(RangeT values, const RecvOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RecvOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getToken() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RecvOpV1Adaptor : public RecvOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using RecvOpV1GenericAdaptor::RecvOpV1GenericAdaptor; + RecvOpV1Adaptor(RecvOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RecvOpV1 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = RecvOpV1Adaptor; + template + using GenericAdaptor = RecvOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_id"), ::llvm::StringRef("channel_type"), ::llvm::StringRef("is_host_transfer")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelIdAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelIdAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getChannelTypeAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getChannelTypeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getIsHostTransferAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getIsHostTransferAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.recv_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getToken() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getTokenMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getChannelIdAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getChannelTypeAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().channel_type); + } + + ::mlir::Attribute getChannelType(); + ::mlir::Attribute getIsHostTransferAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().is_host_transfer); + } + + ::mlir::Attribute getIsHostTransfer(); + void setChannelIdAttr(::mlir::Attribute attr) { + getProperties().channel_id = attr; + } + + void setChannelTypeAttr(::mlir::Attribute attr) { + getProperties().channel_type = attr; + } + + void setIsHostTransferAttr(::mlir::Attribute attr) { + getProperties().is_host_transfer = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value token, ::mlir::Attribute channel_id, ::mlir::Attribute channel_type, ::mlir::Attribute is_host_transfer); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::RecvOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReduceOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReduceOpV1GenericAdaptorBase { +public: + struct Properties { + using dimensionsTy = ::mlir::Attribute; + dimensionsTy dimensions; + + auto getDimensions() const { + auto &propStorage = this->dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setDimensions(const ::mlir::Attribute &propValue) { + this->dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimensions == this->dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReduceOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.reduce_v1", odsAttrs.getContext()); + } + + ReduceOpV1GenericAdaptorBase(ReduceOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().dimensions); + return attr; + } + + ::mlir::Attribute getDimensions(); + ::mlir::Region &getBody() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class ReduceOpV1GenericAdaptor : public detail::ReduceOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReduceOpV1GenericAdaptorBase; +public: + ReduceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReduceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReduceOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReduceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReduceOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ReduceOpV1GenericAdaptor(RangeT values, const ReduceOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReduceOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getInitValues() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReduceOpV1Adaptor : public ReduceOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ReduceOpV1GenericAdaptor::ReduceOpV1GenericAdaptor; + ReduceOpV1Adaptor(ReduceOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReduceOpV1 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = ReduceOpV1Adaptor; + template + using GenericAdaptor = ReduceOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.reduce_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::Operation::operand_range getInitValues() { + return getODSOperands(1); + } + + ::mlir::MutableOperandRange getInputsMutable(); + ::mlir::MutableOperandRange getInitValuesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + ::mlir::Region &getBody() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().dimensions); + } + + ::mlir::Attribute getDimensions(); + void setDimensionsAttr(::mlir::Attribute attr) { + getProperties().dimensions = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::mlir::Attribute dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); + mlir::LogicalResult validateConstraint(mlir::Operation*op, mlir::vhlo::Version targetVersion); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReduceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReducePrecisionOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReducePrecisionOpV1GenericAdaptorBase { +public: + struct Properties { + using exponent_bitsTy = ::mlir::Attribute; + exponent_bitsTy exponent_bits; + + auto getExponentBits() const { + auto &propStorage = this->exponent_bits; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setExponentBits(const ::mlir::Attribute &propValue) { + this->exponent_bits = propValue; + } + using mantissa_bitsTy = ::mlir::Attribute; + mantissa_bitsTy mantissa_bits; + + auto getMantissaBits() const { + auto &propStorage = this->mantissa_bits; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setMantissaBits(const ::mlir::Attribute &propValue) { + this->mantissa_bits = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.exponent_bits == this->exponent_bits && + rhs.mantissa_bits == this->mantissa_bits && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReducePrecisionOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.reduce_precision_v1", odsAttrs.getContext()); + } + + ReducePrecisionOpV1GenericAdaptorBase(ReducePrecisionOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getExponentBitsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().exponent_bits); + return attr; + } + + ::mlir::Attribute getExponentBits(); + ::mlir::Attribute getMantissaBitsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().mantissa_bits); + return attr; + } + + ::mlir::Attribute getMantissaBits(); +}; +} // namespace detail +template +class ReducePrecisionOpV1GenericAdaptor : public detail::ReducePrecisionOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReducePrecisionOpV1GenericAdaptorBase; +public: + ReducePrecisionOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReducePrecisionOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReducePrecisionOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReducePrecisionOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReducePrecisionOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ReducePrecisionOpV1GenericAdaptor(RangeT values, const ReducePrecisionOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReducePrecisionOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReducePrecisionOpV1Adaptor : public ReducePrecisionOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ReducePrecisionOpV1GenericAdaptor::ReducePrecisionOpV1GenericAdaptor; + ReducePrecisionOpV1Adaptor(ReducePrecisionOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReducePrecisionOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReducePrecisionOpV1Adaptor; + template + using GenericAdaptor = ReducePrecisionOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("exponent_bits"), ::llvm::StringRef("mantissa_bits")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getExponentBitsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getExponentBitsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getMantissaBitsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getMantissaBitsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.reduce_precision_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getExponentBitsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().exponent_bits); + } + + ::mlir::Attribute getExponentBits(); + ::mlir::Attribute getMantissaBitsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().mantissa_bits); + } + + ::mlir::Attribute getMantissaBits(); + void setExponentBitsAttr(::mlir::Attribute attr) { + getProperties().exponent_bits = attr; + } + + void setMantissaBitsAttr(::mlir::Attribute attr) { + getProperties().mantissa_bits = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value operand, ::mlir::Attribute exponent_bits, ::mlir::Attribute mantissa_bits); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute exponent_bits, ::mlir::Attribute mantissa_bits); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReducePrecisionOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReduceScatterOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReduceScatterOpV1GenericAdaptorBase { +public: + struct Properties { + using channel_idTy = ::mlir::Attribute; + channel_idTy channel_id; + + auto getChannelId() const { + auto &propStorage = this->channel_id; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setChannelId(const ::mlir::Attribute &propValue) { + this->channel_id = propValue; + } + using replica_groupsTy = ::mlir::Attribute; + replica_groupsTy replica_groups; + + auto getReplicaGroups() const { + auto &propStorage = this->replica_groups; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setReplicaGroups(const ::mlir::Attribute &propValue) { + this->replica_groups = propValue; + } + using scatter_dimensionTy = ::mlir::Attribute; + scatter_dimensionTy scatter_dimension; + + auto getScatterDimension() const { + auto &propStorage = this->scatter_dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setScatterDimension(const ::mlir::Attribute &propValue) { + this->scatter_dimension = propValue; + } + using use_global_device_idsTy = ::mlir::Attribute; + use_global_device_idsTy use_global_device_ids; + + auto getUseGlobalDeviceIds() const { + auto &propStorage = this->use_global_device_ids; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setUseGlobalDeviceIds(const ::mlir::Attribute &propValue) { + this->use_global_device_ids = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_id == this->channel_id && + rhs.replica_groups == this->replica_groups && + rhs.scatter_dimension == this->scatter_dimension && + rhs.use_global_device_ids == this->use_global_device_ids && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReduceScatterOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.reduce_scatter_v1", odsAttrs.getContext()); + } + + ReduceScatterOpV1GenericAdaptorBase(ReduceScatterOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getScatterDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().scatter_dimension); + return attr; + } + + ::mlir::Attribute getScatterDimension(); + ::mlir::Attribute getReplicaGroupsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + return attr; + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + return attr; + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getUseGlobalDeviceIdsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().use_global_device_ids); + return attr; + } + + ::mlir::Attribute getUseGlobalDeviceIds(); + ::mlir::Region &getComputation() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class ReduceScatterOpV1GenericAdaptor : public detail::ReduceScatterOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReduceScatterOpV1GenericAdaptorBase; +public: + ReduceScatterOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReduceScatterOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReduceScatterOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReduceScatterOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReduceScatterOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ReduceScatterOpV1GenericAdaptor(RangeT values, const ReduceScatterOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReduceScatterOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReduceScatterOpV1Adaptor : public ReduceScatterOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ReduceScatterOpV1GenericAdaptor::ReduceScatterOpV1GenericAdaptor; + ReduceScatterOpV1Adaptor(ReduceScatterOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReduceScatterOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait, ::mlir::vhlo::VersionedOpConstraintInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReduceScatterOpV1Adaptor; + template + using GenericAdaptor = ReduceScatterOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_id"), ::llvm::StringRef("replica_groups"), ::llvm::StringRef("scatter_dimension"), ::llvm::StringRef("use_global_device_ids")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelIdAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelIdAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getReplicaGroupsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getReplicaGroupsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getScatterDimensionAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getScatterDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getUseGlobalDeviceIdsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getUseGlobalDeviceIdsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.reduce_scatter_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + ::mlir::Region &getComputation() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getScatterDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().scatter_dimension); + } + + ::mlir::Attribute getScatterDimension(); + ::mlir::Attribute getReplicaGroupsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().replica_groups); + } + + ::mlir::Attribute getReplicaGroups(); + ::mlir::Attribute getChannelIdAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getUseGlobalDeviceIdsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().use_global_device_ids); + } + + ::mlir::Attribute getUseGlobalDeviceIds(); + void setScatterDimensionAttr(::mlir::Attribute attr) { + getProperties().scatter_dimension = attr; + } + + void setReplicaGroupsAttr(::mlir::Attribute attr) { + getProperties().replica_groups = attr; + } + + void setChannelIdAttr(::mlir::Attribute attr) { + getProperties().channel_id = attr; + } + + void setUseGlobalDeviceIdsAttr(::mlir::Attribute attr) { + getProperties().use_global_device_ids = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute scatter_dimension, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute scatter_dimension, ::mlir::Attribute replica_groups, ::mlir::Attribute channel_id, ::mlir::Attribute use_global_device_ids); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); + mlir::LogicalResult validateConstraint(mlir::Operation*op, mlir::vhlo::Version targetVersion); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 4 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReduceScatterOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReduceWindowOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReduceWindowOpV1GenericAdaptorBase { +public: + struct Properties { + using base_dilationsTy = ::mlir::Attribute; + base_dilationsTy base_dilations; + + auto getBaseDilations() const { + auto &propStorage = this->base_dilations; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setBaseDilations(const ::mlir::Attribute &propValue) { + this->base_dilations = propValue; + } + using paddingTy = ::mlir::Attribute; + paddingTy padding; + + auto getPadding() const { + auto &propStorage = this->padding; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setPadding(const ::mlir::Attribute &propValue) { + this->padding = propValue; + } + using window_dilationsTy = ::mlir::Attribute; + window_dilationsTy window_dilations; + + auto getWindowDilations() const { + auto &propStorage = this->window_dilations; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setWindowDilations(const ::mlir::Attribute &propValue) { + this->window_dilations = propValue; + } + using window_dimensionsTy = ::mlir::Attribute; + window_dimensionsTy window_dimensions; + + auto getWindowDimensions() const { + auto &propStorage = this->window_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setWindowDimensions(const ::mlir::Attribute &propValue) { + this->window_dimensions = propValue; + } + using window_stridesTy = ::mlir::Attribute; + window_stridesTy window_strides; + + auto getWindowStrides() const { + auto &propStorage = this->window_strides; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setWindowStrides(const ::mlir::Attribute &propValue) { + this->window_strides = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.base_dilations == this->base_dilations && + rhs.padding == this->padding && + rhs.window_dilations == this->window_dilations && + rhs.window_dimensions == this->window_dimensions && + rhs.window_strides == this->window_strides && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReduceWindowOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.reduce_window_v1", odsAttrs.getContext()); + } + + ReduceWindowOpV1GenericAdaptorBase(ReduceWindowOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getWindowDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().window_dimensions); + return attr; + } + + ::mlir::Attribute getWindowDimensions(); + ::mlir::Attribute getWindowStridesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().window_strides); + return attr; + } + + ::mlir::Attribute getWindowStrides(); + ::mlir::Attribute getBaseDilationsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().base_dilations); + return attr; + } + + ::mlir::Attribute getBaseDilations(); + ::mlir::Attribute getWindowDilationsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().window_dilations); + return attr; + } + + ::mlir::Attribute getWindowDilations(); + ::mlir::Attribute getPaddingAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().padding); + return attr; + } + + ::mlir::Attribute getPadding(); + ::mlir::Region &getBody() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class ReduceWindowOpV1GenericAdaptor : public detail::ReduceWindowOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReduceWindowOpV1GenericAdaptorBase; +public: + ReduceWindowOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReduceWindowOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReduceWindowOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReduceWindowOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReduceWindowOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ReduceWindowOpV1GenericAdaptor(RangeT values, const ReduceWindowOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReduceWindowOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getInitValues() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReduceWindowOpV1Adaptor : public ReduceWindowOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ReduceWindowOpV1GenericAdaptor::ReduceWindowOpV1GenericAdaptor; + ReduceWindowOpV1Adaptor(ReduceWindowOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReduceWindowOpV1 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = ReduceWindowOpV1Adaptor; + template + using GenericAdaptor = ReduceWindowOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("base_dilations"), ::llvm::StringRef("padding"), ::llvm::StringRef("window_dilations"), ::llvm::StringRef("window_dimensions"), ::llvm::StringRef("window_strides")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBaseDilationsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBaseDilationsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getPaddingAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getPaddingAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getWindowDilationsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getWindowDilationsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getWindowDimensionsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getWindowDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getWindowStridesAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getWindowStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.reduce_window_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::Operation::operand_range getInitValues() { + return getODSOperands(1); + } + + ::mlir::MutableOperandRange getInputsMutable(); + ::mlir::MutableOperandRange getInitValuesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + ::mlir::Region &getBody() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getWindowDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().window_dimensions); + } + + ::mlir::Attribute getWindowDimensions(); + ::mlir::Attribute getWindowStridesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().window_strides); + } + + ::mlir::Attribute getWindowStrides(); + ::mlir::Attribute getBaseDilationsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().base_dilations); + } + + ::mlir::Attribute getBaseDilations(); + ::mlir::Attribute getWindowDilationsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().window_dilations); + } + + ::mlir::Attribute getWindowDilations(); + ::mlir::Attribute getPaddingAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().padding); + } + + ::mlir::Attribute getPadding(); + void setWindowDimensionsAttr(::mlir::Attribute attr) { + getProperties().window_dimensions = attr; + } + + void setWindowStridesAttr(::mlir::Attribute attr) { + getProperties().window_strides = attr; + } + + void setBaseDilationsAttr(::mlir::Attribute attr) { + getProperties().base_dilations = attr; + } + + void setWindowDilationsAttr(::mlir::Attribute attr) { + getProperties().window_dilations = attr; + } + + void setPaddingAttr(::mlir::Attribute attr) { + getProperties().padding = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::ValueRange init_values, ::mlir::Attribute window_dimensions, ::mlir::Attribute window_strides, ::mlir::Attribute base_dilations, ::mlir::Attribute window_dilations, ::mlir::Attribute padding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); + mlir::LogicalResult validateConstraint(mlir::Operation*op, mlir::vhlo::Version targetVersion); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 5 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReduceWindowOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RemOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RemOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RemOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.remainder_v1", odsAttrs.getContext()); + } + + RemOpV1GenericAdaptorBase(RemOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class RemOpV1GenericAdaptor : public detail::RemOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RemOpV1GenericAdaptorBase; +public: + RemOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RemOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RemOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RemOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RemOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + RemOpV1GenericAdaptor(RangeT values, const RemOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RemOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RemOpV1Adaptor : public RemOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using RemOpV1GenericAdaptor::RemOpV1GenericAdaptor; + RemOpV1Adaptor(RemOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RemOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RemOpV1Adaptor; + template + using GenericAdaptor = RemOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.remainder_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::RemOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReplicaIdOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReplicaIdOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReplicaIdOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.replica_id_v1", odsAttrs.getContext()); + } + + ReplicaIdOpV1GenericAdaptorBase(ReplicaIdOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ReplicaIdOpV1GenericAdaptor : public detail::ReplicaIdOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReplicaIdOpV1GenericAdaptorBase; +public: + ReplicaIdOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReplicaIdOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReplicaIdOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReplicaIdOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReplicaIdOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ReplicaIdOpV1GenericAdaptor(RangeT values, const ReplicaIdOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReplicaIdOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReplicaIdOpV1Adaptor : public ReplicaIdOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ReplicaIdOpV1GenericAdaptor::ReplicaIdOpV1GenericAdaptor; + ReplicaIdOpV1Adaptor(ReplicaIdOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReplicaIdOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReplicaIdOpV1Adaptor; + template + using GenericAdaptor = ReplicaIdOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.replica_id_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReplicaIdOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReshapeOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReshapeOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReshapeOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.reshape_v1", odsAttrs.getContext()); + } + + ReshapeOpV1GenericAdaptorBase(ReshapeOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ReshapeOpV1GenericAdaptor : public detail::ReshapeOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReshapeOpV1GenericAdaptorBase; +public: + ReshapeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReshapeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReshapeOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReshapeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReshapeOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ReshapeOpV1GenericAdaptor(RangeT values, const ReshapeOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReshapeOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReshapeOpV1Adaptor : public ReshapeOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ReshapeOpV1GenericAdaptor::ReshapeOpV1GenericAdaptor; + ReshapeOpV1Adaptor(ReshapeOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReshapeOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReshapeOpV1Adaptor; + template + using GenericAdaptor = ReshapeOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.reshape_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReshapeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReturnOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReturnOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReturnOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.return_v1", odsAttrs.getContext()); + } + + ReturnOpV1GenericAdaptorBase(ReturnOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ReturnOpV1GenericAdaptor : public detail::ReturnOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReturnOpV1GenericAdaptorBase; +public: + ReturnOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReturnOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReturnOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReturnOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReturnOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ReturnOpV1GenericAdaptor(RangeT values, const ReturnOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReturnOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getResults() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReturnOpV1Adaptor : public ReturnOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ReturnOpV1GenericAdaptor::ReturnOpV1GenericAdaptor; + ReturnOpV1Adaptor(ReturnOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReturnOpV1 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = ReturnOpV1Adaptor; + template + using GenericAdaptor = ReturnOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.return_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getResults() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getResultsMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange results); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReturnOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ReverseOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReverseOpV1GenericAdaptorBase { +public: + struct Properties { + using dimensionsTy = ::mlir::Attribute; + dimensionsTy dimensions; + + auto getDimensions() const { + auto &propStorage = this->dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setDimensions(const ::mlir::Attribute &propValue) { + this->dimensions = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimensions == this->dimensions && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReverseOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.reverse_v1", odsAttrs.getContext()); + } + + ReverseOpV1GenericAdaptorBase(ReverseOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().dimensions); + return attr; + } + + ::mlir::Attribute getDimensions(); +}; +} // namespace detail +template +class ReverseOpV1GenericAdaptor : public detail::ReverseOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReverseOpV1GenericAdaptorBase; +public: + ReverseOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReverseOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReverseOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ReverseOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ReverseOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ReverseOpV1GenericAdaptor(RangeT values, const ReverseOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ReverseOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReverseOpV1Adaptor : public ReverseOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ReverseOpV1GenericAdaptor::ReverseOpV1GenericAdaptor; + ReverseOpV1Adaptor(ReverseOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ReverseOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReverseOpV1Adaptor; + template + using GenericAdaptor = ReverseOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimensions")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.reverse_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().dimensions); + } + + ::mlir::Attribute getDimensions(); + void setDimensionsAttr(::mlir::Attribute attr) { + getProperties().dimensions = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute dimensions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute dimensions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ReverseOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RngBitGeneratorOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RngBitGeneratorOpV1GenericAdaptorBase { +public: + struct Properties { + using rng_algorithmTy = ::mlir::Attribute; + rng_algorithmTy rng_algorithm; + + auto getRngAlgorithm() const { + auto &propStorage = this->rng_algorithm; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setRngAlgorithm(const ::mlir::Attribute &propValue) { + this->rng_algorithm = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.rng_algorithm == this->rng_algorithm && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RngBitGeneratorOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.rng_bit_generator_v1", odsAttrs.getContext()); + } + + RngBitGeneratorOpV1GenericAdaptorBase(RngBitGeneratorOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getRngAlgorithmAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().rng_algorithm); + return attr; + } + + ::mlir::Attribute getRngAlgorithm(); +}; +} // namespace detail +template +class RngBitGeneratorOpV1GenericAdaptor : public detail::RngBitGeneratorOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RngBitGeneratorOpV1GenericAdaptorBase; +public: + RngBitGeneratorOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RngBitGeneratorOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RngBitGeneratorOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RngBitGeneratorOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RngBitGeneratorOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + RngBitGeneratorOpV1GenericAdaptor(RangeT values, const RngBitGeneratorOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RngBitGeneratorOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getInitialState() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RngBitGeneratorOpV1Adaptor : public RngBitGeneratorOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using RngBitGeneratorOpV1GenericAdaptor::RngBitGeneratorOpV1GenericAdaptor; + RngBitGeneratorOpV1Adaptor(RngBitGeneratorOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RngBitGeneratorOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RngBitGeneratorOpV1Adaptor; + template + using GenericAdaptor = RngBitGeneratorOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("rng_algorithm")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getRngAlgorithmAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getRngAlgorithmAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.rng_bit_generator_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getInitialState() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getInitialStateMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOutputState() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(1).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getRngAlgorithmAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().rng_algorithm); + } + + ::mlir::Attribute getRngAlgorithm(); + void setRngAlgorithmAttr(::mlir::Attribute attr) { + getProperties().rng_algorithm = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_state, ::mlir::Type output, ::mlir::Attribute rng_algorithm, ::mlir::Value initial_state); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Attribute rng_algorithm, ::mlir::Value initial_state); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::RngBitGeneratorOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RngOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RngOpV1GenericAdaptorBase { +public: + struct Properties { + using rng_distributionTy = ::mlir::Attribute; + rng_distributionTy rng_distribution; + + auto getRngDistribution() const { + auto &propStorage = this->rng_distribution; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setRngDistribution(const ::mlir::Attribute &propValue) { + this->rng_distribution = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.rng_distribution == this->rng_distribution && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RngOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.rng_v1", odsAttrs.getContext()); + } + + RngOpV1GenericAdaptorBase(RngOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getRngDistributionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().rng_distribution); + return attr; + } + + ::mlir::Attribute getRngDistribution(); +}; +} // namespace detail +template +class RngOpV1GenericAdaptor : public detail::RngOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RngOpV1GenericAdaptorBase; +public: + RngOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RngOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RngOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RngOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RngOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + RngOpV1GenericAdaptor(RangeT values, const RngOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RngOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + ValueT getB() { + return (*getODSOperands(1).begin()); + } + + ValueT getShape() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RngOpV1Adaptor : public RngOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using RngOpV1GenericAdaptor::RngOpV1GenericAdaptor; + RngOpV1Adaptor(RngOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RngOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RngOpV1Adaptor; + template + using GenericAdaptor = RngOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("rng_distribution")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getRngDistributionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getRngDistributionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.rng_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getB() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getShape() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getBMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getShapeMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getRngDistributionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().rng_distribution); + } + + ::mlir::Attribute getRngDistribution(); + void setRngDistributionAttr(::mlir::Attribute attr) { + getProperties().rng_distribution = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::Attribute rng_distribution); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value shape, ::mlir::Attribute rng_distribution); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::RngOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RoundNearestEvenOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RoundNearestEvenOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RoundNearestEvenOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.round_nearest_even_v1", odsAttrs.getContext()); + } + + RoundNearestEvenOpV1GenericAdaptorBase(RoundNearestEvenOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class RoundNearestEvenOpV1GenericAdaptor : public detail::RoundNearestEvenOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RoundNearestEvenOpV1GenericAdaptorBase; +public: + RoundNearestEvenOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RoundNearestEvenOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RoundNearestEvenOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RoundNearestEvenOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RoundNearestEvenOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + RoundNearestEvenOpV1GenericAdaptor(RangeT values, const RoundNearestEvenOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RoundNearestEvenOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RoundNearestEvenOpV1Adaptor : public RoundNearestEvenOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using RoundNearestEvenOpV1GenericAdaptor::RoundNearestEvenOpV1GenericAdaptor; + RoundNearestEvenOpV1Adaptor(RoundNearestEvenOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RoundNearestEvenOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RoundNearestEvenOpV1Adaptor; + template + using GenericAdaptor = RoundNearestEvenOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.round_nearest_even_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::RoundNearestEvenOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RoundOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RoundOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RoundOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.round_nearest_afz_v1", odsAttrs.getContext()); + } + + RoundOpV1GenericAdaptorBase(RoundOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class RoundOpV1GenericAdaptor : public detail::RoundOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RoundOpV1GenericAdaptorBase; +public: + RoundOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RoundOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RoundOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RoundOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RoundOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + RoundOpV1GenericAdaptor(RangeT values, const RoundOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RoundOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RoundOpV1Adaptor : public RoundOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using RoundOpV1GenericAdaptor::RoundOpV1GenericAdaptor; + RoundOpV1Adaptor(RoundOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RoundOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RoundOpV1Adaptor; + template + using GenericAdaptor = RoundOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.round_nearest_afz_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::RoundOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RsqrtOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RsqrtOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RsqrtOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.rsqrt_v1", odsAttrs.getContext()); + } + + RsqrtOpV1GenericAdaptorBase(RsqrtOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class RsqrtOpV1GenericAdaptor : public detail::RsqrtOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RsqrtOpV1GenericAdaptorBase; +public: + RsqrtOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RsqrtOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RsqrtOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RsqrtOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RsqrtOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + RsqrtOpV1GenericAdaptor(RangeT values, const RsqrtOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RsqrtOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RsqrtOpV1Adaptor : public RsqrtOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using RsqrtOpV1GenericAdaptor::RsqrtOpV1GenericAdaptor; + RsqrtOpV1Adaptor(RsqrtOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RsqrtOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RsqrtOpV1Adaptor; + template + using GenericAdaptor = RsqrtOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.rsqrt_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::RsqrtOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::RsqrtOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RsqrtOpV2GenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::Attribute; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResultAccuracy(const ::mlir::Attribute &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + RsqrtOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.rsqrt_v2", odsAttrs.getContext()); + } + + RsqrtOpV2GenericAdaptorBase(RsqrtOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getResultAccuracyAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + return attr; + } + + ::mlir::Attribute getResultAccuracy(); +}; +} // namespace detail +template +class RsqrtOpV2GenericAdaptor : public detail::RsqrtOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RsqrtOpV2GenericAdaptorBase; +public: + RsqrtOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RsqrtOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RsqrtOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + RsqrtOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : RsqrtOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + RsqrtOpV2GenericAdaptor(RangeT values, const RsqrtOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + RsqrtOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RsqrtOpV2Adaptor : public RsqrtOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using RsqrtOpV2GenericAdaptor::RsqrtOpV2GenericAdaptor; + RsqrtOpV2Adaptor(RsqrtOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class RsqrtOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RsqrtOpV2Adaptor; + template + using GenericAdaptor = RsqrtOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.rsqrt_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getResultAccuracyAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + } + + ::mlir::Attribute getResultAccuracy(); + void setResultAccuracyAttr(::mlir::Attribute attr) { + getProperties().result_accuracy = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::RsqrtOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ScatterOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ScatterOpV1GenericAdaptorBase { +public: + struct Properties { + using index_vector_dimTy = ::mlir::Attribute; + index_vector_dimTy index_vector_dim; + + auto getIndexVectorDim() const { + auto &propStorage = this->index_vector_dim; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIndexVectorDim(const ::mlir::Attribute &propValue) { + this->index_vector_dim = propValue; + } + using indices_are_sortedTy = ::mlir::Attribute; + indices_are_sortedTy indices_are_sorted; + + auto getIndicesAreSorted() const { + auto &propStorage = this->indices_are_sorted; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIndicesAreSorted(const ::mlir::Attribute &propValue) { + this->indices_are_sorted = propValue; + } + using inserted_window_dimsTy = ::mlir::Attribute; + inserted_window_dimsTy inserted_window_dims; + + auto getInsertedWindowDims() const { + auto &propStorage = this->inserted_window_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInsertedWindowDims(const ::mlir::Attribute &propValue) { + this->inserted_window_dims = propValue; + } + using scatter_dims_to_operand_dimsTy = ::mlir::Attribute; + scatter_dims_to_operand_dimsTy scatter_dims_to_operand_dims; + + auto getScatterDimsToOperandDims() const { + auto &propStorage = this->scatter_dims_to_operand_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setScatterDimsToOperandDims(const ::mlir::Attribute &propValue) { + this->scatter_dims_to_operand_dims = propValue; + } + using unique_indicesTy = ::mlir::Attribute; + unique_indicesTy unique_indices; + + auto getUniqueIndices() const { + auto &propStorage = this->unique_indices; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setUniqueIndices(const ::mlir::Attribute &propValue) { + this->unique_indices = propValue; + } + using update_window_dimsTy = ::mlir::Attribute; + update_window_dimsTy update_window_dims; + + auto getUpdateWindowDims() const { + auto &propStorage = this->update_window_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setUpdateWindowDims(const ::mlir::Attribute &propValue) { + this->update_window_dims = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.index_vector_dim == this->index_vector_dim && + rhs.indices_are_sorted == this->indices_are_sorted && + rhs.inserted_window_dims == this->inserted_window_dims && + rhs.scatter_dims_to_operand_dims == this->scatter_dims_to_operand_dims && + rhs.unique_indices == this->unique_indices && + rhs.update_window_dims == this->update_window_dims && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ScatterOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.scatter_v1", odsAttrs.getContext()); + } + + ScatterOpV1GenericAdaptorBase(ScatterOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getUpdateWindowDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().update_window_dims); + return attr; + } + + ::mlir::Attribute getUpdateWindowDims(); + ::mlir::Attribute getInsertedWindowDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().inserted_window_dims); + return attr; + } + + ::mlir::Attribute getInsertedWindowDims(); + ::mlir::Attribute getScatterDimsToOperandDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().scatter_dims_to_operand_dims); + return attr; + } + + ::mlir::Attribute getScatterDimsToOperandDims(); + ::mlir::Attribute getIndexVectorDimAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().index_vector_dim); + return attr; + } + + ::mlir::Attribute getIndexVectorDim(); + ::mlir::Attribute getIndicesAreSortedAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().indices_are_sorted); + return attr; + } + + ::mlir::Attribute getIndicesAreSorted(); + ::mlir::Attribute getUniqueIndicesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().unique_indices); + return attr; + } + + ::mlir::Attribute getUniqueIndices(); + ::mlir::Region &getUpdateComputation() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class ScatterOpV1GenericAdaptor : public detail::ScatterOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ScatterOpV1GenericAdaptorBase; +public: + ScatterOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ScatterOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ScatterOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ScatterOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ScatterOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ScatterOpV1GenericAdaptor(RangeT values, const ScatterOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ScatterOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + ValueT getScatterIndices() { + return (*getODSOperands(1).begin()); + } + + RangeT getUpdates() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ScatterOpV1Adaptor : public ScatterOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ScatterOpV1GenericAdaptor::ScatterOpV1GenericAdaptor; + ScatterOpV1Adaptor(ScatterOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ScatterOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait, ::mlir::vhlo::VersionedOpConstraintInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ScatterOpV1Adaptor; + template + using GenericAdaptor = ScatterOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("index_vector_dim"), ::llvm::StringRef("indices_are_sorted"), ::llvm::StringRef("inserted_window_dims"), ::llvm::StringRef("scatter_dims_to_operand_dims"), ::llvm::StringRef("unique_indices"), ::llvm::StringRef("update_window_dims")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getIndexVectorDimAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getIndexVectorDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIndicesAreSortedAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIndicesAreSortedAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getInsertedWindowDimsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getInsertedWindowDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getScatterDimsToOperandDimsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getScatterDimsToOperandDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getUniqueIndicesAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getUniqueIndicesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + ::mlir::StringAttr getUpdateWindowDimsAttrName() { + return getAttributeNameForIndex(5); + } + + static ::mlir::StringAttr getUpdateWindowDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 5); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.scatter_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::TypedValue<::mlir::Type> getScatterIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::Operation::operand_range getUpdates() { + return getODSOperands(2); + } + + ::mlir::MutableOperandRange getInputsMutable(); + ::mlir::OpOperand &getScatterIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::MutableOperandRange getUpdatesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + ::mlir::Region &getUpdateComputation() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getUpdateWindowDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().update_window_dims); + } + + ::mlir::Attribute getUpdateWindowDims(); + ::mlir::Attribute getInsertedWindowDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().inserted_window_dims); + } + + ::mlir::Attribute getInsertedWindowDims(); + ::mlir::Attribute getScatterDimsToOperandDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().scatter_dims_to_operand_dims); + } + + ::mlir::Attribute getScatterDimsToOperandDims(); + ::mlir::Attribute getIndexVectorDimAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().index_vector_dim); + } + + ::mlir::Attribute getIndexVectorDim(); + ::mlir::Attribute getIndicesAreSortedAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().indices_are_sorted); + } + + ::mlir::Attribute getIndicesAreSorted(); + ::mlir::Attribute getUniqueIndicesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().unique_indices); + } + + ::mlir::Attribute getUniqueIndices(); + void setUpdateWindowDimsAttr(::mlir::Attribute attr) { + getProperties().update_window_dims = attr; + } + + void setInsertedWindowDimsAttr(::mlir::Attribute attr) { + getProperties().inserted_window_dims = attr; + } + + void setScatterDimsToOperandDimsAttr(::mlir::Attribute attr) { + getProperties().scatter_dims_to_operand_dims = attr; + } + + void setIndexVectorDimAttr(::mlir::Attribute attr) { + getProperties().index_vector_dim = attr; + } + + void setIndicesAreSortedAttr(::mlir::Attribute attr) { + getProperties().indices_are_sorted = attr; + } + + void setUniqueIndicesAttr(::mlir::Attribute attr) { + getProperties().unique_indices = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::Value scatter_indices, ::mlir::ValueRange updates, ::mlir::Attribute update_window_dims, ::mlir::Attribute inserted_window_dims, ::mlir::Attribute scatter_dims_to_operand_dims, ::mlir::Attribute index_vector_dim, ::mlir::Attribute indices_are_sorted, ::mlir::Attribute unique_indices); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); + mlir::LogicalResult validateConstraint(mlir::Operation*op, mlir::vhlo::Version targetVersion); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 6 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ScatterOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ScatterOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ScatterOpV2GenericAdaptorBase { +public: + struct Properties { + using index_vector_dimTy = ::mlir::Attribute; + index_vector_dimTy index_vector_dim; + + auto getIndexVectorDim() const { + auto &propStorage = this->index_vector_dim; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIndexVectorDim(const ::mlir::Attribute &propValue) { + this->index_vector_dim = propValue; + } + using indices_are_sortedTy = ::mlir::Attribute; + indices_are_sortedTy indices_are_sorted; + + auto getIndicesAreSorted() const { + auto &propStorage = this->indices_are_sorted; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIndicesAreSorted(const ::mlir::Attribute &propValue) { + this->indices_are_sorted = propValue; + } + using input_batching_dimsTy = ::mlir::Attribute; + input_batching_dimsTy input_batching_dims; + + auto getInputBatchingDims() const { + auto &propStorage = this->input_batching_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInputBatchingDims(const ::mlir::Attribute &propValue) { + this->input_batching_dims = propValue; + } + using inserted_window_dimsTy = ::mlir::Attribute; + inserted_window_dimsTy inserted_window_dims; + + auto getInsertedWindowDims() const { + auto &propStorage = this->inserted_window_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setInsertedWindowDims(const ::mlir::Attribute &propValue) { + this->inserted_window_dims = propValue; + } + using scatter_dims_to_operand_dimsTy = ::mlir::Attribute; + scatter_dims_to_operand_dimsTy scatter_dims_to_operand_dims; + + auto getScatterDimsToOperandDims() const { + auto &propStorage = this->scatter_dims_to_operand_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setScatterDimsToOperandDims(const ::mlir::Attribute &propValue) { + this->scatter_dims_to_operand_dims = propValue; + } + using scatter_indices_batching_dimsTy = ::mlir::Attribute; + scatter_indices_batching_dimsTy scatter_indices_batching_dims; + + auto getScatterIndicesBatchingDims() const { + auto &propStorage = this->scatter_indices_batching_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setScatterIndicesBatchingDims(const ::mlir::Attribute &propValue) { + this->scatter_indices_batching_dims = propValue; + } + using unique_indicesTy = ::mlir::Attribute; + unique_indicesTy unique_indices; + + auto getUniqueIndices() const { + auto &propStorage = this->unique_indices; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setUniqueIndices(const ::mlir::Attribute &propValue) { + this->unique_indices = propValue; + } + using update_window_dimsTy = ::mlir::Attribute; + update_window_dimsTy update_window_dims; + + auto getUpdateWindowDims() const { + auto &propStorage = this->update_window_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setUpdateWindowDims(const ::mlir::Attribute &propValue) { + this->update_window_dims = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.index_vector_dim == this->index_vector_dim && + rhs.indices_are_sorted == this->indices_are_sorted && + rhs.input_batching_dims == this->input_batching_dims && + rhs.inserted_window_dims == this->inserted_window_dims && + rhs.scatter_dims_to_operand_dims == this->scatter_dims_to_operand_dims && + rhs.scatter_indices_batching_dims == this->scatter_indices_batching_dims && + rhs.unique_indices == this->unique_indices && + rhs.update_window_dims == this->update_window_dims && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ScatterOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.scatter_v2", odsAttrs.getContext()); + } + + ScatterOpV2GenericAdaptorBase(ScatterOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getUpdateWindowDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().update_window_dims); + return attr; + } + + ::mlir::Attribute getUpdateWindowDims(); + ::mlir::Attribute getInsertedWindowDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().inserted_window_dims); + return attr; + } + + ::mlir::Attribute getInsertedWindowDims(); + ::mlir::Attribute getInputBatchingDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().input_batching_dims); + return attr; + } + + ::mlir::Attribute getInputBatchingDims(); + ::mlir::Attribute getScatterIndicesBatchingDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().scatter_indices_batching_dims); + return attr; + } + + ::mlir::Attribute getScatterIndicesBatchingDims(); + ::mlir::Attribute getScatterDimsToOperandDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().scatter_dims_to_operand_dims); + return attr; + } + + ::mlir::Attribute getScatterDimsToOperandDims(); + ::mlir::Attribute getIndexVectorDimAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().index_vector_dim); + return attr; + } + + ::mlir::Attribute getIndexVectorDim(); + ::mlir::Attribute getIndicesAreSortedAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().indices_are_sorted); + return attr; + } + + ::mlir::Attribute getIndicesAreSorted(); + ::mlir::Attribute getUniqueIndicesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().unique_indices); + return attr; + } + + ::mlir::Attribute getUniqueIndices(); + ::mlir::Region &getUpdateComputation() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class ScatterOpV2GenericAdaptor : public detail::ScatterOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ScatterOpV2GenericAdaptorBase; +public: + ScatterOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ScatterOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ScatterOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ScatterOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ScatterOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + ScatterOpV2GenericAdaptor(RangeT values, const ScatterOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ScatterOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + ValueT getScatterIndices() { + return (*getODSOperands(1).begin()); + } + + RangeT getUpdates() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ScatterOpV2Adaptor : public ScatterOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using ScatterOpV2GenericAdaptor::ScatterOpV2GenericAdaptor; + ScatterOpV2Adaptor(ScatterOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ScatterOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ScatterOpV2Adaptor; + template + using GenericAdaptor = ScatterOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("index_vector_dim"), ::llvm::StringRef("indices_are_sorted"), ::llvm::StringRef("input_batching_dims"), ::llvm::StringRef("inserted_window_dims"), ::llvm::StringRef("scatter_dims_to_operand_dims"), ::llvm::StringRef("scatter_indices_batching_dims"), ::llvm::StringRef("unique_indices"), ::llvm::StringRef("update_window_dims")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getIndexVectorDimAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getIndexVectorDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIndicesAreSortedAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIndicesAreSortedAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getInputBatchingDimsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getInputBatchingDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getInsertedWindowDimsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getInsertedWindowDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getScatterDimsToOperandDimsAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getScatterDimsToOperandDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + ::mlir::StringAttr getScatterIndicesBatchingDimsAttrName() { + return getAttributeNameForIndex(5); + } + + static ::mlir::StringAttr getScatterIndicesBatchingDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 5); + } + + ::mlir::StringAttr getUniqueIndicesAttrName() { + return getAttributeNameForIndex(6); + } + + static ::mlir::StringAttr getUniqueIndicesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 6); + } + + ::mlir::StringAttr getUpdateWindowDimsAttrName() { + return getAttributeNameForIndex(7); + } + + static ::mlir::StringAttr getUpdateWindowDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 7); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.scatter_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::TypedValue<::mlir::Type> getScatterIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::Operation::operand_range getUpdates() { + return getODSOperands(2); + } + + ::mlir::MutableOperandRange getInputsMutable(); + ::mlir::OpOperand &getScatterIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::MutableOperandRange getUpdatesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + ::mlir::Region &getUpdateComputation() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getUpdateWindowDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().update_window_dims); + } + + ::mlir::Attribute getUpdateWindowDims(); + ::mlir::Attribute getInsertedWindowDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().inserted_window_dims); + } + + ::mlir::Attribute getInsertedWindowDims(); + ::mlir::Attribute getInputBatchingDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().input_batching_dims); + } + + ::mlir::Attribute getInputBatchingDims(); + ::mlir::Attribute getScatterIndicesBatchingDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().scatter_indices_batching_dims); + } + + ::mlir::Attribute getScatterIndicesBatchingDims(); + ::mlir::Attribute getScatterDimsToOperandDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().scatter_dims_to_operand_dims); + } + + ::mlir::Attribute getScatterDimsToOperandDims(); + ::mlir::Attribute getIndexVectorDimAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().index_vector_dim); + } + + ::mlir::Attribute getIndexVectorDim(); + ::mlir::Attribute getIndicesAreSortedAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().indices_are_sorted); + } + + ::mlir::Attribute getIndicesAreSorted(); + ::mlir::Attribute getUniqueIndicesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().unique_indices); + } + + ::mlir::Attribute getUniqueIndices(); + void setUpdateWindowDimsAttr(::mlir::Attribute attr) { + getProperties().update_window_dims = attr; + } + + void setInsertedWindowDimsAttr(::mlir::Attribute attr) { + getProperties().inserted_window_dims = attr; + } + + void setInputBatchingDimsAttr(::mlir::Attribute attr) { + getProperties().input_batching_dims = attr; + } + + void setScatterIndicesBatchingDimsAttr(::mlir::Attribute attr) { + getProperties().scatter_indices_batching_dims = attr; + } + + void setScatterDimsToOperandDimsAttr(::mlir::Attribute attr) { + getProperties().scatter_dims_to_operand_dims = attr; + } + + void setIndexVectorDimAttr(::mlir::Attribute attr) { + getProperties().index_vector_dim = attr; + } + + void setIndicesAreSortedAttr(::mlir::Attribute attr) { + getProperties().indices_are_sorted = attr; + } + + void setUniqueIndicesAttr(::mlir::Attribute attr) { + getProperties().unique_indices = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::Value scatter_indices, ::mlir::ValueRange updates, ::mlir::Attribute update_window_dims, ::mlir::Attribute inserted_window_dims, ::mlir::Attribute input_batching_dims, ::mlir::Attribute scatter_indices_batching_dims, ::mlir::Attribute scatter_dims_to_operand_dims, ::mlir::Attribute index_vector_dim, ::mlir::Attribute indices_are_sorted, ::mlir::Attribute unique_indices); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 8 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ScatterOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SelectAndScatterOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SelectAndScatterOpV1GenericAdaptorBase { +public: + struct Properties { + using paddingTy = ::mlir::Attribute; + paddingTy padding; + + auto getPadding() const { + auto &propStorage = this->padding; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setPadding(const ::mlir::Attribute &propValue) { + this->padding = propValue; + } + using window_dimensionsTy = ::mlir::Attribute; + window_dimensionsTy window_dimensions; + + auto getWindowDimensions() const { + auto &propStorage = this->window_dimensions; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setWindowDimensions(const ::mlir::Attribute &propValue) { + this->window_dimensions = propValue; + } + using window_stridesTy = ::mlir::Attribute; + window_stridesTy window_strides; + + auto getWindowStrides() const { + auto &propStorage = this->window_strides; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setWindowStrides(const ::mlir::Attribute &propValue) { + this->window_strides = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.padding == this->padding && + rhs.window_dimensions == this->window_dimensions && + rhs.window_strides == this->window_strides && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SelectAndScatterOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.select_and_scatter_v1", odsAttrs.getContext()); + } + + SelectAndScatterOpV1GenericAdaptorBase(SelectAndScatterOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getWindowDimensionsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().window_dimensions); + return attr; + } + + ::mlir::Attribute getWindowDimensions(); + ::mlir::Attribute getWindowStridesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().window_strides); + return attr; + } + + ::mlir::Attribute getWindowStrides(); + ::mlir::Attribute getPaddingAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().padding); + return attr; + } + + ::mlir::Attribute getPadding(); + ::mlir::Region &getSelect() { + return *odsRegions[0]; + } + + ::mlir::Region &getScatter() { + return *odsRegions[1]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class SelectAndScatterOpV1GenericAdaptor : public detail::SelectAndScatterOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SelectAndScatterOpV1GenericAdaptorBase; +public: + SelectAndScatterOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SelectAndScatterOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SelectAndScatterOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SelectAndScatterOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SelectAndScatterOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + SelectAndScatterOpV1GenericAdaptor(RangeT values, const SelectAndScatterOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SelectAndScatterOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getSource() { + return (*getODSOperands(1).begin()); + } + + ValueT getInitValue() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SelectAndScatterOpV1Adaptor : public SelectAndScatterOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using SelectAndScatterOpV1GenericAdaptor::SelectAndScatterOpV1GenericAdaptor; + SelectAndScatterOpV1Adaptor(SelectAndScatterOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SelectAndScatterOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::OneResult, ::mlir::OpTrait::OneTypedResult<::mlir::Type>::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait, ::mlir::vhlo::VersionedOpConstraintInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SelectAndScatterOpV1Adaptor; + template + using GenericAdaptor = SelectAndScatterOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("padding"), ::llvm::StringRef("window_dimensions"), ::llvm::StringRef("window_strides")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getPaddingAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getPaddingAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getWindowDimensionsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getWindowDimensionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getWindowStridesAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getWindowStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.select_and_scatter_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getInitValue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getSourceMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getInitValueMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + ::mlir::Region &getSelect() { + return (*this)->getRegion(0); + } + + ::mlir::Region &getScatter() { + return (*this)->getRegion(1); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getWindowDimensionsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().window_dimensions); + } + + ::mlir::Attribute getWindowDimensions(); + ::mlir::Attribute getWindowStridesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().window_strides); + } + + ::mlir::Attribute getWindowStrides(); + ::mlir::Attribute getPaddingAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().padding); + } + + ::mlir::Attribute getPadding(); + void setWindowDimensionsAttr(::mlir::Attribute attr) { + getProperties().window_dimensions = attr; + } + + void setWindowStridesAttr(::mlir::Attribute attr) { + getProperties().window_strides = attr; + } + + void setPaddingAttr(::mlir::Attribute attr) { + getProperties().padding = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value source, ::mlir::Value init_value, ::mlir::Attribute window_dimensions, ::mlir::Attribute window_strides, ::mlir::Attribute padding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value source, ::mlir::Value init_value, ::mlir::Attribute window_dimensions, ::mlir::Attribute window_strides, ::mlir::Attribute padding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); + mlir::LogicalResult validateConstraint(mlir::Operation*op, mlir::vhlo::Version targetVersion); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::SelectAndScatterOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SelectOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SelectOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SelectOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.select_v1", odsAttrs.getContext()); + } + + SelectOpV1GenericAdaptorBase(SelectOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class SelectOpV1GenericAdaptor : public detail::SelectOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SelectOpV1GenericAdaptorBase; +public: + SelectOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SelectOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SelectOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SelectOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SelectOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + SelectOpV1GenericAdaptor(RangeT values, const SelectOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SelectOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getPred() { + return (*getODSOperands(0).begin()); + } + + ValueT getOnTrue() { + return (*getODSOperands(1).begin()); + } + + ValueT getOnFalse() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SelectOpV1Adaptor : public SelectOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using SelectOpV1GenericAdaptor::SelectOpV1GenericAdaptor; + SelectOpV1Adaptor(SelectOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SelectOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SelectOpV1Adaptor; + template + using GenericAdaptor = SelectOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.select_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getPred() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getOnTrue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getOnFalse() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(2).begin()); + } + + ::mlir::OpOperand &getPredMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOnTrueMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getOnFalseMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pred, ::mlir::Value on_true, ::mlir::Value on_false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::SelectOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SendOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SendOpV1GenericAdaptorBase { +public: + struct Properties { + using channel_idTy = ::mlir::Attribute; + channel_idTy channel_id; + + auto getChannelId() const { + auto &propStorage = this->channel_id; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setChannelId(const ::mlir::Attribute &propValue) { + this->channel_id = propValue; + } + using channel_typeTy = ::mlir::Attribute; + channel_typeTy channel_type; + + auto getChannelType() const { + auto &propStorage = this->channel_type; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setChannelType(const ::mlir::Attribute &propValue) { + this->channel_type = propValue; + } + using is_host_transferTy = ::mlir::Attribute; + is_host_transferTy is_host_transfer; + + auto getIsHostTransfer() const { + auto &propStorage = this->is_host_transfer; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIsHostTransfer(const ::mlir::Attribute &propValue) { + this->is_host_transfer = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.channel_id == this->channel_id && + rhs.channel_type == this->channel_type && + rhs.is_host_transfer == this->is_host_transfer && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SendOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.send_v1", odsAttrs.getContext()); + } + + SendOpV1GenericAdaptorBase(SendOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getChannelIdAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + return attr; + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getChannelTypeAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().channel_type); + return attr; + } + + ::mlir::Attribute getChannelType(); + ::mlir::Attribute getIsHostTransferAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().is_host_transfer); + return attr; + } + + ::mlir::Attribute getIsHostTransfer(); +}; +} // namespace detail +template +class SendOpV1GenericAdaptor : public detail::SendOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SendOpV1GenericAdaptorBase; +public: + SendOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SendOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SendOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SendOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SendOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + SendOpV1GenericAdaptor(RangeT values, const SendOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SendOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + ValueT getToken() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SendOpV1Adaptor : public SendOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using SendOpV1GenericAdaptor::SendOpV1GenericAdaptor; + SendOpV1Adaptor(SendOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SendOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SendOpV1Adaptor; + template + using GenericAdaptor = SendOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("channel_id"), ::llvm::StringRef("channel_type"), ::llvm::StringRef("is_host_transfer")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getChannelIdAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getChannelIdAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getChannelTypeAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getChannelTypeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getIsHostTransferAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getIsHostTransferAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.send_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::TypedValue<::mlir::Type> getToken() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::MutableOperandRange getInputsMutable(); + ::mlir::OpOperand &getTokenMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getChannelIdAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().channel_id); + } + + ::mlir::Attribute getChannelId(); + ::mlir::Attribute getChannelTypeAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().channel_type); + } + + ::mlir::Attribute getChannelType(); + ::mlir::Attribute getIsHostTransferAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().is_host_transfer); + } + + ::mlir::Attribute getIsHostTransfer(); + void setChannelIdAttr(::mlir::Attribute attr) { + getProperties().channel_id = attr; + } + + void setChannelTypeAttr(::mlir::Attribute attr) { + getProperties().channel_type = attr; + } + + void setIsHostTransferAttr(::mlir::Attribute attr) { + getProperties().is_host_transfer = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::Attribute channel_id, ::mlir::Attribute channel_type, ::mlir::Attribute is_host_transfer); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::Value token, ::mlir::Attribute channel_id, ::mlir::Attribute channel_type, ::mlir::Attribute is_host_transfer); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::SendOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SetDimensionSizeOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SetDimensionSizeOpV1GenericAdaptorBase { +public: + struct Properties { + using dimensionTy = ::mlir::Attribute; + dimensionTy dimension; + + auto getDimension() const { + auto &propStorage = this->dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setDimension(const ::mlir::Attribute &propValue) { + this->dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimension == this->dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SetDimensionSizeOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.set_dimension_size_v1", odsAttrs.getContext()); + } + + SetDimensionSizeOpV1GenericAdaptorBase(SetDimensionSizeOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().dimension); + return attr; + } + + ::mlir::Attribute getDimension(); +}; +} // namespace detail +template +class SetDimensionSizeOpV1GenericAdaptor : public detail::SetDimensionSizeOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SetDimensionSizeOpV1GenericAdaptorBase; +public: + SetDimensionSizeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SetDimensionSizeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SetDimensionSizeOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SetDimensionSizeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SetDimensionSizeOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + SetDimensionSizeOpV1GenericAdaptor(RangeT values, const SetDimensionSizeOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SetDimensionSizeOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getSize() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SetDimensionSizeOpV1Adaptor : public SetDimensionSizeOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using SetDimensionSizeOpV1GenericAdaptor::SetDimensionSizeOpV1GenericAdaptor; + SetDimensionSizeOpV1Adaptor(SetDimensionSizeOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SetDimensionSizeOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SetDimensionSizeOpV1Adaptor; + template + using GenericAdaptor = SetDimensionSizeOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.set_dimension_size_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getSize() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getSizeMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().dimension); + } + + ::mlir::Attribute getDimension(); + void setDimensionAttr(::mlir::Attribute attr) { + getProperties().dimension = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value size, ::mlir::Attribute dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value size, ::mlir::Attribute dimension); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::SetDimensionSizeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ShiftLeftOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ShiftLeftOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ShiftLeftOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.shift_left_v1", odsAttrs.getContext()); + } + + ShiftLeftOpV1GenericAdaptorBase(ShiftLeftOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ShiftLeftOpV1GenericAdaptor : public detail::ShiftLeftOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ShiftLeftOpV1GenericAdaptorBase; +public: + ShiftLeftOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ShiftLeftOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ShiftLeftOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ShiftLeftOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ShiftLeftOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ShiftLeftOpV1GenericAdaptor(RangeT values, const ShiftLeftOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ShiftLeftOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ShiftLeftOpV1Adaptor : public ShiftLeftOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ShiftLeftOpV1GenericAdaptor::ShiftLeftOpV1GenericAdaptor; + ShiftLeftOpV1Adaptor(ShiftLeftOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ShiftLeftOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ShiftLeftOpV1Adaptor; + template + using GenericAdaptor = ShiftLeftOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.shift_left_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ShiftLeftOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ShiftRightArithmeticOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ShiftRightArithmeticOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ShiftRightArithmeticOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.shift_right_arithmetic_v1", odsAttrs.getContext()); + } + + ShiftRightArithmeticOpV1GenericAdaptorBase(ShiftRightArithmeticOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ShiftRightArithmeticOpV1GenericAdaptor : public detail::ShiftRightArithmeticOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ShiftRightArithmeticOpV1GenericAdaptorBase; +public: + ShiftRightArithmeticOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ShiftRightArithmeticOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ShiftRightArithmeticOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ShiftRightArithmeticOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ShiftRightArithmeticOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ShiftRightArithmeticOpV1GenericAdaptor(RangeT values, const ShiftRightArithmeticOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ShiftRightArithmeticOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ShiftRightArithmeticOpV1Adaptor : public ShiftRightArithmeticOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ShiftRightArithmeticOpV1GenericAdaptor::ShiftRightArithmeticOpV1GenericAdaptor; + ShiftRightArithmeticOpV1Adaptor(ShiftRightArithmeticOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ShiftRightArithmeticOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ShiftRightArithmeticOpV1Adaptor; + template + using GenericAdaptor = ShiftRightArithmeticOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.shift_right_arithmetic_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ShiftRightArithmeticOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::ShiftRightLogicalOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ShiftRightLogicalOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ShiftRightLogicalOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.shift_right_logical_v1", odsAttrs.getContext()); + } + + ShiftRightLogicalOpV1GenericAdaptorBase(ShiftRightLogicalOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class ShiftRightLogicalOpV1GenericAdaptor : public detail::ShiftRightLogicalOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ShiftRightLogicalOpV1GenericAdaptorBase; +public: + ShiftRightLogicalOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ShiftRightLogicalOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ShiftRightLogicalOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + ShiftRightLogicalOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : ShiftRightLogicalOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + ShiftRightLogicalOpV1GenericAdaptor(RangeT values, const ShiftRightLogicalOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + ShiftRightLogicalOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ShiftRightLogicalOpV1Adaptor : public ShiftRightLogicalOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using ShiftRightLogicalOpV1GenericAdaptor::ShiftRightLogicalOpV1GenericAdaptor; + ShiftRightLogicalOpV1Adaptor(ShiftRightLogicalOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class ShiftRightLogicalOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ShiftRightLogicalOpV1Adaptor; + template + using GenericAdaptor = ShiftRightLogicalOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.shift_right_logical_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ShiftRightLogicalOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SignOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SignOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SignOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.sign_v1", odsAttrs.getContext()); + } + + SignOpV1GenericAdaptorBase(SignOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class SignOpV1GenericAdaptor : public detail::SignOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SignOpV1GenericAdaptorBase; +public: + SignOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SignOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SignOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SignOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SignOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + SignOpV1GenericAdaptor(RangeT values, const SignOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SignOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SignOpV1Adaptor : public SignOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using SignOpV1GenericAdaptor::SignOpV1GenericAdaptor; + SignOpV1Adaptor(SignOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SignOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SignOpV1Adaptor; + template + using GenericAdaptor = SignOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.sign_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::SignOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SineOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SineOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SineOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.sine_v1", odsAttrs.getContext()); + } + + SineOpV1GenericAdaptorBase(SineOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class SineOpV1GenericAdaptor : public detail::SineOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SineOpV1GenericAdaptorBase; +public: + SineOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SineOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SineOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SineOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SineOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + SineOpV1GenericAdaptor(RangeT values, const SineOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SineOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SineOpV1Adaptor : public SineOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using SineOpV1GenericAdaptor::SineOpV1GenericAdaptor; + SineOpV1Adaptor(SineOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SineOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SineOpV1Adaptor; + template + using GenericAdaptor = SineOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.sine_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::SineOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SineOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SineOpV2GenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::Attribute; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResultAccuracy(const ::mlir::Attribute &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SineOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.sine_v2", odsAttrs.getContext()); + } + + SineOpV2GenericAdaptorBase(SineOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getResultAccuracyAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + return attr; + } + + ::mlir::Attribute getResultAccuracy(); +}; +} // namespace detail +template +class SineOpV2GenericAdaptor : public detail::SineOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SineOpV2GenericAdaptorBase; +public: + SineOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SineOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SineOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SineOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SineOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + SineOpV2GenericAdaptor(RangeT values, const SineOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SineOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SineOpV2Adaptor : public SineOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using SineOpV2GenericAdaptor::SineOpV2GenericAdaptor; + SineOpV2Adaptor(SineOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SineOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SineOpV2Adaptor; + template + using GenericAdaptor = SineOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.sine_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getResultAccuracyAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + } + + ::mlir::Attribute getResultAccuracy(); + void setResultAccuracyAttr(::mlir::Attribute attr) { + getProperties().result_accuracy = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::SineOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SliceOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SliceOpV1GenericAdaptorBase { +public: + struct Properties { + using limit_indicesTy = ::mlir::Attribute; + limit_indicesTy limit_indices; + + auto getLimitIndices() const { + auto &propStorage = this->limit_indices; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLimitIndices(const ::mlir::Attribute &propValue) { + this->limit_indices = propValue; + } + using start_indicesTy = ::mlir::Attribute; + start_indicesTy start_indices; + + auto getStartIndices() const { + auto &propStorage = this->start_indices; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setStartIndices(const ::mlir::Attribute &propValue) { + this->start_indices = propValue; + } + using stridesTy = ::mlir::Attribute; + stridesTy strides; + + auto getStrides() const { + auto &propStorage = this->strides; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setStrides(const ::mlir::Attribute &propValue) { + this->strides = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.limit_indices == this->limit_indices && + rhs.start_indices == this->start_indices && + rhs.strides == this->strides && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SliceOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.slice_v1", odsAttrs.getContext()); + } + + SliceOpV1GenericAdaptorBase(SliceOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getStartIndicesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().start_indices); + return attr; + } + + ::mlir::Attribute getStartIndices(); + ::mlir::Attribute getLimitIndicesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().limit_indices); + return attr; + } + + ::mlir::Attribute getLimitIndices(); + ::mlir::Attribute getStridesAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().strides); + return attr; + } + + ::mlir::Attribute getStrides(); +}; +} // namespace detail +template +class SliceOpV1GenericAdaptor : public detail::SliceOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SliceOpV1GenericAdaptorBase; +public: + SliceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SliceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SliceOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SliceOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SliceOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + SliceOpV1GenericAdaptor(RangeT values, const SliceOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SliceOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SliceOpV1Adaptor : public SliceOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using SliceOpV1GenericAdaptor::SliceOpV1GenericAdaptor; + SliceOpV1Adaptor(SliceOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SliceOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SliceOpV1Adaptor; + template + using GenericAdaptor = SliceOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("limit_indices"), ::llvm::StringRef("start_indices"), ::llvm::StringRef("strides")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getLimitIndicesAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getLimitIndicesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getStartIndicesAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getStartIndicesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getStridesAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.slice_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getStartIndicesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().start_indices); + } + + ::mlir::Attribute getStartIndices(); + ::mlir::Attribute getLimitIndicesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().limit_indices); + } + + ::mlir::Attribute getLimitIndices(); + ::mlir::Attribute getStridesAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().strides); + } + + ::mlir::Attribute getStrides(); + void setStartIndicesAttr(::mlir::Attribute attr) { + getProperties().start_indices = attr; + } + + void setLimitIndicesAttr(::mlir::Attribute attr) { + getProperties().limit_indices = attr; + } + + void setStridesAttr(::mlir::Attribute attr) { + getProperties().strides = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute start_indices, ::mlir::Attribute limit_indices, ::mlir::Attribute strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute start_indices, ::mlir::Attribute limit_indices, ::mlir::Attribute strides); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::SliceOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SortOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SortOpV1GenericAdaptorBase { +public: + struct Properties { + using dimensionTy = ::mlir::Attribute; + dimensionTy dimension; + + auto getDimension() const { + auto &propStorage = this->dimension; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setDimension(const ::mlir::Attribute &propValue) { + this->dimension = propValue; + } + using is_stableTy = ::mlir::Attribute; + is_stableTy is_stable; + + auto getIsStable() const { + auto &propStorage = this->is_stable; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setIsStable(const ::mlir::Attribute &propValue) { + this->is_stable = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimension == this->dimension && + rhs.is_stable == this->is_stable && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SortOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.sort_v1", odsAttrs.getContext()); + } + + SortOpV1GenericAdaptorBase(SortOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getDimensionAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().dimension); + return attr; + } + + ::mlir::Attribute getDimension(); + ::mlir::Attribute getIsStableAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().is_stable); + return attr; + } + + ::mlir::Attribute getIsStable(); + ::mlir::Region &getComparator() { + return *odsRegions[0]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class SortOpV1GenericAdaptor : public detail::SortOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SortOpV1GenericAdaptorBase; +public: + SortOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SortOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SortOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SortOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SortOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + SortOpV1GenericAdaptor(RangeT values, const SortOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SortOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SortOpV1Adaptor : public SortOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using SortOpV1GenericAdaptor::SortOpV1GenericAdaptor; + SortOpV1Adaptor(SortOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SortOpV1 : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = SortOpV1Adaptor; + template + using GenericAdaptor = SortOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimension"), ::llvm::StringRef("is_stable")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIsStableAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIsStableAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.sort_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getInputs() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + ::mlir::Region &getComparator() { + return (*this)->getRegion(0); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getDimensionAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().dimension); + } + + ::mlir::Attribute getDimension(); + ::mlir::Attribute getIsStableAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().is_stable); + } + + ::mlir::Attribute getIsStable(); + void setDimensionAttr(::mlir::Attribute attr) { + getProperties().dimension = attr; + } + + void setIsStableAttr(::mlir::Attribute attr) { + getProperties().is_stable = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::ValueRange inputs, ::mlir::Attribute dimension, ::mlir::Attribute is_stable); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::SortOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SqrtOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SqrtOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SqrtOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.sqrt_v1", odsAttrs.getContext()); + } + + SqrtOpV1GenericAdaptorBase(SqrtOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class SqrtOpV1GenericAdaptor : public detail::SqrtOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SqrtOpV1GenericAdaptorBase; +public: + SqrtOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SqrtOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SqrtOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SqrtOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SqrtOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + SqrtOpV1GenericAdaptor(RangeT values, const SqrtOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SqrtOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SqrtOpV1Adaptor : public SqrtOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using SqrtOpV1GenericAdaptor::SqrtOpV1GenericAdaptor; + SqrtOpV1Adaptor(SqrtOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SqrtOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SqrtOpV1Adaptor; + template + using GenericAdaptor = SqrtOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.sqrt_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::SqrtOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SqrtOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SqrtOpV2GenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::Attribute; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResultAccuracy(const ::mlir::Attribute &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SqrtOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.sqrt_v2", odsAttrs.getContext()); + } + + SqrtOpV2GenericAdaptorBase(SqrtOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getResultAccuracyAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + return attr; + } + + ::mlir::Attribute getResultAccuracy(); +}; +} // namespace detail +template +class SqrtOpV2GenericAdaptor : public detail::SqrtOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SqrtOpV2GenericAdaptorBase; +public: + SqrtOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SqrtOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SqrtOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SqrtOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SqrtOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + SqrtOpV2GenericAdaptor(RangeT values, const SqrtOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SqrtOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SqrtOpV2Adaptor : public SqrtOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using SqrtOpV2GenericAdaptor::SqrtOpV2GenericAdaptor; + SqrtOpV2Adaptor(SqrtOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SqrtOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SqrtOpV2Adaptor; + template + using GenericAdaptor = SqrtOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.sqrt_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getResultAccuracyAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + } + + ::mlir::Attribute getResultAccuracy(); + void setResultAccuracyAttr(::mlir::Attribute attr) { + getProperties().result_accuracy = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::SqrtOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::SubtractOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SubtractOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SubtractOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.subtract_v1", odsAttrs.getContext()); + } + + SubtractOpV1GenericAdaptorBase(SubtractOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class SubtractOpV1GenericAdaptor : public detail::SubtractOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SubtractOpV1GenericAdaptorBase; +public: + SubtractOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SubtractOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SubtractOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + SubtractOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : SubtractOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + SubtractOpV1GenericAdaptor(RangeT values, const SubtractOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + SubtractOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SubtractOpV1Adaptor : public SubtractOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using SubtractOpV1GenericAdaptor::SubtractOpV1GenericAdaptor; + SubtractOpV1Adaptor(SubtractOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class SubtractOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SubtractOpV1Adaptor; + template + using GenericAdaptor = SubtractOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.subtract_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::SubtractOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TanOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TanOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TanOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.tan_v1", odsAttrs.getContext()); + } + + TanOpV1GenericAdaptorBase(TanOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class TanOpV1GenericAdaptor : public detail::TanOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TanOpV1GenericAdaptorBase; +public: + TanOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TanOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TanOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TanOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TanOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + TanOpV1GenericAdaptor(RangeT values, const TanOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TanOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TanOpV1Adaptor : public TanOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using TanOpV1GenericAdaptor::TanOpV1GenericAdaptor; + TanOpV1Adaptor(TanOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TanOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TanOpV1Adaptor; + template + using GenericAdaptor = TanOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.tan_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TanOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TanOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TanOpV2GenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::Attribute; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResultAccuracy(const ::mlir::Attribute &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TanOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.tan_v2", odsAttrs.getContext()); + } + + TanOpV2GenericAdaptorBase(TanOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getResultAccuracyAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + return attr; + } + + ::mlir::Attribute getResultAccuracy(); +}; +} // namespace detail +template +class TanOpV2GenericAdaptor : public detail::TanOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TanOpV2GenericAdaptorBase; +public: + TanOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TanOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TanOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TanOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TanOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + TanOpV2GenericAdaptor(RangeT values, const TanOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TanOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TanOpV2Adaptor : public TanOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using TanOpV2GenericAdaptor::TanOpV2GenericAdaptor; + TanOpV2Adaptor(TanOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TanOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TanOpV2Adaptor; + template + using GenericAdaptor = TanOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.tan_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getResultAccuracyAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + } + + ::mlir::Attribute getResultAccuracy(); + void setResultAccuracyAttr(::mlir::Attribute attr) { + getProperties().result_accuracy = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TanOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TanhOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TanhOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TanhOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.tanh_v1", odsAttrs.getContext()); + } + + TanhOpV1GenericAdaptorBase(TanhOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class TanhOpV1GenericAdaptor : public detail::TanhOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TanhOpV1GenericAdaptorBase; +public: + TanhOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TanhOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TanhOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TanhOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TanhOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + TanhOpV1GenericAdaptor(RangeT values, const TanhOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TanhOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TanhOpV1Adaptor : public TanhOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using TanhOpV1GenericAdaptor::TanhOpV1GenericAdaptor; + TanhOpV1Adaptor(TanhOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TanhOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TanhOpV1Adaptor; + template + using GenericAdaptor = TanhOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.tanh_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TanhOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TanhOpV2 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TanhOpV2GenericAdaptorBase { +public: + struct Properties { + using result_accuracyTy = ::mlir::Attribute; + result_accuracyTy result_accuracy; + + auto getResultAccuracy() const { + auto &propStorage = this->result_accuracy; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setResultAccuracy(const ::mlir::Attribute &propValue) { + this->result_accuracy = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_accuracy == this->result_accuracy && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TanhOpV2GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.tanh_v2", odsAttrs.getContext()); + } + + TanhOpV2GenericAdaptorBase(TanhOpV2 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getResultAccuracyAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + return attr; + } + + ::mlir::Attribute getResultAccuracy(); +}; +} // namespace detail +template +class TanhOpV2GenericAdaptor : public detail::TanhOpV2GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TanhOpV2GenericAdaptorBase; +public: + TanhOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TanhOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TanhOpV2GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TanhOpV2GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TanhOpV2GenericAdaptor(values, attrs, Properties{}, {}) {} + + TanhOpV2GenericAdaptor(RangeT values, const TanhOpV2GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TanhOpV2GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TanhOpV2Adaptor : public TanhOpV2GenericAdaptor<::mlir::ValueRange> { +public: + using TanhOpV2GenericAdaptor::TanhOpV2GenericAdaptor; + TanhOpV2Adaptor(TanhOpV2 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TanhOpV2 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TanhOpV2Adaptor; + template + using GenericAdaptor = TanhOpV2GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_accuracy")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultAccuracyAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultAccuracyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.tanh_v2"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getResultAccuracyAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().result_accuracy); + } + + ::mlir::Attribute getResultAccuracy(); + void setResultAccuracyAttr(::mlir::Attribute attr) { + getProperties().result_accuracy = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute result_accuracy); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TanhOpV2) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TorchIndexSelectOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TorchIndexSelectOpV1GenericAdaptorBase { +public: + struct Properties { + using batch_dimsTy = ::mlir::Attribute; + batch_dimsTy batch_dims; + + auto getBatchDims() const { + auto &propStorage = this->batch_dims; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setBatchDims(const ::mlir::Attribute &propValue) { + this->batch_dims = propValue; + } + using dimTy = ::mlir::Attribute; + dimTy dim; + + auto getDim() const { + auto &propStorage = this->dim; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setDim(const ::mlir::Attribute &propValue) { + this->dim = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.batch_dims == this->batch_dims && + rhs.dim == this->dim && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TorchIndexSelectOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.torch_index_select_v1", odsAttrs.getContext()); + } + + TorchIndexSelectOpV1GenericAdaptorBase(TorchIndexSelectOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getDimAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().dim); + return attr; + } + + ::mlir::Attribute getDim(); + ::mlir::Attribute getBatchDimsAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().batch_dims); + return attr; + } + + ::mlir::Attribute getBatchDims(); +}; +} // namespace detail +template +class TorchIndexSelectOpV1GenericAdaptor : public detail::TorchIndexSelectOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TorchIndexSelectOpV1GenericAdaptorBase; +public: + TorchIndexSelectOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TorchIndexSelectOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TorchIndexSelectOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TorchIndexSelectOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TorchIndexSelectOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + TorchIndexSelectOpV1GenericAdaptor(RangeT values, const TorchIndexSelectOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TorchIndexSelectOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getIndex() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TorchIndexSelectOpV1Adaptor : public TorchIndexSelectOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using TorchIndexSelectOpV1GenericAdaptor::TorchIndexSelectOpV1GenericAdaptor; + TorchIndexSelectOpV1Adaptor(TorchIndexSelectOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TorchIndexSelectOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TorchIndexSelectOpV1Adaptor; + template + using GenericAdaptor = TorchIndexSelectOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("batch_dims"), ::llvm::StringRef("dim")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getBatchDimsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getBatchDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getDimAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.torch_index_select_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getIndex() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getIndexMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getDimAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().dim); + } + + ::mlir::Attribute getDim(); + ::mlir::Attribute getBatchDimsAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().batch_dims); + } + + ::mlir::Attribute getBatchDims(); + void setDimAttr(::mlir::Attribute attr) { + getProperties().dim = attr; + } + + void setBatchDimsAttr(::mlir::Attribute attr) { + getProperties().batch_dims = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value index, ::mlir::Attribute dim, ::mlir::Attribute batch_dims); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value index, ::mlir::Attribute dim, ::mlir::Attribute batch_dims); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TorchIndexSelectOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TransposeOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TransposeOpV1GenericAdaptorBase { +public: + struct Properties { + using permutationTy = ::mlir::Attribute; + permutationTy permutation; + + auto getPermutation() const { + auto &propStorage = this->permutation; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setPermutation(const ::mlir::Attribute &propValue) { + this->permutation = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.permutation == this->permutation && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TransposeOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.transpose_v1", odsAttrs.getContext()); + } + + TransposeOpV1GenericAdaptorBase(TransposeOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getPermutationAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().permutation); + return attr; + } + + ::mlir::Attribute getPermutation(); +}; +} // namespace detail +template +class TransposeOpV1GenericAdaptor : public detail::TransposeOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TransposeOpV1GenericAdaptorBase; +public: + TransposeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TransposeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TransposeOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TransposeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TransposeOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + TransposeOpV1GenericAdaptor(RangeT values, const TransposeOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TransposeOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TransposeOpV1Adaptor : public TransposeOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using TransposeOpV1GenericAdaptor::TransposeOpV1GenericAdaptor; + TransposeOpV1Adaptor(TransposeOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TransposeOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TransposeOpV1Adaptor; + template + using GenericAdaptor = TransposeOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("permutation")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getPermutationAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getPermutationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.transpose_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getPermutationAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().permutation); + } + + ::mlir::Attribute getPermutation(); + void setPermutationAttr(::mlir::Attribute attr) { + getProperties().permutation = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute permutation); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute permutation); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TransposeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TriangularSolveOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TriangularSolveOpV1GenericAdaptorBase { +public: + struct Properties { + using left_sideTy = ::mlir::Attribute; + left_sideTy left_side; + + auto getLeftSide() const { + auto &propStorage = this->left_side; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLeftSide(const ::mlir::Attribute &propValue) { + this->left_side = propValue; + } + using lowerTy = ::mlir::Attribute; + lowerTy lower; + + auto getLower() const { + auto &propStorage = this->lower; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setLower(const ::mlir::Attribute &propValue) { + this->lower = propValue; + } + using transpose_aTy = ::mlir::Attribute; + transpose_aTy transpose_a; + + auto getTransposeA() const { + auto &propStorage = this->transpose_a; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setTransposeA(const ::mlir::Attribute &propValue) { + this->transpose_a = propValue; + } + using unit_diagonalTy = ::mlir::Attribute; + unit_diagonalTy unit_diagonal; + + auto getUnitDiagonal() const { + auto &propStorage = this->unit_diagonal; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setUnitDiagonal(const ::mlir::Attribute &propValue) { + this->unit_diagonal = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.left_side == this->left_side && + rhs.lower == this->lower && + rhs.transpose_a == this->transpose_a && + rhs.unit_diagonal == this->unit_diagonal && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TriangularSolveOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.triangular_solve_v1", odsAttrs.getContext()); + } + + TriangularSolveOpV1GenericAdaptorBase(TriangularSolveOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getLeftSideAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().left_side); + return attr; + } + + ::mlir::Attribute getLeftSide(); + ::mlir::Attribute getLowerAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().lower); + return attr; + } + + ::mlir::Attribute getLower(); + ::mlir::Attribute getUnitDiagonalAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().unit_diagonal); + return attr; + } + + ::mlir::Attribute getUnitDiagonal(); + ::mlir::Attribute getTransposeAAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().transpose_a); + return attr; + } + + ::mlir::Attribute getTransposeA(); +}; +} // namespace detail +template +class TriangularSolveOpV1GenericAdaptor : public detail::TriangularSolveOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TriangularSolveOpV1GenericAdaptorBase; +public: + TriangularSolveOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TriangularSolveOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TriangularSolveOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TriangularSolveOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TriangularSolveOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + TriangularSolveOpV1GenericAdaptor(RangeT values, const TriangularSolveOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TriangularSolveOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + ValueT getB() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TriangularSolveOpV1Adaptor : public TriangularSolveOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using TriangularSolveOpV1GenericAdaptor::TriangularSolveOpV1GenericAdaptor; + TriangularSolveOpV1Adaptor(TriangularSolveOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TriangularSolveOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TriangularSolveOpV1Adaptor; + template + using GenericAdaptor = TriangularSolveOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("left_side"), ::llvm::StringRef("lower"), ::llvm::StringRef("transpose_a"), ::llvm::StringRef("unit_diagonal")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getLeftSideAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getLeftSideAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getLowerAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getLowerAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getTransposeAAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getTransposeAAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getUnitDiagonalAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getUnitDiagonalAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.triangular_solve_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getB() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getBMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getLeftSideAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().left_side); + } + + ::mlir::Attribute getLeftSide(); + ::mlir::Attribute getLowerAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().lower); + } + + ::mlir::Attribute getLower(); + ::mlir::Attribute getUnitDiagonalAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().unit_diagonal); + } + + ::mlir::Attribute getUnitDiagonal(); + ::mlir::Attribute getTransposeAAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().transpose_a); + } + + ::mlir::Attribute getTransposeA(); + void setLeftSideAttr(::mlir::Attribute attr) { + getProperties().left_side = attr; + } + + void setLowerAttr(::mlir::Attribute attr) { + getProperties().lower = attr; + } + + void setUnitDiagonalAttr(::mlir::Attribute attr) { + getProperties().unit_diagonal = attr; + } + + void setTransposeAAttr(::mlir::Attribute attr) { + getProperties().transpose_a = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value a, ::mlir::Value b, ::mlir::Attribute left_side, ::mlir::Attribute lower, ::mlir::Attribute unit_diagonal, ::mlir::Attribute transpose_a); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Attribute left_side, ::mlir::Attribute lower, ::mlir::Attribute unit_diagonal, ::mlir::Attribute transpose_a); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 4 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TriangularSolveOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::TupleOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TupleOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TupleOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.tuple_v1", odsAttrs.getContext()); + } + + TupleOpV1GenericAdaptorBase(TupleOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class TupleOpV1GenericAdaptor : public detail::TupleOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TupleOpV1GenericAdaptorBase; +public: + TupleOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TupleOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TupleOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + TupleOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : TupleOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + TupleOpV1GenericAdaptor(RangeT values, const TupleOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + TupleOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getVal() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TupleOpV1Adaptor : public TupleOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using TupleOpV1GenericAdaptor::TupleOpV1GenericAdaptor; + TupleOpV1Adaptor(TupleOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class TupleOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TupleOpV1Adaptor; + template + using GenericAdaptor = TupleOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.tuple_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getVal() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getValMutable(); + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange val); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TupleOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::UnaryEinsumOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class UnaryEinsumOpV1GenericAdaptorBase { +public: + struct Properties { + using einsum_configTy = ::mlir::Attribute; + einsum_configTy einsum_config; + + auto getEinsumConfig() const { + auto &propStorage = this->einsum_config; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setEinsumConfig(const ::mlir::Attribute &propValue) { + this->einsum_config = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.einsum_config == this->einsum_config && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + UnaryEinsumOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.unary_einsum_v1", odsAttrs.getContext()); + } + + UnaryEinsumOpV1GenericAdaptorBase(UnaryEinsumOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Attribute getEinsumConfigAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().einsum_config); + return attr; + } + + ::mlir::Attribute getEinsumConfig(); +}; +} // namespace detail +template +class UnaryEinsumOpV1GenericAdaptor : public detail::UnaryEinsumOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::UnaryEinsumOpV1GenericAdaptorBase; +public: + UnaryEinsumOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + UnaryEinsumOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : UnaryEinsumOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + UnaryEinsumOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : UnaryEinsumOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + UnaryEinsumOpV1GenericAdaptor(RangeT values, const UnaryEinsumOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + UnaryEinsumOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class UnaryEinsumOpV1Adaptor : public UnaryEinsumOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using UnaryEinsumOpV1GenericAdaptor::UnaryEinsumOpV1GenericAdaptor; + UnaryEinsumOpV1Adaptor(UnaryEinsumOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class UnaryEinsumOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = UnaryEinsumOpV1Adaptor; + template + using GenericAdaptor = UnaryEinsumOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("einsum_config")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getEinsumConfigAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getEinsumConfigAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.unary_einsum_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getEinsumConfigAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().einsum_config); + } + + ::mlir::Attribute getEinsumConfig(); + void setEinsumConfigAttr(::mlir::Attribute attr) { + getProperties().einsum_config = attr; + } + + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Attribute einsum_config); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Attribute einsum_config); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + assert(name.isRegistered() && "Operation isn't registered, missing a " + "dependent dialect loading?"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::UnaryEinsumOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::UniformDequantizeOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class UniformDequantizeOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + UniformDequantizeOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.uniform_dequantize_v1", odsAttrs.getContext()); + } + + UniformDequantizeOpV1GenericAdaptorBase(UniformDequantizeOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class UniformDequantizeOpV1GenericAdaptor : public detail::UniformDequantizeOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::UniformDequantizeOpV1GenericAdaptorBase; +public: + UniformDequantizeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + UniformDequantizeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : UniformDequantizeOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + UniformDequantizeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : UniformDequantizeOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + UniformDequantizeOpV1GenericAdaptor(RangeT values, const UniformDequantizeOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + UniformDequantizeOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class UniformDequantizeOpV1Adaptor : public UniformDequantizeOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using UniformDequantizeOpV1GenericAdaptor::UniformDequantizeOpV1GenericAdaptor; + UniformDequantizeOpV1Adaptor(UniformDequantizeOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class UniformDequantizeOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = UniformDequantizeOpV1Adaptor; + template + using GenericAdaptor = UniformDequantizeOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.uniform_dequantize_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::UniformDequantizeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::UniformQuantizeOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class UniformQuantizeOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + UniformQuantizeOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.uniform_quantize_v1", odsAttrs.getContext()); + } + + UniformQuantizeOpV1GenericAdaptorBase(UniformQuantizeOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class UniformQuantizeOpV1GenericAdaptor : public detail::UniformQuantizeOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::UniformQuantizeOpV1GenericAdaptorBase; +public: + UniformQuantizeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + UniformQuantizeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : UniformQuantizeOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + UniformQuantizeOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : UniformQuantizeOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + UniformQuantizeOpV1GenericAdaptor(RangeT values, const UniformQuantizeOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + UniformQuantizeOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class UniformQuantizeOpV1Adaptor : public UniformQuantizeOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using UniformQuantizeOpV1GenericAdaptor::UniformQuantizeOpV1GenericAdaptor; + UniformQuantizeOpV1Adaptor(UniformQuantizeOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class UniformQuantizeOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = UniformQuantizeOpV1Adaptor; + template + using GenericAdaptor = UniformQuantizeOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.uniform_quantize_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getOperand() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::OpOperand &getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::UniformQuantizeOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::WhileOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class WhileOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + WhileOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.while_v1", odsAttrs.getContext()); + } + + WhileOpV1GenericAdaptorBase(WhileOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + + ::mlir::Region &getCond() { + return *odsRegions[0]; + } + + ::mlir::Region &getBody() { + return *odsRegions[1]; + } + + ::mlir::RegionRange getRegions() { + return odsRegions; + } + +}; +} // namespace detail +template +class WhileOpV1GenericAdaptor : public detail::WhileOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::WhileOpV1GenericAdaptorBase; +public: + WhileOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + WhileOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : WhileOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + WhileOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : WhileOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + WhileOpV1GenericAdaptor(RangeT values, const WhileOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + WhileOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperand() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class WhileOpV1Adaptor : public WhileOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using WhileOpV1GenericAdaptor::WhileOpV1GenericAdaptor; + WhileOpV1Adaptor(WhileOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class WhileOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = WhileOpV1Adaptor; + template + using GenericAdaptor = WhileOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.while_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::operand_range getOperand() { + return getODSOperands(0); + } + + ::mlir::MutableOperandRange getOperandMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::Operation::result_range getResults() { + return getODSResults(0); + } + + ::mlir::Region &getCond() { + return (*this)->getRegion(0); + } + + ::mlir::Region &getBody() { + return (*this)->getRegion(1); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::WhileOpV1) + +namespace mlir { +namespace vhlo { + +//===----------------------------------------------------------------------===// +// ::mlir::vhlo::XorOpV1 declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class XorOpV1GenericAdaptorBase { +public: + using Properties = ::mlir::EmptyProperties; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + XorOpV1GenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vhlo.xor_v1", odsAttrs.getContext()); + } + + XorOpV1GenericAdaptorBase(XorOpV1 op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; + } + + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes() { + return odsAttrs; + } + +}; +} // namespace detail +template +class XorOpV1GenericAdaptor : public detail::XorOpV1GenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::XorOpV1GenericAdaptorBase; +public: + XorOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + XorOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : XorOpV1GenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + XorOpV1GenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr) : XorOpV1GenericAdaptor(values, attrs, Properties{}, {}) {} + + XorOpV1GenericAdaptor(RangeT values, const XorOpV1GenericAdaptorBase &base) : Base(base), odsOperands(values) {} + + template >> + XorOpV1GenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class XorOpV1Adaptor : public XorOpV1GenericAdaptor<::mlir::ValueRange> { +public: + using XorOpV1GenericAdaptor::XorOpV1GenericAdaptor; + XorOpV1Adaptor(XorOpV1 op); + + ::llvm::LogicalResult verify(::mlir::Location loc); +}; +class XorOpV1 : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vhlo::VersionedOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = XorOpV1Adaptor; + template + using GenericAdaptor = XorOpV1GenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vhlo.xor_v1"); + } + + std::pair getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::operand_range getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(0).begin()); + } + + ::mlir::TypedValue<::mlir::Type> getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSOperands(1).begin()); + } + + ::mlir::OpOperand &getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); + } + + ::mlir::OpOperand &getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); + } + + std::pair getODSResultIndexAndLength(unsigned index) { + return {index, 1}; + } + + ::mlir::Operation::result_range getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; + } + + ::mlir::TypedValue<::mlir::Type> getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::Type>>(*getODSResults(0).begin()); + } + + static ::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes = {}); + ::llvm::LogicalResult verifyInvariantsImpl(); + ::llvm::LogicalResult verifyInvariants(); + mlir::vhlo::Version getMinVersion(); + mlir::vhlo::Version getMaxVersion(); +public: +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::XorOpV1) + + +#endif // GET_OP_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypeDefs.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypeDefs.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..61b0b6e87fc628ef352ab34036abd454a6331805 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypeDefs.cpp.inc @@ -0,0 +1,1526 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* TypeDef Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_TYPEDEF_LIST +#undef GET_TYPEDEF_LIST + +::mlir::vhlo::BooleanV1Type, +::mlir::vhlo::ComplexV1Type, +::mlir::vhlo::FloatBF16V1Type, +::mlir::vhlo::FloatF16V1Type, +::mlir::vhlo::FloatF32V1Type, +::mlir::vhlo::FloatF64V1Type, +::mlir::vhlo::FloatF4E2M1FNV1Type, +::mlir::vhlo::FloatF6E2M3FNV1Type, +::mlir::vhlo::FloatF6E3M2FNV1Type, +::mlir::vhlo::FloatF8E3M4V1Type, +::mlir::vhlo::FloatF8E4M3V1Type, +::mlir::vhlo::FloatF8E4M3FNV1Type, +::mlir::vhlo::FloatF8E5M2V1Type, +::mlir::vhlo::FloatF8E4M3FNUZV1Type, +::mlir::vhlo::FloatF8E4M3B11FNUZV1Type, +::mlir::vhlo::FloatF8E5M2FNUZV1Type, +::mlir::vhlo::FloatF8E8M0FNUV1Type, +::mlir::vhlo::FloatTF32V1Type, +::mlir::vhlo::FunctionV1Type, +::mlir::vhlo::IndexV1Type, +::mlir::vhlo::IntegerSI2V1Type, +::mlir::vhlo::IntegerSI4V1Type, +::mlir::vhlo::IntegerSI8V1Type, +::mlir::vhlo::IntegerSI16V1Type, +::mlir::vhlo::IntegerSI32V1Type, +::mlir::vhlo::IntegerSI64V1Type, +::mlir::vhlo::IntegerUI2V1Type, +::mlir::vhlo::IntegerUI4V1Type, +::mlir::vhlo::IntegerUI8V1Type, +::mlir::vhlo::IntegerUI16V1Type, +::mlir::vhlo::IntegerUI32V1Type, +::mlir::vhlo::IntegerUI64V1Type, +::mlir::vhlo::NoneV1Type, +::mlir::vhlo::RankedTensorV1Type, +::mlir::vhlo::TokenV1Type, +::mlir::vhlo::TupleV1Type, +::mlir::vhlo::UniformQuantizedV1Type, +::mlir::vhlo::UniformQuantizedPerAxisV1Type, +::mlir::vhlo::UnrankedTensorV1Type, +::mlir::vhlo::WitnessV1Type + +#endif // GET_TYPEDEF_LIST + +#ifdef GET_TYPEDEF_CLASSES +#undef GET_TYPEDEF_CLASSES + +static ::mlir::OptionalParseResult generatedTypeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type &value) { + return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser) + .Case(::mlir::vhlo::BooleanV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::BooleanV1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::ComplexV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::ComplexV1Type::parse(parser); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatBF16V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatBF16V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF16V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF16V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF32V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF32V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF64V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF64V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF4E2M1FNV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF4E2M1FNV1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF6E2M3FNV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF6E2M3FNV1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF6E3M2FNV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF6E3M2FNV1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF8E3M4V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF8E3M4V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF8E4M3V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF8E4M3V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF8E4M3FNV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF8E4M3FNV1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF8E5M2V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF8E5M2V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF8E4M3FNUZV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF8E4M3FNUZV1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF8E4M3B11FNUZV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF8E4M3B11FNUZV1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF8E5M2FNUZV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF8E5M2FNUZV1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatF8E8M0FNUV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatF8E8M0FNUV1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FloatTF32V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FloatTF32V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::FunctionV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::FunctionV1Type::parse(parser); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IndexV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IndexV1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IntegerSI2V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IntegerSI2V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IntegerSI4V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IntegerSI4V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IntegerSI8V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IntegerSI8V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IntegerSI16V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IntegerSI16V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IntegerSI32V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IntegerSI32V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IntegerSI64V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IntegerSI64V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IntegerUI2V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IntegerUI2V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IntegerUI4V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IntegerUI4V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IntegerUI8V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IntegerUI8V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IntegerUI16V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IntegerUI16V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IntegerUI32V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IntegerUI32V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::IntegerUI64V1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::IntegerUI64V1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::NoneV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::NoneV1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::RankedTensorV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::RankedTensorV1Type::parse(parser); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::TokenV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::TokenV1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::TupleV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::TupleV1Type::parse(parser); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::UniformQuantizedV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::UniformQuantizedV1Type::parse(parser); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::UniformQuantizedPerAxisV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::UniformQuantizedPerAxisV1Type::parse(parser); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::UnrankedTensorV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::UnrankedTensorV1Type::parse(parser); + return ::mlir::success(!!value); + }) + .Case(::mlir::vhlo::WitnessV1Type::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vhlo::WitnessV1Type::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Default([&](llvm::StringRef keyword, llvm::SMLoc) { + *mnemonic = keyword; + return std::nullopt; + }); +} + +static ::llvm::LogicalResult generatedTypePrinter(::mlir::Type def, ::mlir::AsmPrinter &printer) { + return ::llvm::TypeSwitch<::mlir::Type, ::llvm::LogicalResult>(def) .Case<::mlir::vhlo::BooleanV1Type>([&](auto t) { + printer << ::mlir::vhlo::BooleanV1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::ComplexV1Type>([&](auto t) { + printer << ::mlir::vhlo::ComplexV1Type::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatBF16V1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatBF16V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF16V1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF16V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF32V1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF32V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF64V1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF64V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF4E2M1FNV1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF4E2M1FNV1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF6E2M3FNV1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF6E2M3FNV1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF6E3M2FNV1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF6E3M2FNV1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF8E3M4V1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF8E3M4V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF8E4M3V1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF8E4M3V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF8E4M3FNV1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF8E4M3FNV1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF8E5M2V1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF8E5M2V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF8E4M3FNUZV1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF8E4M3FNUZV1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF8E4M3B11FNUZV1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF8E4M3B11FNUZV1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF8E5M2FNUZV1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF8E5M2FNUZV1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatF8E8M0FNUV1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatF8E8M0FNUV1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FloatTF32V1Type>([&](auto t) { + printer << ::mlir::vhlo::FloatTF32V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::FunctionV1Type>([&](auto t) { + printer << ::mlir::vhlo::FunctionV1Type::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IndexV1Type>([&](auto t) { + printer << ::mlir::vhlo::IndexV1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IntegerSI2V1Type>([&](auto t) { + printer << ::mlir::vhlo::IntegerSI2V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IntegerSI4V1Type>([&](auto t) { + printer << ::mlir::vhlo::IntegerSI4V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IntegerSI8V1Type>([&](auto t) { + printer << ::mlir::vhlo::IntegerSI8V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IntegerSI16V1Type>([&](auto t) { + printer << ::mlir::vhlo::IntegerSI16V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IntegerSI32V1Type>([&](auto t) { + printer << ::mlir::vhlo::IntegerSI32V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IntegerSI64V1Type>([&](auto t) { + printer << ::mlir::vhlo::IntegerSI64V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IntegerUI2V1Type>([&](auto t) { + printer << ::mlir::vhlo::IntegerUI2V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IntegerUI4V1Type>([&](auto t) { + printer << ::mlir::vhlo::IntegerUI4V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IntegerUI8V1Type>([&](auto t) { + printer << ::mlir::vhlo::IntegerUI8V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IntegerUI16V1Type>([&](auto t) { + printer << ::mlir::vhlo::IntegerUI16V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IntegerUI32V1Type>([&](auto t) { + printer << ::mlir::vhlo::IntegerUI32V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::IntegerUI64V1Type>([&](auto t) { + printer << ::mlir::vhlo::IntegerUI64V1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::NoneV1Type>([&](auto t) { + printer << ::mlir::vhlo::NoneV1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::RankedTensorV1Type>([&](auto t) { + printer << ::mlir::vhlo::RankedTensorV1Type::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::TokenV1Type>([&](auto t) { + printer << ::mlir::vhlo::TokenV1Type::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::TupleV1Type>([&](auto t) { + printer << ::mlir::vhlo::TupleV1Type::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::UniformQuantizedV1Type>([&](auto t) { + printer << ::mlir::vhlo::UniformQuantizedV1Type::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::UniformQuantizedPerAxisV1Type>([&](auto t) { + printer << ::mlir::vhlo::UniformQuantizedPerAxisV1Type::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::UnrankedTensorV1Type>([&](auto t) { + printer << ::mlir::vhlo::UnrankedTensorV1Type::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vhlo::WitnessV1Type>([&](auto t) { + printer << ::mlir::vhlo::WitnessV1Type::getMnemonic(); + return ::mlir::success(); + }) + .Default([](auto) { return ::mlir::failure(); }); +} + +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::BooleanV1Type) +namespace mlir { +namespace vhlo { +namespace detail { +struct ComplexV1TypeStorage : public ::mlir::TypeStorage { + using KeyTy = std::tuple; + ComplexV1TypeStorage(Type elementType) : elementType(std::move(elementType)) {} + + KeyTy getAsKey() const { + return KeyTy(elementType); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (elementType == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static ComplexV1TypeStorage *construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto elementType = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) ComplexV1TypeStorage(std::move(elementType)); + } + + Type elementType; +}; +} // namespace detail +LogicalResult ComplexV1Type::verify( + llvm::function_ref errFn, mlir::Type elementType) { + if (!isFromVhlo(elementType)) return errFn() << "expected VHLO type"; + return success(); +} +ComplexV1Type ComplexV1Type::get(::mlir::MLIRContext *context, Type elementType) { + return Base::get(context, std::move(elementType)); +} + +ComplexV1Type ComplexV1Type::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, Type elementType) { + return Base::getChecked(emitError, context, elementType); +} + +::llvm::LogicalResult ComplexV1Type::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, Type elementType) { + if (::mlir::failed(verify(emitError, elementType))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::Type ComplexV1Type::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr _result_elementType; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'elementType' + _result_elementType = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_elementType)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_ComplexV1 parameter 'elementType' which is to be a `Type`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_elementType)); + return odsParser.getChecked(odsLoc, odsParser.getContext(), + Type((*_result_elementType))); +} + +void ComplexV1Type::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter.printStrippedAttrOrType(getElementType()); + odsPrinter << ">"; +} + +Type ComplexV1Type::getElementType() const { + return getImpl()->elementType; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::ComplexV1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatBF16V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF16V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF32V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF64V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF4E2M1FNV1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF6E2M3FNV1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF6E3M2FNV1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E3M4V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E4M3V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E4M3FNV1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E5M2V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E4M3FNUZV1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E4M3B11FNUZV1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E5M2FNUZV1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E8M0FNUV1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatTF32V1Type) +namespace mlir { +namespace vhlo { +namespace detail { +struct FunctionV1TypeStorage : public ::mlir::TypeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef<::mlir::Type>, ::llvm::ArrayRef>; + FunctionV1TypeStorage(::llvm::ArrayRef<::mlir::Type> inputs, ::llvm::ArrayRef outputs) : inputs(std::move(inputs)), outputs(std::move(outputs)) {} + + KeyTy getAsKey() const { + return KeyTy(inputs, outputs); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (inputs == std::get<0>(tblgenKey)) && (outputs == std::get<1>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey)); + } + + static FunctionV1TypeStorage *construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto inputs = std::move(std::get<0>(tblgenKey)); + auto outputs = std::move(std::get<1>(tblgenKey)); + inputs = allocator.copyInto(inputs); + outputs = allocator.copyInto(outputs); + return new (allocator.allocate()) FunctionV1TypeStorage(std::move(inputs), std::move(outputs)); + } + + ::llvm::ArrayRef<::mlir::Type> inputs; + ::llvm::ArrayRef outputs; +}; +} // namespace detail +LogicalResult FunctionV1Type::verify( + llvm::function_ref errFn, + ArrayRef inputs, ArrayRef outputs) { + if (!allFromVhlo(inputs) || !allFromVhlo(outputs)) + return errFn() << "expected VHLO types"; + return success(); +} +FunctionV1Type FunctionV1Type::get(::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::Type> inputs, ::llvm::ArrayRef outputs) { + return Base::get(context, std::move(inputs), std::move(outputs)); +} + +FunctionV1Type FunctionV1Type::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::Type> inputs, ::llvm::ArrayRef outputs) { + return Base::getChecked(emitError, context, inputs, outputs); +} + +::llvm::LogicalResult FunctionV1Type::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef<::mlir::Type> inputs, ::llvm::ArrayRef outputs) { + if (::mlir::failed(verify(emitError, inputs, outputs))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::Type FunctionV1Type::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::llvm::SmallVector<::mlir::Type>> _result_inputs; + ::mlir::FailureOr<::llvm::SmallVector> _result_outputs; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + // Parse literal '(' + if (odsParser.parseLParen()) return {}; + { + auto odsCustomLoc = odsParser.getCurrentLocation(); + (void)odsCustomLoc; + auto odsCustomResult = parseTypeArray(odsParser, + ::mlir::detail::unwrapForCustomParse(_result_inputs)); + if (::mlir::failed(odsCustomResult)) return {}; + if (::mlir::failed(_result_inputs)) { + odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'inputs'"); + return {}; + } + } + // Parse literal ')' + if (odsParser.parseRParen()) return {}; + // Parse literal '->' + if (odsParser.parseArrow()) return {}; + { + auto odsCustomLoc = odsParser.getCurrentLocation(); + (void)odsCustomLoc; + auto odsCustomResult = parseTypeArray(odsParser, + ::mlir::detail::unwrapForCustomParse(_result_outputs)); + if (::mlir::failed(odsCustomResult)) return {}; + if (::mlir::failed(_result_outputs)) { + odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'outputs'"); + return {}; + } + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_inputs)); + assert(::mlir::succeeded(_result_outputs)); + return odsParser.getChecked(odsLoc, odsParser.getContext(), + ::llvm::ArrayRef<::mlir::Type>((*_result_inputs)), + ::llvm::ArrayRef((*_result_outputs))); +} + +void FunctionV1Type::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter << "("; + printTypeArray(odsPrinter, + getInputs()); + odsPrinter << ")"; + odsPrinter << ' ' << "->"; + odsPrinter << ' '; + printTypeArray(odsPrinter, + getOutputs()); + odsPrinter << ">"; +} + +::llvm::ArrayRef<::mlir::Type> FunctionV1Type::getInputs() const { + return getImpl()->inputs; +} + +::llvm::ArrayRef FunctionV1Type::getOutputs() const { + return getImpl()->outputs; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::FunctionV1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IndexV1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerSI2V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerSI4V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerSI8V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerSI16V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerSI32V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerSI64V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerUI2V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerUI4V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerUI8V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerUI16V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerUI32V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerUI64V1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::NoneV1Type) +namespace mlir { +namespace vhlo { +namespace detail { +struct RankedTensorV1TypeStorage : public ::mlir::TypeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef, ::mlir::Type, ::mlir::Attribute>; + RankedTensorV1TypeStorage(::llvm::ArrayRef shape, ::mlir::Type elementType, ::mlir::Attribute encoding) : shape(std::move(shape)), elementType(std::move(elementType)), encoding(std::move(encoding)) {} + + KeyTy getAsKey() const { + return KeyTy(shape, elementType, encoding); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (shape == std::get<0>(tblgenKey)) && (elementType == std::get<1>(tblgenKey)) && (encoding == std::get<2>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey)); + } + + static RankedTensorV1TypeStorage *construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto shape = std::move(std::get<0>(tblgenKey)); + auto elementType = std::move(std::get<1>(tblgenKey)); + auto encoding = std::move(std::get<2>(tblgenKey)); + shape = allocator.copyInto(shape); + return new (allocator.allocate()) RankedTensorV1TypeStorage(std::move(shape), std::move(elementType), std::move(encoding)); + } + + ::llvm::ArrayRef shape; + ::mlir::Type elementType; + ::mlir::Attribute encoding; +}; +} // namespace detail +LogicalResult RankedTensorV1Type::verify( + llvm::function_ref errFn, + ArrayRef shape, ::mlir::Type elementType, ::mlir::Attribute encoding) { + if (!isFromVhlo(elementType) || (encoding && !isFromVhlo(encoding))) + return errFn() << "expected VHLO type or attribute"; + return success(); +} +RankedTensorV1Type RankedTensorV1Type::get(::mlir::MLIRContext *context, ::llvm::ArrayRef shape, ::mlir::Type elementType, ::mlir::Attribute encoding) { + return Base::get(context, std::move(shape), std::move(elementType), std::move(encoding)); +} + +RankedTensorV1Type RankedTensorV1Type::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef shape, ::mlir::Type elementType, ::mlir::Attribute encoding) { + return Base::getChecked(emitError, context, shape, elementType, encoding); +} + +::llvm::LogicalResult RankedTensorV1Type::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef shape, ::mlir::Type elementType, ::mlir::Attribute encoding) { + if (::mlir::failed(verify(emitError, shape, elementType, encoding))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::Type RankedTensorV1Type::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::llvm::SmallVector> _result_shape; + ::mlir::FailureOr<::mlir::Type> _result_elementType; + ::mlir::FailureOr<::mlir::Attribute> _result_encoding; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + { + auto odsCustomLoc = odsParser.getCurrentLocation(); + (void)odsCustomLoc; + auto odsCustomResult = parseShape(odsParser, + ::mlir::detail::unwrapForCustomParse(_result_shape)); + if (::mlir::failed(odsCustomResult)) return {}; + if (::mlir::failed(_result_shape)) { + odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'shape'"); + return {}; + } + } + + // Parse variable 'elementType' + _result_elementType = ::mlir::FieldParser<::mlir::Type>::parse(odsParser); + if (::mlir::failed(_result_elementType)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_RankedTensorV1 parameter 'elementType' which is to be a `::mlir::Type`"); + return {}; + } + { + auto odsCustomLoc = odsParser.getCurrentLocation(); + (void)odsCustomLoc; + auto odsCustomResult = parseEncoding(odsParser, + ::mlir::detail::unwrapForCustomParse(_result_encoding)); + if (::mlir::failed(odsCustomResult)) return {}; + if (::mlir::failed(_result_encoding)) { + odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'encoding'"); + return {}; + } + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_shape)); + assert(::mlir::succeeded(_result_elementType)); + assert(::mlir::succeeded(_result_encoding)); + return odsParser.getChecked(odsLoc, odsParser.getContext(), + ::llvm::ArrayRef((*_result_shape)), + ::mlir::Type((*_result_elementType)), + ::mlir::Attribute((*_result_encoding))); +} + +void RankedTensorV1Type::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + printShape(odsPrinter, + getShape()); + odsPrinter.printStrippedAttrOrType(getElementType()); + printEncoding(odsPrinter, + getEncoding()); + odsPrinter << ">"; +} + +::llvm::ArrayRef RankedTensorV1Type::getShape() const { + return getImpl()->shape; +} + +::mlir::Type RankedTensorV1Type::getElementType() const { + return getImpl()->elementType; +} + +::mlir::Attribute RankedTensorV1Type::getEncoding() const { + return getImpl()->encoding; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::RankedTensorV1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TokenV1Type) +namespace mlir { +namespace vhlo { +namespace detail { +struct TupleV1TypeStorage : public ::mlir::TypeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef<::mlir::Type>>; + TupleV1TypeStorage(::llvm::ArrayRef<::mlir::Type> types) : types(std::move(types)) {} + + KeyTy getAsKey() const { + return KeyTy(types); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (types == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static TupleV1TypeStorage *construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto types = std::move(std::get<0>(tblgenKey)); + types = allocator.copyInto(types); + return new (allocator.allocate()) TupleV1TypeStorage(std::move(types)); + } + + ::llvm::ArrayRef<::mlir::Type> types; +}; +} // namespace detail +LogicalResult TupleV1Type::verify( + llvm::function_ref errFn, ArrayRef types) { + if (!allFromVhlo(types)) return errFn() << "expected VHLO types"; + return success(); +} +TupleV1Type TupleV1Type::get(::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::Type> types) { + return Base::get(context, std::move(types)); +} + +TupleV1Type TupleV1Type::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::Type> types) { + return Base::getChecked(emitError, context, types); +} + +::llvm::LogicalResult TupleV1Type::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef<::mlir::Type> types) { + if (::mlir::failed(verify(emitError, types))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::Type TupleV1Type::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::llvm::SmallVector<::mlir::Type>> _result_types; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'types' + _result_types = ::mlir::FieldParser<::llvm::SmallVector<::mlir::Type>>::parse(odsParser); + if (::mlir::failed(_result_types)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_TupleV1 parameter 'types' which is to be a `::llvm::ArrayRef<::mlir::Type>`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_types)); + return odsParser.getChecked(odsLoc, odsParser.getContext(), + ::llvm::ArrayRef<::mlir::Type>((*_result_types))); +} + +void TupleV1Type::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter.printStrippedAttrOrType(getTypes()); + odsPrinter << ">"; +} + +::llvm::ArrayRef<::mlir::Type> TupleV1Type::getTypes() const { + return getImpl()->types; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::TupleV1Type) +namespace mlir { +namespace vhlo { +namespace detail { +struct UniformQuantizedV1TypeStorage : public ::mlir::TypeStorage { + using KeyTy = std::tuple; + UniformQuantizedV1TypeStorage(unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, ::llvm::APFloat scale, int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax) : flags(std::move(flags)), storageType(std::move(storageType)), expressedType(std::move(expressedType)), scale(std::move(scale)), zeroPoint(std::move(zeroPoint)), storageTypeMin(std::move(storageTypeMin)), storageTypeMax(std::move(storageTypeMax)) {} + + KeyTy getAsKey() const { + return KeyTy(flags, storageType, expressedType, scale, zeroPoint, storageTypeMin, storageTypeMax); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (flags == std::get<0>(tblgenKey)) && (storageType == std::get<1>(tblgenKey)) && (expressedType == std::get<2>(tblgenKey)) && (scale.bitwiseIsEqual(std::get<3>(tblgenKey))) && (zeroPoint == std::get<4>(tblgenKey)) && (storageTypeMin == std::get<5>(tblgenKey)) && (storageTypeMax == std::get<6>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey), std::get<4>(tblgenKey), std::get<5>(tblgenKey), std::get<6>(tblgenKey)); + } + + static UniformQuantizedV1TypeStorage *construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto flags = std::move(std::get<0>(tblgenKey)); + auto storageType = std::move(std::get<1>(tblgenKey)); + auto expressedType = std::move(std::get<2>(tblgenKey)); + auto scale = std::move(std::get<3>(tblgenKey)); + auto zeroPoint = std::move(std::get<4>(tblgenKey)); + auto storageTypeMin = std::move(std::get<5>(tblgenKey)); + auto storageTypeMax = std::move(std::get<6>(tblgenKey)); + return new (allocator.allocate()) UniformQuantizedV1TypeStorage(std::move(flags), std::move(storageType), std::move(expressedType), std::move(scale), std::move(zeroPoint), std::move(storageTypeMin), std::move(storageTypeMax)); + } + + unsigned flags; + ::mlir::Type storageType; + ::mlir::Type expressedType; + ::llvm::APFloat scale; + int64_t zeroPoint; + int64_t storageTypeMin; + int64_t storageTypeMax; +}; +} // namespace detail +LogicalResult UniformQuantizedV1Type::verify( + llvm::function_ref errFn, + unsigned int, mlir::Type storageType, mlir::Type expressedType, + llvm::APFloat, int64_t, int64_t, int64_t) { + if (!isFromVhlo(storageType) || !isFromVhlo(expressedType)) + return errFn() << "expected VHLO type"; + return success(); +} +UniformQuantizedV1Type UniformQuantizedV1Type::get(::mlir::MLIRContext *context, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, ::llvm::APFloat scale, int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax) { + return Base::get(context, std::move(flags), std::move(storageType), std::move(expressedType), std::move(scale), std::move(zeroPoint), std::move(storageTypeMin), std::move(storageTypeMax)); +} + +UniformQuantizedV1Type UniformQuantizedV1Type::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, ::llvm::APFloat scale, int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax) { + return Base::getChecked(emitError, context, flags, storageType, expressedType, scale, zeroPoint, storageTypeMin, storageTypeMax); +} + +::llvm::LogicalResult UniformQuantizedV1Type::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, ::llvm::APFloat scale, int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax) { + if (::mlir::failed(verify(emitError, flags, storageType, expressedType, scale, zeroPoint, storageTypeMin, storageTypeMax))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::Type UniformQuantizedV1Type::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr _result_flags; + ::mlir::FailureOr<::mlir::Type> _result_storageType; + ::mlir::FailureOr<::mlir::Type> _result_expressedType; + ::mlir::FailureOr<::llvm::APFloat> _result_scale; + ::mlir::FailureOr _result_zeroPoint; + ::mlir::FailureOr _result_storageTypeMin; + ::mlir::FailureOr _result_storageTypeMax; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'storageType' + _result_storageType = ::mlir::FieldParser<::mlir::Type>::parse(odsParser); + if (::mlir::failed(_result_storageType)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedV1 parameter 'storageType' which is to be a `::mlir::Type`"); + return {}; + } + // Parse literal ':' + if (odsParser.parseColon()) return {}; + + // Parse variable 'expressedType' + _result_expressedType = ::mlir::FieldParser<::mlir::Type>::parse(odsParser); + if (::mlir::failed(_result_expressedType)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedV1 parameter 'expressedType' which is to be a `::mlir::Type`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + + // Parse variable 'scale' + _result_scale = + [&]() -> FailureOr { + double value; + if (failed(odsParser.parseFloat(value))) { + return failure(); + } + return APFloat(value); + }() + ; + if (::mlir::failed(_result_scale)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedV1 parameter 'scale' which is to be a `::llvm::APFloat`"); + return {}; + } + // Parse literal ':' + if (odsParser.parseColon()) return {}; + + // Parse variable 'zeroPoint' + _result_zeroPoint = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_zeroPoint)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedV1 parameter 'zeroPoint' which is to be a `int64_t`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + + // Parse variable 'storageTypeMin' + _result_storageTypeMin = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_storageTypeMin)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedV1 parameter 'storageTypeMin' which is to be a `int64_t`"); + return {}; + } + // Parse literal ':' + if (odsParser.parseColon()) return {}; + + // Parse variable 'storageTypeMax' + _result_storageTypeMax = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_storageTypeMax)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedV1 parameter 'storageTypeMax' which is to be a `int64_t`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + + // Parse variable 'flags' + _result_flags = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_flags)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedV1 parameter 'flags' which is to be a `unsigned`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_flags)); + assert(::mlir::succeeded(_result_storageType)); + assert(::mlir::succeeded(_result_expressedType)); + assert(::mlir::succeeded(_result_scale)); + assert(::mlir::succeeded(_result_zeroPoint)); + assert(::mlir::succeeded(_result_storageTypeMin)); + assert(::mlir::succeeded(_result_storageTypeMax)); + return odsParser.getChecked(odsLoc, odsParser.getContext(), + unsigned((*_result_flags)), + ::mlir::Type((*_result_storageType)), + ::mlir::Type((*_result_expressedType)), + ::llvm::APFloat((*_result_scale)), + int64_t((*_result_zeroPoint)), + int64_t((*_result_storageTypeMin)), + int64_t((*_result_storageTypeMax))); +} + +void UniformQuantizedV1Type::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter.printStrippedAttrOrType(getStorageType()); + odsPrinter << ":"; + odsPrinter.printStrippedAttrOrType(getExpressedType()); + odsPrinter << ","; + odsPrinter << ' '; + odsPrinter.printFloat(getScale());; + odsPrinter << ":"; + odsPrinter.printStrippedAttrOrType(getZeroPoint()); + odsPrinter << ","; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getStorageTypeMin()); + odsPrinter << ":"; + odsPrinter.printStrippedAttrOrType(getStorageTypeMax()); + odsPrinter << ","; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getFlags()); + odsPrinter << ">"; +} + +unsigned UniformQuantizedV1Type::getFlags() const { + return getImpl()->flags; +} + +::mlir::Type UniformQuantizedV1Type::getStorageType() const { + return getImpl()->storageType; +} + +::mlir::Type UniformQuantizedV1Type::getExpressedType() const { + return getImpl()->expressedType; +} + +::llvm::APFloat UniformQuantizedV1Type::getScale() const { + return getImpl()->scale; +} + +int64_t UniformQuantizedV1Type::getZeroPoint() const { + return getImpl()->zeroPoint; +} + +int64_t UniformQuantizedV1Type::getStorageTypeMin() const { + return getImpl()->storageTypeMin; +} + +int64_t UniformQuantizedV1Type::getStorageTypeMax() const { + return getImpl()->storageTypeMax; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::UniformQuantizedV1Type) +namespace mlir { +namespace vhlo { +namespace detail { +struct UniformQuantizedPerAxisV1TypeStorage : public ::mlir::TypeStorage { + using KeyTy = std::tuple, ::llvm::ArrayRef, int64_t, int64_t>; + UniformQuantizedPerAxisV1TypeStorage(unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, int32_t quantizedDimension, ::llvm::ArrayRef<::llvm::APFloat> scales, ::llvm::ArrayRef zeroPoints, int64_t storageTypeMin, int64_t storageTypeMax) : flags(std::move(flags)), storageType(std::move(storageType)), expressedType(std::move(expressedType)), quantizedDimension(std::move(quantizedDimension)), scales(std::move(scales)), zeroPoints(std::move(zeroPoints)), storageTypeMin(std::move(storageTypeMin)), storageTypeMax(std::move(storageTypeMax)) {} + + KeyTy getAsKey() const { + return KeyTy(flags, storageType, expressedType, quantizedDimension, scales, zeroPoints, storageTypeMin, storageTypeMax); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (flags == std::get<0>(tblgenKey)) && (storageType == std::get<1>(tblgenKey)) && (expressedType == std::get<2>(tblgenKey)) && (quantizedDimension == std::get<3>(tblgenKey)) && (scales == std::get<4>(tblgenKey)) && (zeroPoints == std::get<5>(tblgenKey)) && (storageTypeMin == std::get<6>(tblgenKey)) && (storageTypeMax == std::get<7>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey), std::get<4>(tblgenKey), std::get<5>(tblgenKey), std::get<6>(tblgenKey), std::get<7>(tblgenKey)); + } + + static UniformQuantizedPerAxisV1TypeStorage *construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto flags = std::move(std::get<0>(tblgenKey)); + auto storageType = std::move(std::get<1>(tblgenKey)); + auto expressedType = std::move(std::get<2>(tblgenKey)); + auto quantizedDimension = std::move(std::get<3>(tblgenKey)); + auto scales = std::move(std::get<4>(tblgenKey)); + auto zeroPoints = std::move(std::get<5>(tblgenKey)); + auto storageTypeMin = std::move(std::get<6>(tblgenKey)); + auto storageTypeMax = std::move(std::get<7>(tblgenKey)); + scales = allocator.copyInto(scales); + zeroPoints = allocator.copyInto(zeroPoints); + return new (allocator.allocate()) UniformQuantizedPerAxisV1TypeStorage(std::move(flags), std::move(storageType), std::move(expressedType), std::move(quantizedDimension), std::move(scales), std::move(zeroPoints), std::move(storageTypeMin), std::move(storageTypeMax)); + } + + unsigned flags; + ::mlir::Type storageType; + ::mlir::Type expressedType; + int32_t quantizedDimension; + ::llvm::ArrayRef<::llvm::APFloat> scales; + ::llvm::ArrayRef zeroPoints; + int64_t storageTypeMin; + int64_t storageTypeMax; +}; +} // namespace detail +LogicalResult UniformQuantizedPerAxisV1Type::verify( + llvm::function_ref errFn, + unsigned int, mlir::Type storageType, mlir::Type expressedType, + int32_t, ::llvm::ArrayRef<::llvm::APFloat>, ::llvm::ArrayRef, int64_t, int64_t) { + if (!isFromVhlo(storageType) || !isFromVhlo(expressedType)) + return errFn() << "expected VHLO type"; + return success(); +} +UniformQuantizedPerAxisV1Type UniformQuantizedPerAxisV1Type::get(::mlir::MLIRContext *context, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, int32_t quantizedDimension, ::llvm::ArrayRef<::llvm::APFloat> scales, ::llvm::ArrayRef zeroPoints, int64_t storageTypeMin, int64_t storageTypeMax) { + return Base::get(context, std::move(flags), std::move(storageType), std::move(expressedType), std::move(quantizedDimension), std::move(scales), std::move(zeroPoints), std::move(storageTypeMin), std::move(storageTypeMax)); +} + +UniformQuantizedPerAxisV1Type UniformQuantizedPerAxisV1Type::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, int32_t quantizedDimension, ::llvm::ArrayRef<::llvm::APFloat> scales, ::llvm::ArrayRef zeroPoints, int64_t storageTypeMin, int64_t storageTypeMax) { + return Base::getChecked(emitError, context, flags, storageType, expressedType, quantizedDimension, scales, zeroPoints, storageTypeMin, storageTypeMax); +} + +::llvm::LogicalResult UniformQuantizedPerAxisV1Type::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, int32_t quantizedDimension, ::llvm::ArrayRef<::llvm::APFloat> scales, ::llvm::ArrayRef zeroPoints, int64_t storageTypeMin, int64_t storageTypeMax) { + if (::mlir::failed(verify(emitError, flags, storageType, expressedType, quantizedDimension, scales, zeroPoints, storageTypeMin, storageTypeMax))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::Type UniformQuantizedPerAxisV1Type::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr _result_flags; + ::mlir::FailureOr<::mlir::Type> _result_storageType; + ::mlir::FailureOr<::mlir::Type> _result_expressedType; + ::mlir::FailureOr _result_quantizedDimension; + ::mlir::FailureOr<::llvm::SmallVector<::llvm::APFloat>> _result_scales; + ::mlir::FailureOr<::llvm::SmallVector> _result_zeroPoints; + ::mlir::FailureOr _result_storageTypeMin; + ::mlir::FailureOr _result_storageTypeMax; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'storageType' + _result_storageType = ::mlir::FieldParser<::mlir::Type>::parse(odsParser); + if (::mlir::failed(_result_storageType)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedPerAxisV1 parameter 'storageType' which is to be a `::mlir::Type`"); + return {}; + } + // Parse literal ':' + if (odsParser.parseColon()) return {}; + + // Parse variable 'expressedType' + _result_expressedType = ::mlir::FieldParser<::mlir::Type>::parse(odsParser); + if (::mlir::failed(_result_expressedType)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedPerAxisV1 parameter 'expressedType' which is to be a `::mlir::Type`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + + // Parse variable 'quantizedDimension' + _result_quantizedDimension = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_quantizedDimension)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedPerAxisV1 parameter 'quantizedDimension' which is to be a `int32_t`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + + // Parse variable 'scales' + _result_scales = + [&]() -> FailureOr> { + ::llvm::SmallVector scales; + + auto parseResult = odsParser.parseCommaSeparatedList(AsmParser::Delimiter::Square, [&]() { + return odsParser.parseFloat(scales.emplace_back()); + }); + if(failed(parseResult)) return failure(); + return llvm::map_to_vector( + scales, [](double scale) { return APFloat(scale); }); + }() + ; + if (::mlir::failed(_result_scales)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedPerAxisV1 parameter 'scales' which is to be a `::llvm::ArrayRef<::llvm::APFloat>`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + // Parse literal '[' + if (odsParser.parseLSquare()) return {}; + + // Parse variable 'zeroPoints' + _result_zeroPoints = ::mlir::FieldParser<::llvm::SmallVector>::parse(odsParser); + if (::mlir::failed(_result_zeroPoints)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedPerAxisV1 parameter 'zeroPoints' which is to be a `::llvm::ArrayRef`"); + return {}; + } + // Parse literal ']' + if (odsParser.parseRSquare()) return {}; + // Parse literal ',' + if (odsParser.parseComma()) return {}; + + // Parse variable 'storageTypeMin' + _result_storageTypeMin = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_storageTypeMin)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedPerAxisV1 parameter 'storageTypeMin' which is to be a `int64_t`"); + return {}; + } + // Parse literal ':' + if (odsParser.parseColon()) return {}; + + // Parse variable 'storageTypeMax' + _result_storageTypeMax = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_storageTypeMax)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedPerAxisV1 parameter 'storageTypeMax' which is to be a `int64_t`"); + return {}; + } + // Parse literal ',' + if (odsParser.parseComma()) return {}; + + // Parse variable 'flags' + _result_flags = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_flags)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UniformQuantizedPerAxisV1 parameter 'flags' which is to be a `unsigned`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_flags)); + assert(::mlir::succeeded(_result_storageType)); + assert(::mlir::succeeded(_result_expressedType)); + assert(::mlir::succeeded(_result_quantizedDimension)); + assert(::mlir::succeeded(_result_scales)); + assert(::mlir::succeeded(_result_zeroPoints)); + assert(::mlir::succeeded(_result_storageTypeMin)); + assert(::mlir::succeeded(_result_storageTypeMax)); + return odsParser.getChecked(odsLoc, odsParser.getContext(), + unsigned((*_result_flags)), + ::mlir::Type((*_result_storageType)), + ::mlir::Type((*_result_expressedType)), + int32_t((*_result_quantizedDimension)), + ::llvm::ArrayRef<::llvm::APFloat>((*_result_scales)), + ::llvm::ArrayRef((*_result_zeroPoints)), + int64_t((*_result_storageTypeMin)), + int64_t((*_result_storageTypeMax))); +} + +void UniformQuantizedPerAxisV1Type::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter.printStrippedAttrOrType(getStorageType()); + odsPrinter << ":"; + odsPrinter.printStrippedAttrOrType(getExpressedType()); + odsPrinter << ","; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getQuantizedDimension()); + odsPrinter << ","; + odsPrinter << ' '; + + odsPrinter << '['; + llvm::interleaveComma(getScales(), odsPrinter, [&](APFloat scale) { + odsPrinter << scale; + }); + odsPrinter << ']'; + ; + odsPrinter << ","; + odsPrinter << ' ' << "["; + odsPrinter.printStrippedAttrOrType(getZeroPoints()); + odsPrinter << "]"; + odsPrinter << ","; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getStorageTypeMin()); + odsPrinter << ":"; + odsPrinter.printStrippedAttrOrType(getStorageTypeMax()); + odsPrinter << ","; + odsPrinter << ' '; + odsPrinter.printStrippedAttrOrType(getFlags()); + odsPrinter << ">"; +} + +unsigned UniformQuantizedPerAxisV1Type::getFlags() const { + return getImpl()->flags; +} + +::mlir::Type UniformQuantizedPerAxisV1Type::getStorageType() const { + return getImpl()->storageType; +} + +::mlir::Type UniformQuantizedPerAxisV1Type::getExpressedType() const { + return getImpl()->expressedType; +} + +int32_t UniformQuantizedPerAxisV1Type::getQuantizedDimension() const { + return getImpl()->quantizedDimension; +} + +::llvm::ArrayRef<::llvm::APFloat> UniformQuantizedPerAxisV1Type::getScales() const { + return getImpl()->scales; +} + +::llvm::ArrayRef UniformQuantizedPerAxisV1Type::getZeroPoints() const { + return getImpl()->zeroPoints; +} + +int64_t UniformQuantizedPerAxisV1Type::getStorageTypeMin() const { + return getImpl()->storageTypeMin; +} + +int64_t UniformQuantizedPerAxisV1Type::getStorageTypeMax() const { + return getImpl()->storageTypeMax; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::UniformQuantizedPerAxisV1Type) +namespace mlir { +namespace vhlo { +namespace detail { +struct UnrankedTensorV1TypeStorage : public ::mlir::TypeStorage { + using KeyTy = std::tuple<::mlir::Type>; + UnrankedTensorV1TypeStorage(::mlir::Type elementType) : elementType(std::move(elementType)) {} + + KeyTy getAsKey() const { + return KeyTy(elementType); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (elementType == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static UnrankedTensorV1TypeStorage *construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto elementType = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) UnrankedTensorV1TypeStorage(std::move(elementType)); + } + + ::mlir::Type elementType; +}; +} // namespace detail +LogicalResult UnrankedTensorV1Type::verify( + llvm::function_ref errFn, mlir::Type elementType) { + if (!isFromVhlo(elementType)) return errFn() << "expected VHLO type"; + return success(); +} +UnrankedTensorV1Type UnrankedTensorV1Type::get(::mlir::MLIRContext *context, ::mlir::Type elementType) { + return Base::get(context, std::move(elementType)); +} + +UnrankedTensorV1Type UnrankedTensorV1Type::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::mlir::Type elementType) { + return Base::getChecked(emitError, context, elementType); +} + +::llvm::LogicalResult UnrankedTensorV1Type::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type elementType) { + if (::mlir::failed(verify(emitError, elementType))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::Type UnrankedTensorV1Type::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::Type> _result_elementType; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'elementType' + _result_elementType = ::mlir::FieldParser<::mlir::Type>::parse(odsParser); + if (::mlir::failed(_result_elementType)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse VHLO_UnrankedTensorV1 parameter 'elementType' which is to be a `::mlir::Type`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_elementType)); + return odsParser.getChecked(odsLoc, odsParser.getContext(), + ::mlir::Type((*_result_elementType))); +} + +void UnrankedTensorV1Type::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter.printStrippedAttrOrType(getElementType()); + odsPrinter << ">"; +} + +::mlir::Type UnrankedTensorV1Type::getElementType() const { + return getImpl()->elementType; +} + +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::UnrankedTensorV1Type) +namespace mlir { +namespace vhlo { +} // namespace vhlo +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vhlo::WitnessV1Type) + +#endif // GET_TYPEDEF_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypeDefs.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypeDefs.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..5bdbe9aac2652a1254bd11ac9e8e9e56b8b05210 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypeDefs.h.inc @@ -0,0 +1,836 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* TypeDef Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_TYPEDEF_CLASSES +#undef GET_TYPEDEF_CLASSES + + +namespace mlir { +class AsmParser; +class AsmPrinter; +} // namespace mlir +namespace mlir { +namespace vhlo { +class BooleanV1Type; +class ComplexV1Type; +class FloatBF16V1Type; +class FloatF16V1Type; +class FloatF32V1Type; +class FloatF64V1Type; +class FloatF4E2M1FNV1Type; +class FloatF6E2M3FNV1Type; +class FloatF6E3M2FNV1Type; +class FloatF8E3M4V1Type; +class FloatF8E4M3V1Type; +class FloatF8E4M3FNV1Type; +class FloatF8E5M2V1Type; +class FloatF8E4M3FNUZV1Type; +class FloatF8E4M3B11FNUZV1Type; +class FloatF8E5M2FNUZV1Type; +class FloatF8E8M0FNUV1Type; +class FloatTF32V1Type; +class FunctionV1Type; +class IndexV1Type; +class IntegerSI2V1Type; +class IntegerSI4V1Type; +class IntegerSI8V1Type; +class IntegerSI16V1Type; +class IntegerSI32V1Type; +class IntegerSI64V1Type; +class IntegerUI2V1Type; +class IntegerUI4V1Type; +class IntegerUI8V1Type; +class IntegerUI16V1Type; +class IntegerUI32V1Type; +class IntegerUI64V1Type; +class NoneV1Type; +class RankedTensorV1Type; +class TokenV1Type; +class TupleV1Type; +class UniformQuantizedV1Type; +class UniformQuantizedPerAxisV1Type; +class UnrankedTensorV1Type; +class WitnessV1Type; +class BooleanV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.bool_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"bool_v1"}; + } + +}; +namespace detail { +struct ComplexV1TypeStorage; +} // namespace detail +class ComplexV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.complex_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + using Base::getChecked; + static ComplexV1Type get(::mlir::MLIRContext *context, Type elementType); + static ComplexV1Type getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, Type elementType); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, Type elementType); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, Type elementType); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"complex_v1"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + Type getElementType() const; +}; +class FloatBF16V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.bf16_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"bf16_v1"}; + } + +}; +class FloatF16V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f16_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f16_v1"}; + } + +}; +class FloatF32V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f32_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f32_v1"}; + } + +}; +class FloatF64V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f64_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f64_v1"}; + } + +}; +class FloatF4E2M1FNV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(1, 8, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f4E2M1FN_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f4E2M1FN_v1"}; + } + +}; +class FloatF6E2M3FNV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(1, 8, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f6E2M3FN_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f6E2M3FN_v1"}; + } + +}; +class FloatF6E3M2FNV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(1, 8, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f6E3M2FN_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f6E3M2FN_v1"}; + } + +}; +class FloatF8E3M4V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(1, 7, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f8E3M4_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f8E3M4_v1"}; + } + +}; +class FloatF8E4M3V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(1, 7, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f8E4M3_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f8E4M3_v1"}; + } + +}; +class FloatF8E4M3FNV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f8E4M3FN_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f8E4M3FN_v1"}; + } + +}; +class FloatF8E5M2V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f8E5M2_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f8E5M2_v1"}; + } + +}; +class FloatF8E4M3FNUZV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 10, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f8E4M3FNUZ_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f8E4M3FNUZ_v1"}; + } + +}; +class FloatF8E4M3B11FNUZV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 11, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f8E4M3B11FNUZ_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f8E4M3B11FNUZ_v1"}; + } + +}; +class FloatF8E5M2FNUZV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 10, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f8E5M2FNUZ_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f8E5M2FNUZ_v1"}; + } + +}; +class FloatF8E8M0FNUV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(1, 8, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.f8E8M0FNU_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"f8E8M0FNU_v1"}; + } + +}; +class FloatTF32V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(1, 6, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.tf31_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"tf31_v1"}; + } + +}; +namespace detail { +struct FunctionV1TypeStorage; +} // namespace detail +class FunctionV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.func_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + using Base::getChecked; + static FunctionV1Type get(::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::Type> inputs, ::llvm::ArrayRef outputs); + static FunctionV1Type getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::Type> inputs, ::llvm::ArrayRef outputs); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef<::mlir::Type> inputs, ::llvm::ArrayRef outputs); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef<::mlir::Type> inputs, ::llvm::ArrayRef outputs); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"func_v1"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef<::mlir::Type> getInputs() const; + ::llvm::ArrayRef getOutputs() const; +}; +class IndexV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.index_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"index_v1"}; + } + +}; +class IntegerSI2V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(1, 2, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.i2_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"i2_v1"}; + } + +}; +class IntegerSI4V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.i4_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"i4_v1"}; + } + +}; +class IntegerSI8V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.i8_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"i8_v1"}; + } + +}; +class IntegerSI16V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.i16_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"i16_v1"}; + } + +}; +class IntegerSI32V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.i32_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"i32_v1"}; + } + +}; +class IntegerSI64V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.i64_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"i64_v1"}; + } + +}; +class IntegerUI2V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(1, 2, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.ui2_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"ui2_v1"}; + } + +}; +class IntegerUI4V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.ui4_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"ui4_v1"}; + } + +}; +class IntegerUI8V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.ui8_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"ui8_v1"}; + } + +}; +class IntegerUI16V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.ui16_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"ui16_v1"}; + } + +}; +class IntegerUI32V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.ui32_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"ui32_v1"}; + } + +}; +class IntegerUI64V1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.ui64_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"ui64_v1"}; + } + +}; +class NoneV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(1, 6, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.none_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"none_v1"}; + } + +}; +namespace detail { +struct RankedTensorV1TypeStorage; +} // namespace detail +class RankedTensorV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.tensor_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + using Base::getChecked; + static RankedTensorV1Type get(::mlir::MLIRContext *context, ::llvm::ArrayRef shape, ::mlir::Type elementType, ::mlir::Attribute encoding); + static RankedTensorV1Type getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef shape, ::mlir::Type elementType, ::mlir::Attribute encoding); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef shape, ::mlir::Type elementType, ::mlir::Attribute encoding); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef shape, ::mlir::Type elementType, ::mlir::Attribute encoding); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"tensor_v1"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef getShape() const; + ::mlir::Type getElementType() const; + ::mlir::Attribute getEncoding() const; +}; +class TokenV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.token_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"token_v1"}; + } + +}; +namespace detail { +struct TupleV1TypeStorage; +} // namespace detail +class TupleV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.tuple_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + using Base::getChecked; + static TupleV1Type get(::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::Type> types); + static TupleV1Type getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::Type> types); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef<::mlir::Type> types); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef<::mlir::Type> types); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"tuple_v1"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef<::mlir::Type> getTypes() const; +}; +namespace detail { +struct UniformQuantizedV1TypeStorage; +} // namespace detail +class UniformQuantizedV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.quant_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + using Base::getChecked; + static UniformQuantizedV1Type get(::mlir::MLIRContext *context, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, ::llvm::APFloat scale, int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax); + static UniformQuantizedV1Type getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, ::llvm::APFloat scale, int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, ::llvm::APFloat scale, int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, ::llvm::APFloat scale, int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"quant_v1"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + unsigned getFlags() const; + ::mlir::Type getStorageType() const; + ::mlir::Type getExpressedType() const; + ::llvm::APFloat getScale() const; + int64_t getZeroPoint() const; + int64_t getStorageTypeMin() const; + int64_t getStorageTypeMax() const; +}; +namespace detail { +struct UniformQuantizedPerAxisV1TypeStorage; +} // namespace detail +class UniformQuantizedPerAxisV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 18, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.quant_per_axis_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + using Base::getChecked; + static UniformQuantizedPerAxisV1Type get(::mlir::MLIRContext *context, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, int32_t quantizedDimension, ::llvm::ArrayRef<::llvm::APFloat> scales, ::llvm::ArrayRef zeroPoints, int64_t storageTypeMin, int64_t storageTypeMax); + static UniformQuantizedPerAxisV1Type getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, int32_t quantizedDimension, ::llvm::ArrayRef<::llvm::APFloat> scales, ::llvm::ArrayRef zeroPoints, int64_t storageTypeMin, int64_t storageTypeMax); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, int32_t quantizedDimension, ::llvm::ArrayRef<::llvm::APFloat> scales, ::llvm::ArrayRef zeroPoints, int64_t storageTypeMin, int64_t storageTypeMax); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, unsigned flags, ::mlir::Type storageType, ::mlir::Type expressedType, int32_t quantizedDimension, ::llvm::ArrayRef<::llvm::APFloat> scales, ::llvm::ArrayRef zeroPoints, int64_t storageTypeMin, int64_t storageTypeMax); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"quant_per_axis_v1"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + unsigned getFlags() const; + ::mlir::Type getStorageType() const; + ::mlir::Type getExpressedType() const; + int32_t getQuantizedDimension() const; + ::llvm::ArrayRef<::llvm::APFloat> getScales() const; + ::llvm::ArrayRef getZeroPoints() const; + int64_t getStorageTypeMin() const; + int64_t getStorageTypeMax() const; +}; +namespace detail { +struct UnrankedTensorV1TypeStorage; +} // namespace detail +class UnrankedTensorV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.unranked_tensor_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + using Base::getChecked; + static UnrankedTensorV1Type get(::mlir::MLIRContext *context, ::mlir::Type elementType); + static UnrankedTensorV1Type getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::mlir::Type elementType); + static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type elementType); + static ::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type elementType); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"unranked_tensor_v1"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::Type getElementType() const; +}; +class WitnessV1Type : public ::mlir::Type::TypeBase { +public: + using Base::Base; + mlir::vhlo::Version getMinVersion() { + return mlir::vhlo::Version(0, 9, 0); + } + mlir::vhlo::Version getMaxVersion() { + return mlir::vhlo::Version::getCurrentVersion(); + } + static constexpr ::llvm::StringLiteral name = "vhlo.witness_v1"; + static constexpr ::llvm::StringLiteral dialectName = "vhlo"; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"witness_v1"}; + } + +}; +} // namespace vhlo +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::BooleanV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::ComplexV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatBF16V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF16V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF32V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF64V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF4E2M1FNV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF6E2M3FNV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF6E3M2FNV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E3M4V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E4M3V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E4M3FNV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E5M2V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E4M3FNUZV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E4M3B11FNUZV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E5M2FNUZV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatF8E8M0FNUV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FloatTF32V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::FunctionV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IndexV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerSI2V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerSI4V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerSI8V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerSI16V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerSI32V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerSI64V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerUI2V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerUI4V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerUI8V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerUI16V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerUI32V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::IntegerUI64V1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::NoneV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::RankedTensorV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TokenV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::TupleV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::UniformQuantizedV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::UniformQuantizedPerAxisV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::UnrankedTensorV1Type) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vhlo::WitnessV1Type) + +#endif // GET_TYPEDEF_CLASSES + diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypeInterfaces.cpp.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypeInterfaces.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..b8df34d19b6eec351284a715c64823b1b8d46f90 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypeInterfaces.cpp.inc @@ -0,0 +1,18 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + + +/// Returns the minimum version of the VHLO dialect an attribute is supported in. +mlir::vhlo::Version mlir::vhlo::VersionedTypeInterface::getMinVersion() const { + return getImpl()->getMinVersion(getImpl(), *this); + } + +/// Returns the maximum version (inclusive) of the VHLO dialect an attribute is supported in. +mlir::vhlo::Version mlir::vhlo::VersionedTypeInterface::getMaxVersion() const { + return getImpl()->getMaxVersion(getImpl(), *this); + } diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypeInterfaces.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypeInterfaces.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..6eec42fccfb4c2b1f0d199d1391126fdc2220c44 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypeInterfaces.h.inc @@ -0,0 +1,85 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace vhlo { +class VersionedTypeInterface; +namespace detail { +struct VersionedTypeInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + mlir::vhlo::Version (*getMinVersion)(const Concept *impl, ::mlir::Type ); + mlir::vhlo::Version (*getMaxVersion)(const Concept *impl, ::mlir::Type ); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::vhlo::VersionedTypeInterface; + Model() : Concept{getMinVersion, getMaxVersion} {} + + static inline mlir::vhlo::Version getMinVersion(const Concept *impl, ::mlir::Type tablegen_opaque_val); + static inline mlir::vhlo::Version getMaxVersion(const Concept *impl, ::mlir::Type tablegen_opaque_val); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::vhlo::VersionedTypeInterface; + FallbackModel() : Concept{getMinVersion, getMaxVersion} {} + + static inline mlir::vhlo::Version getMinVersion(const Concept *impl, ::mlir::Type tablegen_opaque_val); + static inline mlir::vhlo::Version getMaxVersion(const Concept *impl, ::mlir::Type tablegen_opaque_val); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteType; + }; +}; +template +struct VersionedTypeInterfaceTrait; + +} // namespace detail +class VersionedTypeInterface : public ::mlir::TypeInterface { +public: + using ::mlir::TypeInterface::TypeInterface; + template + struct Trait : public detail::VersionedTypeInterfaceTrait {}; + + /// Returns the minimum version of the VHLO dialect an attribute is supported in. + mlir::vhlo::Version getMinVersion() const; + + /// Returns the maximum version (inclusive) of the VHLO dialect an attribute is supported in. + mlir::vhlo::Version getMaxVersion() const; +}; +namespace detail { + template + struct VersionedTypeInterfaceTrait : public ::mlir::TypeInterface::Trait { + }; +}// namespace detail +} // namespace vhlo +} // namespace mlir +namespace mlir { +namespace vhlo { +template +mlir::vhlo::Version detail::VersionedTypeInterfaceInterfaceTraits::Model::getMinVersion(const Concept *impl, ::mlir::Type tablegen_opaque_val) { + return (::llvm::cast(tablegen_opaque_val)).getMinVersion(); +} +template +mlir::vhlo::Version detail::VersionedTypeInterfaceInterfaceTraits::Model::getMaxVersion(const Concept *impl, ::mlir::Type tablegen_opaque_val) { + return (::llvm::cast(tablegen_opaque_val)).getMaxVersion(); +} +template +mlir::vhlo::Version detail::VersionedTypeInterfaceInterfaceTraits::FallbackModel::getMinVersion(const Concept *impl, ::mlir::Type tablegen_opaque_val) { + return static_cast(impl)->getMinVersion(tablegen_opaque_val); +} +template +mlir::vhlo::Version detail::VersionedTypeInterfaceInterfaceTraits::FallbackModel::getMaxVersion(const Concept *impl, ::mlir::Type tablegen_opaque_val) { + return static_cast(impl)->getMaxVersion(tablegen_opaque_val); +} +} // namespace vhlo +} // namespace mlir diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypes.h b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypes.h new file mode 100644 index 0000000000000000000000000000000000000000..f3a8d68d0062e264e61a2e6db47aa80e93092ede --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/VhloTypes.h @@ -0,0 +1,85 @@ +/* Copyright 2023 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_DIALECT_VHLOTYPES_H +#define STABLEHLO_DIALECT_VHLOTYPES_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallVector.h" +#include "mlir/IR/Attributes.h" +#include "mlir/IR/MLIRContext.h" +#include "mlir/IR/OpImplementation.h" +#include "mlir/Transforms/DialectConversion.h" +#include "stablehlo/dialect/Version.h" + +namespace mlir { +namespace vhlo { + + +// This class is used to manage conversions between VHLO and Builtin +// dialects. +class VhloTypeConverter : public TypeConverter { + public: + VhloTypeConverter() : TypeConverter(), allowOtherDialects(false) {} + VhloTypeConverter(bool allowOtherDialects) + : TypeConverter(), allowOtherDialects(allowOtherDialects) {} + + virtual ~VhloTypeConverter() = default; + + virtual Attribute convertEncoding(Attribute attr) const = 0; + + Attribute convertUnknownAttribute(Attribute attr) const { + if (allowOtherDialects) return attr; + return {}; + } + + // A subclass can call this method to add conversions from VHLO -> Builtin + // types. Note that conversions are applied in reverse order, with the most + // recently added conversion attempted to be applied first. Because of this, + // it is likely that a subclass should call this last, especially if a default + // `Type -> Type` fallback conversion is registered. + void addVhloToBuiltinConversions(); + + // A subclass can call this method to add conversions from Builtin -> VHLO + // types. Note that conversions are applied in reverse order, with the most + // recently added conversion attempted to be applied first. Because of this, + // it is likely that a subclass should call this last, especially if a default + // `Type -> Type` fallback conversion is registered. + void addBuiltinToVhloConversions(); + + // Mark unrealized casts as legal. Useful for dialect mixing. + void addUnrealizedMaterializations(); + + private: + bool allowOtherDialects; +}; + +// Autogenerated VHLO type printers and parsers. +LogicalResult printVhloType(Type type, AsmPrinter& printer); +OptionalParseResult parseVhloType(mlir::AsmParser& parser, + llvm::StringRef* mnemonic, mlir::Type& type); + +// Registers VHLO types in a given context. +// See comments for `VhloDialect::addVhloTypes` for additional details. +void registerVhloTypes(MLIRContext* context); + +} // namespace vhlo +} // namespace mlir + +#include "stablehlo/dialect/VhloTypeInterfaces.h.inc" +#define GET_TYPEDEF_CLASSES +#include "stablehlo/dialect/VhloTypeDefs.h.inc" + +#endif // STABLEHLO_DIALECT_VHLOTYPES_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/dialect/chlo.md b/deps/exla/cache/xla_extension/include/stablehlo/dialect/chlo.md new file mode 100644 index 0000000000000000000000000000000000000000..70048bd93b73a0105e830f6b8694e7b2022381a0 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/dialect/chlo.md @@ -0,0 +1,2069 @@ + + +# 'chlo' Dialect + +_Client HLO Ops_ + +This dialect contains ops that align closely with the API surface area +of the XlaBuilder C++ API, where such ops have semantics that go beyond +what exists in the lower level dialects (such as `stablehlo`). Essentially, +whenever the client library uses syntactic sugar or composition +of multiple ops for an API call, this dialect tries to model the API call +and provide conversion patterns to fully materialize into lower level +dialects. + +[TOC] + +## Operations + +### `chlo._asin_acos_kernel` (chlo::AsinAcosKernelOp) + +_AsinAcosKernel operator_ + +Syntax: + +``` +operation ::= `chlo._asin_acos_kernel` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `AsinAcosKernel(operand)` element-wise. + +``` +If + w = _asin_acos_kernel(z) + w' = _asin_acos_kernel(I * z) +Then + asin(z) = complex(atan2(z.real, w.real), sign(z.imag) * w.imag) + acos(z) = complex(atan2(w.real, z.real), -sign(z.imag) * w.imag) + asinh(z) = complex(sign(z.real) * w'.imag, atan2(z.imag, w'.real)) + acosh(z) = complex(w.imag, sign(z.imag) * atan2(w.real, z.real)) +``` + +This op is used as an intermediate value in decompositions and +should never be constructed directly by frameworks or consumed by +backends. + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of complex type with 32/64-bit float elements values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of complex type with 32/64-bit float elements values | + + + +### `chlo.acos` (chlo::AcosOp) + +_Acos operator_ + +Syntax: + +``` +operation ::= `chlo.acos` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `Acos(operand)` element-wise. + +$$ +\acos(x) = 2 * \atan(\sqrt(1 - x^2) / (1 + x)) if x != -1 + = pi if x == -1 +$$ + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + + + +### `chlo.acosh` (chlo::AcoshOp) + +_Acosh operation_ + +Syntax: + +``` +operation ::= `chlo.acosh` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `Acosh(operand)` element-wise. + +$$ +\acosh(x) = log(x + sqrt(x^2 - 1)) if x >= -1 +\acosh(x) = nan if x < -1 +$$ + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + + + +### `chlo.asin` (chlo::AsinOp) + +_Asin operator_ + +Syntax: + +``` +operation ::= `chlo.asin` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `Asin(operand)` element-wise. + +$$ +\asin(x) = 2 * atan(x / (1 + sqrt(1 - x^2))) +$$ + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + + + +### `chlo.asinh` (chlo::AsinhOp) + +_Asinh operation_ + +Syntax: + +``` +operation ::= `chlo.asinh` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `Asinh(operand)` element-wise. + +$$ +\asinh(x) = log(x + sqrt(x^2 + 1)) +$$ + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + + + +### `chlo.atan` (chlo::AtanOp) + +_Atan operator_ + +Syntax: + +``` +operation ::= `chlo.atan` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `Atan(operand)` element-wise. + +$$ +\atan(x) = \atan2(x, 1) +$$ + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + + + +### `chlo.atanh` (chlo::AtanhOp) + +_Atanh operator_ + +Syntax: + +``` +operation ::= `chlo.atanh` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `Atanh(operand)` element-wise. + +$$ +\atanh(x) = 0.5 * log((1 + x) / (1 - x)) if abs(x) <= 1 + = nan otherwise +$$ + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + + + +### `chlo.bessel_i1e` (chlo::BesselI1eOp) + +_Bessel function of order 1_ + +Syntax: + +``` +operation ::= `chlo.bessel_i1e` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `bessel_i1e(operand)` element-wise. + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + + + +### `chlo.broadcast_add` (chlo::BroadcastAddOp) + +_Addition operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_add` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `lhs + rhs` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `Commutative`, `HLO_BroadcastingElementwise`, `HLO_CompatibleOperandsAndResultElementType`, `InferTensorType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_and` (chlo::BroadcastAndOp) + +_Logical and operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_and` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `logical_and(lhs, rhs)` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `Commutative`, `HLO_BroadcastingElementwise`, `InferTensorType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of bool or 2/4/8/16/32/64-bit integer values | +| `rhs` | tensor of bool or 2/4/8/16/32/64-bit integer values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_atan2` (chlo::BroadcastAtan2Op) + +_Atan2 operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_atan2` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `atan2(lhs/rhs)` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType`, `SameOperandsAndResultElementType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_compare` (chlo::BroadcastCompareOp) + +_Compare operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_compare` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Compares `lhs` and `rhs` elementwise according to `comparison_direction` +and `compare_type`. If unspecified, `compare_type` is FLOAT for float element +types, SIGNED for signed element types and UNSIGNED for unsigned element +types. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_comparison_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
comparison_direction::mlir::chlo::ComparisonDirectionAttrWhich comparison operation to perform.
compare_type::mlir::chlo::ComparisonTypeAttrWhich comparison type to use.
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of bool values | + + + +### `chlo.broadcast_complex` (chlo::BroadcastComplexOp) + +_Complex operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_complex` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Performs element-wise conversion of a pair of real and imaginary values to +a complex value. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of complex type with 32/64-bit float elements values | + + + +### `chlo.broadcast_divide` (chlo::BroadcastDivOp) + +_Division operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_divide` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `lhs / rhs` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType`, `SameOperandsAndResultElementType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_maximum` (chlo::BroadcastMaxOp) + +_Maximum operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_maximum` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `max(lhs, rhs)` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `Commutative`, `HLO_BroadcastingElementwise`, `HLO_CompatibleOperandsAndResultElementType`, `InferTensorType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_minimum` (chlo::BroadcastMinOp) + +_Minimum operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_minimum` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `min(lhs, rhs)` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `Commutative`, `HLO_BroadcastingElementwise`, `HLO_CompatibleOperandsAndResultElementType`, `InferTensorType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_multiply` (chlo::BroadcastMulOp) + +_Multiplication operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_multiply` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `lhs * rhs` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `Commutative`, `HLO_BroadcastingElementwise`, `InferTensorType`, `SameOperandsAndResultElementType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_next_after` (chlo::BroadcastNextAfterOp) + +_Std::nextafter operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_next_after` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns the next representable value of `lhs` in the direction of `rhs`, +element-wise. It can also return a subnormal number. + +Equivalent to the C++ std::nextafter function. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType`, `SameOperandsAndResultElementType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_or` (chlo::BroadcastOrOp) + +_Logical or operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_or` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `logical_or(lhs, rhs)` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `Commutative`, `HLO_BroadcastingElementwise`, `InferTensorType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of bool or 2/4/8/16/32/64-bit integer values | +| `rhs` | tensor of bool or 2/4/8/16/32/64-bit integer values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_polygamma` (chlo::BroadcastPolygammaOp) + +_Polygamma function (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_polygamma` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `Polygamma(operand, operand)` element-wise. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType`, `SameOperandsAndResultElementType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_power` (chlo::BroadcastPowOp) + +_Power operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_power` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `lhs ^ rhs` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType`, `SameOperandsAndResultElementType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_remainder` (chlo::BroadcastRemOp) + +_Remainder operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_remainder` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `lhs % rhs` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType`, `SameOperandsAndResultElementType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_select` (chlo::BroadcastSelectOp) + +_Select operator (with optional numpy-style broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_select` $pred `,` $on_true `,` $on_false attr-dict `:` + `(` type($pred) `,` type($on_true) `,` type($on_false) `)` `->` type(results) +``` + +Constructs an output array from elements of two input arrays, based on the +values of a predicate array. + +See https://www.tensorflow.org/xla/operation_semantics#select + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `pred` | ranked tensor of bool values | +| `on_true` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `on_false` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_shift_left` (chlo::BroadcastShiftLeftOp) + +_Shift left operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_shift_left` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `lhs << rhs` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType`, `SameOperandsAndResultElementType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_shift_right_arithmetic` (chlo::BroadcastShiftRightArithmeticOp) + +_Shift right arithmetic operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_shift_right_arithmetic` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `lhs >> rhs` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType`, `SameOperandsAndResultElementType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_shift_right_logical` (chlo::BroadcastShiftRightLogicalOp) + +_Shift right logical operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_shift_right_logical` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `lhs >> rhs` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType`, `SameOperandsAndResultElementType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_subtract` (chlo::BroadcastSubOp) + +_Subtraction operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_subtract` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `lhs - rhs` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType`, `SameOperandsAndResultElementType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_xor` (chlo::BroadcastXorOp) + +_Logical xor operator (with optional broadcasting)_ + +Syntax: + +``` +operation ::= `chlo.broadcast_xor` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `logical_xor(lhs, rhs)` element-wise. + +See +https://www.tensorflow.org/xla/operation_semantics#element-wise_binary_arithmetic_operations. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `Commutative`, `HLO_BroadcastingElementwise`, `InferTensorType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of bool or 2/4/8/16/32/64-bit integer values | +| `rhs` | tensor of bool or 2/4/8/16/32/64-bit integer values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.broadcast_zeta` (chlo::BroadcastZetaOp) + +_Hurwitz zeta function_ + +Syntax: + +``` +operation ::= `chlo.broadcast_zeta` $lhs `,` $rhs attr-dict `:` + `(` type($lhs) `,` type($rhs) `)` `->` type(results) +``` + +Returns `Zeta(operand, operand)` element-wise. + +$$ +\(\zeta(x, q) = \sum_{n=0}^{\infty} (q + n)^{-x}\) +$$ + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType`, `SameOperandsAndResultElementType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
broadcast_dimensions::mlir::DenseI64ArrayAttri64 dense array attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float values | + + + +### `chlo.conj` (chlo::ConjOp) + +_Conj operator_ + +Syntax: + +``` +operation ::= `chlo.conj` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `Conj(operand)` element-wise. + +$$ +\conj(x) = (\real(x), \neg(\imag(x))) +$$ + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + + + +### `chlo.constant` (chlo::ConstantOp) + +_Constant operator_ + +Syntax: + +``` +operation ::= `chlo.constant` attr-dict $value +``` + +Represents a constant value. + +Traits: `AlwaysSpeculatableImplTrait`, `ConstantLike` + +Interfaces: `ConditionallySpeculatable`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
value::mlir::ElementsAttrconstant vector/tensor attribute
+ +#### Results: + +| Result | Description | +| :----: | ----------- | +| `output` | statically shaped tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized values | + + + +### `chlo.constant_like` (chlo::ConstantLikeOp) + +_Constant like operator_ + +Returns a splat constant of the same shape as the operand. + +Traits: `AlwaysSpeculatableImplTrait`, `CHLO_Broadcasting`, `HLO_BroadcastingElementwise`, `InferTensorType`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
value::mlir::TypedAttrTypedAttr instance
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| «unnamed» | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.cosh` (chlo::CoshOp) + +_Cosh operator_ + +Syntax: + +``` +operation ::= `chlo.cosh` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `Cosh(operand)` element-wise. + +$$ +\cosh(x) = (e^x + e^-x) / 2 +$$ + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + + + +### `chlo.digamma` (chlo::DigammaOp) + +_Digamma function_ + +Syntax: + +``` +operation ::= `chlo.digamma` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `Digamma(operand)` element-wise. + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float values | + + + +### `chlo.erf` (chlo::ErfOp) + +_Erfc operator_ + +Syntax: + +``` +operation ::= `chlo.erf` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Computes the Gauss error function of `x` element-wise. + +erf(x) = erf_impl(x) if |x| < 1 + = 1 - erfc_impl(x) otherwise + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float values | + + + +### `chlo.erf_inv` (chlo::ErfInvOp) + +_Inverse Erf_ + +Syntax: + +``` +operation ::= `chlo.erf_inv` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `ErfInv(operand)` element-wise. + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float values | + + + +### `chlo.erfc` (chlo::ErfcOp) + +_Erfc operator_ + +Syntax: + +``` +operation ::= `chlo.erfc` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Computes an approximation of the error function complement (1 - erf(x)). + +erfc(x) = erfc_impl(x) if |x| > 1 + = 1 - erf_impl(x) otherwise + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float values | + + + +### `chlo.is_inf` (chlo::IsInfOp) + +_IsInf predicate_ + +Syntax: + +``` +operation ::= `chlo.is_inf` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns if a value is +/-inf element-wise. + +Traits: `AlwaysSpeculatableImplTrait`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of bool values | + + + +### `chlo.is_neg_inf` (chlo::IsNegInfOp) + +_IsNegInf predicate_ + +Syntax: + +``` +operation ::= `chlo.is_neg_inf` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns if a value is -inf element-wise. + +Traits: `AlwaysSpeculatableImplTrait`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of bool values | + + + +### `chlo.is_pos_inf` (chlo::IsPosInfOp) + +_IsPosInf predicate_ + +Syntax: + +``` +operation ::= `chlo.is_pos_inf` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns if a value is +inf element-wise. + +Traits: `AlwaysSpeculatableImplTrait`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of bool values | + + + +### `chlo.lgamma` (chlo::LgammaOp) + +_Lgamma function_ + +Syntax: + +``` +operation ::= `chlo.lgamma` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `Lgamma(operand)` element-wise. + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float values | + + + +### `chlo.next_after` (chlo::NextAfterOp) + +_Std::nextafter operator_ + +Syntax: + +``` +operation ::= `chlo.next_after` $x `,` $y attr-dict `:` type($x) `,` type($y) `->` type(results) +``` + +Returns the next representable value of `x` in the direction of `y`, +element-wise. It can also return a subnormal number. + +Equivalent to the C++ std::nextafter function. + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `x` | tensor of 4/6/8/16/32/64-bit float values | +| `y` | tensor of 4/6/8/16/32/64-bit float values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float values | + + + +### `chlo.polygamma` (chlo::PolygammaOp) + +_Polygamma function_ + +Syntax: + +``` +operation ::= `chlo.polygamma` $n `,` $x attr-dict `:` type($n) `,` type($x) `->` type(results) +``` + +Returns `Polygamma(operand, operand)` element-wise. + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `n` | tensor of 4/6/8/16/32/64-bit float values | +| `x` | tensor of 4/6/8/16/32/64-bit float values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float values | + + + +### `chlo.ragged_dot` (chlo::RaggedDotOp) + +_Computes a matmul over a single ragged dimension_ + +This operation takes three tensor args---lhs, rhs, and group_sizes---and +a "ragged_dot_dimension_numbers" attribute. Like dot_general, the lhs and +rhs are allowed arbitrary batch and contracting dimensions. Additionally, +the lhs is required to have one ragged dimension, and the rhs may have at +most one group dimension. The op has three modes, depending on the kind of +the lhs ragged dimension. + +In mode 1, the shape-signature is `[b,m,k], [g,b,k,n], [b,g] -> [b,m,n]`. +Here the ragged dimension is an lhs non-contracting dimension (`m`). The +dimensions `b` and `k` represent batch and contracting dimensions +respectively. The rhs is required to have a group dimension (`g`). + +In mode 2, the shape-signature is `[b,m,k], [b,k,n], [b,g] -> [g,b,m,n]`. +Here the ragged dimension is an lhs/rhs contracting dimension (`k`). + +In mode 3, the shape-signature is `[b,m,k], [b,k,n], [g] -> [b,m,n]`. Here +the ragged dimension is an lhs/rhs batch dimension (`b`). + + +Traits: `AlwaysSpeculatableImplTrait` + +Interfaces: `ConditionallySpeculatable`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + + +
AttributeMLIR TypeDescription
ragged_dot_dimension_numbers::mlir::chlo::RaggedDotDimensionNumbersAttrAttribute that models the dimension information for ragged dot.
precision_config::mlir::ArrayAttrPrecision Config attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `lhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `rhs` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `group_sizes` | ranked tensor of 2/4/8/16/32/64-bit integer values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.sinh` (chlo::SinhOp) + +_Sinh operation_ + +Syntax: + +``` +operation ::= `chlo.sinh` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `Sinh(operand)` element-wise. + +$$ +\sinh(x) = (e^x - e^-x) / 2 if |x| < 1 + = e^(x + log(1/2)) - e^(-x + log(1/2)) otherwise. +$$ + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + + + +### `chlo.square` (chlo::SquareOp) + +_Square operation_ + +Syntax: + +``` +operation ::= `chlo.square` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `Square(operand)` element-wise. + +$$ +\square(x) = complex((x.real - x.imag) * (x.real + x.imag), x.real * x.imag * 2) if x is a complex number + = x * x otherwise +$$ + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + + + +### `chlo.tan` (chlo::TanOp) + +_Tan operation_ + +Syntax: + +``` +operation ::= `chlo.tan` $operand attr-dict `:` type($operand) `->` type($result) +``` + +Returns `Tan(operand)` element-wise. + +$$ +\tan(x) = \sin(x) / \cos(x) +$$ + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType`, `Elementwise`, `SameOperandsAndResultShape` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float or complex type with 32/64-bit float elements values | + + + +### `chlo.top_k` (chlo::TopKOp) + +_Finds values and indices of the `k` largest elements for the last dimension_ + +Syntax: + +``` +operation ::= `chlo.top_k` `(`$operand `,` `k` `=` $k`)` attr-dict `:` + type($operand) `->` `(`type($values)`,` type($indices)`)` +``` + +If the input is a vector (rank-1), finds the `k` largest entries in the +vector and outputs their values and indices as vectors. Thus `values[j]` is +the `j`-th largest entry in `input`, and its index is `indices[j]`. + +For matrices (resp. higher rank input), computes the top `k` entries in each +row (resp. vector along the last dimension). Thus, + +``` +values.shape = indices.shape = input.shape[:-1] + [k] +``` + +If two elements are equal, the lower-index element appears first. + +Traits: `AlwaysSpeculatableImplTrait`, `InferTensorType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Attributes: + + + + +
AttributeMLIR TypeDescription
k::mlir::IntegerAttr64-bit signless integer attribute
+ +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `operand` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `values` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | +| `indices` | tensor of 4/6/8/16/32/64-bit float or bool or 2/4/8/16/32/64-bit integer or complex type with 32/64-bit float elements or per-tensor integer quantized or per-axis integer quantized values | + + + +### `chlo.zeta` (chlo::ZetaOp) + +_Hurwitz zeta function_ + +Syntax: + +``` +operation ::= `chlo.zeta` $x `,` $q attr-dict `:` type($x) `,` type($q) `->` type(results) +``` + +Returns `Zeta(operand, operand)` element-wise. + +$$ +\(\zeta(x, q) = \sum_{n=0}^{\infty} (q + n)^{-x}\) +$$ + +Traits: `AlwaysSpeculatableImplTrait`, `CompatibleOperandsAndResultType` + +Interfaces: `ConditionallySpeculatable`, `InferShapedTypeOpInterface`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)` + +Effects: `MemoryEffects::Effect{}` + +#### Operands: + +| Operand | Description | +| :-----: | ----------- | +| `x` | tensor of 4/6/8/16/32/64-bit float values | +| `q` | tensor of 4/6/8/16/32/64-bit float values | + +#### Results: + +| Result | Description | +| :----: | ----------- | +| `result` | tensor of 4/6/8/16/32/64-bit float values | + + + +## Attributes + +### ComparisonDirectionAttr + +_Which comparison operation to perform._ + +Syntax: + +``` +#chlo.comparison_direction< + ::mlir::chlo::ComparisonDirection # value +> +``` + +#### Parameters: + +| Parameter | C++ type | Description | +| :-------: | :-------: | ----------- | +| value | `::mlir::chlo::ComparisonDirection` | an enum of type ComparisonDirection | + +### ComparisonTypeAttr + +_Which comparison type to use._ + +Syntax: + +``` +#chlo.comparison_type< + ::mlir::chlo::ComparisonType # value +> +``` + +#### Parameters: + +| Parameter | C++ type | Description | +| :-------: | :-------: | ----------- | +| value | `::mlir::chlo::ComparisonType` | an enum of type ComparisonType | + +### PrecisionAttr + +_XLA precision for an operand. Has backend specific meaning._ + +Syntax: + +``` +#chlo.precision< + ::mlir::chlo::Precision # value +> +``` + +#### Parameters: + +| Parameter | C++ type | Description | +| :-------: | :-------: | ----------- | +| value | `::mlir::chlo::Precision` | an enum of type Precision | + +### RaggedDotDimensionNumbersAttr + +_Attribute that models the dimension information for ragged dot._ + +#### Parameters: + +| Parameter | C++ type | Description | +| :-------: | :-------: | ----------- | +| lhsBatchingDimensions | `::llvm::ArrayRef` | Dimension | +| rhsBatchingDimensions | `::llvm::ArrayRef` | Dimension | +| lhsContractingDimensions | `::llvm::ArrayRef` | Dimension | +| rhsContractingDimensions | `::llvm::ArrayRef` | Dimension | +| lhsRaggedDimensions | `::llvm::ArrayRef` | Dimension | +| rhsGroupDimensions | `::llvm::ArrayRef` | Dimension | + +## Enums + +### ComparisonDirection + +_Which comparison operation to perform._ + +#### Cases: + +| Symbol | Value | String | +| :----: | :---: | ------ | +| EQ | `0` | EQ | +| NE | `1` | NE | +| GE | `2` | GE | +| GT | `3` | GT | +| LE | `4` | LE | +| LT | `5` | LT | + +### ComparisonType + +_Which comparison type to use._ + +#### Cases: + +| Symbol | Value | String | +| :----: | :---: | ------ | +| NOTYPE | `0` | NOTYPE | +| FLOAT | `1` | FLOAT | +| TOTALORDER | `2` | TOTALORDER | +| SIGNED | `3` | SIGNED | +| UNSIGNED | `4` | UNSIGNED | + +### Precision + +_XLA precision for an operand. Has backend specific meaning._ + +#### Cases: + +| Symbol | Value | String | +| :----: | :---: | ------ | +| DEFAULT | `0` | DEFAULT | +| HIGH | `1` | HIGH | +| HIGHEST | `2` | HIGHEST | diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/ChloDecompositionPatterns.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/transforms/ChloDecompositionPatterns.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..50445c36ef35b98f775a81b5d4a1d7c65e5047b2 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/ChloDecompositionPatterns.h.inc @@ -0,0 +1,3534 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Rewriters *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: ChloDecompositionPatterns.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ChloDecompositionPatterns1( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Type type, + ::llvm::StringRef failureStr) { + if (!((!isa(cast(type).getElementType())))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": Non-complex element type"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_ChloDecompositionPatterns2( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Type type, + ::llvm::StringRef failureStr) { + if (!((isa(cast(type).getElementType())))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": Complex element type"; + }); + } + return ::mlir::success(); +} +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatterns.td:53 +*/ +struct GeneratedConvert0 : public ::mlir::RewritePattern { + GeneratedConvert0(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.atan", 1, context, {"stablehlo.atan2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range input(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::AtanOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.atan' failed to satisfy constraint: 'Non-complex element type'"))) { + return ::mlir::failure(); + } + input = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1, (*input.begin())); (void)nativeVar_0; + ::mlir::stablehlo::Atan2Op tblgen_Atan2Op_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::Atan2Op::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*input.begin())); + tblgen_values.push_back(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_Atan2Op_1 = rewriter.create<::mlir::stablehlo::Atan2Op>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_Atan2Op_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatterns.td:62 +*/ +struct GeneratedConvert1 : public ::mlir::RewritePattern { + GeneratedConvert1(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.atanh", 1, context, {"stablehlo.abs", "stablehlo.compare", "stablehlo.log_plus_one", "stablehlo.multiply", "stablehlo.negate", "stablehlo.select", "stablehlo.subtract"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range input(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::AtanhOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.atanh' failed to satisfy constraint: 'Non-complex element type'"))) { + return ::mlir::failure(); + } + input = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::AbsOp tblgen_AbsOp_0; + { + ::mlir::Value tblgen_value_0 = (*input.begin()); + tblgen_AbsOp_0 = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto nativeVar_1 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1, (*input.begin())); (void)nativeVar_1; + auto nativeVar_2 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_2; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_3; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AbsOp_0.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_1; + tblgen_CompareOp_3 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_2 + ); + } + auto nativeVar_4 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, NAN, (*input.begin())); (void)nativeVar_4; + ::mlir::stablehlo::Log1pOp tblgen_Log1pOp_5; + { + ::mlir::Value tblgen_value_0 = (*input.begin()); + tblgen_Log1pOp_5 = rewriter.create<::mlir::stablehlo::Log1pOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_6; + { + ::mlir::Value tblgen_value_0 = (*input.begin()); + tblgen_NegOp_6 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::Log1pOp tblgen_Log1pOp_7; + { + ::mlir::Value tblgen_value_0 = (*tblgen_NegOp_6.getODSResults(0).begin()); + tblgen_Log1pOp_7 = rewriter.create<::mlir::stablehlo::Log1pOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_8; + { + ::mlir::Value tblgen_value_0 = (*tblgen_Log1pOp_5.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_Log1pOp_7.getODSResults(0).begin()); + tblgen_SubtractOp_8 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_9 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0.5, (*input.begin())); (void)nativeVar_9; + ::mlir::stablehlo::MulOp tblgen_MulOp_10; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SubtractOp_8.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_9; + tblgen_MulOp_10 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_11; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::SelectOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_CompareOp_3.getODSResults(0).begin())); + tblgen_values.push_back(nativeVar_4); + tblgen_values.push_back((*tblgen_MulOp_10.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_SelectOp_11 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SelectOp_11.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatterns.td:84 +*/ +struct GeneratedConvert2 : public ::mlir::RewritePattern { + GeneratedConvert2(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.conj", 1, context, {"stablehlo.complex", "stablehlo.imag", "stablehlo.negate", "stablehlo.real"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range v(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::ConjOp>(op0); (void)castedOp0; + v = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::RealOp tblgen_RealOp_0; + { + ::mlir::Value tblgen_value_0 = (*v.begin()); + tblgen_RealOp_0 = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ImagOp tblgen_ImagOp_1; + { + ::mlir::Value tblgen_value_0 = (*v.begin()); + tblgen_ImagOp_1 = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_2; + { + ::mlir::Value tblgen_value_0 = (*tblgen_ImagOp_1.getODSResults(0).begin()); + tblgen_NegOp_2 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_3; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ComplexOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_RealOp_0.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_NegOp_2.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ComplexOp_3 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ComplexOp_3.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatterns.td:89 +*/ +struct GeneratedConvert3 : public ::mlir::RewritePattern { + GeneratedConvert3(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.is_inf", 1, context, {"chlo.is_pos_inf", "stablehlo.abs"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range input(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::IsInfOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.is_inf' failed to satisfy constraint: 'Non-complex element type'"))) { + return ::mlir::failure(); + } + input = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::AbsOp tblgen_AbsOp_0; + { + ::mlir::Value tblgen_value_0 = (*input.begin()); + tblgen_AbsOp_0 = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::chlo::IsPosInfOp tblgen_IsPosInfOp_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::chlo::IsPosInfOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_AbsOp_0.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_IsPosInfOp_1 = rewriter.create<::mlir::chlo::IsPosInfOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_IsPosInfOp_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatterns.td:96 +*/ +struct GeneratedConvert4 : public ::mlir::RewritePattern { + GeneratedConvert4(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.is_pos_inf", 1, context, {"stablehlo.compare"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range input(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::IsPosInfOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.is_pos_inf' failed to satisfy constraint: 'Non-complex element type'"))) { + return ::mlir::failure(); + } + input = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = ::mlir::stablehlo::getConstantLikeInfValue(rewriter, odsLoc, (*input.begin()), /*negative=*/false); (void)nativeVar_0; + auto nativeVar_1 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_1; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_2; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::CompareOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*input.begin())); + tblgen_values.push_back(nativeVar_0); + tblgen_props.comparison_direction = ::llvm::dyn_cast_if_present(::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ)); + tblgen_props.compare_type = ::llvm::dyn_cast_if_present(nativeVar_1); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_CompareOp_2 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_CompareOp_2.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatterns.td:106 +*/ +struct GeneratedConvert5 : public ::mlir::RewritePattern { + GeneratedConvert5(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.is_neg_inf", 1, context, {"stablehlo.compare"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range input(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::IsNegInfOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.is_neg_inf' failed to satisfy constraint: 'Non-complex element type'"))) { + return ::mlir::failure(); + } + input = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = ::mlir::stablehlo::getConstantLikeInfValue(rewriter, odsLoc, (*input.begin()), /*negative=*/true); (void)nativeVar_0; + auto nativeVar_1 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_1; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_2; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::CompareOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*input.begin())); + tblgen_values.push_back(nativeVar_0); + tblgen_props.comparison_direction = ::llvm::dyn_cast_if_present(::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ)); + tblgen_props.compare_type = ::llvm::dyn_cast_if_present(nativeVar_1); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_CompareOp_2 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_CompareOp_2.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatterns.td:115 +*/ +struct GeneratedConvert6 : public ::mlir::RewritePattern { + GeneratedConvert6(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.tan", 1, context, {"stablehlo.tan"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range input(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::TanOp>(op0); (void)castedOp0; + input = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::TanOp tblgen_TanOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::TanOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*input.begin())); + tblgen_props.result_accuracy = ::llvm::dyn_cast_if_present(::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_TanOp_0 = rewriter.create<::mlir::stablehlo::TanOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_TanOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatterns.td:118 +*/ +struct GeneratedConvert7 : public ::mlir::RewritePattern { + GeneratedConvert7(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.constant", 1, context, {"stablehlo.constant"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::ElementsAttr v; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::ConstantOp>(op0); (void)castedOp0; + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getValue(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'chlo.constant' to have attribute 'value' of type '::mlir::ElementsAttr'"; + }); + } + v = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::ConstantOp tblgen_ConstantOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ConstantOp::Properties tblgen_props; (void)tblgen_props; + tblgen_props.value = ::llvm::dyn_cast_if_present(v); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ConstantOp_0 = rewriter.create<::mlir::stablehlo::ConstantOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ConstantOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatternsMath.td:43 +*/ +struct GeneratedConvert8 : public ::mlir::RewritePattern { + GeneratedConvert8(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo._asin_acos_kernel", 1, context, {"stablehlo.abs", "stablehlo.add", "stablehlo.and", "stablehlo.compare", "stablehlo.complex", "stablehlo.divide", "stablehlo.imag", "stablehlo.log", "stablehlo.log_plus_one", "stablehlo.maximum", "stablehlo.minimum", "stablehlo.multiply", "stablehlo.negate", "stablehlo.not", "stablehlo.real", "stablehlo.select", "stablehlo.sqrt", "stablehlo.subtract"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range z(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::AsinAcosKernelOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns2(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo._asin_acos_kernel' failed to satisfy constraint: 'Complex element type'"))) { + return ::mlir::failure(); + } + z = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::RealOp signed_x; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + signed_x = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::AbsOp x; + { + ::mlir::Value tblgen_value_0 = (*signed_x.getODSResults(0).begin()); + x = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ImagOp signed_y; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + signed_y = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::AbsOp y; + { + ::mlir::Value tblgen_value_0 = (*signed_y.getODSResults(0).begin()); + y = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::MaxOp tblgen_MaxOp_0; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + tblgen_MaxOp_0 = rewriter.create<::mlir::stablehlo::MaxOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_1 = ::mlir::stablehlo::getConstantLikeMaxFiniteValue(rewriter, odsLoc, (*signed_x.getODSResults(0).begin())); (void)nativeVar_1; + ::mlir::stablehlo::SqrtOp tblgen_SqrtOp_2; + { + ::mlir::Value tblgen_value_0 = nativeVar_1; + tblgen_SqrtOp_2 = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + auto nativeVar_3 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 8, (*signed_x.getODSResults(0).begin())); (void)nativeVar_3; + ::mlir::stablehlo::DivOp safe_max; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SqrtOp_2.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_3; + safe_max = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_4 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_4; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_5; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MaxOp_0.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*safe_max.getODSResults(0).begin()); + tblgen_CompareOp_5 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GE), + /*compare_type=*/nativeVar_4 + ); + } + auto one = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1, (*signed_x.getODSResults(0).begin())); (void)one; + auto nativeVar_6 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_6; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_7; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + tblgen_CompareOp_7 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LE), + /*compare_type=*/nativeVar_6 + ); + } + auto half = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0.5, (*signed_x.getODSResults(0).begin())); (void)half; + ::mlir::stablehlo::AddOp xp1; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + xp1 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AbsOp abs_xp1; + { + ::mlir::Value tblgen_value_0 = (*xp1.getODSResults(0).begin()); + abs_xp1 = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::MaxOp mx; + { + ::mlir::Value tblgen_value_0 = (*abs_xp1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + mx = rewriter.create<::mlir::stablehlo::MaxOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MinOp mn; + { + ::mlir::Value tblgen_value_0 = (*abs_xp1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + mn = rewriter.create<::mlir::stablehlo::MinOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_8 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_8; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_9; + { + ::mlir::Value tblgen_value_0 = (*mx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*mn.getODSResults(0).begin()); + tblgen_CompareOp_9 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_8 + ); + } + auto sqrt_two = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1.4142135623730951, (*signed_x.getODSResults(0).begin())); (void)sqrt_two; + ::mlir::stablehlo::MulOp tblgen_MulOp_10; + { + ::mlir::Value tblgen_value_0 = sqrt_two; + ::mlir::Value tblgen_value_1 = (*mx.getODSResults(0).begin()); + tblgen_MulOp_10 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp mn_over_mx; + { + ::mlir::Value tblgen_value_0 = (*mn.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*mx.getODSResults(0).begin()); + mn_over_mx = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp _r_0_; + { + ::mlir::Value tblgen_value_0 = (*mn_over_mx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*mn_over_mx.getODSResults(0).begin()); + _r_0_ = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_11; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*_r_0_.getODSResults(0).begin()); + tblgen_AddOp_11 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp sqa; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_11.getODSResults(0).begin()); + sqa = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + auto nativeVar_12 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_12; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_13; + { + ::mlir::Value tblgen_value_0 = (*sqa.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + tblgen_CompareOp_13 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_12 + ); + } + auto zero = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0, (*signed_x.getODSResults(0).begin())); (void)zero; + auto nativeVar_14 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_14; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_15; + { + ::mlir::Value tblgen_value_0 = (*_r_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = zero; + tblgen_CompareOp_15 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_14 + ); + } + ::mlir::stablehlo::AndOp tblgen_AndOp_16; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_13.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_CompareOp_15.getODSResults(0).begin()); + tblgen_AndOp_16 = rewriter.create<::mlir::stablehlo::AndOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_17; + { + ::mlir::Value tblgen_value_0 = (*mx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_r_0_.getODSResults(0).begin()); + tblgen_MulOp_17 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto two = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 2, (*signed_x.getODSResults(0).begin())); (void)two; + ::mlir::stablehlo::DivOp tblgen_DivOp_18; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_17.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = two; + tblgen_DivOp_18 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_19; + { + ::mlir::Value tblgen_value_0 = (*mx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_18.getODSResults(0).begin()); + tblgen_AddOp_19 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_20; + { + ::mlir::Value tblgen_value_0 = (*mx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*sqa.getODSResults(0).begin()); + tblgen_MulOp_20 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_21; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AndOp_16.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_19.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_MulOp_20.getODSResults(0).begin()); + tblgen_SelectOp_21 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp r; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_9.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_10.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_21.getODSResults(0).begin()); + r = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SubtractOp xm1; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + xm1 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AbsOp abs_xm1; + { + ::mlir::Value tblgen_value_0 = (*xm1.getODSResults(0).begin()); + abs_xm1 = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::MaxOp _mx_0_; + { + ::mlir::Value tblgen_value_0 = (*abs_xm1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + _mx_0_ = rewriter.create<::mlir::stablehlo::MaxOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MinOp _mn_0_; + { + ::mlir::Value tblgen_value_0 = (*abs_xm1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + _mn_0_ = rewriter.create<::mlir::stablehlo::MinOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_22 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_22; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_23; + { + ::mlir::Value tblgen_value_0 = (*_mx_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_mn_0_.getODSResults(0).begin()); + tblgen_CompareOp_23 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_22 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_24; + { + ::mlir::Value tblgen_value_0 = sqrt_two; + ::mlir::Value tblgen_value_1 = (*_mx_0_.getODSResults(0).begin()); + tblgen_MulOp_24 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp _mn_over_mx_0_; + { + ::mlir::Value tblgen_value_0 = (*_mn_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_mx_0_.getODSResults(0).begin()); + _mn_over_mx_0_ = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp _r_1_; + { + ::mlir::Value tblgen_value_0 = (*_mn_over_mx_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_mn_over_mx_0_.getODSResults(0).begin()); + _r_1_ = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_25; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*_r_1_.getODSResults(0).begin()); + tblgen_AddOp_25 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp _sqa_0_; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_25.getODSResults(0).begin()); + _sqa_0_ = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + auto nativeVar_26 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_26; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_27; + { + ::mlir::Value tblgen_value_0 = (*_sqa_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + tblgen_CompareOp_27 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_26 + ); + } + auto nativeVar_28 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_28; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_29; + { + ::mlir::Value tblgen_value_0 = (*_r_1_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = zero; + tblgen_CompareOp_29 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_28 + ); + } + ::mlir::stablehlo::AndOp tblgen_AndOp_30; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_27.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_CompareOp_29.getODSResults(0).begin()); + tblgen_AndOp_30 = rewriter.create<::mlir::stablehlo::AndOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_31; + { + ::mlir::Value tblgen_value_0 = (*_mx_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_r_1_.getODSResults(0).begin()); + tblgen_MulOp_31 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_32; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_31.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = two; + tblgen_DivOp_32 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_33; + { + ::mlir::Value tblgen_value_0 = (*_mx_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_32.getODSResults(0).begin()); + tblgen_AddOp_33 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_34; + { + ::mlir::Value tblgen_value_0 = (*_mx_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_sqa_0_.getODSResults(0).begin()); + tblgen_MulOp_34 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_35; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AndOp_30.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_33.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_MulOp_34.getODSResults(0).begin()); + tblgen_SelectOp_35 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp s; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_23.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_24.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_35.getODSResults(0).begin()); + s = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_36; + { + ::mlir::Value tblgen_value_0 = (*r.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*s.getODSResults(0).begin()); + tblgen_AddOp_36 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp a; + { + ::mlir::Value tblgen_value_0 = half; + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_36.getODSResults(0).begin()); + a = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_37; + { + ::mlir::Value tblgen_value_0 = (*a.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*x.getODSResults(0).begin()); + tblgen_AddOp_37 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp half_apx; + { + ::mlir::Value tblgen_value_0 = half; + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_37.getODSResults(0).begin()); + half_apx = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp yy; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + yy = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp rpxp1; + { + ::mlir::Value tblgen_value_0 = (*r.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xp1.getODSResults(0).begin()); + rpxp1 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_38; + { + ::mlir::Value tblgen_value_0 = (*yy.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*rpxp1.getODSResults(0).begin()); + tblgen_DivOp_38 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp smxm1; + { + ::mlir::Value tblgen_value_0 = (*s.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xm1.getODSResults(0).begin()); + smxm1 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_39; + { + ::mlir::Value tblgen_value_0 = (*tblgen_DivOp_38.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*smxm1.getODSResults(0).begin()); + tblgen_AddOp_39 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_40; + { + ::mlir::Value tblgen_value_0 = (*half_apx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_39.getODSResults(0).begin()); + tblgen_MulOp_40 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp tblgen_SqrtOp_41; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_40.getODSResults(0).begin()); + tblgen_SqrtOp_41 = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_42; + { + ::mlir::Value tblgen_value_0 = (*half_apx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*rpxp1.getODSResults(0).begin()); + tblgen_DivOp_42 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp spxm1; + { + ::mlir::Value tblgen_value_0 = (*s.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xm1.getODSResults(0).begin()); + spxm1 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_43; + { + ::mlir::Value tblgen_value_0 = (*half_apx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*spxm1.getODSResults(0).begin()); + tblgen_DivOp_43 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_44; + { + ::mlir::Value tblgen_value_0 = (*tblgen_DivOp_42.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_43.getODSResults(0).begin()); + tblgen_AddOp_44 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp tblgen_SqrtOp_45; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_44.getODSResults(0).begin()); + tblgen_SqrtOp_45 = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_46; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SqrtOp_45.getODSResults(0).begin()); + tblgen_MulOp_46 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_47; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_7.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SqrtOp_41.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_MulOp_46.getODSResults(0).begin()); + tblgen_SelectOp_47 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_48; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_5.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_47.getODSResults(0).begin()); + tblgen_SelectOp_48 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + auto nativeVar_49 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1000000000000.0, (*signed_x.getODSResults(0).begin())); (void)nativeVar_49; + ::mlir::stablehlo::MulOp tblgen_MulOp_50; + { + ::mlir::Value tblgen_value_0 = (*safe_max.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_49; + tblgen_MulOp_50 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_51 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_51; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_52; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_50.getODSResults(0).begin()); + tblgen_CompareOp_52 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_51 + ); + } + auto nativeVar_53 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1e-06, (*signed_x.getODSResults(0).begin())); (void)nativeVar_53; + ::mlir::stablehlo::MulOp tblgen_MulOp_54; + { + ::mlir::Value tblgen_value_0 = (*safe_max.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_53; + tblgen_MulOp_54 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_55 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 100.0, (*signed_x.getODSResults(0).begin())); (void)nativeVar_55; + ::mlir::stablehlo::MulOp tblgen_MulOp_56; + { + ::mlir::Value tblgen_value_0 = (*safe_max.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_55; + tblgen_MulOp_56 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp safe_max_opt; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_52.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_54.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_MulOp_56.getODSResults(0).begin()); + safe_max_opt = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + auto nativeVar_57 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_57; + ::mlir::stablehlo::CompareOp y_gt_safe_max_opt; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*safe_max_opt.getODSResults(0).begin()); + y_gt_safe_max_opt = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GE), + /*compare_type=*/nativeVar_57 + ); + } + ::mlir::stablehlo::SelectOp _mx_1_; + { + ::mlir::Value tblgen_value_0 = (*y_gt_safe_max_opt.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*x.getODSResults(0).begin()); + _mx_1_ = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_58; + { + ::mlir::Value tblgen_value_0 = (*y_gt_safe_max_opt.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*safe_max_opt.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*safe_max.getODSResults(0).begin()); + tblgen_SelectOp_58 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + auto nativeVar_59 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_59; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_60; + { + ::mlir::Value tblgen_value_0 = (*_mx_1_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SelectOp_58.getODSResults(0).begin()); + tblgen_CompareOp_60 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GE), + /*compare_type=*/nativeVar_59 + ); + } + ::mlir::stablehlo::LogOp tblgen_LogOp_61; + { + ::mlir::Value tblgen_value_0 = two; + tblgen_LogOp_61 = rewriter.create<::mlir::stablehlo::LogOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::LogOp tblgen_LogOp_62; + { + ::mlir::Value tblgen_value_0 = (*_mx_1_.getODSResults(0).begin()); + tblgen_LogOp_62 = rewriter.create<::mlir::stablehlo::LogOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_63; + { + ::mlir::Value tblgen_value_0 = (*tblgen_LogOp_61.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_LogOp_62.getODSResults(0).begin()); + tblgen_AddOp_63 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_64 = ::mlir::stablehlo::getConstantLikeInfValue(rewriter, odsLoc, (*signed_y.getODSResults(0).begin()), /*negative=*/false); (void)nativeVar_64; + auto nativeVar_65 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_65; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_66; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_64; + tblgen_CompareOp_66 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_65 + ); + } + ::mlir::stablehlo::NotOp tblgen_NotOp_67; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_66.getODSResults(0).begin()); + tblgen_NotOp_67 = rewriter.create<::mlir::stablehlo::NotOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::AndOp tblgen_AndOp_68; + { + ::mlir::Value tblgen_value_0 = (*y_gt_safe_max_opt.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_NotOp_67.getODSResults(0).begin()); + tblgen_AndOp_68 = rewriter.create<::mlir::stablehlo::AndOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_69; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + tblgen_DivOp_69 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp xoy; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AndOp_68.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_69.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = zero; + xoy = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_70; + { + ::mlir::Value tblgen_value_0 = (*xoy.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xoy.getODSResults(0).begin()); + tblgen_MulOp_70 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::Log1pOp tblgen_Log1pOp_71; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_70.getODSResults(0).begin()); + tblgen_Log1pOp_71 = rewriter.create<::mlir::stablehlo::Log1pOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_72; + { + ::mlir::Value tblgen_value_0 = half; + ::mlir::Value tblgen_value_1 = (*tblgen_Log1pOp_71.getODSResults(0).begin()); + tblgen_MulOp_72 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_73; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_63.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_72.getODSResults(0).begin()); + tblgen_AddOp_73 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_74 = ::mlir::stablehlo::getConstantLikeSmallestNormalizedValue(rewriter, odsLoc, (*signed_x.getODSResults(0).begin())); (void)nativeVar_74; + ::mlir::stablehlo::SqrtOp tblgen_SqrtOp_75; + { + ::mlir::Value tblgen_value_0 = nativeVar_74; + tblgen_SqrtOp_75 = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + auto nativeVar_76 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 4, (*signed_x.getODSResults(0).begin())); (void)nativeVar_76; + ::mlir::stablehlo::MulOp tblgen_MulOp_77; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SqrtOp_75.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_76; + tblgen_MulOp_77 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_78 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_78; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_79; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_77.getODSResults(0).begin()); + tblgen_CompareOp_79 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_78 + ); + } + auto nativeVar_80 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_80; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_81; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + tblgen_CompareOp_81 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_80 + ); + } + ::mlir::stablehlo::AndOp logical_and_lt_y_safe_min_lt_x_one; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_79.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_CompareOp_81.getODSResults(0).begin()); + logical_and_lt_y_safe_min_lt_x_one = rewriter.create<::mlir::stablehlo::AndOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_82; + { + ::mlir::Value tblgen_value_0 = (*xp1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xm1.getODSResults(0).begin()); + tblgen_MulOp_82 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp ap1; + { + ::mlir::Value tblgen_value_0 = (*a.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + ap1 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_83; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_82.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ap1.getODSResults(0).begin()); + tblgen_DivOp_83 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_84; + { + ::mlir::Value tblgen_value_0 = (*tblgen_DivOp_83.getODSResults(0).begin()); + tblgen_NegOp_84 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto nativeVar_85 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_85; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_86; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + tblgen_CompareOp_86 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GE), + /*compare_type=*/nativeVar_85 + ); + } + ::mlir::stablehlo::MulOp half_yy; + { + ::mlir::Value tblgen_value_0 = half; + ::mlir::Value tblgen_value_1 = (*yy.getODSResults(0).begin()); + half_yy = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp divide_half_yy_rpxp1; + { + ::mlir::Value tblgen_value_0 = (*half_yy.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*rpxp1.getODSResults(0).begin()); + divide_half_yy_rpxp1 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_87; + { + ::mlir::Value tblgen_value_0 = half; + ::mlir::Value tblgen_value_1 = (*spxm1.getODSResults(0).begin()); + tblgen_MulOp_87 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_88; + { + ::mlir::Value tblgen_value_0 = (*divide_half_yy_rpxp1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_87.getODSResults(0).begin()); + tblgen_AddOp_88 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_89 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1.5, (*signed_x.getODSResults(0).begin())); (void)nativeVar_89; + auto nativeVar_90 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_90; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_91; + { + ::mlir::Value tblgen_value_0 = (*a.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_89; + tblgen_CompareOp_91 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LE), + /*compare_type=*/nativeVar_90 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_92; + { + ::mlir::Value tblgen_value_0 = (*half_yy.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*smxm1.getODSResults(0).begin()); + tblgen_DivOp_92 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_93; + { + ::mlir::Value tblgen_value_0 = (*divide_half_yy_rpxp1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_92.getODSResults(0).begin()); + tblgen_AddOp_93 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_94; + { + ::mlir::Value tblgen_value_0 = (*a.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + tblgen_SubtractOp_94 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_95; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_91.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_93.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SubtractOp_94.getODSResults(0).begin()); + tblgen_SelectOp_95 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp x_ge_1_or_not; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_86.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_88.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_95.getODSResults(0).begin()); + x_ge_1_or_not = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp am1; + { + ::mlir::Value tblgen_value_0 = (*logical_and_lt_y_safe_min_lt_x_one.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_NegOp_84.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*x_ge_1_or_not.getODSResults(0).begin()); + am1 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_96; + { + ::mlir::Value tblgen_value_0 = (*am1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ap1.getODSResults(0).begin()); + tblgen_MulOp_96 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp sq; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_96.getODSResults(0).begin()); + sq = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_97; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*sq.getODSResults(0).begin()); + tblgen_DivOp_97 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_98; + { + ::mlir::Value tblgen_value_0 = (*am1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*sq.getODSResults(0).begin()); + tblgen_AddOp_98 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::Log1pOp tblgen_Log1pOp_99; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_98.getODSResults(0).begin()); + tblgen_Log1pOp_99 = rewriter.create<::mlir::stablehlo::Log1pOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_100; + { + ::mlir::Value tblgen_value_0 = (*logical_and_lt_y_safe_min_lt_x_one.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_97.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_Log1pOp_99.getODSResults(0).begin()); + tblgen_SelectOp_100 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_101; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_60.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_73.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_100.getODSResults(0).begin()); + tblgen_SelectOp_101 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_102; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ComplexOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_SelectOp_48.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_SelectOp_101.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ComplexOp_102 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ComplexOp_102.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatternsMath.td:389 +*/ +struct GeneratedConvert9 : public ::mlir::RewritePattern { + GeneratedConvert9(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.asin", 1, context, {"chlo._asin_acos_kernel", "stablehlo.atan2", "stablehlo.compare", "stablehlo.complex", "stablehlo.imag", "stablehlo.negate", "stablehlo.real", "stablehlo.select"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range z(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::AsinOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns2(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.asin' failed to satisfy constraint: 'Complex element type'"))) { + return ::mlir::failure(); + } + z = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::RealOp signed_x; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + signed_x = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::chlo::AsinAcosKernelOp asin_acos_kernel_z; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + asin_acos_kernel_z = rewriter.create<::mlir::chlo::AsinAcosKernelOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::RealOp tblgen_RealOp_0; + { + ::mlir::Value tblgen_value_0 = (*asin_acos_kernel_z.getODSResults(0).begin()); + tblgen_RealOp_0 = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::Atan2Op real; + { + ::mlir::Value tblgen_value_0 = (*signed_x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_RealOp_0.getODSResults(0).begin()); + real = rewriter.create<::mlir::stablehlo::Atan2Op>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::ImagOp signed_y; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + signed_y = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto nativeVar_1 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0, (*signed_x.getODSResults(0).begin())); (void)nativeVar_1; + auto nativeVar_2 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_2; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_3; + { + ::mlir::Value tblgen_value_0 = (*signed_y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_1; + tblgen_CompareOp_3 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_2 + ); + } + ::mlir::stablehlo::ImagOp imag_asin_acos_kernel_z; + { + ::mlir::Value tblgen_value_0 = (*asin_acos_kernel_z.getODSResults(0).begin()); + imag_asin_acos_kernel_z = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_4; + { + ::mlir::Value tblgen_value_0 = (*imag_asin_acos_kernel_z.getODSResults(0).begin()); + tblgen_NegOp_4 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_5; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_3.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_NegOp_4.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*imag_asin_acos_kernel_z.getODSResults(0).begin()); + tblgen_SelectOp_5 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_6; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ComplexOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*real.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_SelectOp_5.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ComplexOp_6 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ComplexOp_6.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatternsMath.td:413 +*/ +struct GeneratedConvert10 : public ::mlir::RewritePattern { + GeneratedConvert10(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.asin", 1, context, {"stablehlo.add", "stablehlo.atan2", "stablehlo.multiply", "stablehlo.sqrt", "stablehlo.subtract"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range x(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::AsinOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.asin' failed to satisfy constraint: 'Non-complex element type'"))) { + return ::mlir::failure(); + } + x = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto one = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1, (*x.begin())); (void)one; + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_0; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*x.begin()); + tblgen_SubtractOp_0 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_1; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*x.begin()); + tblgen_AddOp_1 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_2; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SubtractOp_0.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_1.getODSResults(0).begin()); + tblgen_MulOp_2 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp tblgen_SqrtOp_3; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_2.getODSResults(0).begin()); + tblgen_SqrtOp_3 = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_4; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*tblgen_SqrtOp_3.getODSResults(0).begin()); + tblgen_AddOp_4 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::Atan2Op ta; + { + ::mlir::Value tblgen_value_0 = (*x.begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_4.getODSResults(0).begin()); + ta = rewriter.create<::mlir::stablehlo::Atan2Op>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_5; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::AddOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*ta.getODSResults(0).begin())); + tblgen_values.push_back((*ta.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_AddOp_5 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AddOp_5.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatternsMath.td:465 +*/ +struct GeneratedConvert11 : public ::mlir::RewritePattern { + GeneratedConvert11(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.acos", 1, context, {"chlo._asin_acos_kernel", "stablehlo.atan2", "stablehlo.compare", "stablehlo.complex", "stablehlo.imag", "stablehlo.negate", "stablehlo.real", "stablehlo.select"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range z(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::AcosOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns2(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.acos' failed to satisfy constraint: 'Complex element type'"))) { + return ::mlir::failure(); + } + z = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::chlo::AsinAcosKernelOp asin_acos_kernel_z; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + asin_acos_kernel_z = rewriter.create<::mlir::chlo::AsinAcosKernelOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::RealOp tblgen_RealOp_0; + { + ::mlir::Value tblgen_value_0 = (*asin_acos_kernel_z.getODSResults(0).begin()); + tblgen_RealOp_0 = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::RealOp signed_x; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + signed_x = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::Atan2Op tblgen_Atan2Op_1; + { + ::mlir::Value tblgen_value_0 = (*tblgen_RealOp_0.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*signed_x.getODSResults(0).begin()); + tblgen_Atan2Op_1 = rewriter.create<::mlir::stablehlo::Atan2Op>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::ImagOp signed_y; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + signed_y = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto nativeVar_2 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0, (*signed_y.getODSResults(0).begin())); (void)nativeVar_2; + auto nativeVar_3 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_3; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_4; + { + ::mlir::Value tblgen_value_0 = (*signed_y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_2; + tblgen_CompareOp_4 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_3 + ); + } + ::mlir::stablehlo::ImagOp imag_asin_acos_kernel_z; + { + ::mlir::Value tblgen_value_0 = (*asin_acos_kernel_z.getODSResults(0).begin()); + imag_asin_acos_kernel_z = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_5; + { + ::mlir::Value tblgen_value_0 = (*imag_asin_acos_kernel_z.getODSResults(0).begin()); + tblgen_NegOp_5 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_6; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_4.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*imag_asin_acos_kernel_z.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_NegOp_5.getODSResults(0).begin()); + tblgen_SelectOp_6 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_7; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ComplexOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_Atan2Op_1.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_SelectOp_6.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ComplexOp_7 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ComplexOp_7.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatternsMath.td:490 +*/ +struct GeneratedConvert12 : public ::mlir::RewritePattern { + GeneratedConvert12(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.acos", 1, context, {"stablehlo.add", "stablehlo.atan2", "stablehlo.multiply", "stablehlo.sqrt", "stablehlo.subtract"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range x(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::AcosOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.acos' failed to satisfy constraint: 'Non-complex element type'"))) { + return ::mlir::failure(); + } + x = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto constant_1 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1, (*x.begin())); (void)constant_1; + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_0; + { + ::mlir::Value tblgen_value_0 = constant_1; + ::mlir::Value tblgen_value_1 = (*x.begin()); + tblgen_SubtractOp_0 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_1; + { + ::mlir::Value tblgen_value_0 = constant_1; + ::mlir::Value tblgen_value_1 = (*x.begin()); + tblgen_AddOp_1 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_2; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SubtractOp_0.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_1.getODSResults(0).begin()); + tblgen_MulOp_2 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp tblgen_SqrtOp_3; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_2.getODSResults(0).begin()); + tblgen_SqrtOp_3 = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::Atan2Op tblgen_Atan2Op_4; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::Atan2Op::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_SqrtOp_3.getODSResults(0).begin())); + tblgen_values.push_back((*x.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_Atan2Op_4 = rewriter.create<::mlir::stablehlo::Atan2Op>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_Atan2Op_4.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatternsMath.td:527 +*/ +struct GeneratedConvert13 : public ::mlir::RewritePattern { + GeneratedConvert13(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.acosh", 1, context, {"chlo._asin_acos_kernel", "stablehlo.atan2", "stablehlo.compare", "stablehlo.complex", "stablehlo.imag", "stablehlo.negate", "stablehlo.real", "stablehlo.select"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range z(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::AcoshOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns2(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.acosh' failed to satisfy constraint: 'Complex element type'"))) { + return ::mlir::failure(); + } + z = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::chlo::AsinAcosKernelOp w; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + w = rewriter.create<::mlir::chlo::AsinAcosKernelOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ImagOp tblgen_ImagOp_0; + { + ::mlir::Value tblgen_value_0 = (*w.getODSResults(0).begin()); + tblgen_ImagOp_0 = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ImagOp signed_y; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + signed_y = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto nativeVar_1 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0, (*signed_y.getODSResults(0).begin())); (void)nativeVar_1; + auto nativeVar_2 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_2; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_3; + { + ::mlir::Value tblgen_value_0 = (*signed_y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_1; + tblgen_CompareOp_3 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_2 + ); + } + ::mlir::stablehlo::RealOp tblgen_RealOp_4; + { + ::mlir::Value tblgen_value_0 = (*w.getODSResults(0).begin()); + tblgen_RealOp_4 = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::RealOp signed_x; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + signed_x = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::Atan2Op imag; + { + ::mlir::Value tblgen_value_0 = (*tblgen_RealOp_4.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*signed_x.getODSResults(0).begin()); + imag = rewriter.create<::mlir::stablehlo::Atan2Op>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_5; + { + ::mlir::Value tblgen_value_0 = (*imag.getODSResults(0).begin()); + tblgen_NegOp_5 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_6; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_3.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_NegOp_5.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*imag.getODSResults(0).begin()); + tblgen_SelectOp_6 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_7; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ComplexOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_ImagOp_0.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_SelectOp_6.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ComplexOp_7 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ComplexOp_7.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatternsMath.td:560 +*/ +struct GeneratedConvert14 : public ::mlir::RewritePattern { + GeneratedConvert14(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.acosh", 1, context, {"stablehlo.add", "stablehlo.compare", "stablehlo.divide", "stablehlo.log", "stablehlo.log_plus_one", "stablehlo.multiply", "stablehlo.select", "stablehlo.sqrt", "stablehlo.subtract"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range x(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::AcoshOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.acosh' failed to satisfy constraint: 'Non-complex element type'"))) { + return ::mlir::failure(); + } + x = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = ::mlir::stablehlo::getConstantLikeMaxFiniteValue(rewriter, odsLoc, (*x.begin())); (void)nativeVar_0; + auto constant_2 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 2, (*x.begin())); (void)constant_2; + ::mlir::stablehlo::DivOp tblgen_DivOp_1; + { + ::mlir::Value tblgen_value_0 = nativeVar_0; + ::mlir::Value tblgen_value_1 = constant_2; + tblgen_DivOp_1 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_2 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_2; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_3; + { + ::mlir::Value tblgen_value_0 = (*x.begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_1.getODSResults(0).begin()); + tblgen_CompareOp_3 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GE), + /*compare_type=*/nativeVar_2 + ); + } + ::mlir::stablehlo::LogOp tblgen_LogOp_4; + { + ::mlir::Value tblgen_value_0 = constant_2; + tblgen_LogOp_4 = rewriter.create<::mlir::stablehlo::LogOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::LogOp tblgen_LogOp_5; + { + ::mlir::Value tblgen_value_0 = (*x.begin()); + tblgen_LogOp_5 = rewriter.create<::mlir::stablehlo::LogOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_6; + { + ::mlir::Value tblgen_value_0 = (*tblgen_LogOp_4.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_LogOp_5.getODSResults(0).begin()); + tblgen_AddOp_6 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto constant_1 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1, (*x.begin())); (void)constant_1; + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_7; + { + ::mlir::Value tblgen_value_0 = (*x.begin()); + ::mlir::Value tblgen_value_1 = constant_1; + tblgen_SubtractOp_7 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp sqrt_subtract_x_constant_1; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SubtractOp_7.getODSResults(0).begin()); + sqrt_subtract_x_constant_1 = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_8; + { + ::mlir::Value tblgen_value_0 = (*x.begin()); + ::mlir::Value tblgen_value_1 = constant_1; + tblgen_AddOp_8 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp tblgen_SqrtOp_9; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_8.getODSResults(0).begin()); + tblgen_SqrtOp_9 = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_10; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SqrtOp_9.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*sqrt_subtract_x_constant_1.getODSResults(0).begin()); + tblgen_AddOp_10 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_11; + { + ::mlir::Value tblgen_value_0 = (*sqrt_subtract_x_constant_1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_10.getODSResults(0).begin()); + tblgen_MulOp_11 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::Log1pOp tblgen_Log1pOp_12; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_11.getODSResults(0).begin()); + tblgen_Log1pOp_12 = rewriter.create<::mlir::stablehlo::Log1pOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_13; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::SelectOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_CompareOp_3.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_AddOp_6.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_Log1pOp_12.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_SelectOp_13 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SelectOp_13.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatternsMath.td:604 +*/ +struct GeneratedConvert15 : public ::mlir::RewritePattern { + GeneratedConvert15(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.asinh", 1, context, {"chlo._asin_acos_kernel", "stablehlo.atan2", "stablehlo.compare", "stablehlo.complex", "stablehlo.imag", "stablehlo.negate", "stablehlo.real", "stablehlo.select"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range z(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::AsinhOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns2(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.asinh' failed to satisfy constraint: 'Complex element type'"))) { + return ::mlir::failure(); + } + z = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::RealOp signed_x; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + signed_x = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto nativeVar_0 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0, (*signed_x.getODSResults(0).begin())); (void)nativeVar_0; + auto nativeVar_1 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_1; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_2; + { + ::mlir::Value tblgen_value_0 = (*signed_x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_0; + tblgen_CompareOp_2 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_1 + ); + } + ::mlir::stablehlo::ImagOp signed_y; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + signed_y = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_3; + { + ::mlir::Value tblgen_value_0 = (*signed_y.getODSResults(0).begin()); + tblgen_NegOp_3 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_4; + { + ::mlir::Value tblgen_value_0 = (*tblgen_NegOp_3.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*signed_x.getODSResults(0).begin()); + tblgen_ComplexOp_4 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::chlo::AsinAcosKernelOp w; + { + ::mlir::Value tblgen_value_0 = (*tblgen_ComplexOp_4.getODSResults(0).begin()); + w = rewriter.create<::mlir::chlo::AsinAcosKernelOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ImagOp imag_w; + { + ::mlir::Value tblgen_value_0 = (*w.getODSResults(0).begin()); + imag_w = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_5; + { + ::mlir::Value tblgen_value_0 = (*imag_w.getODSResults(0).begin()); + tblgen_NegOp_5 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_6; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_2.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_NegOp_5.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*imag_w.getODSResults(0).begin()); + tblgen_SelectOp_6 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::RealOp tblgen_RealOp_7; + { + ::mlir::Value tblgen_value_0 = (*w.getODSResults(0).begin()); + tblgen_RealOp_7 = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::Atan2Op tblgen_Atan2Op_8; + { + ::mlir::Value tblgen_value_0 = (*signed_y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_RealOp_7.getODSResults(0).begin()); + tblgen_Atan2Op_8 = rewriter.create<::mlir::stablehlo::Atan2Op>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_9; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ComplexOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_SelectOp_6.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_Atan2Op_8.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ComplexOp_9 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ComplexOp_9.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatternsMath.td:657 +*/ +struct GeneratedConvert16 : public ::mlir::RewritePattern { + GeneratedConvert16(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.asinh", 1, context, {"stablehlo.abs", "stablehlo.add", "stablehlo.compare", "stablehlo.divide", "stablehlo.log", "stablehlo.log_plus_one", "stablehlo.multiply", "stablehlo.select", "stablehlo.sign", "stablehlo.sqrt"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range x(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::AsinhOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.asinh' failed to satisfy constraint: 'Non-complex element type'"))) { + return ::mlir::failure(); + } + x = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::SignOp tblgen_SignOp_0; + { + ::mlir::Value tblgen_value_0 = (*x.begin()); + tblgen_SignOp_0 = rewriter.create<::mlir::stablehlo::SignOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::AbsOp ax; + { + ::mlir::Value tblgen_value_0 = (*x.begin()); + ax = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto nativeVar_1 = ::mlir::stablehlo::getConstantLikeMaxFiniteValue(rewriter, odsLoc, (*x.begin())); (void)nativeVar_1; + ::mlir::stablehlo::SqrtOp tblgen_SqrtOp_2; + { + ::mlir::Value tblgen_value_0 = nativeVar_1; + tblgen_SqrtOp_2 = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + auto nativeVar_3 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_3; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_4; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SqrtOp_2.getODSResults(0).begin()); + tblgen_CompareOp_4 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GE), + /*compare_type=*/nativeVar_3 + ); + } + auto nativeVar_5 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 2, (*x.begin())); (void)nativeVar_5; + ::mlir::stablehlo::LogOp tblgen_LogOp_6; + { + ::mlir::Value tblgen_value_0 = nativeVar_5; + tblgen_LogOp_6 = rewriter.create<::mlir::stablehlo::LogOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::LogOp tblgen_LogOp_7; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + tblgen_LogOp_7 = rewriter.create<::mlir::stablehlo::LogOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_8; + { + ::mlir::Value tblgen_value_0 = (*tblgen_LogOp_6.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_LogOp_7.getODSResults(0).begin()); + tblgen_AddOp_8 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp ax2; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ax.getODSResults(0).begin()); + ax2 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto one = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1, (*x.begin())); (void)one; + ::mlir::stablehlo::AddOp tblgen_AddOp_9; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*ax2.getODSResults(0).begin()); + tblgen_AddOp_9 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp tblgen_SqrtOp_10; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_9.getODSResults(0).begin()); + tblgen_SqrtOp_10 = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_11; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*tblgen_SqrtOp_10.getODSResults(0).begin()); + tblgen_AddOp_11 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_12; + { + ::mlir::Value tblgen_value_0 = (*ax2.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_11.getODSResults(0).begin()); + tblgen_DivOp_12 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_13; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_12.getODSResults(0).begin()); + tblgen_AddOp_13 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::Log1pOp tblgen_Log1pOp_14; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_13.getODSResults(0).begin()); + tblgen_Log1pOp_14 = rewriter.create<::mlir::stablehlo::Log1pOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_15; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_4.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_8.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_Log1pOp_14.getODSResults(0).begin()); + tblgen_SelectOp_15 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_16; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::MulOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_SignOp_0.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_SelectOp_15.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_MulOp_16 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MulOp_16.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatternsMath.td:685 +*/ +struct GeneratedConvert17 : public ::mlir::RewritePattern { + GeneratedConvert17(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.atan", 1, context, {"chlo.atanh", "stablehlo.complex", "stablehlo.imag", "stablehlo.negate", "stablehlo.real"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range z(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::AtanOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns2(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.atan' failed to satisfy constraint: 'Complex element type'"))) { + return ::mlir::failure(); + } + z = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::ImagOp tblgen_ImagOp_0; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + tblgen_ImagOp_0 = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_1; + { + ::mlir::Value tblgen_value_0 = (*tblgen_ImagOp_0.getODSResults(0).begin()); + tblgen_NegOp_1 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::RealOp tblgen_RealOp_2; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + tblgen_RealOp_2 = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_3; + { + ::mlir::Value tblgen_value_0 = (*tblgen_NegOp_1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_RealOp_2.getODSResults(0).begin()); + tblgen_ComplexOp_3 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::chlo::AtanhOp w; + { + ::mlir::Value tblgen_value_0 = (*tblgen_ComplexOp_3.getODSResults(0).begin()); + w = rewriter.create<::mlir::chlo::AtanhOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ImagOp tblgen_ImagOp_4; + { + ::mlir::Value tblgen_value_0 = (*w.getODSResults(0).begin()); + tblgen_ImagOp_4 = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::RealOp tblgen_RealOp_5; + { + ::mlir::Value tblgen_value_0 = (*w.getODSResults(0).begin()); + tblgen_RealOp_5 = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_6; + { + ::mlir::Value tblgen_value_0 = (*tblgen_RealOp_5.getODSResults(0).begin()); + tblgen_NegOp_6 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_7; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ComplexOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_ImagOp_4.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_NegOp_6.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ComplexOp_7 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ComplexOp_7.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatternsMath.td:772 +*/ +struct GeneratedConvert18 : public ::mlir::RewritePattern { + GeneratedConvert18(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.atanh", 1, context, {"stablehlo.abs", "stablehlo.add", "stablehlo.and", "stablehlo.atan2", "stablehlo.compare", "stablehlo.complex", "stablehlo.divide", "stablehlo.imag", "stablehlo.log_plus_one", "stablehlo.multiply", "stablehlo.or", "stablehlo.real", "stablehlo.select", "stablehlo.subtract"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range z(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::AtanhOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns2(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.atanh' failed to satisfy constraint: 'Complex element type'"))) { + return ::mlir::failure(); + } + z = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::RealOp x; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + x = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto zero = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0, (*x.getODSResults(0).begin())); (void)zero; + auto nativeVar_0 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_0; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_1; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = zero; + tblgen_CompareOp_1 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GE), + /*compare_type=*/nativeVar_0 + ); + } + auto one = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1, (*x.getODSResults(0).begin())); (void)one; + auto constant_neg1 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, -1, (*x.getODSResults(0).begin())); (void)constant_neg1; + ::mlir::stablehlo::SelectOp tblgen_SelectOp_2; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + ::mlir::Value tblgen_value_2 = constant_neg1; + tblgen_SelectOp_2 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + auto nativeVar_3 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 4, (*x.getODSResults(0).begin())); (void)nativeVar_3; + ::mlir::stablehlo::AbsOp ax; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ax = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto largest = ::mlir::stablehlo::getConstantLikeMaxFiniteValue(rewriter, odsLoc, (*x.getODSResults(0).begin())); (void)largest; + auto nativeVar_4 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1e+308, (*x.getODSResults(0).begin())); (void)nativeVar_4; + auto nativeVar_5 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_5; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_6; + { + ::mlir::Value tblgen_value_0 = largest; + ::mlir::Value tblgen_value_1 = nativeVar_4; + tblgen_CompareOp_6 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_5 + ); + } + auto nativeVar_7 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 9007199254740994.0, (*x.getODSResults(0).begin())); (void)nativeVar_7; + auto nativeVar_8 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1e+38, (*x.getODSResults(0).begin())); (void)nativeVar_8; + auto nativeVar_9 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_9; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_10; + { + ::mlir::Value tblgen_value_0 = largest; + ::mlir::Value tblgen_value_1 = nativeVar_8; + tblgen_CompareOp_10 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_9 + ); + } + auto nativeVar_11 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 16777218.0, (*x.getODSResults(0).begin())); (void)nativeVar_11; + auto nativeVar_12 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 2050.0, (*x.getODSResults(0).begin())); (void)nativeVar_12; + ::mlir::stablehlo::SelectOp tblgen_SelectOp_13; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_10.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_11; + ::mlir::Value tblgen_value_2 = nativeVar_12; + tblgen_SelectOp_13 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp inv_negeps; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_6.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_7; + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_13.getODSResults(0).begin()); + inv_negeps = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::MulOp safe_max; + { + ::mlir::Value tblgen_value_0 = (*inv_negeps.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*inv_negeps.getODSResults(0).begin()); + safe_max = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_14 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_14; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_15; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*safe_max.getODSResults(0).begin()); + tblgen_CompareOp_15 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_14 + ); + } + ::mlir::stablehlo::ImagOp y; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + y = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::AbsOp ay; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ay = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto nativeVar_16 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_16; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_17; + { + ::mlir::Value tblgen_value_0 = (*ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*safe_max.getODSResults(0).begin()); + tblgen_CompareOp_17 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_16 + ); + } + ::mlir::stablehlo::AndOp in_safe_region; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_15.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_CompareOp_17.getODSResults(0).begin()); + in_safe_region = rewriter.create<::mlir::stablehlo::AndOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp naxm1; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*ax.getODSResults(0).begin()); + naxm1 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_18; + { + ::mlir::Value tblgen_value_0 = (*naxm1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*naxm1.getODSResults(0).begin()); + tblgen_MulOp_18 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp y2; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + y2 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_19; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_18.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y2.getODSResults(0).begin()); + tblgen_AddOp_19 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_20; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_19.getODSResults(0).begin()); + tblgen_DivOp_20 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_21; + { + ::mlir::Value tblgen_value_0 = (*ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*inv_negeps.getODSResults(0).begin()); + tblgen_MulOp_21 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_22 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_22; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_23; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_21.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ax.getODSResults(0).begin()); + tblgen_CompareOp_23 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_22 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_24; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*ax.getODSResults(0).begin()); + tblgen_DivOp_24 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto constant_posinf = ::mlir::stablehlo::getConstantLikeInfValue(rewriter, odsLoc, (*x.getODSResults(0).begin()), /*negative=*/false); (void)constant_posinf; + auto nativeVar_25 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_25; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_26; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = constant_posinf; + tblgen_CompareOp_26 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_25 + ); + } + auto constant_neginf = ::mlir::stablehlo::getConstantLikeInfValue(rewriter, odsLoc, (*x.getODSResults(0).begin()), /*negative=*/true); (void)constant_neginf; + auto nativeVar_27 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_27; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_28; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = constant_neginf; + tblgen_CompareOp_28 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_27 + ); + } + ::mlir::stablehlo::OrOp tblgen_OrOp_29; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_26.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_CompareOp_28.getODSResults(0).begin()); + tblgen_OrOp_29 = rewriter.create<::mlir::stablehlo::OrOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_30 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_30; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_31; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = constant_posinf; + tblgen_CompareOp_31 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_30 + ); + } + auto nativeVar_32 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_32; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_33; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = constant_neginf; + tblgen_CompareOp_33 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_32 + ); + } + ::mlir::stablehlo::OrOp tblgen_OrOp_34; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_31.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_CompareOp_33.getODSResults(0).begin()); + tblgen_OrOp_34 = rewriter.create<::mlir::stablehlo::OrOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::OrOp tblgen_OrOp_35; + { + ::mlir::Value tblgen_value_0 = (*tblgen_OrOp_29.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_OrOp_34.getODSResults(0).begin()); + tblgen_OrOp_35 = rewriter.create<::mlir::stablehlo::OrOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_36; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + tblgen_DivOp_36 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_37; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ax.getODSResults(0).begin()); + tblgen_DivOp_37 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_38; + { + ::mlir::Value tblgen_value_0 = (*tblgen_DivOp_36.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_37.getODSResults(0).begin()); + tblgen_AddOp_38 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_39; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_38.getODSResults(0).begin()); + tblgen_DivOp_39 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_40; + { + ::mlir::Value tblgen_value_0 = (*tblgen_DivOp_39.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + tblgen_DivOp_40 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_41; + { + ::mlir::Value tblgen_value_0 = (*tblgen_OrOp_35.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = zero; + ::mlir::Value tblgen_value_2 = (*tblgen_DivOp_40.getODSResults(0).begin()); + tblgen_SelectOp_41 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_42; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_23.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_24.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_41.getODSResults(0).begin()); + tblgen_SelectOp_42 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_43; + { + ::mlir::Value tblgen_value_0 = (*in_safe_region.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_20.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_42.getODSResults(0).begin()); + tblgen_SelectOp_43 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_44; + { + ::mlir::Value tblgen_value_0 = nativeVar_3; + ::mlir::Value tblgen_value_1 = (*tblgen_SelectOp_43.getODSResults(0).begin()); + tblgen_MulOp_44 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::Log1pOp tblgen_Log1pOp_45; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_44.getODSResults(0).begin()); + tblgen_Log1pOp_45 = rewriter.create<::mlir::stablehlo::Log1pOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_46; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SelectOp_2.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_Log1pOp_45.getODSResults(0).begin()); + tblgen_MulOp_46 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_47 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0.25, (*x.getODSResults(0).begin())); (void)nativeVar_47; + ::mlir::stablehlo::MulOp tblgen_MulOp_48; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_46.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_47; + tblgen_MulOp_48 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_49; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + tblgen_AddOp_49 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_50; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*ax.getODSResults(0).begin()); + tblgen_AddOp_50 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_51; + { + ::mlir::Value tblgen_value_0 = (*naxm1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_50.getODSResults(0).begin()); + tblgen_MulOp_51 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_52; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_51.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y2.getODSResults(0).begin()); + tblgen_SubtractOp_52 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::Atan2Op tblgen_Atan2Op_53; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_49.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_52.getODSResults(0).begin()); + tblgen_Atan2Op_53 = rewriter.create<::mlir::stablehlo::Atan2Op>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_54 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0, (*y.getODSResults(0).begin())); (void)nativeVar_54; + auto nativeVar_55 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_55; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_56; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_54; + tblgen_CompareOp_56 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GE), + /*compare_type=*/nativeVar_55 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_57; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_56.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + ::mlir::Value tblgen_value_2 = constant_neg1; + tblgen_SelectOp_57 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + auto nativeVar_58 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, M_PI, (*x.getODSResults(0).begin())); (void)nativeVar_58; + ::mlir::stablehlo::MulOp tblgen_MulOp_59; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SelectOp_57.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_58; + tblgen_MulOp_59 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_60; + { + ::mlir::Value tblgen_value_0 = (*in_safe_region.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_Atan2Op_53.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_MulOp_59.getODSResults(0).begin()); + tblgen_SelectOp_60 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + auto nativeVar_61 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0.5, (*x.getODSResults(0).begin())); (void)nativeVar_61; + ::mlir::stablehlo::MulOp tblgen_MulOp_62; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SelectOp_60.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_61; + tblgen_MulOp_62 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_63; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ComplexOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_MulOp_48.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_MulOp_62.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ComplexOp_63 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ComplexOp_63.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatternsMath.td:893 +*/ +struct GeneratedConvert19 : public ::mlir::RewritePattern { + GeneratedConvert19(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.square", 1, context, {"stablehlo.abs", "stablehlo.add", "stablehlo.and", "stablehlo.compare", "stablehlo.complex", "stablehlo.imag", "stablehlo.is_finite", "stablehlo.multiply", "stablehlo.real", "stablehlo.select", "stablehlo.subtract"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range z(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::SquareOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns2(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.square' failed to satisfy constraint: 'Complex element type'"))) { + return ::mlir::failure(); + } + z = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::RealOp x; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + x = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::IsFiniteOp tblgen_IsFiniteOp_0; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + tblgen_IsFiniteOp_0 = rewriter.create<::mlir::stablehlo::IsFiniteOp>(odsLoc, + /*x=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::AbsOp tblgen_AbsOp_1; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + tblgen_AbsOp_1 = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ImagOp y; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + y = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::AbsOp tblgen_AbsOp_2; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + tblgen_AbsOp_2 = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto nativeVar_3 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_3; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_4; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AbsOp_1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AbsOp_2.getODSResults(0).begin()); + tblgen_CompareOp_4 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_3 + ); + } + ::mlir::stablehlo::AndOp tblgen_AndOp_5; + { + ::mlir::Value tblgen_value_0 = (*tblgen_IsFiniteOp_0.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_CompareOp_4.getODSResults(0).begin()); + tblgen_AndOp_5 = rewriter.create<::mlir::stablehlo::AndOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_6 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0, (*x.getODSResults(0).begin())); (void)nativeVar_6; + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_7; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + tblgen_SubtractOp_7 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_8; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + tblgen_AddOp_8 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_9; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SubtractOp_7.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_8.getODSResults(0).begin()); + tblgen_MulOp_9 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_10; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AndOp_5.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_6; + ::mlir::Value tblgen_value_2 = (*tblgen_MulOp_9.getODSResults(0).begin()); + tblgen_SelectOp_10 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + auto nativeVar_11 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 2, (*x.getODSResults(0).begin())); (void)nativeVar_11; + ::mlir::stablehlo::MulOp tblgen_MulOp_12; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + tblgen_MulOp_12 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_13; + { + ::mlir::Value tblgen_value_0 = nativeVar_11; + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_12.getODSResults(0).begin()); + tblgen_MulOp_13 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_14; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ComplexOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_SelectOp_10.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_MulOp_13.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ComplexOp_14 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ComplexOp_14.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/ChloDecompositionPatternsMath.td:914 +*/ +struct GeneratedConvert20 : public ::mlir::RewritePattern { + GeneratedConvert20(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("chlo.square", 1, context, {"stablehlo.multiply"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range x(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::chlo::SquareOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_ChloDecompositionPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'chlo.square' failed to satisfy constraint: 'Non-complex element type'"))) { + return ::mlir::failure(); + } + x = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::MulOp tblgen_MulOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::MulOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*x.begin())); + tblgen_values.push_back((*x.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_MulOp_0 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MulOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +void LLVM_ATTRIBUTE_UNUSED populateWithGenerated(::mlir::RewritePatternSet &patterns) { + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); +} diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/ChloDecompositionUtils.h b/deps/exla/cache/xla_extension/include/stablehlo/transforms/ChloDecompositionUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..6bf3a4ffe696d33354a5191b726cdcc44e149a65 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/ChloDecompositionUtils.h @@ -0,0 +1,36 @@ +/* Copyright 2024 The StableHLO Authors. All Rights Reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_TRANSFORMS_CHLO_DECOMP_UTILS_H_ +#define STABLEHLO_TRANSFORMS_CHLO_DECOMP_UTILS_H_ + +#include "mlir/IR/Value.h" +#include "mlir/IR/ValueRange.h" +#include "mlir/Transforms/DialectConversion.h" + +namespace mlir { +namespace stablehlo { + +// Utility functions used in the Chlo to stablehlo legalization. + +Value materializeLgamma(OpBuilder &rewriter, Location loc, ValueRange args); + +Value materializeDigamma(OpBuilder &rewriter, Location loc, ValueRange args); + +Value materializeZeta(OpBuilder &rewriter, Location loc, ValueRange args); + +Value materializePolygamma(OpBuilder &rewriter, Location loc, ValueRange args); + +} // namespace stablehlo +} // namespace mlir + +#endif // STABLEHLO_TRANSFORMS_CHLO_DECOMP_UTILS_H_ diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/MapStablehloToVhlo.h b/deps/exla/cache/xla_extension/include/stablehlo/transforms/MapStablehloToVhlo.h new file mode 100644 index 0000000000000000000000000000000000000000..1c43df083ad8913db7329dd920a716fd8557bffe --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/MapStablehloToVhlo.h @@ -0,0 +1,196 @@ +/* Copyright 2022 The StableHLO Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_TRANSFORMS_MAPSTABLEHLOTOVHLO_H +#define STABLEHLO_TRANSFORMS_MAPSTABLEHLOTOVHLO_H + +#include + +#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "stablehlo/dialect/StablehloOps.h" +#include "stablehlo/dialect/VhloOps.h" + +namespace mlir { +namespace stablehlo { + +template +struct VhloToStablehloOpImpl { + using Type = std::false_type; +}; +template +using VhloToStablehloOp = typename VhloToStablehloOpImpl::Type; + +template +struct StablehloToVhloOpImpl { + using Type = std::false_type; +}; +template +using StablehloToVhloOp = typename StablehloToVhloOpImpl::Type; + +#define MAP_STABLEHLO_TO_VHLO(OpName, OpVer) \ + template <> \ + struct StablehloToVhloOpImpl { \ + using Type = vhlo::OpName##OpVer; \ + }; \ + template <> \ + struct VhloToStablehloOpImpl { \ + using Type = stablehlo::OpName; \ + }; + +MAP_STABLEHLO_TO_VHLO(AbsOp, V1) +MAP_STABLEHLO_TO_VHLO(AddOp, V1) +MAP_STABLEHLO_TO_VHLO(AfterAllOp, V1) +MAP_STABLEHLO_TO_VHLO(AllGatherOp, V2) +MAP_STABLEHLO_TO_VHLO(AllReduceOp, V2) +MAP_STABLEHLO_TO_VHLO(AllToAllOp, V2) +MAP_STABLEHLO_TO_VHLO(AndOp, V1) +MAP_STABLEHLO_TO_VHLO(Atan2Op, V1) +MAP_STABLEHLO_TO_VHLO(BatchNormGradOp, V1) +MAP_STABLEHLO_TO_VHLO(BatchNormInferenceOp, V1) +MAP_STABLEHLO_TO_VHLO(BatchNormTrainingOp, V1) +MAP_STABLEHLO_TO_VHLO(BitcastConvertOp, V1) +MAP_STABLEHLO_TO_VHLO(BroadcastInDimOp, V1) +MAP_STABLEHLO_TO_VHLO(BroadcastOp, V1) +MAP_STABLEHLO_TO_VHLO(CaseOp, V1) +MAP_STABLEHLO_TO_VHLO(CbrtOp, V2) +MAP_STABLEHLO_TO_VHLO(CeilOp, V1) +MAP_STABLEHLO_TO_VHLO(CholeskyOp, V1) +MAP_STABLEHLO_TO_VHLO(ClampOp, V1) +MAP_STABLEHLO_TO_VHLO(ClzOp, V1) +MAP_STABLEHLO_TO_VHLO(CollectiveBroadcastOp, V1) +MAP_STABLEHLO_TO_VHLO(CollectivePermuteOp, V1) +MAP_STABLEHLO_TO_VHLO(CompareOp, V1) +MAP_STABLEHLO_TO_VHLO(ComplexOp, V1) +MAP_STABLEHLO_TO_VHLO(CompositeOp, V1) +MAP_STABLEHLO_TO_VHLO(ConcatenateOp, V1) +MAP_STABLEHLO_TO_VHLO(ConstantOp, V1) +MAP_STABLEHLO_TO_VHLO(ConvertOp, V1) +MAP_STABLEHLO_TO_VHLO(ConvolutionOp, V1) +MAP_STABLEHLO_TO_VHLO(CosineOp, V2) +MAP_STABLEHLO_TO_VHLO(CreateTokenOp, V1) +MAP_STABLEHLO_TO_VHLO(CrossReplicaSumOp, V1) +MAP_STABLEHLO_TO_VHLO(CustomCallOp, V1) +MAP_STABLEHLO_TO_VHLO(DivOp, V1) +MAP_STABLEHLO_TO_VHLO(DotGeneralOp, V2) +MAP_STABLEHLO_TO_VHLO(DotOp, V1) +MAP_STABLEHLO_TO_VHLO(DynamicBroadcastInDimOp, V1) +MAP_STABLEHLO_TO_VHLO(DynamicConvOp, V2) +MAP_STABLEHLO_TO_VHLO(DynamicGatherOp, V2) +MAP_STABLEHLO_TO_VHLO(DynamicIotaOp, V1) +MAP_STABLEHLO_TO_VHLO(DynamicPadOp, V1) +MAP_STABLEHLO_TO_VHLO(DynamicReshapeOp, V1) +MAP_STABLEHLO_TO_VHLO(DynamicSliceOp, V1) +MAP_STABLEHLO_TO_VHLO(DynamicUpdateSliceOp, V1) +MAP_STABLEHLO_TO_VHLO(EinsumOp, V1) +MAP_STABLEHLO_TO_VHLO(Expm1Op, V2) +MAP_STABLEHLO_TO_VHLO(ExpOp, V2) +MAP_STABLEHLO_TO_VHLO(FftOp, V1) +MAP_STABLEHLO_TO_VHLO(FloorOp, V1) +MAP_STABLEHLO_TO_VHLO(GatherOp, V2) +MAP_STABLEHLO_TO_VHLO(GetDimensionSizeOp, V1) +MAP_STABLEHLO_TO_VHLO(GetTupleElementOp, V1) +MAP_STABLEHLO_TO_VHLO(IfOp, V1) +MAP_STABLEHLO_TO_VHLO(ImagOp, V1) +MAP_STABLEHLO_TO_VHLO(InfeedOp, V1) +MAP_STABLEHLO_TO_VHLO(IotaOp, V1) +MAP_STABLEHLO_TO_VHLO(IsFiniteOp, V1) +MAP_STABLEHLO_TO_VHLO(Log1pOp, V2) +MAP_STABLEHLO_TO_VHLO(LogisticOp, V2) +MAP_STABLEHLO_TO_VHLO(LogOp, V2) +MAP_STABLEHLO_TO_VHLO(MapOp, V1) +MAP_STABLEHLO_TO_VHLO(MaxOp, V1) +MAP_STABLEHLO_TO_VHLO(MinOp, V1) +MAP_STABLEHLO_TO_VHLO(MulOp, V1) +MAP_STABLEHLO_TO_VHLO(NegOp, V1) +MAP_STABLEHLO_TO_VHLO(NotOp, V1) +MAP_STABLEHLO_TO_VHLO(OptimizationBarrierOp, V1) +MAP_STABLEHLO_TO_VHLO(OrOp, V1) +MAP_STABLEHLO_TO_VHLO(OutfeedOp, V1) +MAP_STABLEHLO_TO_VHLO(PadOp, V1) +MAP_STABLEHLO_TO_VHLO(PartitionIdOp, V1) +MAP_STABLEHLO_TO_VHLO(PopulationCountOp, V1) +MAP_STABLEHLO_TO_VHLO(PowOp, V1) +MAP_STABLEHLO_TO_VHLO(RealDynamicSliceOp, V1) +MAP_STABLEHLO_TO_VHLO(RealOp, V1) +MAP_STABLEHLO_TO_VHLO(RecvOp, V1) +MAP_STABLEHLO_TO_VHLO(ReduceOp, V1) +MAP_STABLEHLO_TO_VHLO(ReducePrecisionOp, V1) +MAP_STABLEHLO_TO_VHLO(ReduceScatterOp, V1) +MAP_STABLEHLO_TO_VHLO(ReduceWindowOp, V1) +MAP_STABLEHLO_TO_VHLO(RemOp, V1) +MAP_STABLEHLO_TO_VHLO(ReplicaIdOp, V1) +MAP_STABLEHLO_TO_VHLO(ReshapeOp, V1) +MAP_STABLEHLO_TO_VHLO(ReturnOp, V1) +MAP_STABLEHLO_TO_VHLO(ReverseOp, V1) +MAP_STABLEHLO_TO_VHLO(RngBitGeneratorOp, V1) +MAP_STABLEHLO_TO_VHLO(RngOp, V1) +MAP_STABLEHLO_TO_VHLO(RoundOp, V1) +MAP_STABLEHLO_TO_VHLO(RoundNearestEvenOp, V1) +MAP_STABLEHLO_TO_VHLO(RsqrtOp, V2) +MAP_STABLEHLO_TO_VHLO(ScatterOp, V2) +MAP_STABLEHLO_TO_VHLO(SelectAndScatterOp, V1) +MAP_STABLEHLO_TO_VHLO(SelectOp, V1) +MAP_STABLEHLO_TO_VHLO(SendOp, V1) +MAP_STABLEHLO_TO_VHLO(SetDimensionSizeOp, V1) +MAP_STABLEHLO_TO_VHLO(ShiftLeftOp, V1) +MAP_STABLEHLO_TO_VHLO(ShiftRightArithmeticOp, V1) +MAP_STABLEHLO_TO_VHLO(ShiftRightLogicalOp, V1) +MAP_STABLEHLO_TO_VHLO(SignOp, V1) +MAP_STABLEHLO_TO_VHLO(SineOp, V2) +MAP_STABLEHLO_TO_VHLO(SliceOp, V1) +MAP_STABLEHLO_TO_VHLO(SortOp, V1) +MAP_STABLEHLO_TO_VHLO(SqrtOp, V2) +MAP_STABLEHLO_TO_VHLO(SubtractOp, V1) +MAP_STABLEHLO_TO_VHLO(TanOp, V2) +MAP_STABLEHLO_TO_VHLO(TanhOp, V2) +MAP_STABLEHLO_TO_VHLO(TorchIndexSelectOp, V1) +MAP_STABLEHLO_TO_VHLO(TransposeOp, V1) +MAP_STABLEHLO_TO_VHLO(TriangularSolveOp, V1) +MAP_STABLEHLO_TO_VHLO(TupleOp, V1) +MAP_STABLEHLO_TO_VHLO(UnaryEinsumOp, V1) +MAP_STABLEHLO_TO_VHLO(UniformDequantizeOp, V1) +MAP_STABLEHLO_TO_VHLO(UniformQuantizeOp, V1) +MAP_STABLEHLO_TO_VHLO(WhileOp, V1) +MAP_STABLEHLO_TO_VHLO(XorOp, V1) + +#undef MAP_STABLEHLO_TO_VHLO +#undef MAP_STABLEHLO_TO_VHLO_V0 + +// Nonstandard mappings +#define MAP_UPSTREAM_TO_VHLO(UpstreamOpName, VhloOpName, OpVer) \ + template <> \ + struct StablehloToVhloOpImpl { \ + using Type = VhloOpName##OpVer; \ + }; \ + template <> \ + struct VhloToStablehloOpImpl { \ + using Type = UpstreamOpName; \ + }; + +MAP_UPSTREAM_TO_VHLO(func::FuncOp, vhlo::FuncOp, V1) +MAP_UPSTREAM_TO_VHLO(func::CallOp, vhlo::CallOp, V1) + +// Slight ambiguity between stablehlo::ReturnOp and func::ReturnOp +// Only map in one direction for func.return --> vhlo.return +template <> +struct StablehloToVhloOpImpl { + using Type = vhlo::ReturnOpV1; +}; + +#undef MAP_UPSTREAM_TO_VHLO + +} // namespace stablehlo +} // namespace mlir + +#endif // STABLEHLO_TRANSFORMS_MAPSTABLEHLOTOVHLO_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/PassUtils.h b/deps/exla/cache/xla_extension/include/stablehlo/transforms/PassUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..b0bc4018e0fe13aaa2c213e20445f71fe173dc12 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/PassUtils.h @@ -0,0 +1,82 @@ +/* Copyright 2024 The StableHLO Authors. All Rights Reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_TRANSFORMS_PASS_UTILS_H_ +#define STABLEHLO_TRANSFORMS_PASS_UTILS_H_ + +#include "llvm/Support/ErrorHandling.h" +#include "mlir/Dialect/Complex/IR/Complex.h" +#include "mlir/IR/Attributes.h" +#include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinAttributeInterfaces.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/Location.h" +#include "mlir/IR/TypeUtilities.h" +#include "mlir/IR/Types.h" +#include "mlir/IR/Value.h" +#include "mlir/Support/LLVM.h" +#include "stablehlo/dialect/ChloOps.h" +#include "stablehlo/dialect/StablehloOps.h" + +namespace mlir { +namespace stablehlo { + +// Utility functions common across passes. + +template +Attribute getScalarLike(OpBuilder &b, T constant, Type type) { + Type element = getElementTypeOrSelf(type); + if (isa(element)) return b.getIntegerAttr(element, constant); + if (isa(element)) return b.getFloatAttr(element, constant); + if (auto complexTy = dyn_cast(element)) { + return complex::NumberAttr::get(complexTy, constant, 0); + } + llvm_unreachable("unhandled element type"); +} + +// Creates a constant with using IntegerAttr, FloatAttr, or ComplexAttr stored +// in `scalar`. +// Returns stablehlo::ConstantOp if value type if static, else returns +// chlo::ConstantLikeOp. +Value getConstantLikeImpl(OpBuilder &b, Location loc, Attribute scalar, + Value val); + +// Creates a chlo::ConstantLikeOp using a splat `constant` of the same shape +// as `val`. +template +Value getConstantLike(OpBuilder &b, Location loc, T constant, Value val) { + auto shapedTy = cast(val.getType()); + Attribute scalar = getScalarLike(b, constant, shapedTy); + return getConstantLikeImpl(b, loc, scalar, val); +} + +// Creates a chlo::ConstantLikeOp using a APFloat splat `constant` of the +// same shape as `val`. +// The distinction between double and APFloat causes issues so need this +// explicit template specialization. +Value getConstantLike(OpBuilder &b, Location loc, const APFloat &constant, + Value val); + +// Check if any of the given types are mlir::quant::QuantizedType. +bool isAnyQuantizedTypes(TypeRange types); + +// Creates a quantized element type based on the given parameters. +Type getQuantizedElementType(Location loc, Type storageType, Type expressedType, + ArrayRef scales, + ArrayRef zeroPoints, + int32_t quantizedDimension, int64_t storageTypeMin, + int64_t storageTypeMax); + +} // namespace stablehlo +} // namespace mlir + +#endif // STABLEHLO_TRANSFORMS_PASS_UTILS_H_ diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/Passes.h b/deps/exla/cache/xla_extension/include/stablehlo/transforms/Passes.h new file mode 100644 index 0000000000000000000000000000000000000000..a5a4aa2790db72ca71b3fc19e86934ef094b6ee4 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/Passes.h @@ -0,0 +1,190 @@ +/* Copyright 2022 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_TRANSFORMS_PASSES_H +#define STABLEHLO_TRANSFORMS_PASSES_H + +#include +#include +#include +#include + +#include "mlir/Dialect/Func/IR/FuncOps.h" // IWYU pragma: keep +#include "mlir/Dialect/Quant/IR/Quant.h" // IWYU pragma: keep +#include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/OperationSupport.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/IR/TypeRange.h" +#include "mlir/Pass/Pass.h" +#include "mlir/Pass/PassOptions.h" +#include "mlir/Support/LLVM.h" +#include "mlir/Support/TypeID.h" +#include "mlir/Transforms/DialectConversion.h" +#include "stablehlo/dialect/StablehloOps.h" +#include "stablehlo/dialect/Version.h" +#include "stablehlo/dialect/VhloTypes.h" + +namespace mlir { +namespace stablehlo { + +#define GEN_PASS_DECL +#define GEN_PASS_REGISTRATION +#include "stablehlo/transforms/Passes.h.inc" + +// Populates --stablehlo-canonicalize-dynamism patterns. +void populateStablehloCanonicalizeDynamismPatterns(MLIRContext *context, + RewritePatternSet *patterns); + +// Populates --stablehlo-refine-shapes patterns. +void populateStablehloRefineShapesPatterns(MLIRContext *context, + RewritePatternSet *patterns); + +// Populates StableHLO ops to VHLO ops rewriting patterns. +void populateStablehloToVhloPatterns(MLIRContext *context, + RewritePatternSet *patterns, + vhlo::VhloTypeConverter *converter); + +// Populates VHLO ops to StableHLO ops rewriting patterns. +void populateVhloToStablehloPatterns(MLIRContext *context, + RewritePatternSet *patterns, + vhlo::VhloTypeConverter *converter); + +// Populates VHLO downgrade rewriting patterns. +void populateVhloToVersionPatterns(MLIRContext *context, + RewritePatternSet *patterns, + vhlo::VhloTypeConverter *converter); + +/// Collection of rewrite patterns for lowering of CHLO ops to StableHLO and +/// Shape ops. +void populateChloToStablehloPatterns(MLIRContext *context, + RewritePatternSet *patterns); + +/// CHLO ConstantLikeOp to StableHLO ConstantOp +/// May require dynamic shape broadcasting. +void populateChloConstantLikePattern(MLIRContext *context, + RewritePatternSet *patterns); + +/// Collection of rewrite patterns for lowering quantized StableHLO operations +/// using uniform dequantize/quantize operations. +void populateStablehloLegalizeQuantizedOpToQDQPatterns( + MLIRContext *context, RewritePatternSet *patterns, + PatternBenefit benefit = 1); + +/// Collection of rewrite patterns for composing quantized StableHLO operations +/// using unform dequantize/quantize operations. +void populateStablehloLegalizeQDQToQuantizedOpPatterns( + MLIRContext *context, RewritePatternSet *patterns); + +/// Collection of patterns to upgrade deprecated ops to long-term supported ops. +void populateStablehloLegalizeDeprecatedOpsPatterns( + MLIRContext *context, RewritePatternSet *patterns); + +/// Collection of shape dialect to StableHLO patterns. +void populateShapeToStablehloPatterns(MLIRContext *context, + RewritePatternSet *patterns); + +/// Collection of patterns to create compatibility expander for StableHLO +/// operations. +void populateStablehloCompatibilityExpanderPatterns( + MLIRContext *context, RewritePatternSet *patterns, + vhlo::Version targetVersion); + +//// Additional pass constructors //// + +std::unique_ptr> createStablehloRefineArgumentsPass( + TypeRange refinedTypes); + +/// Creates a pass that wraps StableHLO ops in CompositeOp. +/// The pass takes in a map from op's type id to a function that returns the +/// attributes to be added to the CompositeOp. The pass also takes in a +/// version number for the CompositeOp. +using CompositeAttributeProvider = + std::function(Operation *)>; +using CompositeAttributeProviderMap = + llvm::DenseMap; +std::unique_ptr> createStablehloWrapInCompositePass( + const CompositeAttributeProviderMap &compositeAttributeProviderMap, + int32_t compositeVersion); + +/// Wraps the given operation in a CompositeOp with the specified NamedAttrs and +/// version and returns the CompositeOp. +/// +/// **A typical usage ** +/// +/// ```cpp +/// // To wrap a specific stablehlo.add instance +/// +/// mlir::stablehlo::AddOp addOp = ...; // The op instanced to be wrapped. +/// mlir::ModuleOp module = addOp->getParentOfType(); +/// mlir::OpBuilder builder(addOp); +/// mlir::NamedAttrList attrs = ...; // Attributes to be set on the +/// // composite op. +/// int32_t version = 0; // Composite version. +/// +/// mlir::stablehlo::CompositeOp compositeOp = +/// mlir::stablehlo::wrapOperationInComposite(builder, addOp, attrs, +/// version, module); +/// addOp.replaceAllUsesWith(compositeOp); +/// ``` +stablehlo::CompositeOp wrapOperationInComposite(OpBuilder &builder, + Operation *op, + const NamedAttrList &attrs, + int32_t compositeVersion, + ModuleOp module); +//// Pass pipelines //// + +// StableHLO consumers can add this pipeline to convert portable artifacts to +// StableHLO programs. This pipeline will silently pass if programs are not +// portable artifacts. +// +// Uses vhlo-to-version and vhlo-legalize-to-stablehlo passes. Does not require +// an option to specify VHLO target version since it always converts VHLO to +// the current version in order to legalize to StableHLO. +void createStablehloDeserializePipeline(OpPassManager &pm); + +// Creates a pipeline of StableHLO-specific MLIR passes to remove dynamism from +// the program. This is achieved via refining the "main" function's arguments +// and propagating new shapes throughout the program argument types and shapes +// within an MLIR module. The main function is either a function with name +// "main", if there are multiple functions, or the single function within the +// module. +// +// This pipeline focuses on: +// 1. Refining function argument types based on provided `refinedTypes`. +// 2. Refining shape information of operations within functions. +// 3. Replaces dynamic StableHLO ops with the corresponding static +// counterparts if applicable. +void createStablehloRemoveDynamismPipeline(OpPassManager &pm, + TypeRange refinedTypes); + +// Decomposes quantized operations within a StableHLO module by +// applying a series of MLIR passes essentially breaking down the quantized +// operations into a primitive math operations. +void createStablehloLowerQuantPipeline(OpPassManager &pm); + +/// Collection of patterns to create expander for StableHLO complex +/// math operations. +void populateStablehloComplexMathExpanderPatterns(MLIRContext *context, + RewritePatternSet *patterns); + +// Adds `stablehlo-deserialize` pipeline as a registered pass pipeline +// for opt tools. +void registerPassPipelines(); + +} // namespace stablehlo +} // namespace mlir + +#endif // STABLEHLO_TRANSFORMS_PASSES_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/Passes.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/transforms/Passes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..38f1f62ba43ae62f7272a9b753b02d9a2a8d5b60 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/Passes.h.inc @@ -0,0 +1,2620 @@ +/* Autogenerated by mlir-tblgen; don't manually edit */ + +#ifdef GEN_PASS_DECL +// Generate declarations for all passes. +#define GEN_PASS_DECL_CHLOLEGALIZETOSTABLEHLOPASS +#define GEN_PASS_DECL_SHAPELEGALIZETOSTABLEHLOPASS +#define GEN_PASS_DECL_STABLEHLOCANONICALIZEDYNAMISMPASS +#define GEN_PASS_DECL_STABLEHLOCOMPATIBILITYEXPANDERPASS +#define GEN_PASS_DECL_STABLEHLOCOMPLEXMATHEXPANDERPASS +#define GEN_PASS_DECL_STABLEHLOCONVERTTOSIGNLESSPASS +#define GEN_PASS_DECL_STABLEHLOLEGALIZECOMPOSITETOCALLPASS +#define GEN_PASS_DECL_STABLEHLOLEGALIZEDEPRECATEDOPSPASS +#define GEN_PASS_DECL_STABLEHLOLEGALIZEQDQTOQUANTIZEDOPPASS +#define GEN_PASS_DECL_STABLEHLOLEGALIZEQUANTTOMATHPASS +#define GEN_PASS_DECL_STABLEHLOLEGALIZEQUANTIZEDOPTOQDQPASS +#define GEN_PASS_DECL_STABLEHLOLEGALIZETOVHLOPASS +#define GEN_PASS_DECL_STABLEHLOREFINEARGUMENTSPASS +#define GEN_PASS_DECL_STABLEHLOREFINESHAPESPASS +#define GEN_PASS_DECL_STABLEHLOWRAPINCOMPOSITEPASS +#define GEN_PASS_DECL_VHLOLEGALIZETOSTABLEHLOPASS +#define GEN_PASS_DECL_VHLOTOVERSIONPASS +#undef GEN_PASS_DECL +#endif // GEN_PASS_DECL + +//===----------------------------------------------------------------------===// +// ChloLegalizeToStablehloPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_CHLOLEGALIZETOSTABLEHLOPASS +std::unique_ptr<::mlir::Pass> createChloLegalizeToStablehloPass(); +#undef GEN_PASS_DECL_CHLOLEGALIZETOSTABLEHLOPASS +#endif // GEN_PASS_DECL_CHLOLEGALIZETOSTABLEHLOPASS +#ifdef GEN_PASS_DEF_CHLOLEGALIZETOSTABLEHLOPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createChloLegalizeToStablehloPass(); +} // namespace impl +namespace impl { + +template +class ChloLegalizeToStablehloPassBase : public ::mlir::OperationPass { +public: + using Base = ChloLegalizeToStablehloPassBase; + + ChloLegalizeToStablehloPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + ChloLegalizeToStablehloPassBase(const ChloLegalizeToStablehloPassBase &other) : ::mlir::OperationPass(other) {} + ChloLegalizeToStablehloPassBase& operator=(const ChloLegalizeToStablehloPassBase &) = delete; + ChloLegalizeToStablehloPassBase(ChloLegalizeToStablehloPassBase &&) = delete; + ChloLegalizeToStablehloPassBase& operator=(ChloLegalizeToStablehloPassBase &&) = delete; + ~ChloLegalizeToStablehloPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("chlo-legalize-to-stablehlo"); + } + ::llvm::StringRef getArgument() const override { return "chlo-legalize-to-stablehlo"; } + + ::llvm::StringRef getDescription() const override { return "Legalizes from CHLO ops flow to StableHLO and Shape ops"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("ChloLegalizeToStablehloPass"); + } + ::llvm::StringRef getName() const override { return "ChloLegalizeToStablehloPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ChloLegalizeToStablehloPassBase) + +protected: +private: + + friend std::unique_ptr<::mlir::Pass> createChloLegalizeToStablehloPass() { + return std::make_unique(); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createChloLegalizeToStablehloPass() { + return impl::createChloLegalizeToStablehloPass(); +} +#undef GEN_PASS_DEF_CHLOLEGALIZETOSTABLEHLOPASS +#endif // GEN_PASS_DEF_CHLOLEGALIZETOSTABLEHLOPASS + +//===----------------------------------------------------------------------===// +// ShapeLegalizeToStablehloPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SHAPELEGALIZETOSTABLEHLOPASS +std::unique_ptr<::mlir::Pass> createShapeLegalizeToStablehloPass(); +#undef GEN_PASS_DECL_SHAPELEGALIZETOSTABLEHLOPASS +#endif // GEN_PASS_DECL_SHAPELEGALIZETOSTABLEHLOPASS +#ifdef GEN_PASS_DEF_SHAPELEGALIZETOSTABLEHLOPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createShapeLegalizeToStablehloPass(); +} // namespace impl +namespace impl { + +template +class ShapeLegalizeToStablehloPassBase : public ::mlir::OperationPass { +public: + using Base = ShapeLegalizeToStablehloPassBase; + + ShapeLegalizeToStablehloPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + ShapeLegalizeToStablehloPassBase(const ShapeLegalizeToStablehloPassBase &other) : ::mlir::OperationPass(other) {} + ShapeLegalizeToStablehloPassBase& operator=(const ShapeLegalizeToStablehloPassBase &) = delete; + ShapeLegalizeToStablehloPassBase(ShapeLegalizeToStablehloPassBase &&) = delete; + ShapeLegalizeToStablehloPassBase& operator=(ShapeLegalizeToStablehloPassBase &&) = delete; + ~ShapeLegalizeToStablehloPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("shape-legalize-to-stablehlo"); + } + ::llvm::StringRef getArgument() const override { return "shape-legalize-to-stablehlo"; } + + ::llvm::StringRef getDescription() const override { return "Legalize shape-related ops to StableHLO."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("ShapeLegalizeToStablehloPass"); + } + ::llvm::StringRef getName() const override { return "ShapeLegalizeToStablehloPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeLegalizeToStablehloPassBase) + +protected: +private: + + friend std::unique_ptr<::mlir::Pass> createShapeLegalizeToStablehloPass() { + return std::make_unique(); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createShapeLegalizeToStablehloPass() { + return impl::createShapeLegalizeToStablehloPass(); +} +#undef GEN_PASS_DEF_SHAPELEGALIZETOSTABLEHLOPASS +#endif // GEN_PASS_DEF_SHAPELEGALIZETOSTABLEHLOPASS + +//===----------------------------------------------------------------------===// +// StablehloCanonicalizeDynamismPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOCANONICALIZEDYNAMISMPASS +std::unique_ptr<::mlir::Pass> createStablehloCanonicalizeDynamismPass(); +#undef GEN_PASS_DECL_STABLEHLOCANONICALIZEDYNAMISMPASS +#endif // GEN_PASS_DECL_STABLEHLOCANONICALIZEDYNAMISMPASS +#ifdef GEN_PASS_DEF_STABLEHLOCANONICALIZEDYNAMISMPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloCanonicalizeDynamismPass(); +} // namespace impl +namespace impl { + +template +class StablehloCanonicalizeDynamismPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloCanonicalizeDynamismPassBase; + + StablehloCanonicalizeDynamismPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloCanonicalizeDynamismPassBase(const StablehloCanonicalizeDynamismPassBase &other) : ::mlir::OperationPass(other) {} + StablehloCanonicalizeDynamismPassBase& operator=(const StablehloCanonicalizeDynamismPassBase &) = delete; + StablehloCanonicalizeDynamismPassBase(StablehloCanonicalizeDynamismPassBase &&) = delete; + StablehloCanonicalizeDynamismPassBase& operator=(StablehloCanonicalizeDynamismPassBase &&) = delete; + ~StablehloCanonicalizeDynamismPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-canonicalize-dynamism"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-canonicalize-dynamism"; } + + ::llvm::StringRef getDescription() const override { return "Canonicalizes dynamic StableHLO ops into static ops."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloCanonicalizeDynamismPass"); + } + ::llvm::StringRef getName() const override { return "StablehloCanonicalizeDynamismPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloCanonicalizeDynamismPassBase) + +protected: +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloCanonicalizeDynamismPass() { + return std::make_unique(); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloCanonicalizeDynamismPass() { + return impl::createStablehloCanonicalizeDynamismPass(); +} +#undef GEN_PASS_DEF_STABLEHLOCANONICALIZEDYNAMISMPASS +#endif // GEN_PASS_DEF_STABLEHLOCANONICALIZEDYNAMISMPASS + +//===----------------------------------------------------------------------===// +// StablehloCompatibilityExpanderPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOCOMPATIBILITYEXPANDERPASS +struct StablehloCompatibilityExpanderPassOptions { + std::string targetVersionOption; +}; +std::unique_ptr<::mlir::Pass> createStablehloCompatibilityExpanderPass(); +std::unique_ptr<::mlir::Pass> createStablehloCompatibilityExpanderPass(StablehloCompatibilityExpanderPassOptions options); +#undef GEN_PASS_DECL_STABLEHLOCOMPATIBILITYEXPANDERPASS +#endif // GEN_PASS_DECL_STABLEHLOCOMPATIBILITYEXPANDERPASS +#ifdef GEN_PASS_DEF_STABLEHLOCOMPATIBILITYEXPANDERPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloCompatibilityExpanderPass(); +} // namespace impl + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloCompatibilityExpanderPass(StablehloCompatibilityExpanderPassOptions options); +} // namespace impl +namespace impl { + +template +class StablehloCompatibilityExpanderPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloCompatibilityExpanderPassBase; + + StablehloCompatibilityExpanderPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloCompatibilityExpanderPassBase(const StablehloCompatibilityExpanderPassBase &other) : ::mlir::OperationPass(other) {} + StablehloCompatibilityExpanderPassBase& operator=(const StablehloCompatibilityExpanderPassBase &) = delete; + StablehloCompatibilityExpanderPassBase(StablehloCompatibilityExpanderPassBase &&) = delete; + StablehloCompatibilityExpanderPassBase& operator=(StablehloCompatibilityExpanderPassBase &&) = delete; + ~StablehloCompatibilityExpanderPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-compatibility-expander"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-compatibility-expander"; } + + ::llvm::StringRef getDescription() const override { return "Compatibility expander for StableHLO operations."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloCompatibilityExpanderPass"); + } + ::llvm::StringRef getName() const override { return "StablehloCompatibilityExpanderPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloCompatibilityExpanderPassBase) + + StablehloCompatibilityExpanderPassBase(StablehloCompatibilityExpanderPassOptions options) : StablehloCompatibilityExpanderPassBase() { + targetVersionOption = std::move(options.targetVersionOption); + } +protected: + ::mlir::Pass::Option targetVersionOption{*this, "target", ::llvm::cl::desc("The target version. Must be a version of the form #.#.#.")}; +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloCompatibilityExpanderPass() { + return std::make_unique(); + } + + friend std::unique_ptr<::mlir::Pass> createStablehloCompatibilityExpanderPass(StablehloCompatibilityExpanderPassOptions options) { + return std::make_unique(std::move(options)); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloCompatibilityExpanderPass() { + return impl::createStablehloCompatibilityExpanderPass(); +} + +std::unique_ptr<::mlir::Pass> createStablehloCompatibilityExpanderPass(StablehloCompatibilityExpanderPassOptions options) { + return impl::createStablehloCompatibilityExpanderPass(std::move(options)); +} +#undef GEN_PASS_DEF_STABLEHLOCOMPATIBILITYEXPANDERPASS +#endif // GEN_PASS_DEF_STABLEHLOCOMPATIBILITYEXPANDERPASS + +//===----------------------------------------------------------------------===// +// StablehloComplexMathExpanderPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOCOMPLEXMATHEXPANDERPASS +std::unique_ptr<::mlir::Pass> createStablehloComplexMathExpanderPass(); +#undef GEN_PASS_DECL_STABLEHLOCOMPLEXMATHEXPANDERPASS +#endif // GEN_PASS_DECL_STABLEHLOCOMPLEXMATHEXPANDERPASS +#ifdef GEN_PASS_DEF_STABLEHLOCOMPLEXMATHEXPANDERPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloComplexMathExpanderPass(); +} // namespace impl +namespace impl { + +template +class StablehloComplexMathExpanderPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloComplexMathExpanderPassBase; + + StablehloComplexMathExpanderPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloComplexMathExpanderPassBase(const StablehloComplexMathExpanderPassBase &other) : ::mlir::OperationPass(other) {} + StablehloComplexMathExpanderPassBase& operator=(const StablehloComplexMathExpanderPassBase &) = delete; + StablehloComplexMathExpanderPassBase(StablehloComplexMathExpanderPassBase &&) = delete; + StablehloComplexMathExpanderPassBase& operator=(StablehloComplexMathExpanderPassBase &&) = delete; + ~StablehloComplexMathExpanderPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-complex-math-expander"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-complex-math-expander"; } + + ::llvm::StringRef getDescription() const override { return "Expander for StableHLO complex math operations."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloComplexMathExpanderPass"); + } + ::llvm::StringRef getName() const override { return "StablehloComplexMathExpanderPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloComplexMathExpanderPassBase) + +protected: +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloComplexMathExpanderPass() { + return std::make_unique(); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloComplexMathExpanderPass() { + return impl::createStablehloComplexMathExpanderPass(); +} +#undef GEN_PASS_DEF_STABLEHLOCOMPLEXMATHEXPANDERPASS +#endif // GEN_PASS_DEF_STABLEHLOCOMPLEXMATHEXPANDERPASS + +//===----------------------------------------------------------------------===// +// StablehloConvertToSignlessPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOCONVERTTOSIGNLESSPASS +std::unique_ptr<::mlir::Pass> createStablehloConvertToSignlessPass(); +#undef GEN_PASS_DECL_STABLEHLOCONVERTTOSIGNLESSPASS +#endif // GEN_PASS_DECL_STABLEHLOCONVERTTOSIGNLESSPASS +#ifdef GEN_PASS_DEF_STABLEHLOCONVERTTOSIGNLESSPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloConvertToSignlessPass(); +} // namespace impl +namespace impl { + +template +class StablehloConvertToSignlessPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloConvertToSignlessPassBase; + + StablehloConvertToSignlessPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloConvertToSignlessPassBase(const StablehloConvertToSignlessPassBase &other) : ::mlir::OperationPass(other) {} + StablehloConvertToSignlessPassBase& operator=(const StablehloConvertToSignlessPassBase &) = delete; + StablehloConvertToSignlessPassBase(StablehloConvertToSignlessPassBase &&) = delete; + StablehloConvertToSignlessPassBase& operator=(StablehloConvertToSignlessPassBase &&) = delete; + ~StablehloConvertToSignlessPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-convert-to-signless"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-convert-to-signless"; } + + ::llvm::StringRef getDescription() const override { return "Pass to transform the IR to be on signless integers."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloConvertToSignlessPass"); + } + ::llvm::StringRef getName() const override { return "StablehloConvertToSignlessPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloConvertToSignlessPassBase) + +protected: +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloConvertToSignlessPass() { + return std::make_unique(); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloConvertToSignlessPass() { + return impl::createStablehloConvertToSignlessPass(); +} +#undef GEN_PASS_DEF_STABLEHLOCONVERTTOSIGNLESSPASS +#endif // GEN_PASS_DEF_STABLEHLOCONVERTTOSIGNLESSPASS + +//===----------------------------------------------------------------------===// +// StablehloLegalizeCompositeToCallPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOLEGALIZECOMPOSITETOCALLPASS +struct StablehloLegalizeCompositeToCallPassOptions { + ::llvm::SmallVector exceptListOption; +}; +std::unique_ptr<::mlir::Pass> createStablehloLegalizeCompositeToCallPass(); +std::unique_ptr<::mlir::Pass> createStablehloLegalizeCompositeToCallPass(StablehloLegalizeCompositeToCallPassOptions options); +#undef GEN_PASS_DECL_STABLEHLOLEGALIZECOMPOSITETOCALLPASS +#endif // GEN_PASS_DECL_STABLEHLOLEGALIZECOMPOSITETOCALLPASS +#ifdef GEN_PASS_DEF_STABLEHLOLEGALIZECOMPOSITETOCALLPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloLegalizeCompositeToCallPass(); +} // namespace impl + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloLegalizeCompositeToCallPass(StablehloLegalizeCompositeToCallPassOptions options); +} // namespace impl +namespace impl { + +template +class StablehloLegalizeCompositeToCallPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloLegalizeCompositeToCallPassBase; + + StablehloLegalizeCompositeToCallPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloLegalizeCompositeToCallPassBase(const StablehloLegalizeCompositeToCallPassBase &other) : ::mlir::OperationPass(other) {} + StablehloLegalizeCompositeToCallPassBase& operator=(const StablehloLegalizeCompositeToCallPassBase &) = delete; + StablehloLegalizeCompositeToCallPassBase(StablehloLegalizeCompositeToCallPassBase &&) = delete; + StablehloLegalizeCompositeToCallPassBase& operator=(StablehloLegalizeCompositeToCallPassBase &&) = delete; + ~StablehloLegalizeCompositeToCallPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-legalize-composite-to-call"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-legalize-composite-to-call"; } + + ::llvm::StringRef getDescription() const override { return "Replaces composite ops with a call to their decomposition."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloLegalizeCompositeToCallPass"); + } + ::llvm::StringRef getName() const override { return "StablehloLegalizeCompositeToCallPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloLegalizeCompositeToCallPassBase) + + StablehloLegalizeCompositeToCallPassBase(StablehloLegalizeCompositeToCallPassOptions options) : StablehloLegalizeCompositeToCallPassBase() { + exceptListOption = std::move(options.exceptListOption); + } +protected: + ::mlir::Pass::ListOption exceptListOption{*this, "except", ::llvm::cl::desc("Names of composites that should not be replaced with calls.")}; +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloLegalizeCompositeToCallPass() { + return std::make_unique(); + } + + friend std::unique_ptr<::mlir::Pass> createStablehloLegalizeCompositeToCallPass(StablehloLegalizeCompositeToCallPassOptions options) { + return std::make_unique(std::move(options)); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloLegalizeCompositeToCallPass() { + return impl::createStablehloLegalizeCompositeToCallPass(); +} + +std::unique_ptr<::mlir::Pass> createStablehloLegalizeCompositeToCallPass(StablehloLegalizeCompositeToCallPassOptions options) { + return impl::createStablehloLegalizeCompositeToCallPass(std::move(options)); +} +#undef GEN_PASS_DEF_STABLEHLOLEGALIZECOMPOSITETOCALLPASS +#endif // GEN_PASS_DEF_STABLEHLOLEGALIZECOMPOSITETOCALLPASS + +//===----------------------------------------------------------------------===// +// StablehloLegalizeDeprecatedOpsPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOLEGALIZEDEPRECATEDOPSPASS +struct StablehloLegalizeDeprecatedOpsPassOptions { + bool failOnUnusedOps = true; +}; +std::unique_ptr<::mlir::Pass> createStablehloLegalizeDeprecatedOpsPass(); +std::unique_ptr<::mlir::Pass> createStablehloLegalizeDeprecatedOpsPass(StablehloLegalizeDeprecatedOpsPassOptions options); +#undef GEN_PASS_DECL_STABLEHLOLEGALIZEDEPRECATEDOPSPASS +#endif // GEN_PASS_DECL_STABLEHLOLEGALIZEDEPRECATEDOPSPASS +#ifdef GEN_PASS_DEF_STABLEHLOLEGALIZEDEPRECATEDOPSPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloLegalizeDeprecatedOpsPass(); +} // namespace impl + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloLegalizeDeprecatedOpsPass(StablehloLegalizeDeprecatedOpsPassOptions options); +} // namespace impl +namespace impl { + +template +class StablehloLegalizeDeprecatedOpsPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloLegalizeDeprecatedOpsPassBase; + + StablehloLegalizeDeprecatedOpsPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloLegalizeDeprecatedOpsPassBase(const StablehloLegalizeDeprecatedOpsPassBase &other) : ::mlir::OperationPass(other) {} + StablehloLegalizeDeprecatedOpsPassBase& operator=(const StablehloLegalizeDeprecatedOpsPassBase &) = delete; + StablehloLegalizeDeprecatedOpsPassBase(StablehloLegalizeDeprecatedOpsPassBase &&) = delete; + StablehloLegalizeDeprecatedOpsPassBase& operator=(StablehloLegalizeDeprecatedOpsPassBase &&) = delete; + ~StablehloLegalizeDeprecatedOpsPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-legalize-deprecated-ops"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-legalize-deprecated-ops"; } + + ::llvm::StringRef getDescription() const override { return "Legalize deprecated ops to well-supported ops."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloLegalizeDeprecatedOpsPass"); + } + ::llvm::StringRef getName() const override { return "StablehloLegalizeDeprecatedOpsPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloLegalizeDeprecatedOpsPassBase) + + StablehloLegalizeDeprecatedOpsPassBase(StablehloLegalizeDeprecatedOpsPassOptions options) : StablehloLegalizeDeprecatedOpsPassBase() { + failOnUnusedOps = std::move(options.failOnUnusedOps); + } +protected: + ::mlir::Pass::Option failOnUnusedOps{*this, "fail-on-unused", ::llvm::cl::desc("Fail on (mostly) unused ops that are deprecated without any fallback."), ::llvm::cl::init(true)}; +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloLegalizeDeprecatedOpsPass() { + return std::make_unique(); + } + + friend std::unique_ptr<::mlir::Pass> createStablehloLegalizeDeprecatedOpsPass(StablehloLegalizeDeprecatedOpsPassOptions options) { + return std::make_unique(std::move(options)); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloLegalizeDeprecatedOpsPass() { + return impl::createStablehloLegalizeDeprecatedOpsPass(); +} + +std::unique_ptr<::mlir::Pass> createStablehloLegalizeDeprecatedOpsPass(StablehloLegalizeDeprecatedOpsPassOptions options) { + return impl::createStablehloLegalizeDeprecatedOpsPass(std::move(options)); +} +#undef GEN_PASS_DEF_STABLEHLOLEGALIZEDEPRECATEDOPSPASS +#endif // GEN_PASS_DEF_STABLEHLOLEGALIZEDEPRECATEDOPSPASS + +//===----------------------------------------------------------------------===// +// StablehloLegalizeQDQToQuantizedOpPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOLEGALIZEQDQTOQUANTIZEDOPPASS +std::unique_ptr<::mlir::Pass> createStablehloLegalizeQDQToQuantizedOpPass(); +#undef GEN_PASS_DECL_STABLEHLOLEGALIZEQDQTOQUANTIZEDOPPASS +#endif // GEN_PASS_DECL_STABLEHLOLEGALIZEQDQTOQUANTIZEDOPPASS +#ifdef GEN_PASS_DEF_STABLEHLOLEGALIZEQDQTOQUANTIZEDOPPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloLegalizeQDQToQuantizedOpPass(); +} // namespace impl +namespace impl { + +template +class StablehloLegalizeQDQToQuantizedOpPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloLegalizeQDQToQuantizedOpPassBase; + + StablehloLegalizeQDQToQuantizedOpPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloLegalizeQDQToQuantizedOpPassBase(const StablehloLegalizeQDQToQuantizedOpPassBase &other) : ::mlir::OperationPass(other) {} + StablehloLegalizeQDQToQuantizedOpPassBase& operator=(const StablehloLegalizeQDQToQuantizedOpPassBase &) = delete; + StablehloLegalizeQDQToQuantizedOpPassBase(StablehloLegalizeQDQToQuantizedOpPassBase &&) = delete; + StablehloLegalizeQDQToQuantizedOpPassBase& operator=(StablehloLegalizeQDQToQuantizedOpPassBase &&) = delete; + ~StablehloLegalizeQDQToQuantizedOpPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-legalize-qdq-to-quantized-op"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-legalize-qdq-to-quantized-op"; } + + ::llvm::StringRef getDescription() const override { return "Fuse (de-quantize, floating-point operation and quantize) pattern into StableHLO quantized operation"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloLegalizeQDQToQuantizedOpPass"); + } + ::llvm::StringRef getName() const override { return "StablehloLegalizeQDQToQuantizedOpPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloLegalizeQDQToQuantizedOpPassBase) + +protected: +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloLegalizeQDQToQuantizedOpPass() { + return std::make_unique(); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloLegalizeQDQToQuantizedOpPass() { + return impl::createStablehloLegalizeQDQToQuantizedOpPass(); +} +#undef GEN_PASS_DEF_STABLEHLOLEGALIZEQDQTOQUANTIZEDOPPASS +#endif // GEN_PASS_DEF_STABLEHLOLEGALIZEQDQTOQUANTIZEDOPPASS + +//===----------------------------------------------------------------------===// +// StablehloLegalizeQuantToMathPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOLEGALIZEQUANTTOMATHPASS +std::unique_ptr<::mlir::Pass> createStablehloLegalizeQuantToMathPass(); +#undef GEN_PASS_DECL_STABLEHLOLEGALIZEQUANTTOMATHPASS +#endif // GEN_PASS_DECL_STABLEHLOLEGALIZEQUANTTOMATHPASS +#ifdef GEN_PASS_DEF_STABLEHLOLEGALIZEQUANTTOMATHPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloLegalizeQuantToMathPass(); +} // namespace impl +namespace impl { + +template +class StablehloLegalizeQuantToMathPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloLegalizeQuantToMathPassBase; + + StablehloLegalizeQuantToMathPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloLegalizeQuantToMathPassBase(const StablehloLegalizeQuantToMathPassBase &other) : ::mlir::OperationPass(other) {} + StablehloLegalizeQuantToMathPassBase& operator=(const StablehloLegalizeQuantToMathPassBase &) = delete; + StablehloLegalizeQuantToMathPassBase(StablehloLegalizeQuantToMathPassBase &&) = delete; + StablehloLegalizeQuantToMathPassBase& operator=(StablehloLegalizeQuantToMathPassBase &&) = delete; + ~StablehloLegalizeQuantToMathPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-legalize-quant-to-math"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-legalize-quant-to-math"; } + + ::llvm::StringRef getDescription() const override { return "Convert from StableHLO quantized ops to StableHLO primitive math ops."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloLegalizeQuantToMathPass"); + } + ::llvm::StringRef getName() const override { return "StablehloLegalizeQuantToMathPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloLegalizeQuantToMathPassBase) + +protected: +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloLegalizeQuantToMathPass() { + return std::make_unique(); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloLegalizeQuantToMathPass() { + return impl::createStablehloLegalizeQuantToMathPass(); +} +#undef GEN_PASS_DEF_STABLEHLOLEGALIZEQUANTTOMATHPASS +#endif // GEN_PASS_DEF_STABLEHLOLEGALIZEQUANTTOMATHPASS + +//===----------------------------------------------------------------------===// +// StablehloLegalizeQuantizedOpToQDQPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOLEGALIZEQUANTIZEDOPTOQDQPASS +std::unique_ptr<::mlir::Pass> createStablehloLegalizeQuantizedOpToQDQPass(); +#undef GEN_PASS_DECL_STABLEHLOLEGALIZEQUANTIZEDOPTOQDQPASS +#endif // GEN_PASS_DECL_STABLEHLOLEGALIZEQUANTIZEDOPTOQDQPASS +#ifdef GEN_PASS_DEF_STABLEHLOLEGALIZEQUANTIZEDOPTOQDQPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloLegalizeQuantizedOpToQDQPass(); +} // namespace impl +namespace impl { + +template +class StablehloLegalizeQuantizedOpToQDQPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloLegalizeQuantizedOpToQDQPassBase; + + StablehloLegalizeQuantizedOpToQDQPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloLegalizeQuantizedOpToQDQPassBase(const StablehloLegalizeQuantizedOpToQDQPassBase &other) : ::mlir::OperationPass(other) {} + StablehloLegalizeQuantizedOpToQDQPassBase& operator=(const StablehloLegalizeQuantizedOpToQDQPassBase &) = delete; + StablehloLegalizeQuantizedOpToQDQPassBase(StablehloLegalizeQuantizedOpToQDQPassBase &&) = delete; + StablehloLegalizeQuantizedOpToQDQPassBase& operator=(StablehloLegalizeQuantizedOpToQDQPassBase &&) = delete; + ~StablehloLegalizeQuantizedOpToQDQPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-legalize-quantized-op-to-qdq"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-legalize-quantized-op-to-qdq"; } + + ::llvm::StringRef getDescription() const override { return "Decompose quantized StableHLO operation to (de-quantize, floating-point operation and quantize) pattern."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloLegalizeQuantizedOpToQDQPass"); + } + ::llvm::StringRef getName() const override { return "StablehloLegalizeQuantizedOpToQDQPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloLegalizeQuantizedOpToQDQPassBase) + +protected: +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloLegalizeQuantizedOpToQDQPass() { + return std::make_unique(); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloLegalizeQuantizedOpToQDQPass() { + return impl::createStablehloLegalizeQuantizedOpToQDQPass(); +} +#undef GEN_PASS_DEF_STABLEHLOLEGALIZEQUANTIZEDOPTOQDQPASS +#endif // GEN_PASS_DEF_STABLEHLOLEGALIZEQUANTIZEDOPTOQDQPASS + +//===----------------------------------------------------------------------===// +// StablehloLegalizeToVhloPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOLEGALIZETOVHLOPASS +struct StablehloLegalizeToVhloPassOptions { + bool allowOtherDialects = false; +}; +std::unique_ptr<::mlir::Pass> createStablehloLegalizeToVhloPass(); +std::unique_ptr<::mlir::Pass> createStablehloLegalizeToVhloPass(StablehloLegalizeToVhloPassOptions options); +#undef GEN_PASS_DECL_STABLEHLOLEGALIZETOVHLOPASS +#endif // GEN_PASS_DECL_STABLEHLOLEGALIZETOVHLOPASS +#ifdef GEN_PASS_DEF_STABLEHLOLEGALIZETOVHLOPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloLegalizeToVhloPass(); +} // namespace impl + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloLegalizeToVhloPass(StablehloLegalizeToVhloPassOptions options); +} // namespace impl +namespace impl { + +template +class StablehloLegalizeToVhloPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloLegalizeToVhloPassBase; + + StablehloLegalizeToVhloPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloLegalizeToVhloPassBase(const StablehloLegalizeToVhloPassBase &other) : ::mlir::OperationPass(other) {} + StablehloLegalizeToVhloPassBase& operator=(const StablehloLegalizeToVhloPassBase &) = delete; + StablehloLegalizeToVhloPassBase(StablehloLegalizeToVhloPassBase &&) = delete; + StablehloLegalizeToVhloPassBase& operator=(StablehloLegalizeToVhloPassBase &&) = delete; + ~StablehloLegalizeToVhloPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-legalize-to-vhlo"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-legalize-to-vhlo"; } + + ::llvm::StringRef getDescription() const override { return "Legalize StableHLO to VHLO."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloLegalizeToVhloPass"); + } + ::llvm::StringRef getName() const override { return "StablehloLegalizeToVhloPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloLegalizeToVhloPassBase) + + StablehloLegalizeToVhloPassBase(StablehloLegalizeToVhloPassOptions options) : StablehloLegalizeToVhloPassBase() { + allowOtherDialects = std::move(options.allowOtherDialects); + } +protected: + ::mlir::Pass::Option allowOtherDialects{*this, "allow-other-dialects", ::llvm::cl::desc("Allow serialization to use other (potentially unstable) dialects, inserts unrealized casts between dialects."), ::llvm::cl::init(false)}; +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloLegalizeToVhloPass() { + return std::make_unique(); + } + + friend std::unique_ptr<::mlir::Pass> createStablehloLegalizeToVhloPass(StablehloLegalizeToVhloPassOptions options) { + return std::make_unique(std::move(options)); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloLegalizeToVhloPass() { + return impl::createStablehloLegalizeToVhloPass(); +} + +std::unique_ptr<::mlir::Pass> createStablehloLegalizeToVhloPass(StablehloLegalizeToVhloPassOptions options) { + return impl::createStablehloLegalizeToVhloPass(std::move(options)); +} +#undef GEN_PASS_DEF_STABLEHLOLEGALIZETOVHLOPASS +#endif // GEN_PASS_DEF_STABLEHLOLEGALIZETOVHLOPASS + +//===----------------------------------------------------------------------===// +// StablehloRefineArgumentsPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOREFINEARGUMENTSPASS +struct StablehloRefineArgumentsPassOptions { + ::llvm::SmallVector refinedTypesOption; +}; +std::unique_ptr<::mlir::Pass> createStablehloRefineArgumentsPass(); +std::unique_ptr<::mlir::Pass> createStablehloRefineArgumentsPass(StablehloRefineArgumentsPassOptions options); +#undef GEN_PASS_DECL_STABLEHLOREFINEARGUMENTSPASS +#endif // GEN_PASS_DECL_STABLEHLOREFINEARGUMENTSPASS +#ifdef GEN_PASS_DEF_STABLEHLOREFINEARGUMENTSPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloRefineArgumentsPass(); +} // namespace impl + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloRefineArgumentsPass(StablehloRefineArgumentsPassOptions options); +} // namespace impl +namespace impl { + +template +class StablehloRefineArgumentsPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloRefineArgumentsPassBase; + + StablehloRefineArgumentsPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloRefineArgumentsPassBase(const StablehloRefineArgumentsPassBase &other) : ::mlir::OperationPass(other) {} + StablehloRefineArgumentsPassBase& operator=(const StablehloRefineArgumentsPassBase &) = delete; + StablehloRefineArgumentsPassBase(StablehloRefineArgumentsPassBase &&) = delete; + StablehloRefineArgumentsPassBase& operator=(StablehloRefineArgumentsPassBase &&) = delete; + ~StablehloRefineArgumentsPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-refine-arguments"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-refine-arguments"; } + + ::llvm::StringRef getDescription() const override { return "Refines the argument shapes of the main function."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloRefineArgumentsPass"); + } + ::llvm::StringRef getName() const override { return "StablehloRefineArgumentsPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloRefineArgumentsPassBase) + + StablehloRefineArgumentsPassBase(StablehloRefineArgumentsPassOptions options) : StablehloRefineArgumentsPassBase() { + refinedTypesOption = std::move(options.refinedTypesOption); + } +protected: + ::mlir::Pass::ListOption refinedTypesOption{*this, "types", ::llvm::cl::desc("The new types to be used for the main function's arguments, specified as an MLIR TypeRange 'tensor<1x2xf32>, ...'")}; +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloRefineArgumentsPass() { + return std::make_unique(); + } + + friend std::unique_ptr<::mlir::Pass> createStablehloRefineArgumentsPass(StablehloRefineArgumentsPassOptions options) { + return std::make_unique(std::move(options)); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloRefineArgumentsPass() { + return impl::createStablehloRefineArgumentsPass(); +} + +std::unique_ptr<::mlir::Pass> createStablehloRefineArgumentsPass(StablehloRefineArgumentsPassOptions options) { + return impl::createStablehloRefineArgumentsPass(std::move(options)); +} +#undef GEN_PASS_DEF_STABLEHLOREFINEARGUMENTSPASS +#endif // GEN_PASS_DEF_STABLEHLOREFINEARGUMENTSPASS + +//===----------------------------------------------------------------------===// +// StablehloRefineShapesPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOREFINESHAPESPASS +std::unique_ptr<::mlir::Pass> createStablehloRefineShapesPass(); +#undef GEN_PASS_DECL_STABLEHLOREFINESHAPESPASS +#endif // GEN_PASS_DECL_STABLEHLOREFINESHAPESPASS +#ifdef GEN_PASS_DEF_STABLEHLOREFINESHAPESPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloRefineShapesPass(); +} // namespace impl +namespace impl { + +template +class StablehloRefineShapesPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloRefineShapesPassBase; + + StablehloRefineShapesPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloRefineShapesPassBase(const StablehloRefineShapesPassBase &other) : ::mlir::OperationPass(other) {} + StablehloRefineShapesPassBase& operator=(const StablehloRefineShapesPassBase &) = delete; + StablehloRefineShapesPassBase(StablehloRefineShapesPassBase &&) = delete; + StablehloRefineShapesPassBase& operator=(StablehloRefineShapesPassBase &&) = delete; + ~StablehloRefineShapesPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-refine-shapes"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-refine-shapes"; } + + ::llvm::StringRef getDescription() const override { return "Refines shapes across a StableHLO program."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloRefineShapesPass"); + } + ::llvm::StringRef getName() const override { return "StablehloRefineShapesPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloRefineShapesPassBase) + +protected: +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloRefineShapesPass() { + return std::make_unique(); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloRefineShapesPass() { + return impl::createStablehloRefineShapesPass(); +} +#undef GEN_PASS_DEF_STABLEHLOREFINESHAPESPASS +#endif // GEN_PASS_DEF_STABLEHLOREFINESHAPESPASS + +//===----------------------------------------------------------------------===// +// StablehloWrapInCompositePass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOWRAPINCOMPOSITEPASS +struct StablehloWrapInCompositePassOptions { + ::llvm::SmallVector opNamesOption; + int32_t versionOption = 0; +}; +std::unique_ptr<::mlir::Pass> createStablehloWrapInCompositePass(); +std::unique_ptr<::mlir::Pass> createStablehloWrapInCompositePass(StablehloWrapInCompositePassOptions options); +#undef GEN_PASS_DECL_STABLEHLOWRAPINCOMPOSITEPASS +#endif // GEN_PASS_DECL_STABLEHLOWRAPINCOMPOSITEPASS +#ifdef GEN_PASS_DEF_STABLEHLOWRAPINCOMPOSITEPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloWrapInCompositePass(); +} // namespace impl + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloWrapInCompositePass(StablehloWrapInCompositePassOptions options); +} // namespace impl +namespace impl { + +template +class StablehloWrapInCompositePassBase : public ::mlir::OperationPass { +public: + using Base = StablehloWrapInCompositePassBase; + + StablehloWrapInCompositePassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloWrapInCompositePassBase(const StablehloWrapInCompositePassBase &other) : ::mlir::OperationPass(other) {} + StablehloWrapInCompositePassBase& operator=(const StablehloWrapInCompositePassBase &) = delete; + StablehloWrapInCompositePassBase(StablehloWrapInCompositePassBase &&) = delete; + StablehloWrapInCompositePassBase& operator=(StablehloWrapInCompositePassBase &&) = delete; + ~StablehloWrapInCompositePassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-wrap-in-composite"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-wrap-in-composite"; } + + ::llvm::StringRef getDescription() const override { return "Wraps a non-composite StableHLO op in a composite op."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloWrapInCompositePass"); + } + ::llvm::StringRef getName() const override { return "StablehloWrapInCompositePass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloWrapInCompositePassBase) + + StablehloWrapInCompositePassBase(StablehloWrapInCompositePassOptions options) : StablehloWrapInCompositePassBase() { + opNamesOption = std::move(options.opNamesOption); + versionOption = std::move(options.versionOption); + } +protected: + ::mlir::Pass::ListOption opNamesOption{*this, "op-names", ::llvm::cl::desc("The names of the ops to wrap.")}; + ::mlir::Pass::Option versionOption{*this, "version", ::llvm::cl::desc("The version number of the composite op."), ::llvm::cl::init(0)}; +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloWrapInCompositePass() { + return std::make_unique(); + } + + friend std::unique_ptr<::mlir::Pass> createStablehloWrapInCompositePass(StablehloWrapInCompositePassOptions options) { + return std::make_unique(std::move(options)); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloWrapInCompositePass() { + return impl::createStablehloWrapInCompositePass(); +} + +std::unique_ptr<::mlir::Pass> createStablehloWrapInCompositePass(StablehloWrapInCompositePassOptions options) { + return impl::createStablehloWrapInCompositePass(std::move(options)); +} +#undef GEN_PASS_DEF_STABLEHLOWRAPINCOMPOSITEPASS +#endif // GEN_PASS_DEF_STABLEHLOWRAPINCOMPOSITEPASS + +//===----------------------------------------------------------------------===// +// VhloLegalizeToStablehloPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_VHLOLEGALIZETOSTABLEHLOPASS +std::unique_ptr<::mlir::Pass> createVhloLegalizeToStablehloPass(); +#undef GEN_PASS_DECL_VHLOLEGALIZETOSTABLEHLOPASS +#endif // GEN_PASS_DECL_VHLOLEGALIZETOSTABLEHLOPASS +#ifdef GEN_PASS_DEF_VHLOLEGALIZETOSTABLEHLOPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createVhloLegalizeToStablehloPass(); +} // namespace impl +namespace impl { + +template +class VhloLegalizeToStablehloPassBase : public ::mlir::OperationPass { +public: + using Base = VhloLegalizeToStablehloPassBase; + + VhloLegalizeToStablehloPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + VhloLegalizeToStablehloPassBase(const VhloLegalizeToStablehloPassBase &other) : ::mlir::OperationPass(other) {} + VhloLegalizeToStablehloPassBase& operator=(const VhloLegalizeToStablehloPassBase &) = delete; + VhloLegalizeToStablehloPassBase(VhloLegalizeToStablehloPassBase &&) = delete; + VhloLegalizeToStablehloPassBase& operator=(VhloLegalizeToStablehloPassBase &&) = delete; + ~VhloLegalizeToStablehloPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("vhlo-legalize-to-stablehlo"); + } + ::llvm::StringRef getArgument() const override { return "vhlo-legalize-to-stablehlo"; } + + ::llvm::StringRef getDescription() const override { return "Legalize VHLO to StableHLO."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("VhloLegalizeToStablehloPass"); + } + ::llvm::StringRef getName() const override { return "VhloLegalizeToStablehloPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(VhloLegalizeToStablehloPassBase) + +protected: +private: + + friend std::unique_ptr<::mlir::Pass> createVhloLegalizeToStablehloPass() { + return std::make_unique(); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createVhloLegalizeToStablehloPass() { + return impl::createVhloLegalizeToStablehloPass(); +} +#undef GEN_PASS_DEF_VHLOLEGALIZETOSTABLEHLOPASS +#endif // GEN_PASS_DEF_VHLOLEGALIZETOSTABLEHLOPASS + +//===----------------------------------------------------------------------===// +// VhloToVersionPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_VHLOTOVERSIONPASS +struct VhloToVersionPassOptions { + std::string targetVersionOption; +}; +std::unique_ptr<::mlir::Pass> createVhloToVersionPass(); +std::unique_ptr<::mlir::Pass> createVhloToVersionPass(VhloToVersionPassOptions options); +#undef GEN_PASS_DECL_VHLOTOVERSIONPASS +#endif // GEN_PASS_DECL_VHLOTOVERSIONPASS +#ifdef GEN_PASS_DEF_VHLOTOVERSIONPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createVhloToVersionPass(); +} // namespace impl + +namespace impl { + std::unique_ptr<::mlir::Pass> createVhloToVersionPass(VhloToVersionPassOptions options); +} // namespace impl +namespace impl { + +template +class VhloToVersionPassBase : public ::mlir::OperationPass<> { +public: + using Base = VhloToVersionPassBase; + + VhloToVersionPassBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + VhloToVersionPassBase(const VhloToVersionPassBase &other) : ::mlir::OperationPass<>(other) {} + VhloToVersionPassBase& operator=(const VhloToVersionPassBase &) = delete; + VhloToVersionPassBase(VhloToVersionPassBase &&) = delete; + VhloToVersionPassBase& operator=(VhloToVersionPassBase &&) = delete; + ~VhloToVersionPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("vhlo-to-version"); + } + ::llvm::StringRef getArgument() const override { return "vhlo-to-version"; } + + ::llvm::StringRef getDescription() const override { return "Convert between versions of VHLO for compatibility."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("VhloToVersionPass"); + } + ::llvm::StringRef getName() const override { return "VhloToVersionPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(VhloToVersionPassBase) + + VhloToVersionPassBase(VhloToVersionPassOptions options) : VhloToVersionPassBase() { + targetVersionOption = std::move(options.targetVersionOption); + } +protected: + ::mlir::Pass::Option targetVersionOption{*this, "target", ::llvm::cl::desc("The target version. Must be a version of the form #.#.# .")}; +private: + + friend std::unique_ptr<::mlir::Pass> createVhloToVersionPass() { + return std::make_unique(); + } + + friend std::unique_ptr<::mlir::Pass> createVhloToVersionPass(VhloToVersionPassOptions options) { + return std::make_unique(std::move(options)); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createVhloToVersionPass() { + return impl::createVhloToVersionPass(); +} + +std::unique_ptr<::mlir::Pass> createVhloToVersionPass(VhloToVersionPassOptions options) { + return impl::createVhloToVersionPass(std::move(options)); +} +#undef GEN_PASS_DEF_VHLOTOVERSIONPASS +#endif // GEN_PASS_DEF_VHLOTOVERSIONPASS +#ifdef GEN_PASS_REGISTRATION + +//===----------------------------------------------------------------------===// +// ChloLegalizeToStablehloPass Registration +//===----------------------------------------------------------------------===// + +inline void registerChloLegalizeToStablehloPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createChloLegalizeToStablehloPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerChloLegalizeToStablehloPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createChloLegalizeToStablehloPass(); + }); +} + +//===----------------------------------------------------------------------===// +// ShapeLegalizeToStablehloPass Registration +//===----------------------------------------------------------------------===// + +inline void registerShapeLegalizeToStablehloPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createShapeLegalizeToStablehloPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerShapeLegalizeToStablehloPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createShapeLegalizeToStablehloPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloCanonicalizeDynamismPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloCanonicalizeDynamismPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloCanonicalizeDynamismPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloCanonicalizeDynamismPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloCanonicalizeDynamismPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloCompatibilityExpanderPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloCompatibilityExpanderPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloCompatibilityExpanderPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloCompatibilityExpanderPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloCompatibilityExpanderPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloComplexMathExpanderPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloComplexMathExpanderPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloComplexMathExpanderPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloComplexMathExpanderPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloComplexMathExpanderPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloConvertToSignlessPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloConvertToSignlessPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloConvertToSignlessPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloConvertToSignlessPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloConvertToSignlessPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloLegalizeCompositeToCallPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloLegalizeCompositeToCallPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloLegalizeCompositeToCallPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloLegalizeCompositeToCallPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloLegalizeCompositeToCallPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloLegalizeDeprecatedOpsPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloLegalizeDeprecatedOpsPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloLegalizeDeprecatedOpsPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloLegalizeDeprecatedOpsPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloLegalizeDeprecatedOpsPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloLegalizeQDQToQuantizedOpPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloLegalizeQDQToQuantizedOpPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloLegalizeQDQToQuantizedOpPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloLegalizeQDQToQuantizedOpPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloLegalizeQDQToQuantizedOpPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloLegalizeQuantToMathPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloLegalizeQuantToMathPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloLegalizeQuantToMathPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloLegalizeQuantToMathPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloLegalizeQuantToMathPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloLegalizeQuantizedOpToQDQPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloLegalizeQuantizedOpToQDQPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloLegalizeQuantizedOpToQDQPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloLegalizeQuantizedOpToQDQPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloLegalizeQuantizedOpToQDQPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloLegalizeToVhloPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloLegalizeToVhloPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloLegalizeToVhloPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloLegalizeToVhloPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloLegalizeToVhloPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloRefineArgumentsPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloRefineArgumentsPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloRefineArgumentsPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloRefineArgumentsPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloRefineArgumentsPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloRefineShapesPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloRefineShapesPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloRefineShapesPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloRefineShapesPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloRefineShapesPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloWrapInCompositePass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloWrapInCompositePass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloWrapInCompositePass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloWrapInCompositePassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloWrapInCompositePass(); + }); +} + +//===----------------------------------------------------------------------===// +// VhloLegalizeToStablehloPass Registration +//===----------------------------------------------------------------------===// + +inline void registerVhloLegalizeToStablehloPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createVhloLegalizeToStablehloPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerVhloLegalizeToStablehloPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createVhloLegalizeToStablehloPass(); + }); +} + +//===----------------------------------------------------------------------===// +// VhloToVersionPass Registration +//===----------------------------------------------------------------------===// + +inline void registerVhloToVersionPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createVhloToVersionPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerVhloToVersionPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createVhloToVersionPass(); + }); +} + +//===----------------------------------------------------------------------===// +// Registration +//===----------------------------------------------------------------------===// + +inline void registerPasses() { + registerChloLegalizeToStablehloPass(); + registerShapeLegalizeToStablehloPass(); + registerStablehloCanonicalizeDynamismPass(); + registerStablehloCompatibilityExpanderPass(); + registerStablehloComplexMathExpanderPass(); + registerStablehloConvertToSignlessPass(); + registerStablehloLegalizeCompositeToCallPass(); + registerStablehloLegalizeDeprecatedOpsPass(); + registerStablehloLegalizeQDQToQuantizedOpPass(); + registerStablehloLegalizeQuantToMathPass(); + registerStablehloLegalizeQuantizedOpToQDQPass(); + registerStablehloLegalizeToVhloPass(); + registerStablehloRefineArgumentsPass(); + registerStablehloRefineShapesPass(); + registerStablehloWrapInCompositePass(); + registerVhloLegalizeToStablehloPass(); + registerVhloToVersionPass(); +} +#undef GEN_PASS_REGISTRATION +#endif // GEN_PASS_REGISTRATION +// Deprecated. Please use the new per-pass macros. +#ifdef GEN_PASS_CLASSES + +template +class ChloLegalizeToStablehloPassBase : public ::mlir::OperationPass { +public: + using Base = ChloLegalizeToStablehloPassBase; + + ChloLegalizeToStablehloPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + ChloLegalizeToStablehloPassBase(const ChloLegalizeToStablehloPassBase &other) : ::mlir::OperationPass(other) {} + ChloLegalizeToStablehloPassBase& operator=(const ChloLegalizeToStablehloPassBase &) = delete; + ChloLegalizeToStablehloPassBase(ChloLegalizeToStablehloPassBase &&) = delete; + ChloLegalizeToStablehloPassBase& operator=(ChloLegalizeToStablehloPassBase &&) = delete; + ~ChloLegalizeToStablehloPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("chlo-legalize-to-stablehlo"); + } + ::llvm::StringRef getArgument() const override { return "chlo-legalize-to-stablehlo"; } + + ::llvm::StringRef getDescription() const override { return "Legalizes from CHLO ops flow to StableHLO and Shape ops"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("ChloLegalizeToStablehloPass"); + } + ::llvm::StringRef getName() const override { return "ChloLegalizeToStablehloPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ChloLegalizeToStablehloPassBase) + +protected: +}; + +template +class ShapeLegalizeToStablehloPassBase : public ::mlir::OperationPass { +public: + using Base = ShapeLegalizeToStablehloPassBase; + + ShapeLegalizeToStablehloPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + ShapeLegalizeToStablehloPassBase(const ShapeLegalizeToStablehloPassBase &other) : ::mlir::OperationPass(other) {} + ShapeLegalizeToStablehloPassBase& operator=(const ShapeLegalizeToStablehloPassBase &) = delete; + ShapeLegalizeToStablehloPassBase(ShapeLegalizeToStablehloPassBase &&) = delete; + ShapeLegalizeToStablehloPassBase& operator=(ShapeLegalizeToStablehloPassBase &&) = delete; + ~ShapeLegalizeToStablehloPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("shape-legalize-to-stablehlo"); + } + ::llvm::StringRef getArgument() const override { return "shape-legalize-to-stablehlo"; } + + ::llvm::StringRef getDescription() const override { return "Legalize shape-related ops to StableHLO."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("ShapeLegalizeToStablehloPass"); + } + ::llvm::StringRef getName() const override { return "ShapeLegalizeToStablehloPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeLegalizeToStablehloPassBase) + +protected: +}; + +template +class StablehloCanonicalizeDynamismPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloCanonicalizeDynamismPassBase; + + StablehloCanonicalizeDynamismPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloCanonicalizeDynamismPassBase(const StablehloCanonicalizeDynamismPassBase &other) : ::mlir::OperationPass(other) {} + StablehloCanonicalizeDynamismPassBase& operator=(const StablehloCanonicalizeDynamismPassBase &) = delete; + StablehloCanonicalizeDynamismPassBase(StablehloCanonicalizeDynamismPassBase &&) = delete; + StablehloCanonicalizeDynamismPassBase& operator=(StablehloCanonicalizeDynamismPassBase &&) = delete; + ~StablehloCanonicalizeDynamismPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-canonicalize-dynamism"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-canonicalize-dynamism"; } + + ::llvm::StringRef getDescription() const override { return "Canonicalizes dynamic StableHLO ops into static ops."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloCanonicalizeDynamismPass"); + } + ::llvm::StringRef getName() const override { return "StablehloCanonicalizeDynamismPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloCanonicalizeDynamismPassBase) + +protected: +}; + +template +class StablehloCompatibilityExpanderPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloCompatibilityExpanderPassBase; + + StablehloCompatibilityExpanderPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloCompatibilityExpanderPassBase(const StablehloCompatibilityExpanderPassBase &other) : ::mlir::OperationPass(other) {} + StablehloCompatibilityExpanderPassBase& operator=(const StablehloCompatibilityExpanderPassBase &) = delete; + StablehloCompatibilityExpanderPassBase(StablehloCompatibilityExpanderPassBase &&) = delete; + StablehloCompatibilityExpanderPassBase& operator=(StablehloCompatibilityExpanderPassBase &&) = delete; + ~StablehloCompatibilityExpanderPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-compatibility-expander"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-compatibility-expander"; } + + ::llvm::StringRef getDescription() const override { return "Compatibility expander for StableHLO operations."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloCompatibilityExpanderPass"); + } + ::llvm::StringRef getName() const override { return "StablehloCompatibilityExpanderPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloCompatibilityExpanderPassBase) + +protected: + ::mlir::Pass::Option targetVersionOption{*this, "target", ::llvm::cl::desc("The target version. Must be a version of the form #.#.#.")}; +}; + +template +class StablehloComplexMathExpanderPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloComplexMathExpanderPassBase; + + StablehloComplexMathExpanderPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloComplexMathExpanderPassBase(const StablehloComplexMathExpanderPassBase &other) : ::mlir::OperationPass(other) {} + StablehloComplexMathExpanderPassBase& operator=(const StablehloComplexMathExpanderPassBase &) = delete; + StablehloComplexMathExpanderPassBase(StablehloComplexMathExpanderPassBase &&) = delete; + StablehloComplexMathExpanderPassBase& operator=(StablehloComplexMathExpanderPassBase &&) = delete; + ~StablehloComplexMathExpanderPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-complex-math-expander"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-complex-math-expander"; } + + ::llvm::StringRef getDescription() const override { return "Expander for StableHLO complex math operations."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloComplexMathExpanderPass"); + } + ::llvm::StringRef getName() const override { return "StablehloComplexMathExpanderPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloComplexMathExpanderPassBase) + +protected: +}; + +template +class StablehloConvertToSignlessPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloConvertToSignlessPassBase; + + StablehloConvertToSignlessPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloConvertToSignlessPassBase(const StablehloConvertToSignlessPassBase &other) : ::mlir::OperationPass(other) {} + StablehloConvertToSignlessPassBase& operator=(const StablehloConvertToSignlessPassBase &) = delete; + StablehloConvertToSignlessPassBase(StablehloConvertToSignlessPassBase &&) = delete; + StablehloConvertToSignlessPassBase& operator=(StablehloConvertToSignlessPassBase &&) = delete; + ~StablehloConvertToSignlessPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-convert-to-signless"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-convert-to-signless"; } + + ::llvm::StringRef getDescription() const override { return "Pass to transform the IR to be on signless integers."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloConvertToSignlessPass"); + } + ::llvm::StringRef getName() const override { return "StablehloConvertToSignlessPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloConvertToSignlessPassBase) + +protected: +}; + +template +class StablehloLegalizeCompositeToCallPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloLegalizeCompositeToCallPassBase; + + StablehloLegalizeCompositeToCallPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloLegalizeCompositeToCallPassBase(const StablehloLegalizeCompositeToCallPassBase &other) : ::mlir::OperationPass(other) {} + StablehloLegalizeCompositeToCallPassBase& operator=(const StablehloLegalizeCompositeToCallPassBase &) = delete; + StablehloLegalizeCompositeToCallPassBase(StablehloLegalizeCompositeToCallPassBase &&) = delete; + StablehloLegalizeCompositeToCallPassBase& operator=(StablehloLegalizeCompositeToCallPassBase &&) = delete; + ~StablehloLegalizeCompositeToCallPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-legalize-composite-to-call"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-legalize-composite-to-call"; } + + ::llvm::StringRef getDescription() const override { return "Replaces composite ops with a call to their decomposition."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloLegalizeCompositeToCallPass"); + } + ::llvm::StringRef getName() const override { return "StablehloLegalizeCompositeToCallPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloLegalizeCompositeToCallPassBase) + +protected: + ::mlir::Pass::ListOption exceptListOption{*this, "except", ::llvm::cl::desc("Names of composites that should not be replaced with calls.")}; +}; + +template +class StablehloLegalizeDeprecatedOpsPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloLegalizeDeprecatedOpsPassBase; + + StablehloLegalizeDeprecatedOpsPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloLegalizeDeprecatedOpsPassBase(const StablehloLegalizeDeprecatedOpsPassBase &other) : ::mlir::OperationPass(other) {} + StablehloLegalizeDeprecatedOpsPassBase& operator=(const StablehloLegalizeDeprecatedOpsPassBase &) = delete; + StablehloLegalizeDeprecatedOpsPassBase(StablehloLegalizeDeprecatedOpsPassBase &&) = delete; + StablehloLegalizeDeprecatedOpsPassBase& operator=(StablehloLegalizeDeprecatedOpsPassBase &&) = delete; + ~StablehloLegalizeDeprecatedOpsPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-legalize-deprecated-ops"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-legalize-deprecated-ops"; } + + ::llvm::StringRef getDescription() const override { return "Legalize deprecated ops to well-supported ops."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloLegalizeDeprecatedOpsPass"); + } + ::llvm::StringRef getName() const override { return "StablehloLegalizeDeprecatedOpsPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloLegalizeDeprecatedOpsPassBase) + +protected: + ::mlir::Pass::Option failOnUnusedOps{*this, "fail-on-unused", ::llvm::cl::desc("Fail on (mostly) unused ops that are deprecated without any fallback."), ::llvm::cl::init(true)}; +}; + +template +class StablehloLegalizeQDQToQuantizedOpPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloLegalizeQDQToQuantizedOpPassBase; + + StablehloLegalizeQDQToQuantizedOpPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloLegalizeQDQToQuantizedOpPassBase(const StablehloLegalizeQDQToQuantizedOpPassBase &other) : ::mlir::OperationPass(other) {} + StablehloLegalizeQDQToQuantizedOpPassBase& operator=(const StablehloLegalizeQDQToQuantizedOpPassBase &) = delete; + StablehloLegalizeQDQToQuantizedOpPassBase(StablehloLegalizeQDQToQuantizedOpPassBase &&) = delete; + StablehloLegalizeQDQToQuantizedOpPassBase& operator=(StablehloLegalizeQDQToQuantizedOpPassBase &&) = delete; + ~StablehloLegalizeQDQToQuantizedOpPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-legalize-qdq-to-quantized-op"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-legalize-qdq-to-quantized-op"; } + + ::llvm::StringRef getDescription() const override { return "Fuse (de-quantize, floating-point operation and quantize) pattern into StableHLO quantized operation"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloLegalizeQDQToQuantizedOpPass"); + } + ::llvm::StringRef getName() const override { return "StablehloLegalizeQDQToQuantizedOpPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloLegalizeQDQToQuantizedOpPassBase) + +protected: +}; + +template +class StablehloLegalizeQuantToMathPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloLegalizeQuantToMathPassBase; + + StablehloLegalizeQuantToMathPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloLegalizeQuantToMathPassBase(const StablehloLegalizeQuantToMathPassBase &other) : ::mlir::OperationPass(other) {} + StablehloLegalizeQuantToMathPassBase& operator=(const StablehloLegalizeQuantToMathPassBase &) = delete; + StablehloLegalizeQuantToMathPassBase(StablehloLegalizeQuantToMathPassBase &&) = delete; + StablehloLegalizeQuantToMathPassBase& operator=(StablehloLegalizeQuantToMathPassBase &&) = delete; + ~StablehloLegalizeQuantToMathPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-legalize-quant-to-math"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-legalize-quant-to-math"; } + + ::llvm::StringRef getDescription() const override { return "Convert from StableHLO quantized ops to StableHLO primitive math ops."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloLegalizeQuantToMathPass"); + } + ::llvm::StringRef getName() const override { return "StablehloLegalizeQuantToMathPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloLegalizeQuantToMathPassBase) + +protected: +}; + +template +class StablehloLegalizeQuantizedOpToQDQPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloLegalizeQuantizedOpToQDQPassBase; + + StablehloLegalizeQuantizedOpToQDQPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloLegalizeQuantizedOpToQDQPassBase(const StablehloLegalizeQuantizedOpToQDQPassBase &other) : ::mlir::OperationPass(other) {} + StablehloLegalizeQuantizedOpToQDQPassBase& operator=(const StablehloLegalizeQuantizedOpToQDQPassBase &) = delete; + StablehloLegalizeQuantizedOpToQDQPassBase(StablehloLegalizeQuantizedOpToQDQPassBase &&) = delete; + StablehloLegalizeQuantizedOpToQDQPassBase& operator=(StablehloLegalizeQuantizedOpToQDQPassBase &&) = delete; + ~StablehloLegalizeQuantizedOpToQDQPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-legalize-quantized-op-to-qdq"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-legalize-quantized-op-to-qdq"; } + + ::llvm::StringRef getDescription() const override { return "Decompose quantized StableHLO operation to (de-quantize, floating-point operation and quantize) pattern."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloLegalizeQuantizedOpToQDQPass"); + } + ::llvm::StringRef getName() const override { return "StablehloLegalizeQuantizedOpToQDQPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloLegalizeQuantizedOpToQDQPassBase) + +protected: +}; + +template +class StablehloLegalizeToVhloPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloLegalizeToVhloPassBase; + + StablehloLegalizeToVhloPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloLegalizeToVhloPassBase(const StablehloLegalizeToVhloPassBase &other) : ::mlir::OperationPass(other) {} + StablehloLegalizeToVhloPassBase& operator=(const StablehloLegalizeToVhloPassBase &) = delete; + StablehloLegalizeToVhloPassBase(StablehloLegalizeToVhloPassBase &&) = delete; + StablehloLegalizeToVhloPassBase& operator=(StablehloLegalizeToVhloPassBase &&) = delete; + ~StablehloLegalizeToVhloPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-legalize-to-vhlo"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-legalize-to-vhlo"; } + + ::llvm::StringRef getDescription() const override { return "Legalize StableHLO to VHLO."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloLegalizeToVhloPass"); + } + ::llvm::StringRef getName() const override { return "StablehloLegalizeToVhloPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloLegalizeToVhloPassBase) + +protected: + ::mlir::Pass::Option allowOtherDialects{*this, "allow-other-dialects", ::llvm::cl::desc("Allow serialization to use other (potentially unstable) dialects, inserts unrealized casts between dialects."), ::llvm::cl::init(false)}; +}; + +template +class StablehloRefineArgumentsPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloRefineArgumentsPassBase; + + StablehloRefineArgumentsPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloRefineArgumentsPassBase(const StablehloRefineArgumentsPassBase &other) : ::mlir::OperationPass(other) {} + StablehloRefineArgumentsPassBase& operator=(const StablehloRefineArgumentsPassBase &) = delete; + StablehloRefineArgumentsPassBase(StablehloRefineArgumentsPassBase &&) = delete; + StablehloRefineArgumentsPassBase& operator=(StablehloRefineArgumentsPassBase &&) = delete; + ~StablehloRefineArgumentsPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-refine-arguments"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-refine-arguments"; } + + ::llvm::StringRef getDescription() const override { return "Refines the argument shapes of the main function."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloRefineArgumentsPass"); + } + ::llvm::StringRef getName() const override { return "StablehloRefineArgumentsPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloRefineArgumentsPassBase) + +protected: + ::mlir::Pass::ListOption refinedTypesOption{*this, "types", ::llvm::cl::desc("The new types to be used for the main function's arguments, specified as an MLIR TypeRange 'tensor<1x2xf32>, ...'")}; +}; + +template +class StablehloRefineShapesPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloRefineShapesPassBase; + + StablehloRefineShapesPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloRefineShapesPassBase(const StablehloRefineShapesPassBase &other) : ::mlir::OperationPass(other) {} + StablehloRefineShapesPassBase& operator=(const StablehloRefineShapesPassBase &) = delete; + StablehloRefineShapesPassBase(StablehloRefineShapesPassBase &&) = delete; + StablehloRefineShapesPassBase& operator=(StablehloRefineShapesPassBase &&) = delete; + ~StablehloRefineShapesPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-refine-shapes"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-refine-shapes"; } + + ::llvm::StringRef getDescription() const override { return "Refines shapes across a StableHLO program."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloRefineShapesPass"); + } + ::llvm::StringRef getName() const override { return "StablehloRefineShapesPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloRefineShapesPassBase) + +protected: +}; + +template +class StablehloWrapInCompositePassBase : public ::mlir::OperationPass { +public: + using Base = StablehloWrapInCompositePassBase; + + StablehloWrapInCompositePassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloWrapInCompositePassBase(const StablehloWrapInCompositePassBase &other) : ::mlir::OperationPass(other) {} + StablehloWrapInCompositePassBase& operator=(const StablehloWrapInCompositePassBase &) = delete; + StablehloWrapInCompositePassBase(StablehloWrapInCompositePassBase &&) = delete; + StablehloWrapInCompositePassBase& operator=(StablehloWrapInCompositePassBase &&) = delete; + ~StablehloWrapInCompositePassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-wrap-in-composite"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-wrap-in-composite"; } + + ::llvm::StringRef getDescription() const override { return "Wraps a non-composite StableHLO op in a composite op."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloWrapInCompositePass"); + } + ::llvm::StringRef getName() const override { return "StablehloWrapInCompositePass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloWrapInCompositePassBase) + +protected: + ::mlir::Pass::ListOption opNamesOption{*this, "op-names", ::llvm::cl::desc("The names of the ops to wrap.")}; + ::mlir::Pass::Option versionOption{*this, "version", ::llvm::cl::desc("The version number of the composite op."), ::llvm::cl::init(0)}; +}; + +template +class VhloLegalizeToStablehloPassBase : public ::mlir::OperationPass { +public: + using Base = VhloLegalizeToStablehloPassBase; + + VhloLegalizeToStablehloPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + VhloLegalizeToStablehloPassBase(const VhloLegalizeToStablehloPassBase &other) : ::mlir::OperationPass(other) {} + VhloLegalizeToStablehloPassBase& operator=(const VhloLegalizeToStablehloPassBase &) = delete; + VhloLegalizeToStablehloPassBase(VhloLegalizeToStablehloPassBase &&) = delete; + VhloLegalizeToStablehloPassBase& operator=(VhloLegalizeToStablehloPassBase &&) = delete; + ~VhloLegalizeToStablehloPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("vhlo-legalize-to-stablehlo"); + } + ::llvm::StringRef getArgument() const override { return "vhlo-legalize-to-stablehlo"; } + + ::llvm::StringRef getDescription() const override { return "Legalize VHLO to StableHLO."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("VhloLegalizeToStablehloPass"); + } + ::llvm::StringRef getName() const override { return "VhloLegalizeToStablehloPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(VhloLegalizeToStablehloPassBase) + +protected: +}; + +template +class VhloToVersionPassBase : public ::mlir::OperationPass<> { +public: + using Base = VhloToVersionPassBase; + + VhloToVersionPassBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + VhloToVersionPassBase(const VhloToVersionPassBase &other) : ::mlir::OperationPass<>(other) {} + VhloToVersionPassBase& operator=(const VhloToVersionPassBase &) = delete; + VhloToVersionPassBase(VhloToVersionPassBase &&) = delete; + VhloToVersionPassBase& operator=(VhloToVersionPassBase &&) = delete; + ~VhloToVersionPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("vhlo-to-version"); + } + ::llvm::StringRef getArgument() const override { return "vhlo-to-version"; } + + ::llvm::StringRef getDescription() const override { return "Convert between versions of VHLO for compatibility."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("VhloToVersionPass"); + } + ::llvm::StringRef getName() const override { return "VhloToVersionPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(VhloToVersionPassBase) + +protected: + ::mlir::Pass::Option targetVersionOption{*this, "target", ::llvm::cl::desc("The target version. Must be a version of the form #.#.# .")}; +}; +#undef GEN_PASS_CLASSES +#endif // GEN_PASS_CLASSES diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/StablehloCompatibilityExpanderPatterns.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/transforms/StablehloCompatibilityExpanderPatterns.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..f10767beb0b5166cf006349e241fd7148ad3f89d --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/StablehloCompatibilityExpanderPatterns.h.inc @@ -0,0 +1,233 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Rewriters *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: StablehloCompatibilityExpanderPatterns.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloCompatibilityExpanderPatterns1( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Type type, + ::llvm::StringRef failureStr) { + if (!((!isa(cast(type).getElementType())))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": Non-complex element type"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloCompatibilityExpanderPatterns2( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Type type, + ::llvm::StringRef failureStr) { + if (!((isa(cast(type).getElementType())))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": Complex element type"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloCompatibilityExpanderPatterns1( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!((attr == ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": constant attribute ::mlir::stablehlo::ResultAccuracyMode::DEFAULT"; + }); + } + return ::mlir::success(); +} +/* Generated from: + external/stablehlo/stablehlo/transforms/StablehloCompatibilityExpanderPatterns.td:35 +*/ +struct TanOp_CompatiblityExpander : public ::mlir::RewritePattern { + TanOp_CompatiblityExpander(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.tan", 1, context, {"stablehlo.cosine", "stablehlo.divide", "stablehlo.sine"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range input(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::TanOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_StablehloCompatibilityExpanderPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'stablehlo.tan' failed to satisfy constraint: 'Non-complex element type'"))) { + return ::mlir::failure(); + } + input = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!tblgen_attr) tblgen_attr = ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + if (!tblgen_attr) return ::mlir::failure(); + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloCompatibilityExpanderPatterns1(rewriter, castedOp0, tblgen_attr, "op 'stablehlo.tan' attribute 'result_accuracy' failed to satisfy constraint: 'constant attribute ::mlir::stablehlo::ResultAccuracyMode::DEFAULT'"))) { + return ::mlir::failure(); + } + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::SineOp tblgen_SineOp_0; + { + ::mlir::Value tblgen_value_0 = (*input.begin()); + tblgen_SineOp_0 = rewriter.create<::mlir::stablehlo::SineOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::CosineOp tblgen_CosineOp_1; + { + ::mlir::Value tblgen_value_0 = (*input.begin()); + tblgen_CosineOp_1 = rewriter.create<::mlir::stablehlo::CosineOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_2; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::DivOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_SineOp_0.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_CosineOp_1.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_DivOp_2 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DivOp_2.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/StablehloCompatibilityExpanderPatterns.td:43 +*/ +struct TanOp_ComplexElementType_CompatiblityExpander : public ::mlir::RewritePattern { + TanOp_ComplexElementType_CompatiblityExpander(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.tan", 1, context, {"stablehlo.complex", "stablehlo.divide", "stablehlo.imag", "stablehlo.multiply", "stablehlo.negate", "stablehlo.real", "stablehlo.tan", "stablehlo.tanh"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range input(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::TanOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_StablehloCompatibilityExpanderPatterns2(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'stablehlo.tan' failed to satisfy constraint: 'Complex element type'"))) { + return ::mlir::failure(); + } + input = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!tblgen_attr) tblgen_attr = ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + if (!tblgen_attr) return ::mlir::failure(); + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloCompatibilityExpanderPatterns1(rewriter, castedOp0, tblgen_attr, "op 'stablehlo.tan' attribute 'result_accuracy' failed to satisfy constraint: 'constant attribute ::mlir::stablehlo::ResultAccuracyMode::DEFAULT'"))) { + return ::mlir::failure(); + } + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::RealOp tblgen_RealOp_0; + { + ::mlir::Value tblgen_value_0 = (*input.begin()); + tblgen_RealOp_0 = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::TanOp tan; + { + ::mlir::Value tblgen_value_0 = (*tblgen_RealOp_0.getODSResults(0).begin()); + tan = rewriter.create<::mlir::stablehlo::TanOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::ImagOp tblgen_ImagOp_1; + { + ::mlir::Value tblgen_value_0 = (*input.begin()); + tblgen_ImagOp_1 = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::TanhOp tanh; + { + ::mlir::Value tblgen_value_0 = (*tblgen_ImagOp_1.getODSResults(0).begin()); + tanh = rewriter.create<::mlir::stablehlo::TanhOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_2; + { + ::mlir::Value tblgen_value_0 = (*tan.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tanh.getODSResults(0).begin()); + tblgen_ComplexOp_2 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_3 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1.0, (*tan.getODSResults(0).begin())); (void)nativeVar_3; + ::mlir::stablehlo::MulOp tblgen_MulOp_4; + { + ::mlir::Value tblgen_value_0 = (*tan.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tanh.getODSResults(0).begin()); + tblgen_MulOp_4 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_5; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_4.getODSResults(0).begin()); + tblgen_NegOp_5 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_6; + { + ::mlir::Value tblgen_value_0 = nativeVar_3; + ::mlir::Value tblgen_value_1 = (*tblgen_NegOp_5.getODSResults(0).begin()); + tblgen_ComplexOp_6 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_7; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::DivOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_ComplexOp_2.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_ComplexOp_6.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_DivOp_7 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DivOp_7.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +void LLVM_ATTRIBUTE_UNUSED populateWithGenerated(::mlir::RewritePatternSet &patterns) { + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); +} diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/StablehloComplexMathExpanderPatterns.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/transforms/StablehloComplexMathExpanderPatterns.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..67900f52a1a09b7a709a4b85914f94a1af7c1a16 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/StablehloComplexMathExpanderPatterns.h.inc @@ -0,0 +1,2767 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Rewriters *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: StablehloComplexMathExpanderPatterns.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloComplexMathExpanderPatterns1( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Type type, + ::llvm::StringRef failureStr) { + if (!((isa(cast(type).getElementType())))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": Complex element type"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloComplexMathExpanderPatterns1( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!((attr == ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT))))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": constant attribute ::mlir::stablehlo::ResultAccuracyMode::DEFAULT"; + }); + } + return ::mlir::success(); +} +/* Generated from: + external/stablehlo/stablehlo/transforms/StablehloComplexMathExpanderPatterns.td:691 +*/ +struct ExpOp_ComplexElementType_ComplexMathExpander : public ::mlir::RewritePattern { + ExpOp_ComplexElementType_ComplexMathExpander(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.exponential", 1, context, {"stablehlo.compare", "stablehlo.complex", "stablehlo.cosine", "stablehlo.exponential", "stablehlo.imag", "stablehlo.multiply", "stablehlo.real", "stablehlo.select", "stablehlo.sine"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range z(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::ExpOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_StablehloComplexMathExpanderPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'stablehlo.exponential' failed to satisfy constraint: 'Complex element type'"))) { + return ::mlir::failure(); + } + z = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!tblgen_attr) tblgen_attr = ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + if (!tblgen_attr) return ::mlir::failure(); + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloComplexMathExpanderPatterns1(rewriter, castedOp0, tblgen_attr, "op 'stablehlo.exponential' attribute 'result_accuracy' failed to satisfy constraint: 'constant attribute ::mlir::stablehlo::ResultAccuracyMode::DEFAULT'"))) { + return ::mlir::failure(); + } + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::RealOp x; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + x = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ExpOp e; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + e = rewriter.create<::mlir::stablehlo::ExpOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + auto nativeVar_0 = ::mlir::stablehlo::getConstantLikeInfValue(rewriter, odsLoc, (*x.getODSResults(0).begin()), /*negative=*/false); (void)nativeVar_0; + auto nativeVar_1 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_1; + ::mlir::stablehlo::CompareOp eq_e_constant_posinf; + { + ::mlir::Value tblgen_value_0 = (*e.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_0; + eq_e_constant_posinf = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_1 + ); + } + auto nativeVar_2 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0.5, (*x.getODSResults(0).begin())); (void)nativeVar_2; + ::mlir::stablehlo::MulOp tblgen_MulOp_3; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_2; + tblgen_MulOp_3 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::ExpOp e2; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_3.getODSResults(0).begin()); + e2 = rewriter.create<::mlir::stablehlo::ExpOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::ImagOp y; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + y = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::CosineOp cs; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + cs = rewriter.create<::mlir::stablehlo::CosineOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_4; + { + ::mlir::Value tblgen_value_0 = (*e2.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*cs.getODSResults(0).begin()); + tblgen_MulOp_4 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_5; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_4.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*e2.getODSResults(0).begin()); + tblgen_MulOp_5 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_6; + { + ::mlir::Value tblgen_value_0 = (*e.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*cs.getODSResults(0).begin()); + tblgen_MulOp_6 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_7; + { + ::mlir::Value tblgen_value_0 = (*eq_e_constant_posinf.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_5.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_MulOp_6.getODSResults(0).begin()); + tblgen_SelectOp_7 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + auto zero = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0, (*x.getODSResults(0).begin())); (void)zero; + auto nativeVar_8 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_8; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_9; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = zero; + tblgen_CompareOp_9 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_8 + ); + } + ::mlir::stablehlo::SineOp sn; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + sn = rewriter.create<::mlir::stablehlo::SineOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_10; + { + ::mlir::Value tblgen_value_0 = (*e2.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*sn.getODSResults(0).begin()); + tblgen_MulOp_10 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_11; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_10.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*e2.getODSResults(0).begin()); + tblgen_MulOp_11 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_12; + { + ::mlir::Value tblgen_value_0 = (*e.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*sn.getODSResults(0).begin()); + tblgen_MulOp_12 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_13; + { + ::mlir::Value tblgen_value_0 = (*eq_e_constant_posinf.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_11.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_MulOp_12.getODSResults(0).begin()); + tblgen_SelectOp_13 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_14; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_9.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = zero; + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_13.getODSResults(0).begin()); + tblgen_SelectOp_14 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_15; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ComplexOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_SelectOp_7.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_SelectOp_14.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ComplexOp_15 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ComplexOp_15.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/StablehloComplexMathExpanderPatterns.td:148 +*/ +struct Log1pOp_ComplexElementType_ComplexMathExpander : public ::mlir::RewritePattern { + Log1pOp_ComplexElementType_ComplexMathExpander(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.log_plus_one", 1, context, {"stablehlo.abs", "stablehlo.add", "stablehlo.atan2", "stablehlo.compare", "stablehlo.complex", "stablehlo.divide", "stablehlo.imag", "stablehlo.log", "stablehlo.log_plus_one", "stablehlo.maximum", "stablehlo.minimum", "stablehlo.multiply", "stablehlo.negate", "stablehlo.real", "stablehlo.select", "stablehlo.sqrt", "stablehlo.subtract"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range z(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::Log1pOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_StablehloComplexMathExpanderPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'stablehlo.log_plus_one' failed to satisfy constraint: 'Complex element type'"))) { + return ::mlir::failure(); + } + z = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!tblgen_attr) tblgen_attr = ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + if (!tblgen_attr) return ::mlir::failure(); + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloComplexMathExpanderPatterns1(rewriter, castedOp0, tblgen_attr, "op 'stablehlo.log_plus_one' attribute 'result_accuracy' failed to satisfy constraint: 'constant attribute ::mlir::stablehlo::ResultAccuracyMode::DEFAULT'"))) { + return ::mlir::failure(); + } + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::RealOp x; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + x = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::AbsOp ax; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ax = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ImagOp y; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + y = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::AbsOp ay; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ay = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::MaxOp mx; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ay.getODSResults(0).begin()); + mx = rewriter.create<::mlir::stablehlo::MaxOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto largest = ::mlir::stablehlo::getConstantLikeMaxFiniteValue(rewriter, odsLoc, (*x.getODSResults(0).begin())); (void)largest; + ::mlir::stablehlo::SqrtOp tblgen_SqrtOp_0; + { + ::mlir::Value tblgen_value_0 = largest; + tblgen_SqrtOp_0 = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + auto nativeVar_1 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0.01, (*x.getODSResults(0).begin())); (void)nativeVar_1; + ::mlir::stablehlo::MulOp tblgen_MulOp_2; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SqrtOp_0.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_1; + tblgen_MulOp_2 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_3 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_3; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_4; + { + ::mlir::Value tblgen_value_0 = (*mx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_2.getODSResults(0).begin()); + tblgen_CompareOp_4 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_3 + ); + } + ::mlir::stablehlo::LogOp tblgen_LogOp_5; + { + ::mlir::Value tblgen_value_0 = (*mx.getODSResults(0).begin()); + tblgen_LogOp_5 = rewriter.create<::mlir::stablehlo::LogOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + auto half = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0.5, (*x.getODSResults(0).begin())); (void)half; + ::mlir::stablehlo::MinOp mn; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ay.getODSResults(0).begin()); + mn = rewriter.create<::mlir::stablehlo::MinOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_6 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_6; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_7; + { + ::mlir::Value tblgen_value_0 = (*mn.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*mx.getODSResults(0).begin()); + tblgen_CompareOp_7 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_6 + ); + } + auto one = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1, (*x.getODSResults(0).begin())); (void)one; + ::mlir::stablehlo::DivOp r; + { + ::mlir::Value tblgen_value_0 = (*mn.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*mx.getODSResults(0).begin()); + r = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_8; + { + ::mlir::Value tblgen_value_0 = (*r.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*r.getODSResults(0).begin()); + tblgen_MulOp_8 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_9; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_7.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + ::mlir::Value tblgen_value_2 = (*tblgen_MulOp_8.getODSResults(0).begin()); + tblgen_SelectOp_9 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::Log1pOp tblgen_Log1pOp_10; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SelectOp_9.getODSResults(0).begin()); + tblgen_Log1pOp_10 = rewriter.create<::mlir::stablehlo::Log1pOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_11; + { + ::mlir::Value tblgen_value_0 = half; + ::mlir::Value tblgen_value_1 = (*tblgen_Log1pOp_10.getODSResults(0).begin()); + tblgen_MulOp_11 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_12; + { + ::mlir::Value tblgen_value_0 = (*tblgen_LogOp_5.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_11.getODSResults(0).begin()); + tblgen_AddOp_12 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp xp1; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + xp1 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AbsOp tblgen_AbsOp_13; + { + ::mlir::Value tblgen_value_0 = (*xp1.getODSResults(0).begin()); + tblgen_AbsOp_13 = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_14; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AbsOp_13.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ay.getODSResults(0).begin()); + tblgen_AddOp_14 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_15 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0.2, (*x.getODSResults(0).begin())); (void)nativeVar_15; + auto nativeVar_16 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_16; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_17; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_14.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_15; + tblgen_CompareOp_17 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_16 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_18; + { + ::mlir::Value tblgen_value_0 = (*xp1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xp1.getODSResults(0).begin()); + tblgen_MulOp_18 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp square_dekker_high; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + square_dekker_high = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_19; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_18.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*square_dekker_high.getODSResults(0).begin()); + tblgen_AddOp_19 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::LogOp tblgen_LogOp_20; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_19.getODSResults(0).begin()); + tblgen_LogOp_20 = rewriter.create<::mlir::stablehlo::LogOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_21; + { + ::mlir::Value tblgen_value_0 = half; + ::mlir::Value tblgen_value_1 = (*tblgen_LogOp_20.getODSResults(0).begin()); + tblgen_MulOp_21 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp x2h; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*x.getODSResults(0).begin()); + x2h = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp _add_2sum_high_2_; + { + ::mlir::Value tblgen_value_0 = (*x2h.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*square_dekker_high.getODSResults(0).begin()); + _add_2sum_high_2_ = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp _square_dekker_high_0_; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*x.getODSResults(0).begin()); + _square_dekker_high_0_ = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp _add_2sum_high_1_; + { + ::mlir::Value tblgen_value_0 = (*_add_2sum_high_2_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_square_dekker_high_0_.getODSResults(0).begin()); + _add_2sum_high_1_ = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_22; + { + ::mlir::Value tblgen_value_0 = (*square_dekker_high.getODSResults(0).begin()); + tblgen_NegOp_22 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto nativeVar_23 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1e+308, (*x.getODSResults(0).begin())); (void)nativeVar_23; + auto nativeVar_24 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_24; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_25; + { + ::mlir::Value tblgen_value_0 = largest; + ::mlir::Value tblgen_value_1 = nativeVar_23; + tblgen_CompareOp_25 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_24 + ); + } + auto nativeVar_26 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 134217729, (*x.getODSResults(0).begin())); (void)nativeVar_26; + auto nativeVar_27 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1e+38, (*x.getODSResults(0).begin())); (void)nativeVar_27; + auto nativeVar_28 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_28; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_29; + { + ::mlir::Value tblgen_value_0 = largest; + ::mlir::Value tblgen_value_1 = nativeVar_27; + tblgen_CompareOp_29 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_28 + ); + } + auto nativeVar_30 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 4097, (*x.getODSResults(0).begin())); (void)nativeVar_30; + auto nativeVar_31 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 65, (*x.getODSResults(0).begin())); (void)nativeVar_31; + ::mlir::stablehlo::SelectOp tblgen_SelectOp_32; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_29.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_30; + ::mlir::Value tblgen_value_2 = nativeVar_31; + tblgen_SelectOp_32 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp veltkamp_splitter_constant; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_25.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_26; + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_32.getODSResults(0).begin()); + veltkamp_splitter_constant = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::MulOp multiply_veltkamp_splitter_constant_y; + { + ::mlir::Value tblgen_value_0 = (*veltkamp_splitter_constant.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + multiply_veltkamp_splitter_constant_y = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_33; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*multiply_veltkamp_splitter_constant_y.getODSResults(0).begin()); + tblgen_SubtractOp_33 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp yh; + { + ::mlir::Value tblgen_value_0 = (*multiply_veltkamp_splitter_constant_y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_33.getODSResults(0).begin()); + yh = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_34; + { + ::mlir::Value tblgen_value_0 = (*yh.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*yh.getODSResults(0).begin()); + tblgen_MulOp_34 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_35; + { + ::mlir::Value tblgen_value_0 = (*tblgen_NegOp_22.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_34.getODSResults(0).begin()); + tblgen_AddOp_35 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp yl; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*yh.getODSResults(0).begin()); + yl = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp multiply_yh_yl; + { + ::mlir::Value tblgen_value_0 = (*yh.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*yl.getODSResults(0).begin()); + multiply_yh_yl = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_36; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_35.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*multiply_yh_yl.getODSResults(0).begin()); + tblgen_AddOp_36 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_37; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_36.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*multiply_yh_yl.getODSResults(0).begin()); + tblgen_AddOp_37 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_38; + { + ::mlir::Value tblgen_value_0 = (*yl.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*yl.getODSResults(0).begin()); + tblgen_MulOp_38 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp square_dekker_low; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_37.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_38.getODSResults(0).begin()); + square_dekker_low = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp _add_2sum_high_0_; + { + ::mlir::Value tblgen_value_0 = (*_add_2sum_high_1_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*square_dekker_low.getODSResults(0).begin()); + _add_2sum_high_0_ = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_39; + { + ::mlir::Value tblgen_value_0 = (*_square_dekker_high_0_.getODSResults(0).begin()); + tblgen_NegOp_39 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::MulOp multiply_veltkamp_splitter_constant_x; + { + ::mlir::Value tblgen_value_0 = (*veltkamp_splitter_constant.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*x.getODSResults(0).begin()); + multiply_veltkamp_splitter_constant_x = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_40; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*multiply_veltkamp_splitter_constant_x.getODSResults(0).begin()); + tblgen_SubtractOp_40 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp xh; + { + ::mlir::Value tblgen_value_0 = (*multiply_veltkamp_splitter_constant_x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_40.getODSResults(0).begin()); + xh = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_41; + { + ::mlir::Value tblgen_value_0 = (*xh.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xh.getODSResults(0).begin()); + tblgen_MulOp_41 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_42; + { + ::mlir::Value tblgen_value_0 = (*tblgen_NegOp_39.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_41.getODSResults(0).begin()); + tblgen_AddOp_42 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp xl; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xh.getODSResults(0).begin()); + xl = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp multiply_xh_xl; + { + ::mlir::Value tblgen_value_0 = (*xh.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xl.getODSResults(0).begin()); + multiply_xh_xl = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_43; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_42.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*multiply_xh_xl.getODSResults(0).begin()); + tblgen_AddOp_43 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_44; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_43.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*multiply_xh_xl.getODSResults(0).begin()); + tblgen_AddOp_44 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_45; + { + ::mlir::Value tblgen_value_0 = (*xl.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xl.getODSResults(0).begin()); + tblgen_MulOp_45 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp _square_dekker_low_0_; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_44.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_45.getODSResults(0).begin()); + _square_dekker_low_0_ = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp add_2sum_high; + { + ::mlir::Value tblgen_value_0 = (*_add_2sum_high_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_square_dekker_low_0_.getODSResults(0).begin()); + add_2sum_high = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp subtract__add_2sum_high_2__x2h; + { + ::mlir::Value tblgen_value_0 = (*_add_2sum_high_2_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*x2h.getODSResults(0).begin()); + subtract__add_2sum_high_2__x2h = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_46; + { + ::mlir::Value tblgen_value_0 = (*_add_2sum_high_2_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*subtract__add_2sum_high_2__x2h.getODSResults(0).begin()); + tblgen_SubtractOp_46 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_47; + { + ::mlir::Value tblgen_value_0 = (*x2h.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_46.getODSResults(0).begin()); + tblgen_SubtractOp_47 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_48; + { + ::mlir::Value tblgen_value_0 = (*square_dekker_high.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*subtract__add_2sum_high_2__x2h.getODSResults(0).begin()); + tblgen_SubtractOp_48 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp add_2sum_low; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SubtractOp_47.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_48.getODSResults(0).begin()); + add_2sum_low = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp subtract__add_2sum_high_1___add_2sum_high_2_; + { + ::mlir::Value tblgen_value_0 = (*_add_2sum_high_1_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_add_2sum_high_2_.getODSResults(0).begin()); + subtract__add_2sum_high_1___add_2sum_high_2_ = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_49; + { + ::mlir::Value tblgen_value_0 = (*_add_2sum_high_1_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*subtract__add_2sum_high_1___add_2sum_high_2_.getODSResults(0).begin()); + tblgen_SubtractOp_49 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_50; + { + ::mlir::Value tblgen_value_0 = (*_add_2sum_high_2_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_49.getODSResults(0).begin()); + tblgen_SubtractOp_50 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_51; + { + ::mlir::Value tblgen_value_0 = (*_square_dekker_high_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*subtract__add_2sum_high_1___add_2sum_high_2_.getODSResults(0).begin()); + tblgen_SubtractOp_51 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp _add_2sum_low_0_; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SubtractOp_50.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_51.getODSResults(0).begin()); + _add_2sum_low_0_ = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_52; + { + ::mlir::Value tblgen_value_0 = (*add_2sum_low.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_add_2sum_low_0_.getODSResults(0).begin()); + tblgen_AddOp_52 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp subtract__add_2sum_high_0___add_2sum_high_1_; + { + ::mlir::Value tblgen_value_0 = (*_add_2sum_high_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_add_2sum_high_1_.getODSResults(0).begin()); + subtract__add_2sum_high_0___add_2sum_high_1_ = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_53; + { + ::mlir::Value tblgen_value_0 = (*_add_2sum_high_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*subtract__add_2sum_high_0___add_2sum_high_1_.getODSResults(0).begin()); + tblgen_SubtractOp_53 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_54; + { + ::mlir::Value tblgen_value_0 = (*_add_2sum_high_1_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_53.getODSResults(0).begin()); + tblgen_SubtractOp_54 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_55; + { + ::mlir::Value tblgen_value_0 = (*square_dekker_low.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*subtract__add_2sum_high_0___add_2sum_high_1_.getODSResults(0).begin()); + tblgen_SubtractOp_55 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp _add_2sum_low_1_; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SubtractOp_54.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_55.getODSResults(0).begin()); + _add_2sum_low_1_ = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_56; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_52.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_add_2sum_low_1_.getODSResults(0).begin()); + tblgen_AddOp_56 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp subtract_add_2sum_high__add_2sum_high_0_; + { + ::mlir::Value tblgen_value_0 = (*add_2sum_high.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_add_2sum_high_0_.getODSResults(0).begin()); + subtract_add_2sum_high__add_2sum_high_0_ = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_57; + { + ::mlir::Value tblgen_value_0 = (*add_2sum_high.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*subtract_add_2sum_high__add_2sum_high_0_.getODSResults(0).begin()); + tblgen_SubtractOp_57 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_58; + { + ::mlir::Value tblgen_value_0 = (*_add_2sum_high_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_57.getODSResults(0).begin()); + tblgen_SubtractOp_58 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_59; + { + ::mlir::Value tblgen_value_0 = (*_square_dekker_low_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*subtract_add_2sum_high__add_2sum_high_0_.getODSResults(0).begin()); + tblgen_SubtractOp_59 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp _add_2sum_low_2_; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SubtractOp_58.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_59.getODSResults(0).begin()); + _add_2sum_low_2_ = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_60; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_56.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_add_2sum_low_2_.getODSResults(0).begin()); + tblgen_AddOp_60 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp sum_2sum_high; + { + ::mlir::Value tblgen_value_0 = (*add_2sum_high.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_60.getODSResults(0).begin()); + sum_2sum_high = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::Log1pOp tblgen_Log1pOp_61; + { + ::mlir::Value tblgen_value_0 = (*sum_2sum_high.getODSResults(0).begin()); + tblgen_Log1pOp_61 = rewriter.create<::mlir::stablehlo::Log1pOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_62; + { + ::mlir::Value tblgen_value_0 = half; + ::mlir::Value tblgen_value_1 = (*tblgen_Log1pOp_61.getODSResults(0).begin()); + tblgen_MulOp_62 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_63; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_17.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_21.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_MulOp_62.getODSResults(0).begin()); + tblgen_SelectOp_63 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_64; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_4.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_12.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_63.getODSResults(0).begin()); + tblgen_SelectOp_64 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::Atan2Op tblgen_Atan2Op_65; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xp1.getODSResults(0).begin()); + tblgen_Atan2Op_65 = rewriter.create<::mlir::stablehlo::Atan2Op>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_66; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ComplexOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_SelectOp_64.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_Atan2Op_65.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ComplexOp_66 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ComplexOp_66.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/StablehloComplexMathExpanderPatterns.td:553 +*/ +struct LogOp_ComplexElementType_ComplexMathExpander : public ::mlir::RewritePattern { + LogOp_ComplexElementType_ComplexMathExpander(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.log", 1, context, {"stablehlo.abs", "stablehlo.add", "stablehlo.atan2", "stablehlo.compare", "stablehlo.complex", "stablehlo.divide", "stablehlo.imag", "stablehlo.log", "stablehlo.log_plus_one", "stablehlo.maximum", "stablehlo.minimum", "stablehlo.multiply", "stablehlo.negate", "stablehlo.real", "stablehlo.select", "stablehlo.subtract"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range z(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::LogOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_StablehloComplexMathExpanderPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'stablehlo.log' failed to satisfy constraint: 'Complex element type'"))) { + return ::mlir::failure(); + } + z = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!tblgen_attr) tblgen_attr = ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + if (!tblgen_attr) return ::mlir::failure(); + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloComplexMathExpanderPatterns1(rewriter, castedOp0, tblgen_attr, "op 'stablehlo.log' attribute 'result_accuracy' failed to satisfy constraint: 'constant attribute ::mlir::stablehlo::ResultAccuracyMode::DEFAULT'"))) { + return ::mlir::failure(); + } + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::RealOp x; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + x = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto constant_fneg1 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, -1.0, x); (void)constant_fneg1; + ::mlir::stablehlo::ImagOp y; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + y = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::MulOp square_dekker_high; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + square_dekker_high = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp _square_dekker_high_0_; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*x.getODSResults(0).begin()); + _square_dekker_high_0_ = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_0 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_0; + ::mlir::stablehlo::CompareOp gt_square_dekker_high__square_dekker_high_0_; + { + ::mlir::Value tblgen_value_0 = (*square_dekker_high.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_square_dekker_high_0_.getODSResults(0).begin()); + gt_square_dekker_high__square_dekker_high_0_ = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_0 + ); + } + ::mlir::stablehlo::SelectOp mxh; + { + ::mlir::Value tblgen_value_0 = (*gt_square_dekker_high__square_dekker_high_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*square_dekker_high.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*_square_dekker_high_0_.getODSResults(0).begin()); + mxh = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::AddOp _add_fast2sum_high_2_; + { + ::mlir::Value tblgen_value_0 = constant_fneg1; + ::mlir::Value tblgen_value_1 = (*mxh.getODSResults(0).begin()); + _add_fast2sum_high_2_ = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp mnh; + { + ::mlir::Value tblgen_value_0 = (*gt_square_dekker_high__square_dekker_high_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_square_dekker_high_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*square_dekker_high.getODSResults(0).begin()); + mnh = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::AddOp _add_fast2sum_high_1_; + { + ::mlir::Value tblgen_value_0 = (*_add_fast2sum_high_2_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*mnh.getODSResults(0).begin()); + _add_fast2sum_high_1_ = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_1; + { + ::mlir::Value tblgen_value_0 = (*square_dekker_high.getODSResults(0).begin()); + tblgen_NegOp_1 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto largest = ::mlir::stablehlo::getConstantLikeMaxFiniteValue(rewriter, odsLoc, (*x.getODSResults(0).begin())); (void)largest; + auto nativeVar_2 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1e+308, (*x.getODSResults(0).begin())); (void)nativeVar_2; + auto nativeVar_3 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_3; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_4; + { + ::mlir::Value tblgen_value_0 = largest; + ::mlir::Value tblgen_value_1 = nativeVar_2; + tblgen_CompareOp_4 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_3 + ); + } + auto nativeVar_5 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 134217729, (*x.getODSResults(0).begin())); (void)nativeVar_5; + auto nativeVar_6 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1e+38, (*x.getODSResults(0).begin())); (void)nativeVar_6; + auto nativeVar_7 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_7; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_8; + { + ::mlir::Value tblgen_value_0 = largest; + ::mlir::Value tblgen_value_1 = nativeVar_6; + tblgen_CompareOp_8 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_7 + ); + } + auto nativeVar_9 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 4097, (*x.getODSResults(0).begin())); (void)nativeVar_9; + auto nativeVar_10 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 65, (*x.getODSResults(0).begin())); (void)nativeVar_10; + ::mlir::stablehlo::SelectOp tblgen_SelectOp_11; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_8.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_9; + ::mlir::Value tblgen_value_2 = nativeVar_10; + tblgen_SelectOp_11 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp veltkamp_splitter_constant; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_4.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_5; + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_11.getODSResults(0).begin()); + veltkamp_splitter_constant = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::MulOp multiply_veltkamp_splitter_constant_y; + { + ::mlir::Value tblgen_value_0 = (*veltkamp_splitter_constant.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*y.getODSResults(0).begin()); + multiply_veltkamp_splitter_constant_y = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_12; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*multiply_veltkamp_splitter_constant_y.getODSResults(0).begin()); + tblgen_SubtractOp_12 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp yh; + { + ::mlir::Value tblgen_value_0 = (*multiply_veltkamp_splitter_constant_y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_12.getODSResults(0).begin()); + yh = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_13; + { + ::mlir::Value tblgen_value_0 = (*yh.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*yh.getODSResults(0).begin()); + tblgen_MulOp_13 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_14; + { + ::mlir::Value tblgen_value_0 = (*tblgen_NegOp_1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_13.getODSResults(0).begin()); + tblgen_AddOp_14 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp yl; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*yh.getODSResults(0).begin()); + yl = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp multiply_yh_yl; + { + ::mlir::Value tblgen_value_0 = (*yh.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*yl.getODSResults(0).begin()); + multiply_yh_yl = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_15; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_14.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*multiply_yh_yl.getODSResults(0).begin()); + tblgen_AddOp_15 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_16; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_15.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*multiply_yh_yl.getODSResults(0).begin()); + tblgen_AddOp_16 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_17; + { + ::mlir::Value tblgen_value_0 = (*yl.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*yl.getODSResults(0).begin()); + tblgen_MulOp_17 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp square_dekker_low; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_16.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_17.getODSResults(0).begin()); + square_dekker_low = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp _add_fast2sum_high_0_; + { + ::mlir::Value tblgen_value_0 = (*_add_fast2sum_high_1_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*square_dekker_low.getODSResults(0).begin()); + _add_fast2sum_high_0_ = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_18; + { + ::mlir::Value tblgen_value_0 = (*_square_dekker_high_0_.getODSResults(0).begin()); + tblgen_NegOp_18 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::MulOp multiply_veltkamp_splitter_constant_x; + { + ::mlir::Value tblgen_value_0 = (*veltkamp_splitter_constant.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*x.getODSResults(0).begin()); + multiply_veltkamp_splitter_constant_x = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_19; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*multiply_veltkamp_splitter_constant_x.getODSResults(0).begin()); + tblgen_SubtractOp_19 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp xh; + { + ::mlir::Value tblgen_value_0 = (*multiply_veltkamp_splitter_constant_x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_19.getODSResults(0).begin()); + xh = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_20; + { + ::mlir::Value tblgen_value_0 = (*xh.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xh.getODSResults(0).begin()); + tblgen_MulOp_20 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_21; + { + ::mlir::Value tblgen_value_0 = (*tblgen_NegOp_18.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_20.getODSResults(0).begin()); + tblgen_AddOp_21 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp xl; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xh.getODSResults(0).begin()); + xl = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp multiply_xh_xl; + { + ::mlir::Value tblgen_value_0 = (*xh.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xl.getODSResults(0).begin()); + multiply_xh_xl = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_22; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_21.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*multiply_xh_xl.getODSResults(0).begin()); + tblgen_AddOp_22 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_23; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_22.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*multiply_xh_xl.getODSResults(0).begin()); + tblgen_AddOp_23 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_24; + { + ::mlir::Value tblgen_value_0 = (*xl.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*xl.getODSResults(0).begin()); + tblgen_MulOp_24 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp _square_dekker_low_0_; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_23.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_24.getODSResults(0).begin()); + _square_dekker_low_0_ = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp add_fast2sum_high; + { + ::mlir::Value tblgen_value_0 = (*_add_fast2sum_high_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_square_dekker_low_0_.getODSResults(0).begin()); + add_fast2sum_high = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_25; + { + ::mlir::Value tblgen_value_0 = (*_add_fast2sum_high_2_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = constant_fneg1; + tblgen_SubtractOp_25 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp add_fast2sum_low; + { + ::mlir::Value tblgen_value_0 = (*mxh.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_25.getODSResults(0).begin()); + add_fast2sum_low = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_26; + { + ::mlir::Value tblgen_value_0 = (*_add_fast2sum_high_1_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_add_fast2sum_high_2_.getODSResults(0).begin()); + tblgen_SubtractOp_26 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp _add_fast2sum_low_0_; + { + ::mlir::Value tblgen_value_0 = (*mnh.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_26.getODSResults(0).begin()); + _add_fast2sum_low_0_ = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_27; + { + ::mlir::Value tblgen_value_0 = (*add_fast2sum_low.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_add_fast2sum_low_0_.getODSResults(0).begin()); + tblgen_AddOp_27 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_28; + { + ::mlir::Value tblgen_value_0 = (*_add_fast2sum_high_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_add_fast2sum_high_1_.getODSResults(0).begin()); + tblgen_SubtractOp_28 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp _add_fast2sum_low_1_; + { + ::mlir::Value tblgen_value_0 = (*square_dekker_low.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_28.getODSResults(0).begin()); + _add_fast2sum_low_1_ = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_29; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_27.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_add_fast2sum_low_1_.getODSResults(0).begin()); + tblgen_AddOp_29 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp tblgen_SubtractOp_30; + { + ::mlir::Value tblgen_value_0 = (*add_fast2sum_high.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_add_fast2sum_high_0_.getODSResults(0).begin()); + tblgen_SubtractOp_30 = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SubtractOp _add_fast2sum_low_2_; + { + ::mlir::Value tblgen_value_0 = (*_square_dekker_low_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SubtractOp_30.getODSResults(0).begin()); + _add_fast2sum_low_2_ = rewriter.create<::mlir::stablehlo::SubtractOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_31; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_29.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_add_fast2sum_low_2_.getODSResults(0).begin()); + tblgen_AddOp_31 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp sum_fast2sum_high; + { + ::mlir::Value tblgen_value_0 = (*add_fast2sum_high.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_31.getODSResults(0).begin()); + sum_fast2sum_high = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AbsOp tblgen_AbsOp_32; + { + ::mlir::Value tblgen_value_0 = (*sum_fast2sum_high.getODSResults(0).begin()); + tblgen_AbsOp_32 = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto half = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0.5, (*x.getODSResults(0).begin())); (void)half; + auto nativeVar_33 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_33; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_34; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AbsOp_32.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = half; + tblgen_CompareOp_34 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_33 + ); + } + ::mlir::stablehlo::Log1pOp tblgen_Log1pOp_35; + { + ::mlir::Value tblgen_value_0 = (*sum_fast2sum_high.getODSResults(0).begin()); + tblgen_Log1pOp_35 = rewriter.create<::mlir::stablehlo::Log1pOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_36; + { + ::mlir::Value tblgen_value_0 = half; + ::mlir::Value tblgen_value_1 = (*tblgen_Log1pOp_35.getODSResults(0).begin()); + tblgen_MulOp_36 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AbsOp abs_x; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + abs_x = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::AbsOp abs_y; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + abs_y = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::MaxOp mx; + { + ::mlir::Value tblgen_value_0 = (*abs_x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*abs_y.getODSResults(0).begin()); + mx = rewriter.create<::mlir::stablehlo::MaxOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::LogOp tblgen_LogOp_37; + { + ::mlir::Value tblgen_value_0 = (*mx.getODSResults(0).begin()); + tblgen_LogOp_37 = rewriter.create<::mlir::stablehlo::LogOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::MinOp mn; + { + ::mlir::Value tblgen_value_0 = (*abs_x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*abs_y.getODSResults(0).begin()); + mn = rewriter.create<::mlir::stablehlo::MinOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_38 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_38; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_39; + { + ::mlir::Value tblgen_value_0 = (*mn.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*mx.getODSResults(0).begin()); + tblgen_CompareOp_39 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_38 + ); + } + auto nativeVar_40 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1.0, (*x.getODSResults(0).begin())); (void)nativeVar_40; + ::mlir::stablehlo::DivOp tblgen_DivOp_41; + { + ::mlir::Value tblgen_value_0 = (*mn.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*mx.getODSResults(0).begin()); + tblgen_DivOp_41 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp mn_over_mx; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_39.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_40; + ::mlir::Value tblgen_value_2 = (*tblgen_DivOp_41.getODSResults(0).begin()); + mn_over_mx = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_42; + { + ::mlir::Value tblgen_value_0 = (*mn_over_mx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*mn_over_mx.getODSResults(0).begin()); + tblgen_MulOp_42 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::Log1pOp tblgen_Log1pOp_43; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_42.getODSResults(0).begin()); + tblgen_Log1pOp_43 = rewriter.create<::mlir::stablehlo::Log1pOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_44; + { + ::mlir::Value tblgen_value_0 = half; + ::mlir::Value tblgen_value_1 = (*tblgen_Log1pOp_43.getODSResults(0).begin()); + tblgen_MulOp_44 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_45; + { + ::mlir::Value tblgen_value_0 = (*tblgen_LogOp_37.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_44.getODSResults(0).begin()); + tblgen_AddOp_45 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_46; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_34.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_36.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_AddOp_45.getODSResults(0).begin()); + tblgen_SelectOp_46 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::Atan2Op tblgen_Atan2Op_47; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*x.getODSResults(0).begin()); + tblgen_Atan2Op_47 = rewriter.create<::mlir::stablehlo::Atan2Op>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_48; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ComplexOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_SelectOp_46.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_Atan2Op_47.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ComplexOp_48 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ComplexOp_48.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/StablehloComplexMathExpanderPatterns.td:335 +*/ +struct SqrtOp_ComplexElementType_ComplexMathExpander : public ::mlir::RewritePattern { + SqrtOp_ComplexElementType_ComplexMathExpander(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.sqrt", 1, context, {"stablehlo.abs", "stablehlo.add", "stablehlo.and", "stablehlo.compare", "stablehlo.complex", "stablehlo.divide", "stablehlo.imag", "stablehlo.maximum", "stablehlo.minimum", "stablehlo.multiply", "stablehlo.negate", "stablehlo.or", "stablehlo.real", "stablehlo.select", "stablehlo.sqrt"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range z(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::SqrtOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_StablehloComplexMathExpanderPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'stablehlo.sqrt' failed to satisfy constraint: 'Complex element type'"))) { + return ::mlir::failure(); + } + z = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!tblgen_attr) tblgen_attr = ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)); + if (!tblgen_attr) return ::mlir::failure(); + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloComplexMathExpanderPatterns1(rewriter, castedOp0, tblgen_attr, "op 'stablehlo.sqrt' attribute 'result_accuracy' failed to satisfy constraint: 'constant attribute ::mlir::stablehlo::ResultAccuracyMode::DEFAULT'"))) { + return ::mlir::failure(); + } + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::RealOp x; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + x = rewriter.create<::mlir::stablehlo::RealOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto constant_0 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0, (*x.getODSResults(0).begin())); (void)constant_0; + auto nativeVar_0 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_0; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_1; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = constant_0; + tblgen_CompareOp_1 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GE), + /*compare_type=*/nativeVar_0 + ); + } + ::mlir::stablehlo::AbsOp ax; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ax = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::ImagOp y; + { + ::mlir::Value tblgen_value_0 = (*z.begin()); + y = rewriter.create<::mlir::stablehlo::ImagOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::AbsOp ay; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ay = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + auto nativeVar_2 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_2; + ::mlir::stablehlo::CompareOp eq_ax_ay; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ay.getODSResults(0).begin()); + eq_ax_ay = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_2 + ); + } + ::mlir::stablehlo::SqrtOp sq_ax; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + sq_ax = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + auto nativeVar_3 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1.5537739740300374, (*x.getODSResults(0).begin())); (void)nativeVar_3; + ::mlir::stablehlo::MulOp tblgen_MulOp_4; + { + ::mlir::Value tblgen_value_0 = (*sq_ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_3; + tblgen_MulOp_4 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto sq_2 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1.4142135623730951, (*x.getODSResults(0).begin())); (void)sq_2; + ::mlir::stablehlo::DivOp tblgen_DivOp_5; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_4.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = sq_2; + tblgen_DivOp_5 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MaxOp mx; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ay.getODSResults(0).begin()); + mx = rewriter.create<::mlir::stablehlo::MaxOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MinOp mn; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ay.getODSResults(0).begin()); + mn = rewriter.create<::mlir::stablehlo::MinOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_6 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_6; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_7; + { + ::mlir::Value tblgen_value_0 = (*mx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*mn.getODSResults(0).begin()); + tblgen_CompareOp_7 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_6 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_8; + { + ::mlir::Value tblgen_value_0 = sq_2; + ::mlir::Value tblgen_value_1 = (*mx.getODSResults(0).begin()); + tblgen_MulOp_8 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto one = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 1, (*x.getODSResults(0).begin())); (void)one; + ::mlir::stablehlo::DivOp mn_over_mx; + { + ::mlir::Value tblgen_value_0 = (*mn.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*mx.getODSResults(0).begin()); + mn_over_mx = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp r; + { + ::mlir::Value tblgen_value_0 = (*mn_over_mx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*mn_over_mx.getODSResults(0).begin()); + r = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_9; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*r.getODSResults(0).begin()); + tblgen_AddOp_9 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp sqa; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_9.getODSResults(0).begin()); + sqa = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + auto nativeVar_10 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_10; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_11; + { + ::mlir::Value tblgen_value_0 = (*sqa.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + tblgen_CompareOp_11 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_10 + ); + } + auto nativeVar_12 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_12; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_13; + { + ::mlir::Value tblgen_value_0 = (*r.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = constant_0; + tblgen_CompareOp_13 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_12 + ); + } + ::mlir::stablehlo::AndOp tblgen_AndOp_14; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_11.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_CompareOp_13.getODSResults(0).begin()); + tblgen_AndOp_14 = rewriter.create<::mlir::stablehlo::AndOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_15; + { + ::mlir::Value tblgen_value_0 = (*mx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*r.getODSResults(0).begin()); + tblgen_MulOp_15 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto two = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 2, (*x.getODSResults(0).begin())); (void)two; + ::mlir::stablehlo::DivOp tblgen_DivOp_16; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_15.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = two; + tblgen_DivOp_16 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_17; + { + ::mlir::Value tblgen_value_0 = (*mx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_16.getODSResults(0).begin()); + tblgen_AddOp_17 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_18; + { + ::mlir::Value tblgen_value_0 = (*mx.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*sqa.getODSResults(0).begin()); + tblgen_MulOp_18 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_19; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AndOp_14.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_17.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_MulOp_18.getODSResults(0).begin()); + tblgen_SelectOp_19 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_20; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_7.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_8.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_19.getODSResults(0).begin()); + tblgen_SelectOp_20 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_21; + { + ::mlir::Value tblgen_value_0 = (*tblgen_SelectOp_20.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = two; + tblgen_DivOp_21 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_22; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = two; + tblgen_DivOp_22 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_23; + { + ::mlir::Value tblgen_value_0 = (*tblgen_DivOp_21.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_22.getODSResults(0).begin()); + tblgen_AddOp_23 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp u_general; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_23.getODSResults(0).begin()); + u_general = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + auto nativeVar_24 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_24; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_25; + { + ::mlir::Value tblgen_value_0 = (*u_general.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = constant_0; + tblgen_CompareOp_25 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_24 + ); + } + auto nativeVar_26 = ::mlir::stablehlo::getConstantLikeInfValue(rewriter, odsLoc, (*x.getODSResults(0).begin()), /*negative=*/false); (void)nativeVar_26; + auto nativeVar_27 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_27; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_28; + { + ::mlir::Value tblgen_value_0 = (*u_general.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_26; + tblgen_CompareOp_28 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_27 + ); + } + ::mlir::stablehlo::OrOp logical_or_eq_u_general_constant_0_eq_u_general_constant_posinf; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_25.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_CompareOp_28.getODSResults(0).begin()); + logical_or_eq_u_general_constant_0_eq_u_general_constant_posinf = rewriter.create<::mlir::stablehlo::OrOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_29 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_29; + ::mlir::stablehlo::CompareOp gt_ax_ay; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ay.getODSResults(0).begin()); + gt_ax_ay = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_29 + ); + } + auto nativeVar_30 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_30; + ::mlir::stablehlo::CompareOp lt_ax_ay; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ay.getODSResults(0).begin()); + lt_ax_ay = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_30 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_31; + { + ::mlir::Value tblgen_value_0 = (*ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ay.getODSResults(0).begin()); + tblgen_DivOp_31 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_32; + { + ::mlir::Value tblgen_value_0 = (*ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*ax.getODSResults(0).begin()); + tblgen_DivOp_32 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_33; + { + ::mlir::Value tblgen_value_0 = (*lt_ax_ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_31.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_DivOp_32.getODSResults(0).begin()); + tblgen_SelectOp_33 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp _r_0_; + { + ::mlir::Value tblgen_value_0 = (*eq_ax_ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_33.getODSResults(0).begin()); + _r_0_ = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::AbsOp abs__r_0_; + { + ::mlir::Value tblgen_value_0 = (*_r_0_.getODSResults(0).begin()); + abs__r_0_ = rewriter.create<::mlir::stablehlo::AbsOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::MaxOp _mx_0_; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*abs__r_0_.getODSResults(0).begin()); + _mx_0_ = rewriter.create<::mlir::stablehlo::MaxOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MinOp _mn_0_; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*abs__r_0_.getODSResults(0).begin()); + _mn_0_ = rewriter.create<::mlir::stablehlo::MinOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + auto nativeVar_34 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_34; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_35; + { + ::mlir::Value tblgen_value_0 = (*_mx_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_mn_0_.getODSResults(0).begin()); + tblgen_CompareOp_35 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_34 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_36; + { + ::mlir::Value tblgen_value_0 = sq_2; + ::mlir::Value tblgen_value_1 = (*_mx_0_.getODSResults(0).begin()); + tblgen_MulOp_36 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp _mn_over_mx_0_; + { + ::mlir::Value tblgen_value_0 = (*_mn_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_mx_0_.getODSResults(0).begin()); + _mn_over_mx_0_ = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp _r_1_; + { + ::mlir::Value tblgen_value_0 = (*_mn_over_mx_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_mn_over_mx_0_.getODSResults(0).begin()); + _r_1_ = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_37; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*_r_1_.getODSResults(0).begin()); + tblgen_AddOp_37 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp _sqa_0_; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_37.getODSResults(0).begin()); + _sqa_0_ = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + auto nativeVar_38 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_38; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_39; + { + ::mlir::Value tblgen_value_0 = (*_sqa_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + tblgen_CompareOp_39 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::EQ), + /*compare_type=*/nativeVar_38 + ); + } + auto nativeVar_40 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_40; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_41; + { + ::mlir::Value tblgen_value_0 = (*_r_1_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = constant_0; + tblgen_CompareOp_41 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::GT), + /*compare_type=*/nativeVar_40 + ); + } + ::mlir::stablehlo::AndOp tblgen_AndOp_42; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_39.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_CompareOp_41.getODSResults(0).begin()); + tblgen_AndOp_42 = rewriter.create<::mlir::stablehlo::AndOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_43; + { + ::mlir::Value tblgen_value_0 = (*_mx_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_r_1_.getODSResults(0).begin()); + tblgen_MulOp_43 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_44; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_43.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = two; + tblgen_DivOp_44 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_45; + { + ::mlir::Value tblgen_value_0 = (*_mx_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_44.getODSResults(0).begin()); + tblgen_AddOp_45 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_46; + { + ::mlir::Value tblgen_value_0 = (*_mx_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*_sqa_0_.getODSResults(0).begin()); + tblgen_MulOp_46 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_47; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AndOp_42.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_AddOp_45.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_MulOp_46.getODSResults(0).begin()); + tblgen_SelectOp_47 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp h; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_35.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_36.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_47.getODSResults(0).begin()); + h = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_48; + { + ::mlir::Value tblgen_value_0 = one; + ::mlir::Value tblgen_value_1 = (*h.getODSResults(0).begin()); + tblgen_AddOp_48 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp sq_1h; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_48.getODSResults(0).begin()); + sq_1h = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_49; + { + ::mlir::Value tblgen_value_0 = (*sq_1h.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = sq_2; + tblgen_DivOp_49 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_50; + { + ::mlir::Value tblgen_value_0 = (*sq_ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_49.getODSResults(0).begin()); + tblgen_MulOp_50 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp sq_ay; + { + ::mlir::Value tblgen_value_0 = (*ay.getODSResults(0).begin()); + sq_ay = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::AddOp tblgen_AddOp_51; + { + ::mlir::Value tblgen_value_0 = (*_r_0_.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*h.getODSResults(0).begin()); + tblgen_AddOp_51 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SqrtOp sq_rh; + { + ::mlir::Value tblgen_value_0 = (*tblgen_AddOp_51.getODSResults(0).begin()); + sq_rh = rewriter.create<::mlir::stablehlo::SqrtOp>(odsLoc, + /*operand=*/tblgen_value_0, + ::mlir::stablehlo::ResultAccuracyAttr::get(rewriter.getContext(), APFloat(0.0), APFloat(0.0), 0, ::mlir::stablehlo::ResultAccuracyModeAttr::get(rewriter.getContext(), ::mlir::stablehlo::ResultAccuracyMode::DEFAULT)) + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_52; + { + ::mlir::Value tblgen_value_0 = (*sq_rh.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = sq_2; + tblgen_DivOp_52 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_53; + { + ::mlir::Value tblgen_value_0 = (*sq_ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_52.getODSResults(0).begin()); + tblgen_MulOp_53 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_54; + { + ::mlir::Value tblgen_value_0 = (*gt_ax_ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_50.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_MulOp_53.getODSResults(0).begin()); + tblgen_SelectOp_54 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_55; + { + ::mlir::Value tblgen_value_0 = (*logical_or_eq_u_general_constant_0_eq_u_general_constant_posinf.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SelectOp_54.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*u_general.getODSResults(0).begin()); + tblgen_SelectOp_55 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp u; + { + ::mlir::Value tblgen_value_0 = (*eq_ax_ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_5.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_55.getODSResults(0).begin()); + u = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + auto nativeVar_56 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 2.19736822693562, (*x.getODSResults(0).begin())); (void)nativeVar_56; + ::mlir::stablehlo::DivOp tblgen_DivOp_57; + { + ::mlir::Value tblgen_value_0 = (*sq_ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = nativeVar_56; + tblgen_DivOp_57 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_58; + { + ::mlir::Value tblgen_value_0 = (*sq_ax.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*sq_ay.getODSResults(0).begin()); + tblgen_DivOp_58 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_59; + { + ::mlir::Value tblgen_value_0 = (*sq_ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*sq_ax.getODSResults(0).begin()); + tblgen_DivOp_59 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_60; + { + ::mlir::Value tblgen_value_0 = (*lt_ax_ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_58.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_DivOp_59.getODSResults(0).begin()); + tblgen_SelectOp_60 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_61; + { + ::mlir::Value tblgen_value_0 = (*eq_ax_ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = one; + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_60.getODSResults(0).begin()); + tblgen_SelectOp_61 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_62; + { + ::mlir::Value tblgen_value_0 = (*sq_ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SelectOp_61.getODSResults(0).begin()); + tblgen_MulOp_62 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_63; + { + ::mlir::Value tblgen_value_0 = (*sq_1h.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = sq_2; + tblgen_MulOp_63 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_64; + { + ::mlir::Value tblgen_value_0 = (*tblgen_MulOp_62.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_63.getODSResults(0).begin()); + tblgen_DivOp_64 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_65; + { + ::mlir::Value tblgen_value_0 = (*sq_rh.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = sq_2; + tblgen_MulOp_65 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_66; + { + ::mlir::Value tblgen_value_0 = (*sq_ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_65.getODSResults(0).begin()); + tblgen_DivOp_66 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_67; + { + ::mlir::Value tblgen_value_0 = (*gt_ax_ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_64.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_DivOp_66.getODSResults(0).begin()); + tblgen_SelectOp_67 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::MulOp tblgen_MulOp_68; + { + ::mlir::Value tblgen_value_0 = (*u_general.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = two; + tblgen_MulOp_68 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::DivOp tblgen_DivOp_69; + { + ::mlir::Value tblgen_value_0 = (*ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_MulOp_68.getODSResults(0).begin()); + tblgen_DivOp_69 = rewriter.create<::mlir::stablehlo::DivOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_70; + { + ::mlir::Value tblgen_value_0 = (*logical_or_eq_u_general_constant_0_eq_u_general_constant_posinf.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SelectOp_67.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_DivOp_69.getODSResults(0).begin()); + tblgen_SelectOp_70 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp ay_div_u; + { + ::mlir::Value tblgen_value_0 = (*eq_ax_ay.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_DivOp_57.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_70.getODSResults(0).begin()); + ay_div_u = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_71; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_1.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*u.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*ay_div_u.getODSResults(0).begin()); + tblgen_SelectOp_71 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + auto nativeVar_72 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_72; + ::mlir::stablehlo::CompareOp tblgen_CompareOp_73; + { + ::mlir::Value tblgen_value_0 = (*x.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = constant_0; + tblgen_CompareOp_73 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_72 + ); + } + auto nativeVar_74 = ::mlir::stablehlo::ComparisonTypeAttr(); (void)nativeVar_74; + ::mlir::stablehlo::CompareOp lt_y_constant_0; + { + ::mlir::Value tblgen_value_0 = (*y.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = constant_0; + lt_y_constant_0 = rewriter.create<::mlir::stablehlo::CompareOp>(odsLoc, + /*lhs=*/tblgen_value_0, + /*rhs=*/tblgen_value_1, + ::mlir::stablehlo::ComparisonDirectionAttr::get(rewriter.getContext(), ::mlir::stablehlo::ComparisonDirection::LT), + /*compare_type=*/nativeVar_74 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_75; + { + ::mlir::Value tblgen_value_0 = (*u.getODSResults(0).begin()); + tblgen_NegOp_75 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_76; + { + ::mlir::Value tblgen_value_0 = (*lt_y_constant_0.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_NegOp_75.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*u.getODSResults(0).begin()); + tblgen_SelectOp_76 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::NegOp tblgen_NegOp_77; + { + ::mlir::Value tblgen_value_0 = (*ay_div_u.getODSResults(0).begin()); + tblgen_NegOp_77 = rewriter.create<::mlir::stablehlo::NegOp>(odsLoc, + /*operand=*/tblgen_value_0 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_78; + { + ::mlir::Value tblgen_value_0 = (*lt_y_constant_0.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_NegOp_77.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*ay_div_u.getODSResults(0).begin()); + tblgen_SelectOp_78 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_79; + { + ::mlir::Value tblgen_value_0 = (*tblgen_CompareOp_73.getODSResults(0).begin()); + ::mlir::Value tblgen_value_1 = (*tblgen_SelectOp_76.getODSResults(0).begin()); + ::mlir::Value tblgen_value_2 = (*tblgen_SelectOp_78.getODSResults(0).begin()); + tblgen_SelectOp_79 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, + /*pred=*/tblgen_value_0, + /*on_true=*/tblgen_value_1, + /*on_false=*/tblgen_value_2 + ); + } + ::mlir::stablehlo::ComplexOp tblgen_ComplexOp_80; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::ComplexOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_SelectOp_71.getODSResults(0).begin())); + tblgen_values.push_back((*tblgen_SelectOp_79.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ComplexOp_80 = rewriter.create<::mlir::stablehlo::ComplexOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ComplexOp_80.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +void LLVM_ATTRIBUTE_UNUSED populateWithGenerated(::mlir::RewritePatternSet &patterns) { + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); +} diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/StablehloLegalizeDeprecatedOpsPatterns.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/transforms/StablehloLegalizeDeprecatedOpsPatterns.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..cc9efe57c69618079b488c3f0ddba099d5f7427d --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/StablehloLegalizeDeprecatedOpsPatterns.h.inc @@ -0,0 +1,227 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Rewriters *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: StablehloLegalizeDeprecatedOpsPatterns.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +/* Generated from: + external/stablehlo/stablehlo/transforms/StablehloLegalizeDeprecatedOpsPatterns.td:38 +*/ +struct BroadcastToBroadcastInDim : public ::mlir::RewritePattern { + BroadcastToBroadcastInDim(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.broadcast", 1, context, {"stablehlo.broadcast_in_dim"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseI64ArrayAttr broadcast_sizes; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::mlir::stablehlo::BroadcastOp result; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::BroadcastOp>(op0); (void)castedOp0; + result = castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getBroadcastSizes(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.broadcast' to have attribute 'broadcast_sizes' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + broadcast_sizes = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getBroadcastDimensionsFromBroadcastSizes(cast((*result.getODSResults(0).begin()).getType()), cast(broadcast_sizes)); (void)nativeVar_0; + ::mlir::stablehlo::BroadcastInDimOp tblgen_BroadcastInDimOp_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::BroadcastInDimOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.broadcast_dimensions = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_BroadcastInDimOp_1 = rewriter.create<::mlir::stablehlo::BroadcastInDimOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_BroadcastInDimOp_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/StablehloLegalizeDeprecatedOpsPatterns.td:42 +*/ +struct CreateTokenToAfterAll : public ::mlir::RewritePattern { + CreateTokenToAfterAll(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.create_token", 1, context, {"stablehlo.after_all"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::CreateTokenOp>(op0); (void)castedOp0; + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = ValueRange{}; (void)nativeVar_0; + ::mlir::stablehlo::AfterAllOp tblgen_AfterAllOp_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::AfterAllOp::Properties tblgen_props; (void)tblgen_props; + for (auto v: nativeVar_0) { + tblgen_values.push_back(v); + } + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_AfterAllOp_1 = rewriter.create<::mlir::stablehlo::AfterAllOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AfterAllOp_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/StablehloLegalizeDeprecatedOpsPatterns.td:48 +*/ +struct DotToDotGeneral : public ::mlir::RewritePattern { + DotToDotGeneral(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.dot", 1, context, {"stablehlo.dot_general"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::ArrayAttr precision_config; + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::DotOp>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + rhs = castedOp0.getODSOperands(1); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getPrecisionConfig(); + precision_config = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultDotDimensionNumbers((*lhs.begin())); (void)nativeVar_0; + auto nativeVar_1 = Attribute{}; (void)nativeVar_1; + ::mlir::stablehlo::DotGeneralOp tblgen_DotGeneralOp_2; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::DotGeneralOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*lhs.begin())); + tblgen_values.push_back((*rhs.begin())); + tblgen_props.dot_dimension_numbers = ::llvm::dyn_cast_if_present(nativeVar_0); + tblgen_props.precision_config = ::llvm::dyn_cast_if_present(precision_config); + tblgen_props.algorithm = ::llvm::dyn_cast_if_present(nativeVar_1); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_DotGeneralOp_2 = rewriter.create<::mlir::stablehlo::DotGeneralOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DotGeneralOp_2.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/StablehloLegalizeDeprecatedOpsPatterns.td:52 +*/ +struct UnaryEinsumToEinsum : public ::mlir::RewritePattern { + UnaryEinsumToEinsum(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.unary_einsum", 1, context, {"stablehlo.constant", "stablehlo.einsum"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::StringAttr equation; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::UnaryEinsumOp>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getEinsumConfig(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.unary_einsum' to have attribute 'einsum_config' of type '::mlir::StringAttr'"; + }); + } + equation = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getScalarOfType(getElementTypeOrSelf((*operand.begin())),1); (void)nativeVar_0; + ::mlir::stablehlo::ConstantOp tblgen_ConstantOp_1; + { + tblgen_ConstantOp_1 = rewriter.create<::mlir::stablehlo::ConstantOp>(odsLoc, + /*value=*/nativeVar_0 + ); + } + auto nativeVar_2 = rewriter.getStringAttr("," + equation.getValue().str()); (void)nativeVar_2; + ::mlir::stablehlo::EinsumOp tblgen_EinsumOp_3; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::EinsumOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_ConstantOp_1.getODSResults(0).begin())); + tblgen_values.push_back((*operand.begin())); + tblgen_props.einsum_config = ::llvm::dyn_cast_if_present(nativeVar_2); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_EinsumOp_3 = rewriter.create<::mlir::stablehlo::EinsumOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_EinsumOp_3.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +void LLVM_ATTRIBUTE_UNUSED populateWithGenerated(::mlir::RewritePatternSet &patterns) { + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); +} diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/StablehloRefineShapes.h b/deps/exla/cache/xla_extension/include/stablehlo/transforms/StablehloRefineShapes.h new file mode 100644 index 0000000000000000000000000000000000000000..7f35092d0600fd1657d76ac0fbb49f9d4dba4c41 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/StablehloRefineShapes.h @@ -0,0 +1,143 @@ +/* Copyright 2022 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_TRANSFORMS_STABLEHLO_REFINE_SHAPES_H +#define STABLEHLO_TRANSFORMS_STABLEHLO_REFINE_SHAPES_H + +#include + +#include "llvm/ADT/SmallVector.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/Operation.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/IR/TypeRange.h" +#include "mlir/IR/Types.h" +#include "mlir/IR/Value.h" +#include "mlir/IR/ValueRange.h" +#include "mlir/Interfaces/InferTypeOpInterface.h" +#include "mlir/Support/LLVM.h" +#include "mlir/Support/LogicalResult.h" +#include "stablehlo/dialect/Base.h" + +namespace mlir { +namespace stablehlo { + +// Emits an error message for invalid refinement. +LogicalResult refinementError(Operation* op, int64_t idx, Type argType, + Type refinedType, StringRef msg); + +// Validates refinement types: +// - A type refinement must be specified for each operand +// - Refinement types that match operand types are skipped +// - Refinement types that do not match operands must be refining tensors +// - Refined tensor types must be ranked, operand type can be unranked +// - Refined tensor types must match operand type for all static dimensions +LogicalResult validateRefinedTypes(Operation* op, TypeRange argTypes, + TypeRange refinedTypes); + +// Gets a FuncOp that --stablehlo-refine-shapes will run on. +// Returns a nullptr and emits appropriate errors if such a function cannot +// be obtained from the module. +func::FuncOp getStablehloRefineShapesTarget(ModuleOp module); + +// Refine the arguments of the given function using the given types. +// Wraps all operands in a custom call to keep the IR valid during refinement. +// %0 = stablehlo.custom_call @stablehlo.shape_refinement_operand_wrapper(%arg0) +LogicalResult refineArguments(func::FuncOp func, TypeRange refinedTypes); + +// Refines the values using the given types. +// Tricky implementation details: +// 1) Need to support partial shape refinements, e.g. if just a single +// dimension size out of an entire tensor type got refined. This is done +// via inferMostSpecificType. +// 2) Need to signal propagation of the refined shapes across the +// StableHLO program. Different callers of this function have different +// propagation needs, so this function doesn't signal anything on its own +// and leaves that to the callers. +LogicalResult refineValues(PatternRewriter& rewriter, Operation* op, + ValueRange values, TypeRange types); + +// Refines the return types of the given operation using the given types. +// This function also signals PatternRewriter that it needs to visit all the +// users of this op if any updates to its results have happened during execution +// of the function. +LogicalResult refineReturnTypes(PatternRewriter& rewriter, Operation* op, + ArrayRef types); + +// Refines the return types of the given operation using the given types. +// Tricky implementation details: +// 1) `types` can include non-shaped types. If there are tuple types, +// then they are first flattened into non-tuple types using in-order +// traversal, and only then we apply the refinements. If there are other +// types, then the corresponding refinements must be completely empty. +// 2) Encodings are not supported. In principle, TypeExtensions should be +// supportable, but this needs careful thinking through. Given that no one +// asked for support for bounded dynamism in this pass yet, this is left +// for future work. +// This function also signals PatternRewriter that it needs to visit all the +// users of this op if any updates to its results have happened during execution +// of the function. +LogicalResult refineReturnTypes(PatternRewriter& rewriter, Operation* op, + ArrayRef refinements); + +// Refines the return type of the given operation using the given shape. +// This function also signals PatternRewriter that it needs to visit all the +// users of this op if any updates to its results have happened during execution +// of the function. +template +LogicalResult refineReturnShape(PatternRewriter& rewriter, OpType op, + ArrayRef shape) { + return refineReturnTypes(rewriter, op, ShapedTypeComponents(shape)); +} + +// Refines the return type of the given operation using the given shape. +// This function also signals PatternRewriter that it needs to visit all the +// users of this op if any updates to its results have happened during execution +// of the function. +template +LogicalResult refineReturnShape(PatternRewriter& rewriter, OpType op, + Value shapeValue) { + // At the moment, we only support refining return types using fully static + // shape values which serves the current use cases well. + // Support for partially static shape values is left for future work. + SmallVector shape; + if (failed(hlo::matchInts(shapeValue, shape))) + return rewriter.notifyMatchFailure(op, "expected constant output shape"); + return refineReturnShape(rewriter, op, shape); +} + +// Entrypoint for any pass adding extensibility to the StableHLO shape +// refinement pass. If program is inlined before shape refinement, +// populateShapeRefinementPatterns can be safely used, but if shape refinement +// needs to operate on programs with functions and calls, then +// additionalPatterns will need to be populated and passed in. +using AdditionalShapeRefinementPatternsFn = + std::function; +LogicalResult refineEntryFunction( + MLIRContext& context, func::FuncOp func, + std::optional additionalPatternsFn = + std::nullopt); + +// Custom call used to buffer operands for shape refinement +// This is a temporary artifact that is introduced by StablehloRefineArguments +// and is washed away during StablehloRefineShapes. +constexpr StringRef kCustomCallOperandBarrierTarget = + "stablehlo.shape_refinement_operand_wrapper"; + +} // namespace stablehlo +} // namespace mlir + +#endif // STABLEHLO_TRANSFORMS_STABLEHLO_REFINE_SHAPES_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/VhloToVersionPatterns.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/transforms/VhloToVersionPatterns.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..362a15ba205dd3037bc02dd5202eaa6be0a65c1c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/VhloToVersionPatterns.h.inc @@ -0,0 +1,2869 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Rewriters *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: VhloToVersionPatterns.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_VhloToVersionPatterns1( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!((isNoneType(attr)))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": None type"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_VhloToVersionPatterns2( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!((isEmptyTensor(attr)))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": Empty dims"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_VhloToVersionPatterns3( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!((isDefaultResultAccuracy(attr)))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": Default result accuracy"; + }); + } + return ::mlir::success(); +} +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:71 +*/ +struct AllGatherOpDowngradeV2ToV1 : public ::mlir::RewritePattern { + AllGatherOpDowngradeV2ToV1(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.all_gather_v2", 1, context, {"vhlo.all_gather_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute use_global_device_ids; + ::mlir::Attribute channel_id; + ::mlir::Attribute replica_groups; + ::mlir::Attribute all_gather_dim; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::AllGatherOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getAllGatherDim(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_gather_v2' to have attribute 'all_gather_dim' of type '::mlir::Attribute'"; + }); + } + all_gather_dim = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getReplicaGroups(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_gather_v2' to have attribute 'replica_groups' of type '::mlir::Attribute'"; + }); + } + replica_groups = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getChannelId(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_gather_v2' to have attribute 'channel_id' of type '::mlir::Attribute'"; + }); + } + channel_id = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getUseGlobalDeviceIds(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_gather_v2' to have attribute 'use_global_device_ids' of type '::mlir::Attribute'"; + }); + } + use_global_device_ids = tblgen_attr; + } + if (!((operand.size() == 1))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'operand' failed to satisfy constraint: 'Single operand'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = operand.front(); (void)nativeVar_0; + ::mlir::vhlo::AllGatherOpV1 tblgen_AllGatherOpV1_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::AllGatherOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back(nativeVar_0); + tblgen_props.all_gather_dim = ::llvm::dyn_cast_if_present(all_gather_dim); + tblgen_props.replica_groups = ::llvm::dyn_cast_if_present(replica_groups); + tblgen_props.channel_id = ::llvm::dyn_cast_if_present(channel_id); + tblgen_props.use_global_device_ids = ::llvm::dyn_cast_if_present(use_global_device_ids); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_AllGatherOpV1_1 = rewriter.create<::mlir::vhlo::AllGatherOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AllGatherOpV1_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:67 +*/ +struct AllGatherOpUpgradeV1ToV2 : public ::mlir::RewritePattern { + AllGatherOpUpgradeV1ToV2(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.all_gather_v1", 1, context, {"vhlo.all_gather_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute use_global_device_ids; + ::mlir::Attribute channel_id; + ::mlir::Attribute replica_groups; + ::mlir::Attribute all_gather_dim; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::AllGatherOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getAllGatherDim(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_gather_v1' to have attribute 'all_gather_dim' of type '::mlir::Attribute'"; + }); + } + all_gather_dim = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getReplicaGroups(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_gather_v1' to have attribute 'replica_groups' of type '::mlir::Attribute'"; + }); + } + replica_groups = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getChannelId(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_gather_v1' to have attribute 'channel_id' of type '::mlir::Attribute'"; + }); + } + channel_id = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getUseGlobalDeviceIds(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_gather_v1' to have attribute 'use_global_device_ids' of type '::mlir::Attribute'"; + }); + } + use_global_device_ids = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = {(*operand.begin())}; (void)nativeVar_0; + ::mlir::vhlo::AllGatherOpV2 tblgen_AllGatherOpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::AllGatherOpV2::Properties tblgen_props; (void)tblgen_props; + for (auto v: nativeVar_0) { + tblgen_values.push_back(v); + } + tblgen_props.all_gather_dim = ::llvm::dyn_cast_if_present(all_gather_dim); + tblgen_props.replica_groups = ::llvm::dyn_cast_if_present(replica_groups); + tblgen_props.channel_id = ::llvm::dyn_cast_if_present(channel_id); + tblgen_props.use_global_device_ids = ::llvm::dyn_cast_if_present(use_global_device_ids); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_AllGatherOpV2_1 = rewriter.create<::mlir::vhlo::AllGatherOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AllGatherOpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:80 +*/ +struct AllToAllOpDowngradeV2ToV1 : public ::mlir::RewritePattern { + AllToAllOpDowngradeV2ToV1(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.all_to_all_v2", 1, context, {"vhlo.all_to_all_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute channel_id; + ::mlir::Attribute replica_groups; + ::mlir::Attribute concat_dimension; + ::mlir::Attribute split_count; + ::mlir::Attribute split_dimension; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::AllToAllOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getSplitDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_to_all_v2' to have attribute 'split_dimension' of type '::mlir::Attribute'"; + }); + } + split_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getConcatDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_to_all_v2' to have attribute 'concat_dimension' of type '::mlir::Attribute'"; + }); + } + concat_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getSplitCount(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_to_all_v2' to have attribute 'split_count' of type '::mlir::Attribute'"; + }); + } + split_count = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getReplicaGroups(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_to_all_v2' to have attribute 'replica_groups' of type '::mlir::Attribute'"; + }); + } + replica_groups = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getChannelId(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_to_all_v2' to have attribute 'channel_id' of type '::mlir::Attribute'"; + }); + } + channel_id = tblgen_attr; + } + if (!((operand.size() == 1))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'operand' failed to satisfy constraint: 'Single operand'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = operand.front(); (void)nativeVar_0; + ::mlir::vhlo::AllToAllOpV1 tblgen_AllToAllOpV1_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::AllToAllOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back(nativeVar_0); + tblgen_props.split_dimension = ::llvm::dyn_cast_if_present(split_dimension); + tblgen_props.concat_dimension = ::llvm::dyn_cast_if_present(concat_dimension); + tblgen_props.split_count = ::llvm::dyn_cast_if_present(split_count); + tblgen_props.replica_groups = ::llvm::dyn_cast_if_present(replica_groups); + tblgen_props.channel_id = ::llvm::dyn_cast_if_present(channel_id); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_AllToAllOpV1_1 = rewriter.create<::mlir::vhlo::AllToAllOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AllToAllOpV1_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:76 +*/ +struct AllToAllOpUpgradeV1ToV2 : public ::mlir::RewritePattern { + AllToAllOpUpgradeV1ToV2(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.all_to_all_v1", 1, context, {"vhlo.all_to_all_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute channel_id; + ::mlir::Attribute replica_groups; + ::mlir::Attribute concat_dimension; + ::mlir::Attribute split_count; + ::mlir::Attribute split_dimension; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::AllToAllOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getSplitDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_to_all_v1' to have attribute 'split_dimension' of type '::mlir::Attribute'"; + }); + } + split_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getConcatDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_to_all_v1' to have attribute 'concat_dimension' of type '::mlir::Attribute'"; + }); + } + concat_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getSplitCount(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_to_all_v1' to have attribute 'split_count' of type '::mlir::Attribute'"; + }); + } + split_count = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getReplicaGroups(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_to_all_v1' to have attribute 'replica_groups' of type '::mlir::Attribute'"; + }); + } + replica_groups = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getChannelId(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.all_to_all_v1' to have attribute 'channel_id' of type '::mlir::Attribute'"; + }); + } + channel_id = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = {(*operand.begin())}; (void)nativeVar_0; + ::mlir::vhlo::AllToAllOpV2 tblgen_AllToAllOpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::AllToAllOpV2::Properties tblgen_props; (void)tblgen_props; + for (auto v: nativeVar_0) { + tblgen_values.push_back(v); + } + tblgen_props.split_dimension = ::llvm::dyn_cast_if_present(split_dimension); + tblgen_props.concat_dimension = ::llvm::dyn_cast_if_present(concat_dimension); + tblgen_props.split_count = ::llvm::dyn_cast_if_present(split_count); + tblgen_props.replica_groups = ::llvm::dyn_cast_if_present(replica_groups); + tblgen_props.channel_id = ::llvm::dyn_cast_if_present(channel_id); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_AllToAllOpV2_1 = rewriter.create<::mlir::vhlo::AllToAllOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AllToAllOpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:85 +*/ +struct DotGeneralOpDowngradeV2ToV1 : public ::mlir::RewritePattern { + DotGeneralOpDowngradeV2ToV1(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.dot_general_v2", 1, context, {"vhlo.dot_general_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute allow_imprecise_accumulation; + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::Attribute lhs_batching_dimensions; + ::mlir::Attribute lhs_component_count; + ::mlir::Attribute rhs_precision_type; + ::mlir::Attribute rhs_batching_dimensions; + ::mlir::Attribute lhs_contracting_dimensions; + ::mlir::Attribute rhs_contracting_dimensions; + ::mlir::Attribute precision_config; + ::mlir::Attribute lhs_precision_type; + ::mlir::Attribute rhs_component_count; + ::mlir::Attribute accumulation_type; + ::mlir::Attribute num_primitive_operations; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::DotGeneralOpV2>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + rhs = castedOp0.getODSOperands(1); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getLhsBatchingDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v2' to have attribute 'lhs_batching_dimensions' of type '::mlir::Attribute'"; + }); + } + lhs_batching_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRhsBatchingDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v2' to have attribute 'rhs_batching_dimensions' of type '::mlir::Attribute'"; + }); + } + rhs_batching_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getLhsContractingDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v2' to have attribute 'lhs_contracting_dimensions' of type '::mlir::Attribute'"; + }); + } + lhs_contracting_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRhsContractingDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v2' to have attribute 'rhs_contracting_dimensions' of type '::mlir::Attribute'"; + }); + } + rhs_contracting_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getPrecisionConfig(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v2' to have attribute 'precision_config' of type '::mlir::Attribute'"; + }); + } + precision_config = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getLhsPrecisionType(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v2' to have attribute 'lhs_precision_type' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns1(rewriter, castedOp0, tblgen_attr, "op 'vhlo.dot_general_v2' attribute 'lhs_precision_type' failed to satisfy constraint: 'None type'"))) { + return ::mlir::failure(); + } + lhs_precision_type = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRhsPrecisionType(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v2' to have attribute 'rhs_precision_type' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns1(rewriter, castedOp0, tblgen_attr, "op 'vhlo.dot_general_v2' attribute 'rhs_precision_type' failed to satisfy constraint: 'None type'"))) { + return ::mlir::failure(); + } + rhs_precision_type = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getAccumulationType(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v2' to have attribute 'accumulation_type' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns1(rewriter, castedOp0, tblgen_attr, "op 'vhlo.dot_general_v2' attribute 'accumulation_type' failed to satisfy constraint: 'None type'"))) { + return ::mlir::failure(); + } + accumulation_type = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getLhsComponentCount(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v2' to have attribute 'lhs_component_count' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns1(rewriter, castedOp0, tblgen_attr, "op 'vhlo.dot_general_v2' attribute 'lhs_component_count' failed to satisfy constraint: 'None type'"))) { + return ::mlir::failure(); + } + lhs_component_count = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRhsComponentCount(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v2' to have attribute 'rhs_component_count' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns1(rewriter, castedOp0, tblgen_attr, "op 'vhlo.dot_general_v2' attribute 'rhs_component_count' failed to satisfy constraint: 'None type'"))) { + return ::mlir::failure(); + } + rhs_component_count = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getNumPrimitiveOperations(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v2' to have attribute 'num_primitive_operations' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns1(rewriter, castedOp0, tblgen_attr, "op 'vhlo.dot_general_v2' attribute 'num_primitive_operations' failed to satisfy constraint: 'None type'"))) { + return ::mlir::failure(); + } + num_primitive_operations = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getAllowImpreciseAccumulation(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v2' to have attribute 'allow_imprecise_accumulation' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns1(rewriter, castedOp0, tblgen_attr, "op 'vhlo.dot_general_v2' attribute 'allow_imprecise_accumulation' failed to satisfy constraint: 'None type'"))) { + return ::mlir::failure(); + } + allow_imprecise_accumulation = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::DotGeneralOpV1 tblgen_DotGeneralOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::DotGeneralOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*lhs.begin())); + tblgen_values.push_back((*rhs.begin())); + tblgen_props.lhs_batching_dimensions = ::llvm::dyn_cast_if_present(lhs_batching_dimensions); + tblgen_props.rhs_batching_dimensions = ::llvm::dyn_cast_if_present(rhs_batching_dimensions); + tblgen_props.lhs_contracting_dimensions = ::llvm::dyn_cast_if_present(lhs_contracting_dimensions); + tblgen_props.rhs_contracting_dimensions = ::llvm::dyn_cast_if_present(rhs_contracting_dimensions); + tblgen_props.precision_config = ::llvm::dyn_cast_if_present(precision_config); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_DotGeneralOpV1_0 = rewriter.create<::mlir::vhlo::DotGeneralOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DotGeneralOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:90 +*/ +struct DotGeneralOpUpradeV1ToV2 : public ::mlir::RewritePattern { + DotGeneralOpUpradeV1ToV2(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.dot_general_v1", 1, context, {"vhlo.dot_general_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute precision_config; + ::mlir::Attribute rhs_contracting_dimensions; + ::mlir::Attribute lhs_contracting_dimensions; + ::mlir::Attribute rhs_batching_dimensions; + ::mlir::Attribute lhs_batching_dimensions; + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::DotGeneralOpV1>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + rhs = castedOp0.getODSOperands(1); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getLhsBatchingDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v1' to have attribute 'lhs_batching_dimensions' of type '::mlir::Attribute'"; + }); + } + lhs_batching_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRhsBatchingDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v1' to have attribute 'rhs_batching_dimensions' of type '::mlir::Attribute'"; + }); + } + rhs_batching_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getLhsContractingDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v1' to have attribute 'lhs_contracting_dimensions' of type '::mlir::Attribute'"; + }); + } + lhs_contracting_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRhsContractingDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v1' to have attribute 'rhs_contracting_dimensions' of type '::mlir::Attribute'"; + }); + } + rhs_contracting_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getPrecisionConfig(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dot_general_v1' to have attribute 'precision_config' of type '::mlir::Attribute'"; + }); + } + precision_config = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getNoneType(rewriter); (void)nativeVar_0; + auto nativeVar_1 = getNoneType(rewriter); (void)nativeVar_1; + auto nativeVar_2 = getNoneType(rewriter); (void)nativeVar_2; + auto nativeVar_3 = getNoneType(rewriter); (void)nativeVar_3; + auto nativeVar_4 = getNoneType(rewriter); (void)nativeVar_4; + auto nativeVar_5 = getNoneType(rewriter); (void)nativeVar_5; + auto nativeVar_6 = getNoneType(rewriter); (void)nativeVar_6; + ::mlir::vhlo::DotGeneralOpV2 tblgen_DotGeneralOpV2_7; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::DotGeneralOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*lhs.begin())); + tblgen_values.push_back((*rhs.begin())); + tblgen_props.lhs_batching_dimensions = ::llvm::dyn_cast_if_present(lhs_batching_dimensions); + tblgen_props.rhs_batching_dimensions = ::llvm::dyn_cast_if_present(rhs_batching_dimensions); + tblgen_props.lhs_contracting_dimensions = ::llvm::dyn_cast_if_present(lhs_contracting_dimensions); + tblgen_props.rhs_contracting_dimensions = ::llvm::dyn_cast_if_present(rhs_contracting_dimensions); + tblgen_props.precision_config = ::llvm::dyn_cast_if_present(precision_config); + tblgen_props.lhs_precision_type = ::llvm::dyn_cast_if_present(nativeVar_0); + tblgen_props.rhs_precision_type = ::llvm::dyn_cast_if_present(nativeVar_1); + tblgen_props.accumulation_type = ::llvm::dyn_cast_if_present(nativeVar_2); + tblgen_props.lhs_component_count = ::llvm::dyn_cast_if_present(nativeVar_3); + tblgen_props.rhs_component_count = ::llvm::dyn_cast_if_present(nativeVar_4); + tblgen_props.num_primitive_operations = ::llvm::dyn_cast_if_present(nativeVar_5); + tblgen_props.allow_imprecise_accumulation = ::llvm::dyn_cast_if_present(nativeVar_6); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_DotGeneralOpV2_7 = rewriter.create<::mlir::vhlo::DotGeneralOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DotGeneralOpV2_7.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:47 +*/ +struct DynamicConvDowngradeV2ToV1 : public ::mlir::RewritePattern { + DynamicConvDowngradeV2ToV1(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.dynamic_conv_v2", 1, context, {"vhlo.dynamic_conv_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute feature_group_count; + ::mlir::Attribute output_feature_dimension; + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::Attribute output_batch_dimension; + ::mlir::Attribute lhs_dilation; + ::mlir::Attribute output_spatial_dimensions; + ::mlir::Attribute window_reversal; + ::mlir::Operation::operand_range d_padding(op0->getOperands()); + ::mlir::Attribute rhs_dilation; + ::mlir::Attribute input_batch_dimension; + ::mlir::Attribute window_strides; + ::mlir::Attribute input_spatial_dimensions; + ::mlir::Attribute kernel_spatial_dimensions; + ::mlir::Attribute precision_config; + ::mlir::Attribute batch_group_count; + ::mlir::Attribute input_feature_dimension; + ::mlir::Attribute kernel_input_feature_dimension; + ::mlir::Attribute kernel_output_feature_dimension; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::DynamicConvOpV2>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + rhs = castedOp0.getODSOperands(1); + d_padding = castedOp0.getODSOperands(2); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getWindowStrides(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'window_strides' of type '::mlir::Attribute'"; + }); + } + window_strides = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getLhsDilation(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'lhs_dilation' of type '::mlir::Attribute'"; + }); + } + lhs_dilation = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRhsDilation(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'rhs_dilation' of type '::mlir::Attribute'"; + }); + } + rhs_dilation = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getWindowReversal(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'window_reversal' of type '::mlir::Attribute'"; + }); + } + window_reversal = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getInputBatchDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'input_batch_dimension' of type '::mlir::Attribute'"; + }); + } + input_batch_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getInputFeatureDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'input_feature_dimension' of type '::mlir::Attribute'"; + }); + } + input_feature_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getInputSpatialDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'input_spatial_dimensions' of type '::mlir::Attribute'"; + }); + } + input_spatial_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKernelInputFeatureDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'kernel_input_feature_dimension' of type '::mlir::Attribute'"; + }); + } + kernel_input_feature_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKernelOutputFeatureDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'kernel_output_feature_dimension' of type '::mlir::Attribute'"; + }); + } + kernel_output_feature_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKernelSpatialDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'kernel_spatial_dimensions' of type '::mlir::Attribute'"; + }); + } + kernel_spatial_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOutputBatchDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'output_batch_dimension' of type '::mlir::Attribute'"; + }); + } + output_batch_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOutputFeatureDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'output_feature_dimension' of type '::mlir::Attribute'"; + }); + } + output_feature_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOutputSpatialDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'output_spatial_dimensions' of type '::mlir::Attribute'"; + }); + } + output_spatial_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getFeatureGroupCount(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'feature_group_count' of type '::mlir::Attribute'"; + }); + } + feature_group_count = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getBatchGroupCount(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'batch_group_count' of type '::mlir::Attribute'"; + }); + } + batch_group_count = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getPrecisionConfig(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v2' to have attribute 'precision_config' of type '::mlir::Attribute'"; + }); + } + precision_config = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultConvPadding(rewriter, (*lhs.begin())); (void)nativeVar_0; + ::mlir::vhlo::DynamicConvOpV1 tblgen_DynamicConvOpV1_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::DynamicConvOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*lhs.begin())); + tblgen_values.push_back((*rhs.begin())); + tblgen_values.push_back((*d_padding.begin())); + tblgen_props.window_strides = ::llvm::dyn_cast_if_present(window_strides); + tblgen_props.padding = ::llvm::dyn_cast_if_present(nativeVar_0); + tblgen_props.lhs_dilation = ::llvm::dyn_cast_if_present(lhs_dilation); + tblgen_props.rhs_dilation = ::llvm::dyn_cast_if_present(rhs_dilation); + tblgen_props.window_reversal = ::llvm::dyn_cast_if_present(window_reversal); + tblgen_props.input_batch_dimension = ::llvm::dyn_cast_if_present(input_batch_dimension); + tblgen_props.input_feature_dimension = ::llvm::dyn_cast_if_present(input_feature_dimension); + tblgen_props.input_spatial_dimensions = ::llvm::dyn_cast_if_present(input_spatial_dimensions); + tblgen_props.kernel_input_feature_dimension = ::llvm::dyn_cast_if_present(kernel_input_feature_dimension); + tblgen_props.kernel_output_feature_dimension = ::llvm::dyn_cast_if_present(kernel_output_feature_dimension); + tblgen_props.kernel_spatial_dimensions = ::llvm::dyn_cast_if_present(kernel_spatial_dimensions); + tblgen_props.output_batch_dimension = ::llvm::dyn_cast_if_present(output_batch_dimension); + tblgen_props.output_feature_dimension = ::llvm::dyn_cast_if_present(output_feature_dimension); + tblgen_props.output_spatial_dimensions = ::llvm::dyn_cast_if_present(output_spatial_dimensions); + tblgen_props.feature_group_count = ::llvm::dyn_cast_if_present(feature_group_count); + tblgen_props.batch_group_count = ::llvm::dyn_cast_if_present(batch_group_count); + tblgen_props.precision_config = ::llvm::dyn_cast_if_present(precision_config); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_DynamicConvOpV1_1 = rewriter.create<::mlir::vhlo::DynamicConvOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DynamicConvOpV1_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:43 +*/ +struct DynamicConvUpgradeV1ToV2 : public ::mlir::RewritePattern { + DynamicConvUpgradeV1ToV2(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.dynamic_conv_v1", 1, context, {"vhlo.dynamic_conv_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute feature_group_count; + ::mlir::Attribute output_feature_dimension; + ::mlir::Attribute kernel_spatial_dimensions; + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::Attribute output_batch_dimension; + ::mlir::Attribute lhs_dilation; + ::mlir::Attribute output_spatial_dimensions; + ::mlir::Attribute window_reversal; + ::mlir::Operation::operand_range d_padding(op0->getOperands()); + ::mlir::Attribute padding; + ::mlir::Attribute rhs_dilation; + ::mlir::Attribute input_batch_dimension; + ::mlir::Attribute window_strides; + ::mlir::Attribute input_spatial_dimensions; + ::mlir::Attribute precision_config; + ::mlir::Attribute batch_group_count; + ::mlir::Attribute kernel_input_feature_dimension; + ::mlir::Attribute input_feature_dimension; + ::mlir::Attribute kernel_output_feature_dimension; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::DynamicConvOpV1>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + rhs = castedOp0.getODSOperands(1); + d_padding = castedOp0.getODSOperands(2); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getWindowStrides(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'window_strides' of type '::mlir::Attribute'"; + }); + } + window_strides = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getPadding(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'padding' of type '::mlir::Attribute'"; + }); + } + padding = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getLhsDilation(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'lhs_dilation' of type '::mlir::Attribute'"; + }); + } + lhs_dilation = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRhsDilation(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'rhs_dilation' of type '::mlir::Attribute'"; + }); + } + rhs_dilation = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getWindowReversal(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'window_reversal' of type '::mlir::Attribute'"; + }); + } + window_reversal = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getInputBatchDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'input_batch_dimension' of type '::mlir::Attribute'"; + }); + } + input_batch_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getInputFeatureDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'input_feature_dimension' of type '::mlir::Attribute'"; + }); + } + input_feature_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getInputSpatialDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'input_spatial_dimensions' of type '::mlir::Attribute'"; + }); + } + input_spatial_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKernelInputFeatureDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'kernel_input_feature_dimension' of type '::mlir::Attribute'"; + }); + } + kernel_input_feature_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKernelOutputFeatureDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'kernel_output_feature_dimension' of type '::mlir::Attribute'"; + }); + } + kernel_output_feature_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKernelSpatialDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'kernel_spatial_dimensions' of type '::mlir::Attribute'"; + }); + } + kernel_spatial_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOutputBatchDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'output_batch_dimension' of type '::mlir::Attribute'"; + }); + } + output_batch_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOutputFeatureDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'output_feature_dimension' of type '::mlir::Attribute'"; + }); + } + output_feature_dimension = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOutputSpatialDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'output_spatial_dimensions' of type '::mlir::Attribute'"; + }); + } + output_spatial_dimensions = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getFeatureGroupCount(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'feature_group_count' of type '::mlir::Attribute'"; + }); + } + feature_group_count = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getBatchGroupCount(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'batch_group_count' of type '::mlir::Attribute'"; + }); + } + batch_group_count = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getPrecisionConfig(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_conv_v1' to have attribute 'precision_config' of type '::mlir::Attribute'"; + }); + } + precision_config = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::DynamicConvOpV2 tblgen_DynamicConvOpV2_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::DynamicConvOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*lhs.begin())); + tblgen_values.push_back((*rhs.begin())); + tblgen_values.push_back((*d_padding.begin())); + tblgen_props.window_strides = ::llvm::dyn_cast_if_present(window_strides); + tblgen_props.lhs_dilation = ::llvm::dyn_cast_if_present(lhs_dilation); + tblgen_props.rhs_dilation = ::llvm::dyn_cast_if_present(rhs_dilation); + tblgen_props.window_reversal = ::llvm::dyn_cast_if_present(window_reversal); + tblgen_props.input_batch_dimension = ::llvm::dyn_cast_if_present(input_batch_dimension); + tblgen_props.input_feature_dimension = ::llvm::dyn_cast_if_present(input_feature_dimension); + tblgen_props.input_spatial_dimensions = ::llvm::dyn_cast_if_present(input_spatial_dimensions); + tblgen_props.kernel_input_feature_dimension = ::llvm::dyn_cast_if_present(kernel_input_feature_dimension); + tblgen_props.kernel_output_feature_dimension = ::llvm::dyn_cast_if_present(kernel_output_feature_dimension); + tblgen_props.kernel_spatial_dimensions = ::llvm::dyn_cast_if_present(kernel_spatial_dimensions); + tblgen_props.output_batch_dimension = ::llvm::dyn_cast_if_present(output_batch_dimension); + tblgen_props.output_feature_dimension = ::llvm::dyn_cast_if_present(output_feature_dimension); + tblgen_props.output_spatial_dimensions = ::llvm::dyn_cast_if_present(output_spatial_dimensions); + tblgen_props.feature_group_count = ::llvm::dyn_cast_if_present(feature_group_count); + tblgen_props.batch_group_count = ::llvm::dyn_cast_if_present(batch_group_count); + tblgen_props.precision_config = ::llvm::dyn_cast_if_present(precision_config); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_DynamicConvOpV2_0 = rewriter.create<::mlir::vhlo::DynamicConvOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DynamicConvOpV2_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:63 +*/ +struct DynamicGatherOpDowngradeV2ToV1 : public ::mlir::RewritePattern { + DynamicGatherOpDowngradeV2ToV1(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.dynamic_gather_v2", 1, context, {"vhlo.dynamic_gather_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute index_vector_dim; + ::mlir::Attribute collapsed_slice_dims; + ::mlir::Attribute start_index_map; + ::mlir::Attribute offset_dims; + ::mlir::Operation::operand_range slice_sizes(op0->getOperands()); + ::mlir::Attribute start_indices_batching_dims; + ::mlir::Operation::operand_range start_indices(op0->getOperands()); + ::mlir::Attribute indices_are_sorted; + ::mlir::Attribute operand_batching_dims; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::DynamicGatherOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + start_indices = castedOp0.getODSOperands(1); + slice_sizes = castedOp0.getODSOperands(2); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOffsetDims(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_gather_v2' to have attribute 'offset_dims' of type '::mlir::Attribute'"; + }); + } + offset_dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getCollapsedSliceDims(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_gather_v2' to have attribute 'collapsed_slice_dims' of type '::mlir::Attribute'"; + }); + } + collapsed_slice_dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOperandBatchingDims(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_gather_v2' to have attribute 'operand_batching_dims' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns2(rewriter, castedOp0, tblgen_attr, "op 'vhlo.dynamic_gather_v2' attribute 'operand_batching_dims' failed to satisfy constraint: 'Empty dims'"))) { + return ::mlir::failure(); + } + operand_batching_dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getStartIndicesBatchingDims(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_gather_v2' to have attribute 'start_indices_batching_dims' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns2(rewriter, castedOp0, tblgen_attr, "op 'vhlo.dynamic_gather_v2' attribute 'start_indices_batching_dims' failed to satisfy constraint: 'Empty dims'"))) { + return ::mlir::failure(); + } + start_indices_batching_dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getStartIndexMap(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_gather_v2' to have attribute 'start_index_map' of type '::mlir::Attribute'"; + }); + } + start_index_map = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getIndexVectorDim(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_gather_v2' to have attribute 'index_vector_dim' of type '::mlir::Attribute'"; + }); + } + index_vector_dim = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getIndicesAreSorted(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_gather_v2' to have attribute 'indices_are_sorted' of type '::mlir::Attribute'"; + }); + } + indices_are_sorted = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::DynamicGatherOpV1 tblgen_DynamicGatherOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::DynamicGatherOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_values.push_back((*start_indices.begin())); + tblgen_values.push_back((*slice_sizes.begin())); + tblgen_props.offset_dims = ::llvm::dyn_cast_if_present(offset_dims); + tblgen_props.collapsed_slice_dims = ::llvm::dyn_cast_if_present(collapsed_slice_dims); + tblgen_props.start_index_map = ::llvm::dyn_cast_if_present(start_index_map); + tblgen_props.index_vector_dim = ::llvm::dyn_cast_if_present(index_vector_dim); + tblgen_props.indices_are_sorted = ::llvm::dyn_cast_if_present(indices_are_sorted); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_DynamicGatherOpV1_0 = rewriter.create<::mlir::vhlo::DynamicGatherOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DynamicGatherOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:59 +*/ +struct DynamicGatherOpUpgradeV1ToV2 : public ::mlir::RewritePattern { + DynamicGatherOpUpgradeV1ToV2(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.dynamic_gather_v1", 1, context, {"vhlo.dynamic_gather_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute index_vector_dim; + ::mlir::Attribute collapsed_slice_dims; + ::mlir::Attribute start_index_map; + ::mlir::Attribute offset_dims; + ::mlir::Operation::operand_range slice_sizes(op0->getOperands()); + ::mlir::Operation::operand_range start_indices(op0->getOperands()); + ::mlir::Attribute indices_are_sorted; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::DynamicGatherOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + start_indices = castedOp0.getODSOperands(1); + slice_sizes = castedOp0.getODSOperands(2); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOffsetDims(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_gather_v1' to have attribute 'offset_dims' of type '::mlir::Attribute'"; + }); + } + offset_dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getCollapsedSliceDims(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_gather_v1' to have attribute 'collapsed_slice_dims' of type '::mlir::Attribute'"; + }); + } + collapsed_slice_dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getStartIndexMap(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_gather_v1' to have attribute 'start_index_map' of type '::mlir::Attribute'"; + }); + } + start_index_map = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getIndexVectorDim(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_gather_v1' to have attribute 'index_vector_dim' of type '::mlir::Attribute'"; + }); + } + index_vector_dim = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getIndicesAreSorted(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.dynamic_gather_v1' to have attribute 'indices_are_sorted' of type '::mlir::Attribute'"; + }); + } + indices_are_sorted = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getEmptyI64Tensor(rewriter); (void)nativeVar_0; + auto nativeVar_1 = getEmptyI64Tensor(rewriter); (void)nativeVar_1; + ::mlir::vhlo::DynamicGatherOpV2 tblgen_DynamicGatherOpV2_2; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::DynamicGatherOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_values.push_back((*start_indices.begin())); + tblgen_values.push_back((*slice_sizes.begin())); + tblgen_props.offset_dims = ::llvm::dyn_cast_if_present(offset_dims); + tblgen_props.collapsed_slice_dims = ::llvm::dyn_cast_if_present(collapsed_slice_dims); + tblgen_props.operand_batching_dims = ::llvm::dyn_cast_if_present(nativeVar_0); + tblgen_props.start_indices_batching_dims = ::llvm::dyn_cast_if_present(nativeVar_1); + tblgen_props.start_index_map = ::llvm::dyn_cast_if_present(start_index_map); + tblgen_props.index_vector_dim = ::llvm::dyn_cast_if_present(index_vector_dim); + tblgen_props.indices_are_sorted = ::llvm::dyn_cast_if_present(indices_are_sorted); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_DynamicGatherOpV2_2 = rewriter.create<::mlir::vhlo::DynamicGatherOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DynamicGatherOpV2_2.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:55 +*/ +struct GatherOpDowngradeV2ToV1 : public ::mlir::RewritePattern { + GatherOpDowngradeV2ToV1(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.gather_v2", 1, context, {"vhlo.gather_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute slice_sizes; + ::mlir::Attribute index_vector_dim; + ::mlir::Attribute collapsed_slice_dims; + ::mlir::Attribute start_index_map; + ::mlir::Attribute offset_dims; + ::mlir::Attribute start_indices_batching_dims; + ::mlir::Operation::operand_range start_indices(op0->getOperands()); + ::mlir::Attribute indices_are_sorted; + ::mlir::Attribute operand_batching_dims; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::GatherOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + start_indices = castedOp0.getODSOperands(1); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOffsetDims(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v2' to have attribute 'offset_dims' of type '::mlir::Attribute'"; + }); + } + offset_dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getCollapsedSliceDims(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v2' to have attribute 'collapsed_slice_dims' of type '::mlir::Attribute'"; + }); + } + collapsed_slice_dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOperandBatchingDims(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v2' to have attribute 'operand_batching_dims' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns2(rewriter, castedOp0, tblgen_attr, "op 'vhlo.gather_v2' attribute 'operand_batching_dims' failed to satisfy constraint: 'Empty dims'"))) { + return ::mlir::failure(); + } + operand_batching_dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getStartIndicesBatchingDims(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v2' to have attribute 'start_indices_batching_dims' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns2(rewriter, castedOp0, tblgen_attr, "op 'vhlo.gather_v2' attribute 'start_indices_batching_dims' failed to satisfy constraint: 'Empty dims'"))) { + return ::mlir::failure(); + } + start_indices_batching_dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getStartIndexMap(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v2' to have attribute 'start_index_map' of type '::mlir::Attribute'"; + }); + } + start_index_map = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getIndexVectorDim(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v2' to have attribute 'index_vector_dim' of type '::mlir::Attribute'"; + }); + } + index_vector_dim = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getSliceSizes(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v2' to have attribute 'slice_sizes' of type '::mlir::Attribute'"; + }); + } + slice_sizes = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getIndicesAreSorted(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v2' to have attribute 'indices_are_sorted' of type '::mlir::Attribute'"; + }); + } + indices_are_sorted = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::GatherOpV1 tblgen_GatherOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::GatherOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_values.push_back((*start_indices.begin())); + tblgen_props.offset_dims = ::llvm::dyn_cast_if_present(offset_dims); + tblgen_props.collapsed_slice_dims = ::llvm::dyn_cast_if_present(collapsed_slice_dims); + tblgen_props.start_index_map = ::llvm::dyn_cast_if_present(start_index_map); + tblgen_props.index_vector_dim = ::llvm::dyn_cast_if_present(index_vector_dim); + tblgen_props.slice_sizes = ::llvm::dyn_cast_if_present(slice_sizes); + tblgen_props.indices_are_sorted = ::llvm::dyn_cast_if_present(indices_are_sorted); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_GatherOpV1_0 = rewriter.create<::mlir::vhlo::GatherOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_GatherOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:51 +*/ +struct GatherOpUpgradeV1ToV2 : public ::mlir::RewritePattern { + GatherOpUpgradeV1ToV2(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.gather_v1", 1, context, {"vhlo.gather_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute slice_sizes; + ::mlir::Attribute index_vector_dim; + ::mlir::Attribute collapsed_slice_dims; + ::mlir::Attribute start_index_map; + ::mlir::Attribute offset_dims; + ::mlir::Operation::operand_range start_indices(op0->getOperands()); + ::mlir::Attribute indices_are_sorted; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::GatherOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + start_indices = castedOp0.getODSOperands(1); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOffsetDims(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v1' to have attribute 'offset_dims' of type '::mlir::Attribute'"; + }); + } + offset_dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getCollapsedSliceDims(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v1' to have attribute 'collapsed_slice_dims' of type '::mlir::Attribute'"; + }); + } + collapsed_slice_dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getStartIndexMap(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v1' to have attribute 'start_index_map' of type '::mlir::Attribute'"; + }); + } + start_index_map = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getIndexVectorDim(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v1' to have attribute 'index_vector_dim' of type '::mlir::Attribute'"; + }); + } + index_vector_dim = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getSliceSizes(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v1' to have attribute 'slice_sizes' of type '::mlir::Attribute'"; + }); + } + slice_sizes = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getIndicesAreSorted(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.gather_v1' to have attribute 'indices_are_sorted' of type '::mlir::Attribute'"; + }); + } + indices_are_sorted = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getEmptyI64Tensor(rewriter); (void)nativeVar_0; + auto nativeVar_1 = getEmptyI64Tensor(rewriter); (void)nativeVar_1; + ::mlir::vhlo::GatherOpV2 tblgen_GatherOpV2_2; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::GatherOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_values.push_back((*start_indices.begin())); + tblgen_props.offset_dims = ::llvm::dyn_cast_if_present(offset_dims); + tblgen_props.collapsed_slice_dims = ::llvm::dyn_cast_if_present(collapsed_slice_dims); + tblgen_props.operand_batching_dims = ::llvm::dyn_cast_if_present(nativeVar_0); + tblgen_props.start_indices_batching_dims = ::llvm::dyn_cast_if_present(nativeVar_1); + tblgen_props.start_index_map = ::llvm::dyn_cast_if_present(start_index_map); + tblgen_props.index_vector_dim = ::llvm::dyn_cast_if_present(index_vector_dim); + tblgen_props.slice_sizes = ::llvm::dyn_cast_if_present(slice_sizes); + tblgen_props.indices_are_sorted = ::llvm::dyn_cast_if_present(indices_are_sorted); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_GatherOpV2_2 = rewriter.create<::mlir::vhlo::GatherOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_GatherOpV2_2.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:108 +*/ +struct GeneratedConvert0 : public ::mlir::RewritePattern { + GeneratedConvert0(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.cbrt_v1", 1, context, {"vhlo.cbrt_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::CbrtOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultResultAccuracy(rewriter); (void)nativeVar_0; + ::mlir::vhlo::CbrtOpV2 tblgen_CbrtOpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::CbrtOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.result_accuracy = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_CbrtOpV2_1 = rewriter.create<::mlir::vhlo::CbrtOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_CbrtOpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:110 +*/ +struct GeneratedConvert1 : public ::mlir::RewritePattern { + GeneratedConvert1(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.cbrt_v2", 1, context, {"vhlo.cbrt_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute result_accuracy; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::CbrtOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.cbrt_v2' to have attribute 'result_accuracy' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns3(rewriter, castedOp0, tblgen_attr, "op 'vhlo.cbrt_v2' attribute 'result_accuracy' failed to satisfy constraint: 'Default result accuracy'"))) { + return ::mlir::failure(); + } + result_accuracy = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::CbrtOpV1 tblgen_CbrtOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::CbrtOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_CbrtOpV1_0 = rewriter.create<::mlir::vhlo::CbrtOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_CbrtOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:108 +*/ +struct GeneratedConvert2 : public ::mlir::RewritePattern { + GeneratedConvert2(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.cosine_v1", 1, context, {"vhlo.cosine_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::CosineOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultResultAccuracy(rewriter); (void)nativeVar_0; + ::mlir::vhlo::CosineOpV2 tblgen_CosineOpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::CosineOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.result_accuracy = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_CosineOpV2_1 = rewriter.create<::mlir::vhlo::CosineOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_CosineOpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:110 +*/ +struct GeneratedConvert3 : public ::mlir::RewritePattern { + GeneratedConvert3(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.cosine_v2", 1, context, {"vhlo.cosine_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute result_accuracy; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::CosineOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.cosine_v2' to have attribute 'result_accuracy' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns3(rewriter, castedOp0, tblgen_attr, "op 'vhlo.cosine_v2' attribute 'result_accuracy' failed to satisfy constraint: 'Default result accuracy'"))) { + return ::mlir::failure(); + } + result_accuracy = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::CosineOpV1 tblgen_CosineOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::CosineOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_CosineOpV1_0 = rewriter.create<::mlir::vhlo::CosineOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_CosineOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:108 +*/ +struct GeneratedConvert4 : public ::mlir::RewritePattern { + GeneratedConvert4(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.exponential_v1", 1, context, {"vhlo.exponential_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::ExpOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultResultAccuracy(rewriter); (void)nativeVar_0; + ::mlir::vhlo::ExpOpV2 tblgen_ExpOpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::ExpOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.result_accuracy = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ExpOpV2_1 = rewriter.create<::mlir::vhlo::ExpOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ExpOpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:110 +*/ +struct GeneratedConvert5 : public ::mlir::RewritePattern { + GeneratedConvert5(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.exponential_v2", 1, context, {"vhlo.exponential_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute result_accuracy; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::ExpOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.exponential_v2' to have attribute 'result_accuracy' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns3(rewriter, castedOp0, tblgen_attr, "op 'vhlo.exponential_v2' attribute 'result_accuracy' failed to satisfy constraint: 'Default result accuracy'"))) { + return ::mlir::failure(); + } + result_accuracy = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::ExpOpV1 tblgen_ExpOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::ExpOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ExpOpV1_0 = rewriter.create<::mlir::vhlo::ExpOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ExpOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:108 +*/ +struct GeneratedConvert6 : public ::mlir::RewritePattern { + GeneratedConvert6(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.exponential_minus_one_v1", 1, context, {"vhlo.exponential_minus_one_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::Expm1OpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultResultAccuracy(rewriter); (void)nativeVar_0; + ::mlir::vhlo::Expm1OpV2 tblgen_Expm1OpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::Expm1OpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.result_accuracy = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_Expm1OpV2_1 = rewriter.create<::mlir::vhlo::Expm1OpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_Expm1OpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:110 +*/ +struct GeneratedConvert7 : public ::mlir::RewritePattern { + GeneratedConvert7(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.exponential_minus_one_v2", 1, context, {"vhlo.exponential_minus_one_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute result_accuracy; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::Expm1OpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.exponential_minus_one_v2' to have attribute 'result_accuracy' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns3(rewriter, castedOp0, tblgen_attr, "op 'vhlo.exponential_minus_one_v2' attribute 'result_accuracy' failed to satisfy constraint: 'Default result accuracy'"))) { + return ::mlir::failure(); + } + result_accuracy = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::Expm1OpV1 tblgen_Expm1OpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::Expm1OpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_Expm1OpV1_0 = rewriter.create<::mlir::vhlo::Expm1OpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_Expm1OpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:108 +*/ +struct GeneratedConvert8 : public ::mlir::RewritePattern { + GeneratedConvert8(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.log_v1", 1, context, {"vhlo.log_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::LogOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultResultAccuracy(rewriter); (void)nativeVar_0; + ::mlir::vhlo::LogOpV2 tblgen_LogOpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::LogOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.result_accuracy = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_LogOpV2_1 = rewriter.create<::mlir::vhlo::LogOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_LogOpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:110 +*/ +struct GeneratedConvert9 : public ::mlir::RewritePattern { + GeneratedConvert9(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.log_v2", 1, context, {"vhlo.log_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute result_accuracy; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::LogOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.log_v2' to have attribute 'result_accuracy' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns3(rewriter, castedOp0, tblgen_attr, "op 'vhlo.log_v2' attribute 'result_accuracy' failed to satisfy constraint: 'Default result accuracy'"))) { + return ::mlir::failure(); + } + result_accuracy = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::LogOpV1 tblgen_LogOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::LogOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_LogOpV1_0 = rewriter.create<::mlir::vhlo::LogOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_LogOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:108 +*/ +struct GeneratedConvert10 : public ::mlir::RewritePattern { + GeneratedConvert10(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.log_plus_one_v1", 1, context, {"vhlo.log_plus_one_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::Log1pOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultResultAccuracy(rewriter); (void)nativeVar_0; + ::mlir::vhlo::Log1pOpV2 tblgen_Log1pOpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::Log1pOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.result_accuracy = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_Log1pOpV2_1 = rewriter.create<::mlir::vhlo::Log1pOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_Log1pOpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:110 +*/ +struct GeneratedConvert11 : public ::mlir::RewritePattern { + GeneratedConvert11(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.log_plus_one_v2", 1, context, {"vhlo.log_plus_one_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute result_accuracy; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::Log1pOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.log_plus_one_v2' to have attribute 'result_accuracy' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns3(rewriter, castedOp0, tblgen_attr, "op 'vhlo.log_plus_one_v2' attribute 'result_accuracy' failed to satisfy constraint: 'Default result accuracy'"))) { + return ::mlir::failure(); + } + result_accuracy = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::Log1pOpV1 tblgen_Log1pOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::Log1pOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_Log1pOpV1_0 = rewriter.create<::mlir::vhlo::Log1pOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_Log1pOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:108 +*/ +struct GeneratedConvert12 : public ::mlir::RewritePattern { + GeneratedConvert12(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.logistic_v1", 1, context, {"vhlo.logistic_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::LogisticOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultResultAccuracy(rewriter); (void)nativeVar_0; + ::mlir::vhlo::LogisticOpV2 tblgen_LogisticOpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::LogisticOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.result_accuracy = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_LogisticOpV2_1 = rewriter.create<::mlir::vhlo::LogisticOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_LogisticOpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:110 +*/ +struct GeneratedConvert13 : public ::mlir::RewritePattern { + GeneratedConvert13(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.logistic_v2", 1, context, {"vhlo.logistic_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute result_accuracy; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::LogisticOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.logistic_v2' to have attribute 'result_accuracy' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns3(rewriter, castedOp0, tblgen_attr, "op 'vhlo.logistic_v2' attribute 'result_accuracy' failed to satisfy constraint: 'Default result accuracy'"))) { + return ::mlir::failure(); + } + result_accuracy = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::LogisticOpV1 tblgen_LogisticOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::LogisticOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_LogisticOpV1_0 = rewriter.create<::mlir::vhlo::LogisticOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_LogisticOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:108 +*/ +struct GeneratedConvert14 : public ::mlir::RewritePattern { + GeneratedConvert14(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.rsqrt_v1", 1, context, {"vhlo.rsqrt_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::RsqrtOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultResultAccuracy(rewriter); (void)nativeVar_0; + ::mlir::vhlo::RsqrtOpV2 tblgen_RsqrtOpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::RsqrtOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.result_accuracy = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_RsqrtOpV2_1 = rewriter.create<::mlir::vhlo::RsqrtOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_RsqrtOpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:110 +*/ +struct GeneratedConvert15 : public ::mlir::RewritePattern { + GeneratedConvert15(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.rsqrt_v2", 1, context, {"vhlo.rsqrt_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute result_accuracy; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::RsqrtOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.rsqrt_v2' to have attribute 'result_accuracy' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns3(rewriter, castedOp0, tblgen_attr, "op 'vhlo.rsqrt_v2' attribute 'result_accuracy' failed to satisfy constraint: 'Default result accuracy'"))) { + return ::mlir::failure(); + } + result_accuracy = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::RsqrtOpV1 tblgen_RsqrtOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::RsqrtOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_RsqrtOpV1_0 = rewriter.create<::mlir::vhlo::RsqrtOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_RsqrtOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:108 +*/ +struct GeneratedConvert16 : public ::mlir::RewritePattern { + GeneratedConvert16(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.sine_v1", 1, context, {"vhlo.sine_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::SineOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultResultAccuracy(rewriter); (void)nativeVar_0; + ::mlir::vhlo::SineOpV2 tblgen_SineOpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::SineOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.result_accuracy = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_SineOpV2_1 = rewriter.create<::mlir::vhlo::SineOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SineOpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:110 +*/ +struct GeneratedConvert17 : public ::mlir::RewritePattern { + GeneratedConvert17(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.sine_v2", 1, context, {"vhlo.sine_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute result_accuracy; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::SineOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.sine_v2' to have attribute 'result_accuracy' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns3(rewriter, castedOp0, tblgen_attr, "op 'vhlo.sine_v2' attribute 'result_accuracy' failed to satisfy constraint: 'Default result accuracy'"))) { + return ::mlir::failure(); + } + result_accuracy = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::SineOpV1 tblgen_SineOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::SineOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_SineOpV1_0 = rewriter.create<::mlir::vhlo::SineOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SineOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:108 +*/ +struct GeneratedConvert18 : public ::mlir::RewritePattern { + GeneratedConvert18(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.sqrt_v1", 1, context, {"vhlo.sqrt_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::SqrtOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultResultAccuracy(rewriter); (void)nativeVar_0; + ::mlir::vhlo::SqrtOpV2 tblgen_SqrtOpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::SqrtOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.result_accuracy = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_SqrtOpV2_1 = rewriter.create<::mlir::vhlo::SqrtOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SqrtOpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:110 +*/ +struct GeneratedConvert19 : public ::mlir::RewritePattern { + GeneratedConvert19(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.sqrt_v2", 1, context, {"vhlo.sqrt_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute result_accuracy; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::SqrtOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.sqrt_v2' to have attribute 'result_accuracy' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns3(rewriter, castedOp0, tblgen_attr, "op 'vhlo.sqrt_v2' attribute 'result_accuracy' failed to satisfy constraint: 'Default result accuracy'"))) { + return ::mlir::failure(); + } + result_accuracy = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::SqrtOpV1 tblgen_SqrtOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::SqrtOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_SqrtOpV1_0 = rewriter.create<::mlir::vhlo::SqrtOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SqrtOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:108 +*/ +struct GeneratedConvert20 : public ::mlir::RewritePattern { + GeneratedConvert20(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.tan_v1", 1, context, {"vhlo.tan_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::TanOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultResultAccuracy(rewriter); (void)nativeVar_0; + ::mlir::vhlo::TanOpV2 tblgen_TanOpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::TanOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.result_accuracy = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_TanOpV2_1 = rewriter.create<::mlir::vhlo::TanOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_TanOpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:110 +*/ +struct GeneratedConvert21 : public ::mlir::RewritePattern { + GeneratedConvert21(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.tan_v2", 1, context, {"vhlo.tan_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute result_accuracy; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::TanOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.tan_v2' to have attribute 'result_accuracy' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns3(rewriter, castedOp0, tblgen_attr, "op 'vhlo.tan_v2' attribute 'result_accuracy' failed to satisfy constraint: 'Default result accuracy'"))) { + return ::mlir::failure(); + } + result_accuracy = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::TanOpV1 tblgen_TanOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::TanOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_TanOpV1_0 = rewriter.create<::mlir::vhlo::TanOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_TanOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:108 +*/ +struct GeneratedConvert22 : public ::mlir::RewritePattern { + GeneratedConvert22(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.tanh_v1", 1, context, {"vhlo.tanh_v2"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::TanhOpV1>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getDefaultResultAccuracy(rewriter); (void)nativeVar_0; + ::mlir::vhlo::TanhOpV2 tblgen_TanhOpV2_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::TanhOpV2::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.result_accuracy = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_TanhOpV2_1 = rewriter.create<::mlir::vhlo::TanhOpV2>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_TanhOpV2_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/VhloToVersionPatterns.td:110 +*/ +struct GeneratedConvert23 : public ::mlir::RewritePattern { + GeneratedConvert23(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("vhlo.tanh_v2", 1, context, {"vhlo.tanh_v1"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute result_accuracy; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::vhlo::TanhOpV2>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getResultAccuracy(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'vhlo.tanh_v2' to have attribute 'result_accuracy' of type '::mlir::Attribute'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_VhloToVersionPatterns3(rewriter, castedOp0, tblgen_attr, "op 'vhlo.tanh_v2' attribute 'result_accuracy' failed to satisfy constraint: 'Default result accuracy'"))) { + return ::mlir::failure(); + } + result_accuracy = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::vhlo::TanhOpV1 tblgen_TanhOpV1_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::vhlo::TanhOpV1::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_TanhOpV1_0 = rewriter.create<::mlir::vhlo::TanhOpV1>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_TanhOpV1_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +void LLVM_ATTRIBUTE_UNUSED populateWithGenerated(::mlir::RewritePatternSet &patterns) { + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); +} diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/conversions/TypeConversion.h b/deps/exla/cache/xla_extension/include/stablehlo/transforms/conversions/TypeConversion.h new file mode 100644 index 0000000000000000000000000000000000000000..ab081dda412f58867247ceb01de50a644d152d49 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/conversions/TypeConversion.h @@ -0,0 +1,35 @@ +/* Copyright 2021 The IREE Authors + Copyright 2023 OpenXLA Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_TRANSFORMS_CONVERSIONS_TYPE_CONVERSION_H +#define STABLEHLO_TRANSFORMS_CONVERSIONS_TYPE_CONVERSION_H + +#include "mlir/IR/Attributes.h" +#include "mlir/IR/Dialect.h" +#include "mlir/Transforms/DialectConversion.h" + +namespace mlir::stablehlo { + +// Type converter to use as part of lowerings from dialects that carry signs +// in their types to those that are signless. +class RemoveSignTypeConverter : public TypeConverter { + public: + RemoveSignTypeConverter(); +}; + +} // namespace mlir::stablehlo + +#endif // STABLEHLO_TRANSFORMS_CONVERSIONS_TYPE_CONVERSION_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/optimization/Passes.h b/deps/exla/cache/xla_extension/include/stablehlo/transforms/optimization/Passes.h new file mode 100644 index 0000000000000000000000000000000000000000..2a3cd5705aba2c510e29f705974f110425dd5e8f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/optimization/Passes.h @@ -0,0 +1,110 @@ +/* Copyright 2025 The StableHLO Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef STABLEHLO_TRANSFORMS_OPTIMIZATION_PASSES_H +#define STABLEHLO_TRANSFORMS_OPTIMIZATION_PASSES_H + +#include +#include + +#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/Pass/Pass.h" +#include "mlir/Support/LogicalResult.h" +#include "mlir/Transforms/DialectConversion.h" +#include "mlir/Transforms/GreedyPatternRewriteDriver.h" +#include "stablehlo/dialect/StablehloOps.h" + +namespace mlir { +namespace stablehlo { + +#define GEN_PASS_DECL +#define GEN_PASS_REGISTRATION +#include "stablehlo/transforms/optimization/Passes.h.inc" + +std::unique_ptr<::mlir::Pass> createStablehloAggressiveSimplificationPass( + StablehloAggressiveSimplificationPassOptions options, + GreedyRewriteConfig rewriteConfig); +std::unique_ptr<::mlir::Pass> createStablehloAggressiveFolderPass( + StablehloAggressiveFolderPassOptions options, + GreedyRewriteConfig rewriteConfig); +std::unique_ptr<::mlir::Pass> createStablehloTargetIndependentOptimizationPass( + StablehloTargetIndependentOptimizationPassOptions options, + GreedyRewriteConfig rewriteConfig); + +/// Collection of canonicalization patterns for StableHLO. +void populateStablehloCanonicalizationPatterns( + MLIRContext *context, RewritePatternSet *patterns, + const StablehloAggressiveSimplificationPassOptions &options, + PatternBenefit benefit = 1); + +void populateStablehloCanonicalizationPatterns(MLIRContext *context, + RewritePatternSet *patterns, + PatternBenefit benefit = 1); + +/// Collection of folding patterns for StableHLO. +void populateStablehloAggressiveFolderPatterns( + MLIRContext *context, RewritePatternSet *patterns, + const StablehloAggressiveFolderPassOptions &options, + PatternBenefit benefit = 1); + +void populateStablehloAggressiveFolderPatterns(MLIRContext *context, + RewritePatternSet *patterns, + PatternBenefit benefit = 1); + +/// A subset of folding patterns for StableHLO that is necessary for shape +/// refinement. +void populateStablehloShapeFolderPatterns( + MLIRContext *context, RewritePatternSet *patterns, + const StablehloAggressiveFolderPassOptions &options, + PatternBenefit benefit = 1); + +void populateStablehloShapeFolderPatterns(MLIRContext *context, + RewritePatternSet *patterns, + PatternBenefit benefit = 1); + +/// Some workloads in XLA import StableHLO from HLO. Since there are a few +/// differences in HLO (no implicit captures, lots of tuples, etc.), this +/// set of patterns brings the imported HLO back to a more canonical form +/// without applying a full set of graph simplifications. +void populateStablehloHloImportCanonicalizationPatterns( + MLIRContext *context, RewritePatternSet *patterns, + const StablehloAggressiveSimplificationPassOptions &options); + +void populateStablehloHloImportCanonicalizationPatterns( + MLIRContext *context, RewritePatternSet *patterns); + +// If the `options` argument is provided, ensure it's not a temporary. +void populateStablehloCanonicalizationPatterns( + MLIRContext *context, RewritePatternSet *patterns, + StablehloAggressiveSimplificationPassOptions &&options, + PatternBenefit benefit = 1) = delete; +void populateStablehloShapeFolderPatterns( + MLIRContext *context, RewritePatternSet *patterns, + StablehloAggressiveFolderPassOptions &&options, + PatternBenefit benefit = 1) = delete; +void populateStablehloAggressiveFolderPatterns( + MLIRContext *context, RewritePatternSet *patterns, + StablehloAggressiveFolderPassOptions &&options, + PatternBenefit benefit = 1) = delete; +void populateStablehloHloImportCanonicalizationPatterns( + MLIRContext *context, RewritePatternSet *patterns, + StablehloAggressiveSimplificationPassOptions &&options) = delete; + +} // namespace stablehlo +} // namespace mlir + +#endif // STABLEHLO_TRANSFORMS_OPTIMIZATION_PASSES_H diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/optimization/Passes.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/transforms/optimization/Passes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..295ef940ac9b830123cf5be7fd30054ff1c06ed9 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/optimization/Passes.h.inc @@ -0,0 +1,530 @@ +/* Autogenerated by mlir-tblgen; don't manually edit */ + +#ifdef GEN_PASS_DECL +// Generate declarations for all passes. +#define GEN_PASS_DECL_STABLEHLOAGGRESSIVEFOLDERPASS +#define GEN_PASS_DECL_STABLEHLOAGGRESSIVESIMPLIFICATIONPASS +#define GEN_PASS_DECL_STABLEHLOTARGETINDEPENDENTOPTIMIZATIONPASS +#undef GEN_PASS_DECL +#endif // GEN_PASS_DECL + +//===----------------------------------------------------------------------===// +// StablehloAggressiveFolderPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOAGGRESSIVEFOLDERPASS +struct StablehloAggressiveFolderPassOptions { + bool assumeNoUndeclaredSideEffects = false; + int64_t foldOpElementLimit = 65536; + bool optimizeFloat = true; +}; +std::unique_ptr<::mlir::Pass> createStablehloAggressiveFolderPass(); +std::unique_ptr<::mlir::Pass> createStablehloAggressiveFolderPass(StablehloAggressiveFolderPassOptions options); +#undef GEN_PASS_DECL_STABLEHLOAGGRESSIVEFOLDERPASS +#endif // GEN_PASS_DECL_STABLEHLOAGGRESSIVEFOLDERPASS +#ifdef GEN_PASS_DEF_STABLEHLOAGGRESSIVEFOLDERPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloAggressiveFolderPass(); +} // namespace impl + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloAggressiveFolderPass(StablehloAggressiveFolderPassOptions options); +} // namespace impl +namespace impl { + +template +class StablehloAggressiveFolderPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloAggressiveFolderPassBase; + + StablehloAggressiveFolderPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloAggressiveFolderPassBase(const StablehloAggressiveFolderPassBase &other) : ::mlir::OperationPass(other) {} + StablehloAggressiveFolderPassBase& operator=(const StablehloAggressiveFolderPassBase &) = delete; + StablehloAggressiveFolderPassBase(StablehloAggressiveFolderPassBase &&) = delete; + StablehloAggressiveFolderPassBase& operator=(StablehloAggressiveFolderPassBase &&) = delete; + ~StablehloAggressiveFolderPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-aggressive-folder"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-aggressive-folder"; } + + ::llvm::StringRef getDescription() const override { return "Folds StableHLO operations"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloAggressiveFolderPass"); + } + ::llvm::StringRef getName() const override { return "StablehloAggressiveFolderPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloAggressiveFolderPassBase) + + StablehloAggressiveFolderPassBase(StablehloAggressiveFolderPassOptions options) : StablehloAggressiveFolderPassBase() { + assumeNoUndeclaredSideEffects = std::move(options.assumeNoUndeclaredSideEffects); + foldOpElementLimit = std::move(options.foldOpElementLimit); + optimizeFloat = std::move(options.optimizeFloat); + } +protected: + ::mlir::Pass::Option assumeNoUndeclaredSideEffects{*this, "assume-no-undeclared-side-effects", ::llvm::cl::desc("Allow dead code to be eliminated in some situations (e.g. dead while loops) under the assumption that ops are pure unless declared with explicit MLIR `MemoryEffects`. Notably, this means `func.call` ops will be assumed pure."), ::llvm::cl::init(false)}; + ::mlir::Pass::Option foldOpElementLimit{*this, "fold-op-element-limit", ::llvm::cl::desc("Upper limit on how many elements may be folded by an op folder. This limit doesn't apply in certain special cases such as addition with 0, multiplication by 1, and some splat operations."), ::llvm::cl::init(65536)}; + ::mlir::Pass::Option optimizeFloat{*this, "optimize-float", ::llvm::cl::desc("Allow float optimizations that, though mathematically equivalent, may result in slightly different quantization of floating-point values (e.g. `log(sqrt(x))` -> `0.5 * log(x)`). Float optimizations that can't affect numerical results are always enabled."), ::llvm::cl::init(true)}; +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloAggressiveFolderPass() { + return std::make_unique(); + } + + friend std::unique_ptr<::mlir::Pass> createStablehloAggressiveFolderPass(StablehloAggressiveFolderPassOptions options) { + return std::make_unique(std::move(options)); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloAggressiveFolderPass() { + return impl::createStablehloAggressiveFolderPass(); +} + +std::unique_ptr<::mlir::Pass> createStablehloAggressiveFolderPass(StablehloAggressiveFolderPassOptions options) { + return impl::createStablehloAggressiveFolderPass(std::move(options)); +} +#undef GEN_PASS_DEF_STABLEHLOAGGRESSIVEFOLDERPASS +#endif // GEN_PASS_DEF_STABLEHLOAGGRESSIVEFOLDERPASS + +//===----------------------------------------------------------------------===// +// StablehloAggressiveSimplificationPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOAGGRESSIVESIMPLIFICATIONPASS +struct StablehloAggressiveSimplificationPassOptions { + int64_t foldOpElementLimit = 65536; +}; +std::unique_ptr<::mlir::Pass> createStablehloAggressiveSimplificationPass(); +std::unique_ptr<::mlir::Pass> createStablehloAggressiveSimplificationPass(StablehloAggressiveSimplificationPassOptions options); +#undef GEN_PASS_DECL_STABLEHLOAGGRESSIVESIMPLIFICATIONPASS +#endif // GEN_PASS_DECL_STABLEHLOAGGRESSIVESIMPLIFICATIONPASS +#ifdef GEN_PASS_DEF_STABLEHLOAGGRESSIVESIMPLIFICATIONPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloAggressiveSimplificationPass(); +} // namespace impl + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloAggressiveSimplificationPass(StablehloAggressiveSimplificationPassOptions options); +} // namespace impl +namespace impl { + +template +class StablehloAggressiveSimplificationPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloAggressiveSimplificationPassBase; + + StablehloAggressiveSimplificationPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloAggressiveSimplificationPassBase(const StablehloAggressiveSimplificationPassBase &other) : ::mlir::OperationPass(other) {} + StablehloAggressiveSimplificationPassBase& operator=(const StablehloAggressiveSimplificationPassBase &) = delete; + StablehloAggressiveSimplificationPassBase(StablehloAggressiveSimplificationPassBase &&) = delete; + StablehloAggressiveSimplificationPassBase& operator=(StablehloAggressiveSimplificationPassBase &&) = delete; + ~StablehloAggressiveSimplificationPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-aggressive-simplification"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-aggressive-simplification"; } + + ::llvm::StringRef getDescription() const override { return "Canonicalizes StableHLO operations"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloAggressiveSimplificationPass"); + } + ::llvm::StringRef getName() const override { return "StablehloAggressiveSimplificationPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloAggressiveSimplificationPassBase) + + StablehloAggressiveSimplificationPassBase(StablehloAggressiveSimplificationPassOptions options) : StablehloAggressiveSimplificationPassBase() { + foldOpElementLimit = std::move(options.foldOpElementLimit); + } +protected: + ::mlir::Pass::Option foldOpElementLimit{*this, "fold-op-element-limit", ::llvm::cl::desc("Upper limit on how many elements may be folded by an op folder. This limit doesn't apply in certain special cases such as addition with 0, multiplication by 1, and some splat operations."), ::llvm::cl::init(65536)}; +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloAggressiveSimplificationPass() { + return std::make_unique(); + } + + friend std::unique_ptr<::mlir::Pass> createStablehloAggressiveSimplificationPass(StablehloAggressiveSimplificationPassOptions options) { + return std::make_unique(std::move(options)); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloAggressiveSimplificationPass() { + return impl::createStablehloAggressiveSimplificationPass(); +} + +std::unique_ptr<::mlir::Pass> createStablehloAggressiveSimplificationPass(StablehloAggressiveSimplificationPassOptions options) { + return impl::createStablehloAggressiveSimplificationPass(std::move(options)); +} +#undef GEN_PASS_DEF_STABLEHLOAGGRESSIVESIMPLIFICATIONPASS +#endif // GEN_PASS_DEF_STABLEHLOAGGRESSIVESIMPLIFICATIONPASS + +//===----------------------------------------------------------------------===// +// StablehloTargetIndependentOptimizationPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STABLEHLOTARGETINDEPENDENTOPTIMIZATIONPASS +struct StablehloTargetIndependentOptimizationPassOptions { + bool assumeNoUndeclaredSideEffects = false; + int64_t foldOpElementLimit = 65536; + bool optimizeFloat = true; +}; +std::unique_ptr<::mlir::Pass> createStablehloTargetIndependentOptimizationPass(); +std::unique_ptr<::mlir::Pass> createStablehloTargetIndependentOptimizationPass(StablehloTargetIndependentOptimizationPassOptions options); +#undef GEN_PASS_DECL_STABLEHLOTARGETINDEPENDENTOPTIMIZATIONPASS +#endif // GEN_PASS_DECL_STABLEHLOTARGETINDEPENDENTOPTIMIZATIONPASS +#ifdef GEN_PASS_DEF_STABLEHLOTARGETINDEPENDENTOPTIMIZATIONPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloTargetIndependentOptimizationPass(); +} // namespace impl + +namespace impl { + std::unique_ptr<::mlir::Pass> createStablehloTargetIndependentOptimizationPass(StablehloTargetIndependentOptimizationPassOptions options); +} // namespace impl +namespace impl { + +template +class StablehloTargetIndependentOptimizationPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloTargetIndependentOptimizationPassBase; + + StablehloTargetIndependentOptimizationPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloTargetIndependentOptimizationPassBase(const StablehloTargetIndependentOptimizationPassBase &other) : ::mlir::OperationPass(other) {} + StablehloTargetIndependentOptimizationPassBase& operator=(const StablehloTargetIndependentOptimizationPassBase &) = delete; + StablehloTargetIndependentOptimizationPassBase(StablehloTargetIndependentOptimizationPassBase &&) = delete; + StablehloTargetIndependentOptimizationPassBase& operator=(StablehloTargetIndependentOptimizationPassBase &&) = delete; + ~StablehloTargetIndependentOptimizationPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-target-independent-optimization"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-target-independent-optimization"; } + + ::llvm::StringRef getDescription() const override { return "Runs canonicalizers, folders, and other target-independent optimizations."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloTargetIndependentOptimizationPass"); + } + ::llvm::StringRef getName() const override { return "StablehloTargetIndependentOptimizationPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloTargetIndependentOptimizationPassBase) + + StablehloTargetIndependentOptimizationPassBase(StablehloTargetIndependentOptimizationPassOptions options) : StablehloTargetIndependentOptimizationPassBase() { + assumeNoUndeclaredSideEffects = std::move(options.assumeNoUndeclaredSideEffects); + foldOpElementLimit = std::move(options.foldOpElementLimit); + optimizeFloat = std::move(options.optimizeFloat); + } +protected: + ::mlir::Pass::Option assumeNoUndeclaredSideEffects{*this, "assume-no-undeclared-side-effects", ::llvm::cl::desc("Allow dead code to be eliminated in some situations (e.g. dead while loops) under the assumption that ops are pure unless declared with explicit MLIR `MemoryEffects`. Notably, this means `func.call` ops will be assumed pure."), ::llvm::cl::init(false)}; + ::mlir::Pass::Option foldOpElementLimit{*this, "fold-op-element-limit", ::llvm::cl::desc("Upper limit on how many elements may be folded by an op folder. This limit doesn't apply in certain special cases such as addition with 0, multiplication by 1, and some splat operations."), ::llvm::cl::init(65536)}; + ::mlir::Pass::Option optimizeFloat{*this, "optimize-float", ::llvm::cl::desc("Allow float optimizations that, though mathematically equivalent, may result in slightly different quantization of floating-point values (e.g. `log(sqrt(x))` -> `0.5 * log(x)`). Float optimizations that can't affect numerical results are always enabled."), ::llvm::cl::init(true)}; +private: + + friend std::unique_ptr<::mlir::Pass> createStablehloTargetIndependentOptimizationPass() { + return std::make_unique(); + } + + friend std::unique_ptr<::mlir::Pass> createStablehloTargetIndependentOptimizationPass(StablehloTargetIndependentOptimizationPassOptions options) { + return std::make_unique(std::move(options)); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createStablehloTargetIndependentOptimizationPass() { + return impl::createStablehloTargetIndependentOptimizationPass(); +} + +std::unique_ptr<::mlir::Pass> createStablehloTargetIndependentOptimizationPass(StablehloTargetIndependentOptimizationPassOptions options) { + return impl::createStablehloTargetIndependentOptimizationPass(std::move(options)); +} +#undef GEN_PASS_DEF_STABLEHLOTARGETINDEPENDENTOPTIMIZATIONPASS +#endif // GEN_PASS_DEF_STABLEHLOTARGETINDEPENDENTOPTIMIZATIONPASS +#ifdef GEN_PASS_REGISTRATION + +//===----------------------------------------------------------------------===// +// StablehloAggressiveFolderPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloAggressiveFolderPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloAggressiveFolderPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloAggressiveFolderPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloAggressiveFolderPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloAggressiveSimplificationPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloAggressiveSimplificationPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloAggressiveSimplificationPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloAggressiveSimplificationPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloAggressiveSimplificationPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StablehloTargetIndependentOptimizationPass Registration +//===----------------------------------------------------------------------===// + +inline void registerStablehloTargetIndependentOptimizationPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloTargetIndependentOptimizationPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStablehloTargetIndependentOptimizationPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createStablehloTargetIndependentOptimizationPass(); + }); +} + +//===----------------------------------------------------------------------===// +// Optimization Registration +//===----------------------------------------------------------------------===// + +inline void registerOptimizationPasses() { + registerStablehloAggressiveFolderPass(); + registerStablehloAggressiveSimplificationPass(); + registerStablehloTargetIndependentOptimizationPass(); +} +#undef GEN_PASS_REGISTRATION +#endif // GEN_PASS_REGISTRATION +// Deprecated. Please use the new per-pass macros. +#ifdef GEN_PASS_CLASSES + +template +class StablehloAggressiveFolderPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloAggressiveFolderPassBase; + + StablehloAggressiveFolderPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloAggressiveFolderPassBase(const StablehloAggressiveFolderPassBase &other) : ::mlir::OperationPass(other) {} + StablehloAggressiveFolderPassBase& operator=(const StablehloAggressiveFolderPassBase &) = delete; + StablehloAggressiveFolderPassBase(StablehloAggressiveFolderPassBase &&) = delete; + StablehloAggressiveFolderPassBase& operator=(StablehloAggressiveFolderPassBase &&) = delete; + ~StablehloAggressiveFolderPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-aggressive-folder"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-aggressive-folder"; } + + ::llvm::StringRef getDescription() const override { return "Folds StableHLO operations"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloAggressiveFolderPass"); + } + ::llvm::StringRef getName() const override { return "StablehloAggressiveFolderPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloAggressiveFolderPassBase) + +protected: + ::mlir::Pass::Option assumeNoUndeclaredSideEffects{*this, "assume-no-undeclared-side-effects", ::llvm::cl::desc("Allow dead code to be eliminated in some situations (e.g. dead while loops) under the assumption that ops are pure unless declared with explicit MLIR `MemoryEffects`. Notably, this means `func.call` ops will be assumed pure."), ::llvm::cl::init(false)}; + ::mlir::Pass::Option foldOpElementLimit{*this, "fold-op-element-limit", ::llvm::cl::desc("Upper limit on how many elements may be folded by an op folder. This limit doesn't apply in certain special cases such as addition with 0, multiplication by 1, and some splat operations."), ::llvm::cl::init(65536)}; + ::mlir::Pass::Option optimizeFloat{*this, "optimize-float", ::llvm::cl::desc("Allow float optimizations that, though mathematically equivalent, may result in slightly different quantization of floating-point values (e.g. `log(sqrt(x))` -> `0.5 * log(x)`). Float optimizations that can't affect numerical results are always enabled."), ::llvm::cl::init(true)}; +}; + +template +class StablehloAggressiveSimplificationPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloAggressiveSimplificationPassBase; + + StablehloAggressiveSimplificationPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloAggressiveSimplificationPassBase(const StablehloAggressiveSimplificationPassBase &other) : ::mlir::OperationPass(other) {} + StablehloAggressiveSimplificationPassBase& operator=(const StablehloAggressiveSimplificationPassBase &) = delete; + StablehloAggressiveSimplificationPassBase(StablehloAggressiveSimplificationPassBase &&) = delete; + StablehloAggressiveSimplificationPassBase& operator=(StablehloAggressiveSimplificationPassBase &&) = delete; + ~StablehloAggressiveSimplificationPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-aggressive-simplification"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-aggressive-simplification"; } + + ::llvm::StringRef getDescription() const override { return "Canonicalizes StableHLO operations"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloAggressiveSimplificationPass"); + } + ::llvm::StringRef getName() const override { return "StablehloAggressiveSimplificationPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloAggressiveSimplificationPassBase) + +protected: + ::mlir::Pass::Option foldOpElementLimit{*this, "fold-op-element-limit", ::llvm::cl::desc("Upper limit on how many elements may be folded by an op folder. This limit doesn't apply in certain special cases such as addition with 0, multiplication by 1, and some splat operations."), ::llvm::cl::init(65536)}; +}; + +template +class StablehloTargetIndependentOptimizationPassBase : public ::mlir::OperationPass { +public: + using Base = StablehloTargetIndependentOptimizationPassBase; + + StablehloTargetIndependentOptimizationPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StablehloTargetIndependentOptimizationPassBase(const StablehloTargetIndependentOptimizationPassBase &other) : ::mlir::OperationPass(other) {} + StablehloTargetIndependentOptimizationPassBase& operator=(const StablehloTargetIndependentOptimizationPassBase &) = delete; + StablehloTargetIndependentOptimizationPassBase(StablehloTargetIndependentOptimizationPassBase &&) = delete; + StablehloTargetIndependentOptimizationPassBase& operator=(StablehloTargetIndependentOptimizationPassBase &&) = delete; + ~StablehloTargetIndependentOptimizationPassBase() = default; + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stablehlo-target-independent-optimization"); + } + ::llvm::StringRef getArgument() const override { return "stablehlo-target-independent-optimization"; } + + ::llvm::StringRef getDescription() const override { return "Runs canonicalizers, folders, and other target-independent optimizations."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StablehloTargetIndependentOptimizationPass"); + } + ::llvm::StringRef getName() const override { return "StablehloTargetIndependentOptimizationPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Register the dialects that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + registry.insert(); + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StablehloTargetIndependentOptimizationPassBase) + +protected: + ::mlir::Pass::Option assumeNoUndeclaredSideEffects{*this, "assume-no-undeclared-side-effects", ::llvm::cl::desc("Allow dead code to be eliminated in some situations (e.g. dead while loops) under the assumption that ops are pure unless declared with explicit MLIR `MemoryEffects`. Notably, this means `func.call` ops will be assumed pure."), ::llvm::cl::init(false)}; + ::mlir::Pass::Option foldOpElementLimit{*this, "fold-op-element-limit", ::llvm::cl::desc("Upper limit on how many elements may be folded by an op folder. This limit doesn't apply in certain special cases such as addition with 0, multiplication by 1, and some splat operations."), ::llvm::cl::init(65536)}; + ::mlir::Pass::Option optimizeFloat{*this, "optimize-float", ::llvm::cl::desc("Allow float optimizations that, though mathematically equivalent, may result in slightly different quantization of floating-point values (e.g. `log(sqrt(x))` -> `0.5 * log(x)`). Float optimizations that can't affect numerical results are always enabled."), ::llvm::cl::init(true)}; +}; +#undef GEN_PASS_CLASSES +#endif // GEN_PASS_CLASSES diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.h.inc b/deps/exla/cache/xla_extension/include/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..049bc342915cd6e42be81a42568bde1fe7fd56c2 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.h.inc @@ -0,0 +1,3061 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Rewriters *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: StablehloAggressiveSimplificationPatterns.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + + +static ::llvm::LogicalResult __mlir_ods_local_type_constraint_StablehloAggressiveSimplificationPatterns1( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Type type, + ::llvm::StringRef failureStr) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape()))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": statically shaped tensor of any type values"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns1( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!((::mlir::matchPattern(attr, m_AnyAttrOf(m_Zero(), m_AnyZeroFloat()))))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": is int or float zero"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns2( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!((::mlir::matchPattern(attr, m_Zero())))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": is integer zero"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns3( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!(( + ::mlir::matchPattern(attr, + ::mlir::detail::constant_int_predicate_matcher{ + [](const llvm::APInt &val) { + return val.isAllOnes(); + }}) + ))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": is integer with all bits set to 1"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns4( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!((isIotaRange(cast(attr).asArrayRef())))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": is iota dimensions"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns5( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!((llvm::is_sorted(cast(attr).asArrayRef())))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": is sorted dimensions"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns6( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!((llvm::isa(attr)))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": is dense int elements attr"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns7( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!(((::llvm::isa<::mlir::DenseIntElementsAttr>(attr))) && ((true)))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": integer elements attribute"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns8( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!((cast(attr).getNumElements() == 0))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": is zero extent"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns9( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!((::mlir::matchPattern(attr, m_AnyAttrOf(m_One(), m_OneFloat()))))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": is integer one"; + }); + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns10( + ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, + ::llvm::StringRef failureStr) { + if (!((cast(attr).empty()))) { + return rewriter.notifyMatchFailure(op, [&](::mlir::Diagnostic &diag) { + diag << failureStr << ": is empty i64 array"; + }); + } + return ::mlir::success(); +} +static ::llvm::LogicalResult static_dag_matcher_0(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::ElementsAttr &value, ::mlir::stablehlo::ConstantOp &lhs) { + (void)tblgen_ops; + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::ConstantOp>(op0); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::ConstantOp type"; + }); + } + lhs = castedOp1; + { + [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getValue(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp1, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.constant' to have attribute 'value' of type '::mlir::ElementsAttr'"; + }); + } + value = tblgen_attr; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult static_dag_matcher_1(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::ElementsAttr &value, ::mlir::stablehlo::ConstantOp &zero) { + (void)tblgen_ops; + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::ConstantOp>(op0); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::ConstantOp type"; + }); + } + zero = castedOp1; + { + [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getValue(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp1, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.constant' to have attribute 'value' of type '::mlir::ElementsAttr'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns2(rewriter, castedOp1, tblgen_attr, "op 'stablehlo.constant' attribute 'value' failed to satisfy constraint: 'is integer zero'"))) { + return ::mlir::failure(); + } + value = tblgen_attr; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult static_dag_matcher_2(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::ElementsAttr &value, ::mlir::stablehlo::ConstantOp &one) { + (void)tblgen_ops; + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::ConstantOp>(op0); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::ConstantOp type"; + }); + } + one = castedOp1; + { + [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getValue(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp1, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.constant' to have attribute 'value' of type '::mlir::ElementsAttr'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns3(rewriter, castedOp1, tblgen_attr, "op 'stablehlo.constant' attribute 'value' failed to satisfy constraint: 'is integer with all bits set to 1'"))) { + return ::mlir::failure(); + } + value = tblgen_attr; + } + return ::mlir::success(); +} + +static ::llvm::LogicalResult static_dag_matcher_3(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &rhs, ::mlir::Operation::operand_range &lhs) { + (void)tblgen_ops; + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::ComplexOp>(op0); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::ComplexOp type"; + }); + } + lhs = castedOp1.getODSOperands(0); + rhs = castedOp1.getODSOperands(1); + return ::mlir::success(); +} + +static ::llvm::LogicalResult static_dag_matcher_4(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &pred) { + (void)tblgen_ops; + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::NotOp>(op0); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::NotOp type"; + }); + } + pred = castedOp1.getODSOperands(0); + return ::mlir::success(); +} + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:139 +*/ +struct AddOp_CanonicalizeConstantToRhs : public ::mlir::RewritePattern { + AddOp_CanonicalizeConstantToRhs(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.add", 2, context, {"stablehlo.add"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::stablehlo::ConstantOp lhs; + ::mlir::ElementsAttr value; + ::mlir::stablehlo::AddOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::AddOp>(op0); (void)castedOp0; + op = castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_0(rewriter, op1, tblgen_ops, value, lhs))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + rhs = castedOp0.getODSOperands(1); + if (!((llvm::isa((*rhs.begin())) || !llvm::isa((*rhs.begin()).getDefiningOp())))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'rhs' failed to satisfy constraint: 'is not a constant.'"; + }); + } + if (!(((*op.getODSResults(0).begin()).getDefiningOp()->hasTrait()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'op' failed to satisfy constraint: 'op is commutative'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::AddOp tblgen_AddOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::AddOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*rhs.begin())); + tblgen_values.push_back((*lhs.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_AddOp_0 = rewriter.create<::mlir::stablehlo::AddOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AddOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:143 +*/ +struct AddOp_RemoveNoop : public ::mlir::RewritePattern { + AddOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.add", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute value; + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::AddOp>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + { + auto *op1 = (*castedOp0.getODSOperands(1).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 1 of castedOp0"; + }); + } + ::mlir::Attribute arg1_0; + if (!(!::mlir::failed(::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0)))))){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure"; + }); + } + value = arg1_0; + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns1(rewriter, op1, arg1_0, "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'is int or float zero'"))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ lhs }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:151 +*/ +struct AndOp_CanonicalizeConstantToRhs : public ::mlir::RewritePattern { + AndOp_CanonicalizeConstantToRhs(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.and", 2, context, {"stablehlo.and"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::stablehlo::ConstantOp lhs; + ::mlir::ElementsAttr value; + ::mlir::stablehlo::AndOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::AndOp>(op0); (void)castedOp0; + op = castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_0(rewriter, op1, tblgen_ops, value, lhs))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + rhs = castedOp0.getODSOperands(1); + if (!((llvm::isa((*rhs.begin())) || !llvm::isa((*rhs.begin()).getDefiningOp())))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'rhs' failed to satisfy constraint: 'is not a constant.'"; + }); + } + if (!(((*op.getODSResults(0).begin()).getDefiningOp()->hasTrait()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'op' failed to satisfy constraint: 'op is commutative'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::AndOp tblgen_AndOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::AndOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*rhs.begin())); + tblgen_values.push_back((*lhs.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_AndOp_0 = rewriter.create<::mlir::stablehlo::AndOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AndOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:155 +*/ +struct AndOp_FoldToZero : public ::mlir::RewritePattern { + AndOp_FoldToZero(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.and", 2, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::ElementsAttr value; + ::mlir::stablehlo::ConstantOp zero; + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::AndOp>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + { + auto *op1 = (*castedOp0.getODSOperands(1).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 1 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_1(rewriter, op1, tblgen_ops, value, zero))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ zero.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:160 +*/ +struct AndOp_RemoveNoop : public ::mlir::RewritePattern { + AndOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.and", 2, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::ElementsAttr value; + ::mlir::stablehlo::ConstantOp one; + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::AndOp>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + { + auto *op1 = (*castedOp0.getODSOperands(1).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 1 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_2(rewriter, op1, tblgen_ops, value, one))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ lhs }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:175 +*/ +struct BroadcastInDimOp_MergeComposition : public ::mlir::RewritePattern { + BroadcastInDimOp_MergeComposition(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.broadcast_in_dim", 2, context, {"stablehlo.broadcast_in_dim"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseI64ArrayAttr dims; + ::mlir::DenseI64ArrayAttr dims_parent; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::BroadcastInDimOp>(op0); (void)castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::BroadcastInDimOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::BroadcastInDimOp type"; + }); + } + operand = castedOp1.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getBroadcastDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp1, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.broadcast_in_dim' to have attribute 'broadcast_dimensions' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + dims_parent = tblgen_attr; + } + tblgen_ops.push_back(op1); + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getBroadcastDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.broadcast_in_dim' to have attribute 'broadcast_dimensions' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + dims = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getMergedBroadcastDimensions(rewriter, dims, dims_parent); (void)nativeVar_0; + ::mlir::stablehlo::BroadcastInDimOp tblgen_BroadcastInDimOp_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::BroadcastInDimOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.broadcast_dimensions = ::llvm::dyn_cast_if_present(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_BroadcastInDimOp_1 = rewriter.create<::mlir::stablehlo::BroadcastInDimOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_BroadcastInDimOp_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:168 +*/ +struct BroadcastInDimOp_RemoveNoop : public ::mlir::RewritePattern { + BroadcastInDimOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.broadcast_in_dim", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseI64ArrayAttr dims; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::mlir::stablehlo::BroadcastInDimOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::BroadcastInDimOp>(op0); (void)castedOp0; + op = castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getBroadcastDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.broadcast_in_dim' to have attribute 'broadcast_dimensions' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns4(rewriter, castedOp0, tblgen_attr, "op 'stablehlo.broadcast_in_dim' attribute 'broadcast_dimensions' failed to satisfy constraint: 'is iota dimensions'"))) { + return ::mlir::failure(); + } + dims = tblgen_attr; + } + if (!(((*op.getODSResults(0).begin()).getType() == (*operand.begin()).getType()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'op, operand' failed to satisfy constraint: 'operands are equal'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ operand }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:183 +*/ +struct BroadcastInDimOp_ReplaceWithReshape : public ::mlir::RewritePattern { + BroadcastInDimOp_ReplaceWithReshape(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.broadcast_in_dim", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseI64ArrayAttr dims; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::mlir::stablehlo::BroadcastInDimOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::BroadcastInDimOp>(op0); (void)castedOp0; + op = castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getBroadcastDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.broadcast_in_dim' to have attribute 'broadcast_dimensions' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns5(rewriter, castedOp0, tblgen_attr, "op 'stablehlo.broadcast_in_dim' attribute 'broadcast_dimensions' failed to satisfy constraint: 'is sorted dimensions'"))) { + return ::mlir::failure(); + } + dims = tblgen_attr; + } + if (!((llvm::cast((*op.getODSResults(0).begin()).getType()).getNumElements() == llvm::cast((*operand.begin()).getType()).getNumElements()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'op, operand' failed to satisfy constraint: 'same number of elements'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = rewriter.create(odsLoc, (*op.getODSResults(0).begin()).getType(), (*operand.begin())); (void)nativeVar_0; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ {nativeVar_0} }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:190 +*/ +struct BroadcastInDimOp_ReplaceWithTranspose : public ::mlir::RewritePattern { + BroadcastInDimOp_ReplaceWithTranspose(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.broadcast_in_dim", 1, context, {"stablehlo.transpose"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseI64ArrayAttr dims; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::mlir::stablehlo::BroadcastInDimOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::BroadcastInDimOp>(op0); (void)castedOp0; + op = castedOp0; + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getBroadcastDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.broadcast_in_dim' to have attribute 'broadcast_dimensions' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + dims = tblgen_attr; + } + if (!((llvm::cast((*op.getODSResults(0).begin()).getType()).getNumElements() == llvm::cast((*operand.begin()).getType()).getNumElements()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'op, operand' failed to satisfy constraint: 'same number of elements'"; + }); + } + if (!((llvm::cast((*op.getODSResults(0).begin()).getType()).getRank() == llvm::cast((*operand.begin()).getType()).getRank()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'op, operand' failed to satisfy constraint: 'same rank'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::TransposeOp tblgen_TransposeOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::TransposeOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.permutation = ::llvm::dyn_cast_if_present(dims); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_TransposeOp_0 = rewriter.create<::mlir::stablehlo::TransposeOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_TransposeOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:339 +*/ +struct ComplexOp_CancelOutComposedOps : public ::mlir::RewritePattern { + ComplexOp_CancelOutComposedOps(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.complex", 3, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::mlir::Operation::operand_range operand0(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::ComplexOp>(op0); (void)castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::RealOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::RealOp type"; + }); + } + operand0 = castedOp1.getODSOperands(0); + tblgen_ops.push_back(op1); + } + { + auto *op1 = (*castedOp0.getODSOperands(1).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 1 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::ImagOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::ImagOp type"; + }); + } + operand = castedOp1.getODSOperands(0); + tblgen_ops.push_back(op1); + } + if (!(*operand.begin() == *operand0.begin())){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "Operands 'operand' and 'operand0' must be equal"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc(), tblgen_ops[2]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ operand }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:199 +*/ +struct ConvertOp_RemoveNoop : public ::mlir::RewritePattern { + ConvertOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.convert", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::mlir::stablehlo::ConvertOp convert; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::ConvertOp>(op0); (void)castedOp0; + convert = castedOp0; + operand = castedOp0.getODSOperands(0); + if (!(((*convert.getODSResults(0).begin()).getType() == (*operand.begin()).getType()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'convert, operand' failed to satisfy constraint: 'operands are equal'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ operand }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:244 +*/ +struct DynamicBroadcastInDimOp_FoldToDynamicReshape : public ::mlir::RewritePattern { + DynamicBroadcastInDimOp_FoldToDynamicReshape(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.dynamic_broadcast_in_dim", 2, context, {"stablehlo.dynamic_reshape"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseI64ArrayAttr nonexpanding; + ::mlir::DenseI64ArrayAttr expanding; + ::mlir::DenseI64ArrayAttr dims; + ::mlir::Operation::operand_range shape(op0->getOperands()); + ::mlir::Operation::operand_range shape0(op0->getOperands()); + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::DynamicBroadcastInDimOp>(op0); (void)castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::DynamicReshapeOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::DynamicReshapeOp type"; + }); + } + operand = castedOp1.getODSOperands(0); + shape0 = castedOp1.getODSOperands(1); + tblgen_ops.push_back(op1); + } + shape = castedOp0.getODSOperands(1); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getBroadcastDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.dynamic_broadcast_in_dim' to have attribute 'broadcast_dimensions' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns4(rewriter, castedOp0, tblgen_attr, "op 'stablehlo.dynamic_broadcast_in_dim' attribute 'broadcast_dimensions' failed to satisfy constraint: 'is iota dimensions'"))) { + return ::mlir::failure(); + } + dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKnownExpandingDimensions(); + expanding = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKnownNonexpandingDimensions(); + nonexpanding = tblgen_attr; + } + if (!(*shape.begin() == *shape0.begin())){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "Operands 'shape' and 'shape0' must be equal"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::DynamicReshapeOp tblgen_DynamicReshapeOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::DynamicReshapeOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_values.push_back((*shape.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_DynamicReshapeOp_0 = rewriter.create<::mlir::stablehlo::DynamicReshapeOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DynamicReshapeOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:213 +*/ +struct DynamicBroadcastInDimOp_MergeComposition : public ::mlir::RewritePattern { + DynamicBroadcastInDimOp_MergeComposition(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.dynamic_broadcast_in_dim", 2, context, {"stablehlo.dynamic_broadcast_in_dim"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseI64ArrayAttr nonexpanding; + ::mlir::DenseI64ArrayAttr nonexpanding_p; + ::mlir::DenseI64ArrayAttr dims; + ::mlir::DenseI64ArrayAttr expanding_p; + ::mlir::DenseI64ArrayAttr dims_p; + ::mlir::DenseI64ArrayAttr expanding; + ::mlir::Operation::operand_range shape_p(op0->getOperands()); + ::mlir::Operation::operand_range shape(op0->getOperands()); + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::DynamicBroadcastInDimOp>(op0); (void)castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::DynamicBroadcastInDimOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::DynamicBroadcastInDimOp type"; + }); + } + operand = castedOp1.getODSOperands(0); + shape_p = castedOp1.getODSOperands(1); + { + [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getBroadcastDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp1, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.dynamic_broadcast_in_dim' to have attribute 'broadcast_dimensions' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + dims_p = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getKnownExpandingDimensions(); + expanding_p = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getKnownNonexpandingDimensions(); + nonexpanding_p = tblgen_attr; + } + tblgen_ops.push_back(op1); + } + shape = castedOp0.getODSOperands(1); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getBroadcastDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.dynamic_broadcast_in_dim' to have attribute 'broadcast_dimensions' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKnownExpandingDimensions(); + expanding = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKnownNonexpandingDimensions(); + nonexpanding = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = getMergedBroadcastDimensions(rewriter, dims, dims_p); (void)nativeVar_0; + auto nativeVar_1 = rewriter.getDenseI64ArrayAttr({}); (void)nativeVar_1; + auto nativeVar_2 = rewriter.getDenseI64ArrayAttr({}); (void)nativeVar_2; + ::mlir::stablehlo::DynamicBroadcastInDimOp tblgen_DynamicBroadcastInDimOp_3; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::DynamicBroadcastInDimOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_values.push_back((*shape.begin())); + tblgen_props.broadcast_dimensions = ::llvm::dyn_cast_if_present(nativeVar_0); + tblgen_props.known_expanding_dimensions = ::llvm::dyn_cast_if_present(nativeVar_1); + tblgen_props.known_nonexpanding_dimensions = ::llvm::dyn_cast_if_present(nativeVar_2); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_DynamicBroadcastInDimOp_3 = rewriter.create<::mlir::stablehlo::DynamicBroadcastInDimOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DynamicBroadcastInDimOp_3.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:254 +*/ +struct DynamicBroadcastInDimOp_RemoveNoop : public ::mlir::RewritePattern { + DynamicBroadcastInDimOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.dynamic_broadcast_in_dim", 2, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseI64ArrayAttr nonexpanding; + ::mlir::DenseI64ArrayAttr expanding; + ::mlir::DenseI64ArrayAttr dims; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::mlir::Operation::operand_range operand0(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::DynamicBroadcastInDimOp>(op0); (void)castedOp0; + operand0 = castedOp0.getODSOperands(0); + { + auto *op1 = (*castedOp0.getODSOperands(1).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 1 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::shape::ShapeOfOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::shape::ShapeOfOp type"; + }); + } + operand = castedOp1.getODSOperands(0); + tblgen_ops.push_back(op1); + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getBroadcastDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.dynamic_broadcast_in_dim' to have attribute 'broadcast_dimensions' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns4(rewriter, castedOp0, tblgen_attr, "op 'stablehlo.dynamic_broadcast_in_dim' attribute 'broadcast_dimensions' failed to satisfy constraint: 'is iota dimensions'"))) { + return ::mlir::failure(); + } + dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKnownExpandingDimensions(); + expanding = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKnownNonexpandingDimensions(); + nonexpanding = tblgen_attr; + } + if (!(*operand.begin() == *operand0.begin())){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "Operands 'operand' and 'operand0' must be equal"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ operand }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:234 +*/ +struct DynamicBroadcastInDimOp_ReplaceNoopWithConvert : public ::mlir::RewritePattern { + DynamicBroadcastInDimOp_ReplaceNoopWithConvert(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.dynamic_broadcast_in_dim", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseI64ArrayAttr nonexpanding; + ::mlir::DenseI64ArrayAttr expanding; + ::mlir::DenseI64ArrayAttr dims; + ::mlir::Operation::operand_range shape(op0->getOperands()); + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::mlir::stablehlo::DynamicBroadcastInDimOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::DynamicBroadcastInDimOp>(op0); (void)castedOp0; + op = castedOp0; + operand = castedOp0.getODSOperands(0); + shape = castedOp0.getODSOperands(1); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getBroadcastDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.dynamic_broadcast_in_dim' to have attribute 'broadcast_dimensions' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns4(rewriter, castedOp0, tblgen_attr, "op 'stablehlo.dynamic_broadcast_in_dim' attribute 'broadcast_dimensions' failed to satisfy constraint: 'is iota dimensions'"))) { + return ::mlir::failure(); + } + dims = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKnownExpandingDimensions(); + expanding = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getKnownNonexpandingDimensions(); + nonexpanding = tblgen_attr; + } + if (!((nonexpanding && cast(nonexpanding).size() == llvm::cast((*op.getODSResults(0).begin()).getType()).getRank()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'nonexpanding, op' failed to satisfy constraint: 'all dims are non-expanding'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = rewriter.create(odsLoc, (*op.getODSResults(0).begin()).getType(), (*operand.begin())); (void)nativeVar_0; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ {nativeVar_0} }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:267 +*/ +struct DynamicGatherOp_ReplaceWithGather : public ::mlir::RewritePattern { + DynamicGatherOp_ReplaceWithGather(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.dynamic_gather", 2, context, {"stablehlo.gather"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::stablehlo::GatherDimensionNumbersAttr dimension_numbers; + ::mlir::ElementsAttr slice_sizes; + ::mlir::Operation::operand_range start_indices(op0->getOperands()); + ::mlir::BoolAttr indices_are_sorted; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::DynamicGatherOp>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + start_indices = castedOp0.getODSOperands(1); + { + auto *op1 = (*castedOp0.getODSOperands(2).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 2 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::ConstantOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::ConstantOp type"; + }); + } + { + [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getValue(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp1, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.constant' to have attribute 'value' of type '::mlir::ElementsAttr'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns6(rewriter, castedOp1, tblgen_attr, "op 'stablehlo.constant' attribute 'value' failed to satisfy constraint: 'is dense int elements attr'"))) { + return ::mlir::failure(); + } + slice_sizes = tblgen_attr; + } + tblgen_ops.push_back(op1); + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getDimensionNumbers(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.dynamic_gather' to have attribute 'dimension_numbers' of type '::mlir::stablehlo::GatherDimensionNumbersAttr'"; + }); + } + dimension_numbers = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getIndicesAreSorted(); + if (!tblgen_attr) tblgen_attr = rewriter.getBoolAttr(false); + indices_are_sorted = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = convertToI64Array(rewriter, slice_sizes); (void)nativeVar_0; + ::mlir::stablehlo::GatherOp tblgen_GatherOp_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::GatherOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_values.push_back((*start_indices.begin())); + tblgen_props.dimension_numbers = ::llvm::dyn_cast_if_present(dimension_numbers); + tblgen_props.slice_sizes = ::llvm::dyn_cast_if_present(nativeVar_0); + tblgen_props.indices_are_sorted = ::llvm::dyn_cast_if_present(indices_are_sorted); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_GatherOp_1 = rewriter.create<::mlir::stablehlo::GatherOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_GatherOp_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:286 +*/ +struct DynamicPadOp_ReplaceWithPad : public ::mlir::RewritePattern { + DynamicPadOp_ReplaceWithPad(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.dynamic_pad", 1, context, {"stablehlo.pad"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute interior_padding; + ::mlir::Attribute edge_padding_low; + ::mlir::Operation::operand_range padding_value(op0->getOperands()); + ::mlir::Attribute edge_padding_high; + ::mlir::Operation::operand_range input(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::DynamicPadOp>(op0); (void)castedOp0; + input = castedOp0.getODSOperands(0); + padding_value = castedOp0.getODSOperands(1); + { + auto *op1 = (*castedOp0.getODSOperands(2).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 2 of castedOp0"; + }); + } + ::mlir::Attribute arg1_0; + if (!(!::mlir::failed(::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0)))))){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure"; + }); + } + edge_padding_low = arg1_0; + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns7(rewriter, op1, arg1_0, "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'integer elements attribute'"))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + { + auto *op1 = (*castedOp0.getODSOperands(3).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 3 of castedOp0"; + }); + } + ::mlir::Attribute arg1_0; + if (!(!::mlir::failed(::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0)))))){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure"; + }); + } + edge_padding_high = arg1_0; + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns7(rewriter, op1, arg1_0, "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'integer elements attribute'"))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + { + auto *op1 = (*castedOp0.getODSOperands(4).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 4 of castedOp0"; + }); + } + ::mlir::Attribute arg1_0; + if (!(!::mlir::failed(::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0)))))){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure"; + }); + } + interior_padding = arg1_0; + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns7(rewriter, op1, arg1_0, "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'integer elements attribute'"))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = convertToI64Array(rewriter, edge_padding_low); (void)nativeVar_0; + auto nativeVar_1 = convertToI64Array(rewriter, edge_padding_high); (void)nativeVar_1; + auto nativeVar_2 = convertToI64Array(rewriter, interior_padding); (void)nativeVar_2; + ::mlir::stablehlo::PadOp tblgen_PadOp_3; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::PadOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*input.begin())); + tblgen_values.push_back((*padding_value.begin())); + tblgen_props.edge_padding_low = ::llvm::dyn_cast_if_present(nativeVar_0); + tblgen_props.edge_padding_high = ::llvm::dyn_cast_if_present(nativeVar_1); + tblgen_props.interior_padding = ::llvm::dyn_cast_if_present(nativeVar_2); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_PadOp_3 = rewriter.create<::mlir::stablehlo::PadOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_PadOp_3.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:311 +*/ +struct DynamicReshapeOp_FoldComposedOpsToShapeOperand : public ::mlir::RewritePattern { + DynamicReshapeOp_FoldComposedOpsToShapeOperand(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("shape.shape_of", 2, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range shape(op0->getOperands()); + ::mlir::Operation::operand_range x(op0->getOperands()); + ::mlir::shape::ShapeOfOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::shape::ShapeOfOp>(op0); (void)castedOp0; + op = castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::DynamicReshapeOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::DynamicReshapeOp type"; + }); + } + x = castedOp1.getODSOperands(0); + shape = castedOp1.getODSOperands(1); + tblgen_ops.push_back(op1); + } + if (!(((*shape.begin()).getType() == (*op.getODSResults(0).begin()).getType()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'shape, op' failed to satisfy constraint: 'operands are equal'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ shape }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:305 +*/ +struct DynamicReshapeOp_MergeComposition : public ::mlir::RewritePattern { + DynamicReshapeOp_MergeComposition(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.dynamic_reshape", 2, context, {"stablehlo.dynamic_reshape"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range shape_p(op0->getOperands()); + ::mlir::Operation::operand_range shape(op0->getOperands()); + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::DynamicReshapeOp>(op0); (void)castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::DynamicReshapeOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::DynamicReshapeOp type"; + }); + } + operand = castedOp1.getODSOperands(0); + shape_p = castedOp1.getODSOperands(1); + tblgen_ops.push_back(op1); + } + shape = castedOp0.getODSOperands(1); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::DynamicReshapeOp tblgen_DynamicReshapeOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::DynamicReshapeOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_values.push_back((*shape.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_DynamicReshapeOp_0 = rewriter.create<::mlir::stablehlo::DynamicReshapeOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DynamicReshapeOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:326 +*/ +struct DynamicUpdateSliceOp_FoldToUpdateOperand : public ::mlir::RewritePattern { + DynamicUpdateSliceOp_FoldToUpdateOperand(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.dynamic_update_slice", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range start_indices(op0->getOperands()); + ::mlir::Operation::operand_range update(op0->getOperands()); + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::DynamicUpdateSliceOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_StablehloAggressiveSimplificationPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'stablehlo.dynamic_update_slice' failed to satisfy constraint: 'statically shaped tensor of any type values'"))) { + return ::mlir::failure(); + } + operand = castedOp0.getODSOperands(0); + if(::mlir::failed(__mlir_ods_local_type_constraint_StablehloAggressiveSimplificationPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(1).begin()).getType(), "operand 1 of op 'stablehlo.dynamic_update_slice' failed to satisfy constraint: 'statically shaped tensor of any type values'"))) { + return ::mlir::failure(); + } + update = castedOp0.getODSOperands(1); + start_indices = castedOp0.getODSOperands(2); + if (!(((*operand.begin()).getType() == (*update.begin()).getType()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'operand, update' failed to satisfy constraint: 'operands are equal'"; + }); + } + if (!((llvm::all_of(start_indices, [](Value operand) {return matchPattern(operand, m_Zero()); })))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'start_indices' failed to satisfy constraint: 'is all zero'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ update }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:320 +*/ +struct DynamicUpdateSliceOp_RemoveNoop : public ::mlir::RewritePattern { + DynamicUpdateSliceOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.dynamic_update_slice", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range start_indices(op0->getOperands()); + ::mlir::Attribute update; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::DynamicUpdateSliceOp>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + auto *op1 = (*castedOp0.getODSOperands(1).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 1 of castedOp0"; + }); + } + ::mlir::Attribute arg1_0; + if (!(!::mlir::failed(::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0)))))){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure"; + }); + } + update = arg1_0; + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns8(rewriter, op1, arg1_0, "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'is zero extent'"))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + start_indices = castedOp0.getODSOperands(2); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ operand }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:539 +*/ +struct GetTupleElementOp_UnpackTuple : public ::mlir::RewritePattern { + GetTupleElementOp_UnpackTuple(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.get_tuple_element", 2, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::IntegerAttr idx; + ::mlir::Operation::operand_range operands(op0->getOperands()); + ::mlir::stablehlo::TupleOp tuple; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::GetTupleElementOp>(op0); (void)castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::TupleOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::TupleOp type"; + }); + } + tuple = castedOp1; + operands = castedOp1.getODSOperands(0); + tblgen_ops.push_back(op1); + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getIndex(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.get_tuple_element' to have attribute 'index' of type '::mlir::IntegerAttr'"; + }); + } + idx = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = (*tuple.getODSResults(0).begin()).getDefiningOp()->getOperand(idx.getInt()); (void)nativeVar_0; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ {nativeVar_0} }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:349 +*/ +struct ImagOp_CancelOutComposedOps : public ::mlir::RewritePattern { + ImagOp_CancelOutComposedOps(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.imag", 2, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::ImagOp>(op0); (void)castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_3(rewriter, op1, tblgen_ops, rhs, lhs))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ rhs }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:357 +*/ +struct IotaOp_FoldScalarToZero : public ::mlir::RewritePattern { + IotaOp_FoldScalarToZero(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.iota", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::IntegerAttr dim; + ::mlir::stablehlo::IotaOp iota; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::IotaOp>(op0); (void)castedOp0; + iota = castedOp0; + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getIotaDimension(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.iota' to have attribute 'iota_dimension' of type '::mlir::IntegerAttr'"; + }); + } + dim = tblgen_attr; + } + if (!((llvm::cast((*iota.getODSResults(0).begin()).getType()).getDimSize(dim.getInt()) == 1))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'iota, dim' failed to satisfy constraint: 'dim size is 1'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0, (*iota.getODSResults(0).begin())); (void)nativeVar_0; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ {nativeVar_0} }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:367 +*/ +struct MaxOp_CanonicalizeConstantToRhs : public ::mlir::RewritePattern { + MaxOp_CanonicalizeConstantToRhs(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.maximum", 2, context, {"stablehlo.maximum"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::stablehlo::ConstantOp lhs; + ::mlir::ElementsAttr value; + ::mlir::stablehlo::MaxOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::MaxOp>(op0); (void)castedOp0; + op = castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_0(rewriter, op1, tblgen_ops, value, lhs))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + rhs = castedOp0.getODSOperands(1); + if (!((llvm::isa((*rhs.begin())) || !llvm::isa((*rhs.begin()).getDefiningOp())))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'rhs' failed to satisfy constraint: 'is not a constant.'"; + }); + } + if (!(((*op.getODSResults(0).begin()).getDefiningOp()->hasTrait()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'op' failed to satisfy constraint: 'op is commutative'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::MaxOp tblgen_MaxOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::MaxOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*rhs.begin())); + tblgen_values.push_back((*lhs.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_MaxOp_0 = rewriter.create<::mlir::stablehlo::MaxOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MaxOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:374 +*/ +struct MinOp_CanonicalizeConstantToRhs : public ::mlir::RewritePattern { + MinOp_CanonicalizeConstantToRhs(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.minimum", 2, context, {"stablehlo.minimum"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::stablehlo::ConstantOp lhs; + ::mlir::ElementsAttr value; + ::mlir::stablehlo::MinOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::MinOp>(op0); (void)castedOp0; + op = castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_0(rewriter, op1, tblgen_ops, value, lhs))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + rhs = castedOp0.getODSOperands(1); + if (!((llvm::isa((*rhs.begin())) || !llvm::isa((*rhs.begin()).getDefiningOp())))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'rhs' failed to satisfy constraint: 'is not a constant.'"; + }); + } + if (!(((*op.getODSResults(0).begin()).getDefiningOp()->hasTrait()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'op' failed to satisfy constraint: 'op is commutative'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::MinOp tblgen_MinOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::MinOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*rhs.begin())); + tblgen_values.push_back((*lhs.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_MinOp_0 = rewriter.create<::mlir::stablehlo::MinOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MinOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:381 +*/ +struct MulOp_CanonicalizeConstantToRhs : public ::mlir::RewritePattern { + MulOp_CanonicalizeConstantToRhs(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.multiply", 2, context, {"stablehlo.multiply"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::stablehlo::ConstantOp lhs; + ::mlir::ElementsAttr value; + ::mlir::stablehlo::MulOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::MulOp>(op0); (void)castedOp0; + op = castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_0(rewriter, op1, tblgen_ops, value, lhs))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + rhs = castedOp0.getODSOperands(1); + if (!((llvm::isa((*rhs.begin())) || !llvm::isa((*rhs.begin()).getDefiningOp())))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'rhs' failed to satisfy constraint: 'is not a constant.'"; + }); + } + if (!(((*op.getODSResults(0).begin()).getDefiningOp()->hasTrait()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'op' failed to satisfy constraint: 'op is commutative'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::MulOp tblgen_MulOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::MulOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*rhs.begin())); + tblgen_values.push_back((*lhs.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_MulOp_0 = rewriter.create<::mlir::stablehlo::MulOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MulOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:387 +*/ +struct MulOp_FoldToZero : public ::mlir::RewritePattern { + MulOp_FoldToZero(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.multiply", 2, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::ElementsAttr value; + ::mlir::stablehlo::ConstantOp zero; + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::MulOp>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + { + auto *op1 = (*castedOp0.getODSOperands(1).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 1 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::ConstantOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::ConstantOp type"; + }); + } + zero = castedOp1; + { + [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getValue(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp1, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.constant' to have attribute 'value' of type '::mlir::ElementsAttr'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns1(rewriter, castedOp1, tblgen_attr, "op 'stablehlo.constant' attribute 'value' failed to satisfy constraint: 'is int or float zero'"))) { + return ::mlir::failure(); + } + value = tblgen_attr; + } + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ zero.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:392 +*/ +struct MulOp_RemoveNoop : public ::mlir::RewritePattern { + MulOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.multiply", 2, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::ElementsAttr value; + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::MulOp>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + { + auto *op1 = (*castedOp0.getODSOperands(1).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 1 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::ConstantOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::ConstantOp type"; + }); + } + { + [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getValue(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp1, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.constant' to have attribute 'value' of type '::mlir::ElementsAttr'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns9(rewriter, castedOp1, tblgen_attr, "op 'stablehlo.constant' attribute 'value' failed to satisfy constraint: 'is integer one'"))) { + return ::mlir::failure(); + } + value = tblgen_attr; + } + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ lhs }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:400 +*/ +struct OrOp_CanonicalizeConstantToRhs : public ::mlir::RewritePattern { + OrOp_CanonicalizeConstantToRhs(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.or", 2, context, {"stablehlo.or"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::stablehlo::ConstantOp lhs; + ::mlir::ElementsAttr value; + ::mlir::stablehlo::OrOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::OrOp>(op0); (void)castedOp0; + op = castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_0(rewriter, op1, tblgen_ops, value, lhs))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + rhs = castedOp0.getODSOperands(1); + if (!((llvm::isa((*rhs.begin())) || !llvm::isa((*rhs.begin()).getDefiningOp())))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'rhs' failed to satisfy constraint: 'is not a constant.'"; + }); + } + if (!(((*op.getODSResults(0).begin()).getDefiningOp()->hasTrait()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'op' failed to satisfy constraint: 'op is commutative'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::OrOp tblgen_OrOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::OrOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*rhs.begin())); + tblgen_values.push_back((*lhs.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_OrOp_0 = rewriter.create<::mlir::stablehlo::OrOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_OrOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:403 +*/ +struct OrOp_FoldToOne : public ::mlir::RewritePattern { + OrOp_FoldToOne(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.or", 2, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::ElementsAttr value; + ::mlir::stablehlo::ConstantOp one; + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::OrOp>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + { + auto *op1 = (*castedOp0.getODSOperands(1).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 1 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_2(rewriter, op1, tblgen_ops, value, one))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ one.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:408 +*/ +struct OrOp_RemoveNoop : public ::mlir::RewritePattern { + OrOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.or", 2, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::ElementsAttr value; + ::mlir::stablehlo::ConstantOp zero; + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::OrOp>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + { + auto *op1 = (*castedOp0.getODSOperands(1).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 1 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_1(rewriter, op1, tblgen_ops, value, zero))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ lhs }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:416 +*/ +struct PadOp_RemoveNoop : public ::mlir::RewritePattern { + PadOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.pad", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseI64ArrayAttr interior_padding; + ::mlir::DenseI64ArrayAttr edge_padding_high; + ::mlir::DenseI64ArrayAttr edge_padding_low; + ::mlir::Operation::operand_range padding_value(op0->getOperands()); + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::mlir::stablehlo::PadOp pad; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::PadOp>(op0); (void)castedOp0; + pad = castedOp0; + operand = castedOp0.getODSOperands(0); + padding_value = castedOp0.getODSOperands(1); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getEdgePaddingLow(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.pad' to have attribute 'edge_padding_low' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + edge_padding_low = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getEdgePaddingHigh(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.pad' to have attribute 'edge_padding_high' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + edge_padding_high = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getInteriorPadding(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.pad' to have attribute 'interior_padding' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + interior_padding = tblgen_attr; + } + if (!(((*pad.getODSResults(0).begin()).getType() == (*operand.begin()).getType()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'pad, operand' failed to satisfy constraint: 'operands are equal'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ operand }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:432 +*/ +struct RealDynamicSliceOp_ReplaceWithSlice : public ::mlir::RewritePattern { + RealDynamicSliceOp_ReplaceWithSlice(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.real_dynamic_slice", 1, context, {"stablehlo.slice"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Attribute strides; + ::mlir::Attribute limit_indices; + ::mlir::Attribute start_indices; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::RealDynamicSliceOp>(op0); (void)castedOp0; + operand = castedOp0.getODSOperands(0); + { + auto *op1 = (*castedOp0.getODSOperands(1).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 1 of castedOp0"; + }); + } + ::mlir::Attribute arg1_0; + if (!(!::mlir::failed(::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0)))))){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure"; + }); + } + start_indices = arg1_0; + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns6(rewriter, op1, arg1_0, "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'is dense int elements attr'"))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + { + auto *op1 = (*castedOp0.getODSOperands(2).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 2 of castedOp0"; + }); + } + ::mlir::Attribute arg1_0; + if (!(!::mlir::failed(::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0)))))){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure"; + }); + } + limit_indices = arg1_0; + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns6(rewriter, op1, arg1_0, "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'is dense int elements attr'"))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + { + auto *op1 = (*castedOp0.getODSOperands(3).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 3 of castedOp0"; + }); + } + ::mlir::Attribute arg1_0; + if (!(!::mlir::failed(::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0)))))){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure"; + }); + } + strides = arg1_0; + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns6(rewriter, op1, arg1_0, "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'is dense int elements attr'"))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = convertToI64Array(rewriter, start_indices); (void)nativeVar_0; + auto nativeVar_1 = convertToI64Array(rewriter, limit_indices); (void)nativeVar_1; + auto nativeVar_2 = convertToI64Array(rewriter, strides); (void)nativeVar_2; + ::mlir::stablehlo::SliceOp tblgen_SliceOp_3; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::SliceOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*operand.begin())); + tblgen_props.start_indices = ::llvm::dyn_cast_if_present(nativeVar_0); + tblgen_props.limit_indices = ::llvm::dyn_cast_if_present(nativeVar_1); + tblgen_props.strides = ::llvm::dyn_cast_if_present(nativeVar_2); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_SliceOp_3 = rewriter.create<::mlir::stablehlo::SliceOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SliceOp_3.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:448 +*/ +struct RealOp_CancelOutComposedOps : public ::mlir::RewritePattern { + RealOp_CancelOutComposedOps(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.real", 2, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::RealOp>(op0); (void)castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_3(rewriter, op1, tblgen_ops, rhs, lhs))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ lhs }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:457 +*/ +struct ReduceOp_RemoveNoop : public ::mlir::RewritePattern { + ReduceOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.reduce", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseI64ArrayAttr dims; + ::mlir::Operation::operand_range init(op0->getOperands()); + ::mlir::Operation::operand_range operands(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::ReduceOp>(op0); (void)castedOp0; + operands = castedOp0.getODSOperands(0); + init = castedOp0.getODSOperands(1); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.reduce' to have attribute 'dimensions' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns10(rewriter, castedOp0, tblgen_attr, "op 'stablehlo.reduce' attribute 'dimensions' failed to satisfy constraint: 'is empty i64 array'"))) { + return ::mlir::failure(); + } + dims = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ operands }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:465 +*/ +struct ReshapeOp_MergeComposition : public ::mlir::RewritePattern { + ReshapeOp_MergeComposition(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.reshape", 2, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::mlir::stablehlo::ReshapeOp reshape; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::ReshapeOp>(op0); (void)castedOp0; + reshape = castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::ReshapeOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::ReshapeOp type"; + }); + } + operand = castedOp1.getODSOperands(0); + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = rewriter.create(odsLoc, (*reshape.getODSResults(0).begin()).getType(), (*operand.begin())); (void)nativeVar_0; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ {nativeVar_0} }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:470 +*/ +struct ReshapeOp_RemoveNoop : public ::mlir::RewritePattern { + ReshapeOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.reshape", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::mlir::stablehlo::ReshapeOp reshape; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::ReshapeOp>(op0); (void)castedOp0; + reshape = castedOp0; + operand = castedOp0.getODSOperands(0); + if (!(((*reshape.getODSResults(0).begin()).getType() == (*operand.begin()).getType()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'reshape, operand' failed to satisfy constraint: 'operands are equal'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ operand }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:485 +*/ +struct SelectOp_InvertBroadcastPredicateAndSwap : public ::mlir::RewritePattern { + SelectOp_InvertBroadcastPredicateAndSwap(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.select", 3, context, {"stablehlo.broadcast_in_dim", "stablehlo.select"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range on_true(op0->getOperands()); + ::mlir::Operation::operand_range on_false(op0->getOperands()); + ::mlir::DenseI64ArrayAttr broadcast_dimensions; + ::mlir::Operation::operand_range pred(op0->getOperands()); + ::mlir::stablehlo::BroadcastInDimOp b; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::SelectOp>(op0); (void)castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::BroadcastInDimOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::BroadcastInDimOp type"; + }); + } + b = castedOp1; + { + auto *op2 = (*castedOp1.getODSOperands(0).begin()).getDefiningOp(); + if (!(op2)){ + return rewriter.notifyMatchFailure(castedOp1, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp1"; + }); + } + if(::mlir::failed(static_dag_matcher_4(rewriter, op2, tblgen_ops, pred))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op2); + } + { + [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getBroadcastDimensions(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp1, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.broadcast_in_dim' to have attribute 'broadcast_dimensions' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + broadcast_dimensions = tblgen_attr; + } + tblgen_ops.push_back(op1); + } + on_true = castedOp0.getODSOperands(1); + on_false = castedOp0.getODSOperands(2); + if (!(((*b.getODSResults(0).begin()).hasOneUse()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'b' failed to satisfy constraint: ''"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc(), tblgen_ops[2]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::BroadcastInDimOp tblgen_BroadcastInDimOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::BroadcastInDimOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*pred.begin())); + tblgen_props.broadcast_dimensions = ::llvm::dyn_cast_if_present(broadcast_dimensions); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + tblgen_types.push_back((*b.getODSResults(0).begin()).getType()); + tblgen_BroadcastInDimOp_0 = rewriter.create<::mlir::stablehlo::BroadcastInDimOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + ::mlir::stablehlo::SelectOp tblgen_SelectOp_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::SelectOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*tblgen_BroadcastInDimOp_0.getODSResults(0).begin())); + tblgen_values.push_back((*on_false.begin())); + tblgen_values.push_back((*on_true.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_SelectOp_1 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SelectOp_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:480 +*/ +struct SelectOp_InvertPredicateAndSwap : public ::mlir::RewritePattern { + SelectOp_InvertPredicateAndSwap(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.select", 2, context, {"stablehlo.select"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range on_false(op0->getOperands()); + ::mlir::Operation::operand_range on_true(op0->getOperands()); + ::mlir::Operation::operand_range pred(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::SelectOp>(op0); (void)castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_4(rewriter, op1, tblgen_ops, pred))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + on_true = castedOp0.getODSOperands(1); + on_false = castedOp0.getODSOperands(2); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::SelectOp tblgen_SelectOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::SelectOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*pred.begin())); + tblgen_values.push_back((*on_false.begin())); + tblgen_values.push_back((*on_true.begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_SelectOp_0 = rewriter.create<::mlir::stablehlo::SelectOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SelectOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:518 +*/ +struct SliceOp_RemoveNoop : public ::mlir::RewritePattern { + SliceOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.slice", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseI64ArrayAttr strides; + ::mlir::DenseI64ArrayAttr limit_indices; + ::mlir::DenseI64ArrayAttr start_indices; + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::mlir::stablehlo::SliceOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::SliceOp>(op0); (void)castedOp0; + op = castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_StablehloAggressiveSimplificationPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'stablehlo.slice' failed to satisfy constraint: 'statically shaped tensor of any type values'"))) { + return ::mlir::failure(); + } + operand = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getStartIndices(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.slice' to have attribute 'start_indices' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + start_indices = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getLimitIndices(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.slice' to have attribute 'limit_indices' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + limit_indices = tblgen_attr; + } + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getStrides(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.slice' to have attribute 'strides' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + strides = tblgen_attr; + } + if (!(((*operand.begin()).getType() == (*op.getODSResults(0).begin()).getType()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'operand, op' failed to satisfy constraint: 'operands are equal'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ operand }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:505 +*/ +struct SubtractOp_FoldToZero : public ::mlir::RewritePattern { + SubtractOp_FoldToZero(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.subtract", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range operand(op0->getOperands()); + ::mlir::Operation::operand_range operand0(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::SubtractOp>(op0); (void)castedOp0; + if(::mlir::failed(__mlir_ods_local_type_constraint_StablehloAggressiveSimplificationPatterns1(rewriter, castedOp0, (*castedOp0.getODSOperands(0).begin()).getType(), "operand 0 of op 'stablehlo.subtract' failed to satisfy constraint: 'statically shaped tensor of any type values'"))) { + return ::mlir::failure(); + } + operand0 = castedOp0.getODSOperands(0); + operand = castedOp0.getODSOperands(1); + if (!(*operand.begin() == *operand0.begin())){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "Operands 'operand' and 'operand0' must be equal"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = ::mlir::stablehlo::getConstantLike(rewriter, odsLoc, 0, (*operand.begin())); (void)nativeVar_0; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ {nativeVar_0} }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:510 +*/ +struct SubtractOp_RemoveNoop : public ::mlir::RewritePattern { + SubtractOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.subtract", 2, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::ElementsAttr value; + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::SubtractOp>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + { + auto *op1 = (*castedOp0.getODSOperands(1).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 1 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::stablehlo::ConstantOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::stablehlo::ConstantOp type"; + }); + } + { + [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getValue(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp1, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.constant' to have attribute 'value' of type '::mlir::ElementsAttr'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns1(rewriter, castedOp1, tblgen_attr, "op 'stablehlo.constant' attribute 'value' failed to satisfy constraint: 'is int or float zero'"))) { + return ::mlir::failure(); + } + value = tblgen_attr; + } + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ lhs }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:531 +*/ +struct TransposeOp_RemoveNoop : public ::mlir::RewritePattern { + TransposeOp_RemoveNoop(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.transpose", 1, context, {}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseI64ArrayAttr dims; + ::mlir::Operation::operand_range lhs(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::TransposeOp>(op0); (void)castedOp0; + lhs = castedOp0.getODSOperands(0); + { + [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getPermutation(); + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'stablehlo.transpose' to have attribute 'permutation' of type '::mlir::DenseI64ArrayAttr'"; + }); + } + if(::mlir::failed(__mlir_ods_local_attr_constraint_StablehloAggressiveSimplificationPatterns4(rewriter, castedOp0, tblgen_attr, "op 'stablehlo.transpose' attribute 'permutation' failed to satisfy constraint: 'is iota dimensions'"))) { + return ::mlir::failure(); + } + dims = tblgen_attr; + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ lhs }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +/* Generated from: + external/stablehlo/stablehlo/transforms/optimization/StablehloAggressiveSimplificationPatterns.td:549 +*/ +struct XorOp_CanonicalizeConstantToRhs : public ::mlir::RewritePattern { + XorOp_CanonicalizeConstantToRhs(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("stablehlo.xor", 2, context, {"stablehlo.xor"}) {} + ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range rhs(op0->getOperands()); + ::mlir::stablehlo::ConstantOp lhs; + ::mlir::ElementsAttr value; + ::mlir::stablehlo::XorOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::stablehlo::XorOp>(op0); (void)castedOp0; + op = castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + if(::mlir::failed(static_dag_matcher_0(rewriter, op1, tblgen_ops, value, lhs))) { + return ::mlir::failure(); + } + tblgen_ops.push_back(op1); + } + rhs = castedOp0.getODSOperands(1); + if (!((llvm::isa((*rhs.begin())) || !llvm::isa((*rhs.begin()).getDefiningOp())))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'rhs' failed to satisfy constraint: 'is not a constant.'"; + }); + } + if (!(((*op.getODSResults(0).begin()).getDefiningOp()->hasTrait()))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'op' failed to satisfy constraint: 'op is commutative'"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::stablehlo::XorOp tblgen_XorOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::mlir::stablehlo::XorOp::Properties tblgen_props; (void)tblgen_props; + tblgen_values.push_back((*rhs.begin())); + tblgen_values.push_back((*lhs.getODSResults(0).begin())); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_XorOp_0 = rewriter.create<::mlir::stablehlo::XorOp>(odsLoc, tblgen_types, tblgen_values, tblgen_props); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_XorOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + } +}; + +void LLVM_ATTRIBUTE_UNUSED populateWithGenerated(::mlir::RewritePatternSet &patterns) { + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); +} diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/optimization/stablehlo_optimization_passes.md b/deps/exla/cache/xla_extension/include/stablehlo/transforms/optimization/stablehlo_optimization_passes.md new file mode 100644 index 0000000000000000000000000000000000000000..8b3ed2f71649208bbf43b860d65dcd7c7cf1ef9c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/optimization/stablehlo_optimization_passes.md @@ -0,0 +1,128 @@ + + +### `-stablehlo-aggressive-folder` + +_Folds StableHLO operations_ + +#### Options + +``` +-assume-no-undeclared-side-effects : Allow dead code to be eliminated in some situations (e.g. dead while loops) under the assumption that ops are pure unless declared with explicit MLIR `MemoryEffects`. Notably, this means `func.call` ops will be assumed pure. +-fold-op-element-limit : Upper limit on how many elements may be folded by an op folder. This limit doesn't apply in certain special cases such as addition with 0, multiplication by 1, and some splat operations. +-optimize-float : Allow float optimizations that, though mathematically equivalent, may result in slightly different quantization of floating-point values (e.g. `log(sqrt(x))` -> `0.5 * log(x)`). Float optimizations that can't affect numerical results are always enabled. +``` + +### `-stablehlo-aggressive-simplification` + +_Canonicalizes StableHLO operations_ + + + +Note: Prefer StablehloTargetIndependentOptimizationPass to get best results. + +Performs graph simplifications, including: + +``` +- add(cst, X) -> add(X, cst) +- add(X, 0) -> X +- and(cst, X) -> and(X, cst) +- and(X, 0) -> 0 +- and(X, 1) -> X +- broadcast_in_dim(broadcast_in_dim(X, [dimsA...]), [dimsB...]) -> broadcast_in_dim(X, merge(dimsA, dimsB)) +- broadcast_in_dim(X, [dims...]) -> transpose(X, [dims...]) [if same numel & rank] +- broadcast_in_dim(X, [iota...]) -> X +- broadcast_in_dim(X, [sorted...]) -> reshape(X, [sorted...]) [if same numel] +- compare(cst, X, comparator) -> compare(X, cst, inv(comparator)) +- compare(X, X, [EQ,GE,LE]) -> true +- compare(X, X, [NE,GT,LT]) -> false +- complex(real(X), imag(X))) -> X +- concatenate(concatenate(X, Y), Z) -> concatenate(X, Y, Z) +- concatenate(X) -> X +- concatenate(X, Y, []) -> concatenate(X, Y) +- convert(X, [X.type]) -> X +- dynamic_broadcast_in_dim(dynamic_broadcast_in_dim(X, _, [dimsA...]), shape, [dimsB...]) -> dynamic_broadcast_in_dim(X, shape, merge(dimsA, dimsB)) +- dynamic_broadcast_in_dim(dynamic_reshape(X, shape), shape) -> dynamic_reshape(X, shape) +- dynamic_broadcast_in_dim(X, _, _, [all_nonexpanding...]) -> convert(X) +- dynamic_broadcast_in_dim(X, shape_of(X)) -> X +- dynamic_gather(x, constant(slice_sizes)) -> gather(x, slice_sizes) +- dynamic_iota(shape, dim) -> +- dynamic_pad(X, low, high, interior) -> pad(X, low, high, interior) +- dynamic_reshape(dynamic_reshape(X, _), shape)) -> dynamic_reshape(X, shape) +- dynamic_reshape(op(dynamic_reshape(X, shape)), shape) +- dynamic_slice(X, begin, slice_sizes) -> slice(X, begin, slice_sizes) +- dynamic_update_slice(X, update, start_indices : zero)) -> update +- dynamic_update_slice(X, update : zero_extent)) -> X +- gather(X, cst_start_indices) -> slice(X, slice_start, slice_end) +- get_dimension_size(X, i) -> X.shape[i] +- get_tuple_element(tuple(X_0, X_1, ...), i) -> X_i +- imag(complex(R,I)) -> I +- iota(dim) : multi_rank +- iota(dim) : type -> constant(0) : type [if type[dim] == 1] +- max(cst, X) -> max(X, cst) +- minimum(cst, X) -> minimum(X, cst) +- multiply(cst, X) -> multiply(X, cst) +- multiply(X, 0i) -> 0i +- multiply(X, 1i) -> X +- op(X : zero_extent_tensor) -> constant([]) +- or(cst, X) -> or(X, cst) +- or(X, 0) -> X +- or(X, 1) -> 1 +- pad(empty_tensor, _) -> broadcast_in_dim(empty_tensor, _) +- real(complex(R,I)) -> X +- real_dynamic_slice(X, start, limit, strides) +- real_dynamic_slice(X, start, limit, strides) +- reduce[A](_, _, fn:return A) -> A... +- reduce(empty_0, empty_1, ...) -> [broadcast_in_dim(empty_i)...] +- reduce(in_1, in_2, _, _) -> reduce(in_1, _, _) [if unused(in_2)] +- reduce(X..., dims=[], add) -> X... +- reshape(reshape(X, _), [shape]) -> reshape(X, [shape]) +- reshape(X, [X.shape]) -> X +- select(broadcast(not(p)), t, f) => select(broadcast(p), f, t) +- select(not(p), t, f) => select(p, f, t) +- shape_of(dynamic_reshape(X, shape)) -> shape +- slice(concat(X,Y,Z,...),...) -> concat(slice(X),slice(Y),slice(Z)) +- slice(X, [A:A], [B:B], ...) -> X +- sort(X) -> sort(X, dim = N) [when dim can be inferred] +- sort(X,Y) -> sort(X) [if Y unused and unused in comparator] +- subtract(X, 0) -> X +- subtract(X, X) -> 0 +- transpose(X, [iota...]) -> X +- transpose(X, [no_mem_layout_change...]) -> reshape(X) +- tuple(get_tuple_element(X, 0), get_tuple_element(X, 1), ...) -> X +- while -> while (loop invariants as implicit captures) +- xor(cst, X) -> xor(X, cst) +- (+more) +``` + +This list is pulled from code comments so is not fully exhaustive, but has +high coverage of the pass today. + +#### Options + +``` +-fold-op-element-limit : Upper limit on how many elements may be folded by an op folder. This limit doesn't apply in certain special cases such as addition with 0, multiplication by 1, and some splat operations. +``` + +### `-stablehlo-target-independent-optimization` + +_Runs canonicalizers, folders, and other target-independent optimizations._ + +Uses patterns from StablehloAggressiveSimplificationPass and +StablehloAggressiveFolderPass together, allowing canonicalization and +folding to be performed in the same pattern set, often leading to better +results. + +Users should prefer this pass to calling the others directly. + +#### Options + +``` +-assume-no-undeclared-side-effects : Allow dead code to be eliminated in some situations (e.g. dead while loops) under the assumption that ops are pure unless declared with explicit MLIR `MemoryEffects`. Notably, this means `func.call` ops will be assumed pure. +-fold-op-element-limit : Upper limit on how many elements may be folded by an op folder. This limit doesn't apply in certain special cases such as addition with 0, multiplication by 1, and some splat operations. +-optimize-float : Allow float optimizations that, though mathematically equivalent, may result in slightly different quantization of floating-point values (e.g. `log(sqrt(x))` -> `0.5 * log(x)`). Float optimizations that can't affect numerical results are always enabled. +``` diff --git a/deps/exla/cache/xla_extension/include/stablehlo/transforms/stablehlo_passes.md b/deps/exla/cache/xla_extension/include/stablehlo/transforms/stablehlo_passes.md new file mode 100644 index 0000000000000000000000000000000000000000..65a94a86d5947f5349c3222345ed95e51a769ac4 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/stablehlo/transforms/stablehlo_passes.md @@ -0,0 +1,504 @@ + + +### `-chlo-legalize-to-stablehlo` + +_Legalizes from CHLO ops flow to StableHLO and Shape ops_ + +### `-shape-legalize-to-stablehlo` + +_Legalize shape-related ops to StableHLO._ + +An experimental pass that legalizes shape-related ops to StableHLO ops. + +Bringing shape and data computations together via an optional pass will +make it possible for the StableHLO ecosystem to potentially leverage the +compilation pipelines that use StableHLO operations to model dynamism. + +### `-stablehlo-canonicalize-dynamism` + +_Canonicalizes dynamic StableHLO ops into static ops._ + +Replaces dynamic StableHLO ops like DynamicReshapeOp with the corresponding +static counterparts like `DynamicReshapeOp` to `ReshapeOp` or +`DynamicBroadcastInDim` to `BroadcastInDim` if all the dynamic elements of = +these ops are actually constants. + +``` + %c = stablehlo.constant dense<16> : tensor<1xi32> + %0 = stablehlo.dynamic_broadcast_in_dim %cst, %c, dims = [] : (tensor, tensor<1xi32>) -> tensor<16xf32> + + ==> + + %0 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<16xf32> +``` + +### `-stablehlo-compatibility-expander` + +_Compatibility expander for StableHLO operations._ + +StableHLO ops gets updates or new op is introduced in the latest versions. +This opt-in pass expands backward compatibility with older StableHLO +versions by decomposing newer StableHLO operations into equivalent +operations supported by those older versions. + +Why is this an opt-in pass? + +Occasionally, StableHLO op enhancements are used to greatly simplify the +handling of certain common patterns in the OpenXLA ecosystem. This +includes things like TanOp, which has high framework and compiler support, +as well as gather/scatter batching dimensions, which can be represented +using slices, but makes sharding much more difficult. For this category of +new features, we do not offer automatic downgrade, since it may throw away +important information used in subsequent optimizations. This pass can be +used to expand these ops based on a target version to maximize compatibility +at the expense of potentially less optimal compilation. + +```mlir +func.func @tan_op_non_complex(%arg0: tensor<4xf64>) -> tensor<4xf64> { + %1 = stablehlo.tan %arg0 : tensor<4xf64> + func.return %1 : tensor<4xf64> +} + +==> + +func.func @tan_op_non_complex(%arg0: tensor<4xf64>) -> tensor<4xf64> { + %0 = stablehlo.sine %arg0 : tensor<4xf64> + %1 = stablehlo.cosine %arg0 : tensor<4xf64> + %2 = stablehlo.divide %0, %1 : tensor<4xf64> + return %2 : tensor<4xf64> +} +``` + +#### Options + +``` +-target : The target version. Must be a version of the form #.#.#. +``` + +### `-stablehlo-complex-math-expander` + +_Expander for StableHLO complex math operations._ + +StableHLO complex math operations are decompositions using +StableHLO real math operations. + +This statement is based on the assumption that no hardware exists +that supports complex numbers nor complex math operations +natively. This means that the fallback mechanisms on complex math +operations that compilers may implement, are redundant. With +enabling this pass, all StableHLO complex math operations will be +expanded. + +```mlir +func.func @sqrt_op_complex(%arg0: tensor<4xcomplex>) -> tensor<4xcomplex> { + %1 = stablehlo.sqrt %arg0 : tensor<4xcomplex> + func.return %1 : tensor<4xcomplex> +} + +==> + +func.func @sqrt_op_complex(%arg0: tensor<4xcomplex>) -> tensor<4xcomplex> { + TBD + return %2 : tensor<4xcomplex> +} +``` + +### `-stablehlo-convert-to-signless` + +_Pass to transform the IR to be on signless integers._ + +### `-stablehlo-legalize-composite-to-call` + +_Replaces composite ops with a call to their decomposition._ + +Replaces composite ops with a call to their decomposition, e.g. the below: + +```mlir +stablehlo.composite "my_namespace.my_op" %arg0, %arg1 { + decomposition = @bar, + version = 1, + composite_attributes = { + "my_attribute": "my_value" + } +} +``` + +Will become: + +```mlir +func.call @bar(%arg0, %arg1) +``` + +A subset of composites can be excepted from this transformation using the +"except" flag, e.g.: + +```bash +stablehlo-opt --stablehlo-legalize-composite-to-call=except='foo.baz,foo.qux' +``` + +#### Options + +``` +-except : Names of composites that should not be replaced with calls. +``` + +### `-stablehlo-legalize-deprecated-ops` + +_Legalize deprecated ops to well-supported ops._ + +The StableHLO v1.0 Opset Deprecations RFC (#2283) proposes to remove +several redundant ops. This pass helps to evaluate the impact of these op +removals in various compilation pipelines by legalizing them to their +long-term supported counterparts. + +#### Options + +``` +-fail-on-unused : Fail on (mostly) unused ops that are deprecated without any fallback. +``` + +### `-stablehlo-legalize-qdq-to-quantized-op` + +_Fuse (de-quantize, floating-point operation and quantize) pattern into StableHLO quantized operation_ + +Fuse (de-quantize, floating-point operation and quantize) pattern into StableHLO quantized operation +Note: The pass does not delete any preexisting op. +For example, the following program + +```mlir +func.func @add(%arg0: tensor<16x16x!quant.uniform>) -> tensor<16x16x!quant.uniform> { + %0 = stablehlo.uniform_dequantize %arg0 : (tensor<16x16x!quant.uniform>) -> tensor<16x16xf32> + %1 = stablehlo.abs %0 : tensor<16x16xf32> + %2 = stablehlo.uniform_quantize %1 : (tensor<16x16xf32>) -> tensor<16x16x!quant.uniform> + func.return %2 : tensor<16x16x!quant.uniform> +} +``` + +Will become: + +```mlir +func.func @add(%arg0: tensor<16x16x!quant.uniform>) -> tensor<16x16x!quant.uniform> { + %0 = stablehlo.uniform_dequantize %arg0 : (tensor<16x16x!quant.uniform>) -> tensor<16x16xf32> + %1 = stablehlo.abs %0 : tensor<16x16xf32> + %2 = stablehlo.abs %arg0 : tensor<16x16x!quant.uniform> + %3 = stablehlo.uniform_quantize %1 : (tensor<16x16xf32>) -> tensor<16x16x!quant.uniform> + return %2 : tensor<16x16x!quant.uniform> +} +``` + +### `-stablehlo-legalize-quant-to-math` + +_Convert from StableHLO quantized ops to StableHLO primitive math ops._ + +Convert StableHLO programs using UniformQuantized types to semantically +equivalent integer math operations. + +```mlir +func.func @add(%arg0: tensor>, %arg1: tensor>) -> tensor> { + %0 = "stablehlo.add"(%arg0, %arg1) : (tensor>, tensor>) -> tensor> + func.return %0 : tensor> +} +``` + +Will become: + +```mlir +func.func @add(%arg0: tensor, %arg1: tensor) -> tensor { + %0 = stablehlo.convert %arg0 : (tensor) -> tensor + %cst = stablehlo.constant dense<0.333333343> : tensor + %1 = chlo.broadcast_multiply %0, %cst : (tensor, tensor) -> tensor + %cst_0 = stablehlo.constant dense<2.000000e+00> : tensor + %2 = chlo.broadcast_add %1, %cst_0 : (tensor, tensor) -> tensor + %3 = stablehlo.round_nearest_even %2 : tensor + %4 = stablehlo.convert %3 : (tensor) -> tensor + %5 = stablehlo.convert %arg1 : (tensor) -> tensor + %cst_1 = stablehlo.constant dense<0.666666686> : tensor + %6 = chlo.broadcast_multiply %5, %cst_1 : (tensor, tensor) -> tensor + %cst_2 = stablehlo.constant dense<1.33333337> : tensor + %7 = chlo.broadcast_add %6, %cst_2 : (tensor, tensor) -> tensor + %8 = stablehlo.round_nearest_even %7 : tensor + %9 = stablehlo.convert %8 : (tensor) -> tensor + %c = stablehlo.constant dense<2> : tensor + %10 = chlo.broadcast_add %4, %9 : (tensor, tensor) -> tensor + %11 = chlo.broadcast_subtract %10, %c : (tensor, tensor) -> tensor + %c_3 = stablehlo.constant dense<-128> : tensor + %c_4 = stablehlo.constant dense<127> : tensor + %12 = stablehlo.clamp %c_3, %11, %c_4 : tensor + %13 = stablehlo.convert %12 : (tensor) -> tensor + return %13 : tensor +} +``` + +### `-stablehlo-legalize-quantized-op-to-qdq` + +_Decompose quantized StableHLO operation to (de-quantize, floating-point operation and quantize) pattern._ + +Decompose StableHLO quantized programs using uniform quantize/dequantize +operations. For example, the following program + +```mlir +func.func @add(%arg0: tensor>, %arg1: tensor>) -> tensor> { + %0 = "stablehlo.add"(%arg0, %arg1) : (tensor>, tensor>) -> tensor> + func.return %0 : tensor> +} +``` + +Will become: + +```mlir +func.func @add(%arg0: tensor>, %arg1: tensor>) -> tensor> { + %0 = stablehlo.uniform_dequantize %arg0 : (tensor>) -> tensor + %1 = stablehlo.uniform_dequantize %arg1 : (tensor>) -> tensor + %2 = stablehlo.add %0, %1 : tensor + %3 = stablehlo.uniform_quantize %2 : (tensor) -> tensor> + return %3 : tensor> +} +``` + +### `-stablehlo-legalize-to-vhlo` + +_Legalize StableHLO to VHLO._ + +Legalize StableHLO to the latest version of ops in VHLO. These ops can then +be downgraded to older versions of VHLO for forward compatibility using +`VhloToVersionPass`. + +```mlir +stablehlo.exponential %[[ARG0]] <{result_accuracy = DEFAULT}> : tensor +# ====> +"vhlo.exponential_v2"(%[[ARG0]]) <{result_accuracy = #vhlo.DEFAULT_v1}> : !vhlo.tensor_v1 +``` + +See [vhlo.md > The VHLO dialect](https://github.com/openxla/stablehlo/blob/main/docs/vhlo.md) +for full details on how VHLO is used to preserve forward and backward +compatibility. + +#### Options + +``` +-allow-other-dialects : Allow serialization to use other (potentially unstable) dialects, inserts unrealized casts between dialects. +``` + +### `-stablehlo-refine-arguments` + +_Refines the argument shapes of the main function._ + +Modifies the arguments of the main function using the input type signature. +Wraps arguments in `custom_call @stablehlo.shape_refinement_operand_wrapper` +to keep the IR valid before shape refinement is run. + +``` +func.func public @main(%arg0: tensor) -> tensor { + ... +} + +==> + +func.func public @main(%arg0: tensor<16xf32>) -> tensor { + %c = stablehlo.constant dense<16> : tensor<1xi64> + %0 = stablehlo.custom_call @stablehlo.shape_refinement_operand_wrapper(%arg0, %c) {...} + : (tensor<16xf32>, tensor<1xi64>) -> tensor + ... +} +``` + +The `refinedTypesOption` can be used to specify a list of refined types. +This can be specified in MLIR with `--types='tensor<...>,tensor<...>'`, or +passed to the pass create method. The refinement type list must specify the +type of every argument to the `main` method being refined. + +#### Options + +``` +-types : The new types to be used for the main function's arguments, specified as an MLIR TypeRange 'tensor<1x2xf32>, ...' +``` + +### `-stablehlo-refine-shapes` + +_Refines shapes across a StableHLO program._ + + Walks through a StableHLO program refining shapes within ops. + + The flagship use case for this pass is specializing dynamically-shaped + programs to static shapes. If a dynamically-shaped StableHLO program has the + right structure, then updating its argument types from dynamic shapes to + static shapes and running this pass will propagate static shapes across the + program. + + This pass removes `custom_call @shape_refinement_operand_wrapper` by + replacing uses of the result with the operand directly, and propagates + static shapes throughout the program. + + ``` + %c = stablehlo.constant dense<16> : tensor<1xi64> + %0 = stablehlo.custom_call @stablehlo.shape_refinement_operand_wrapper(%arg0, %c) {...} + : (tensor<16xf32>, tensor<1xi64>) -> tensor + %1 = stablehlo.add %0, %0 : tensor + + ==> + + %1 = stablehlo.add %arg0, %arg0 : tensor<16xf32> + ``` + +Modules valid for shape refinement must have the following properties: + + * All the dynamic shapes depend only on the input shapes (no shape + dependency on the input array contents). We refer to the operations that + depend transitively only on the input shapes (e.g., as given by + `stablehlo.get_dimension_size`) or global constants like the resolved + values of symbolic integers (i.e. tensor : A = 5), as `dimension` + operations. All dimension values can be resolved to constants through + inter-procedural constant folding. + * Intermediate functions may take a number of token arguments (of type + !stablehlo.token) at the start of the argument list, followed by some + global constant arguments which are constant integer scalars, such as the + resolved values of symbolic integers (i.e. tensor : A = 5). + * Some intermediate functions may return computations on global constants, + i.e. `floordiv` on symint values. These functions are indicated by only + returning constant values after refinement. These functions are inlined. + * All calls to a single function resolve to the same argument shapes, and no + recursive / co-recursive function calls are made. + +### `-stablehlo-wrap-in-composite` + +_Wraps a non-composite StableHLO op in a composite op._ + +Wraps StableHLO operations in `stablehlo.composite` operations. + +For instance, consider a simple StableHLO program: + +```mlir +func.func @main(%arg0 : tensor<2xf32>, %arg1 : tensor<2xf32>) -> tensor<2xf32> { + %0 = stablehlo.add %arg0, %arg1 : tensor<2xf32> + return %0 : tensor<2xf32> +} +``` + +Applying this pass to wrap `stablehlo.add` operations will result in the +following program: + +```mlir +func.func @main(%arg0: tensor<2xf32>, %arg1: tensor<2xf32>) -> tensor<2xf32> { + %0 = stablehlo.composite "stablehlo.add" %arg0, %arg1 {decomposition = @stablehlo.add.impl} : (tensor<2xf32>, tensor<2xf32>) -> tensor<2xf32> + return %0 : tensor<2xf32> +} +func.func private @stablehlo.add.impl(%arg0: tensor<2xf32>, %arg1: tensor<2xf32>) -> tensor<2xf32> { + %0 = stablehlo.add %arg0, %arg1 : tensor<2xf32> + return %0 : tensor<2xf32> +} +``` + +Notes: + + - The `name` attribute of the generated `stablehlo.composite` operation + will always be the same as the name of the original operation that was + wrapped (e.g., if you wrap a `stablehlo.add` operation, the composite + will also be named `"stablehlo.add"`). + - The private function that encapsulates the original operation + (referenced by the `decomposition` attribute of the + `stablehlo.composite` operation) will be named using the pattern + `.impl[.N]`, where `` is the name of the original + operation, and `N` is a unique integer identifier generated to prevent + naming conflicts within the module. + +This pass can be used in two distinct ways: + +**Mode 1: Command-line Usage** + +This mode is intended for debugging or testing, as it offers minimal control +over the attributes of the generated `stablehlo.composite` operations. +It wraps **all instances** of operations specified using the `op-names` +(a comma-separated list of operation names) options. The attributes of the +newly created `stablehlo.composite` operation will be the same as the +attributes of the original operation. + +**Usage Example:** + +```bash +stablehlo-opt input.mlir --stablehlo-wrap-in-composite=op-names='stablehlo.add,stablehlo.mul' -o output.mlir +``` + +**Mode 2: Programmatic Module-Wide Wrapping with customized Attribute Handling** + +This mode extends programmatic wrapping to the entire module, offering +fine-grained control over which operations are wrapped and their attributes. +This is achieved by using the `createStablehloWrapInCompositePass` API, +which takes an `CompositeAttributeProviderMap` as an argument. + +The `CompositeAttributeProviderMap` is a map that dictates which operations +should be considered for wrapping and how their attributes should be +handled. Its semantics are as follows: + +- **Keys (mlir::TypeID):** `TypeID` of an MLIR operation. If an operation's + `TypeID` matches a key in the map, it becomes a candidate for wrapping. +- **Values (Lambda Functions):** Lambda function of type + `std::function(Operation*)>`. This function + is applied to each candidate operation. + - **Input:** An `mlir::Operation*`, which is an instance of the + operation type corresponding to the `TypeID` key. + - **Return Value:** An `std::optional`. + - If the lambda returns a `NamedAttrList` (wrapped in + `std::optional`), the operation is wrapped in a + `stablehlo::composite` operation, and the returned attributes are + used to set the composite's attributes. + - If the lambda returns `std::nullopt`, the operation is **not** + wrapped. This allows for selective wrapping based on custom + criteria. + +**Example (C++):** + +```cpp + +stablehlo::CompositeAttributeProviderMap compositeAttributeProviderMap; + +compositeAttributeProviderMap[mlir::TypeID::get()] = + [](mlir::Operation* op) -> std::optional { + // Custom logic to determine if and how to wrap the operation. + // Example: Only wrap if it's on a specific type. + if (mlir::isa(op->getOperand(0).getType())) { + return mlir::NamedAttrList(op->getAttrs()); + } + return std::nullopt; // Do not wrap. +}; + +pm.addPass(createStablehloWrapInCompositePass(compositeAttributeProviderMap, compositeVersion)); +if (mlir::failed(pm.run(module))) { + return; +} +``` + +#### Options + +``` +-op-names : The names of the ops to wrap. +-version : The version number of the composite op. +``` + +### `-vhlo-legalize-to-stablehlo` + +_Legalize VHLO to StableHLO._ + +### `-vhlo-to-version` + +_Convert between versions of VHLO for compatibility._ + +Converts between versions of VHLO for IR upgrading and downgrading to +preserve forward and backward compatibility. + +```mlir +"vhlo.exponential_v2"(%[[ARG0]]) <{result_accuracy = DEFAULT}> +# ==( -target=1.0.0 )==> +"vhlo.exponential_v1"(%[[ARG0]]) +# ==( -target=1.9.0 )==> +"vhlo.exponential_v2"(%[[ARG0]]) <{result_accuracy = DEFAULT}> +``` + +See [vhlo.md > The VHLO dialect](https://github.com/openxla/stablehlo/blob/main/docs/vhlo.md) +for full details on how VHLO is used to preserve forward and backward +compatibility. + +#### Options + +``` +-target : The target version. Must be a version of the form #.#.# . +``` diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/abi.h b/deps/exla/cache/xla_extension/include/tsl/platform/abi.h new file mode 100644 index 0000000000000000000000000000000000000000..20f2fbf063ea38f09cae5ca0b6627f66d139c796 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/abi.h @@ -0,0 +1,31 @@ +/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_ABI_H_ +#define TENSORFLOW_TSL_PLATFORM_ABI_H_ + +#include + +#include "xla/tsl/platform/types.h" + +namespace tsl { +namespace port { + +std::string MaybeAbiDemangle(const char* name); + +} // namespace port +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_ABI_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/base64.h b/deps/exla/cache/xla_extension/include/tsl/platform/base64.h new file mode 100644 index 0000000000000000000000000000000000000000..08867207f6e76e6e398715e3504c0c018f9cd2c6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/base64.h @@ -0,0 +1,62 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_BASE64_H_ +#define TENSORFLOW_TSL_PLATFORM_BASE64_H_ + +#include + +#include "absl/status/status.h" +#include "xla/tsl/platform/status.h" +#include "tsl/platform/stringpiece.h" + +namespace tsl { + +/// \brief Converts data into web-safe base64 encoding. +/// +/// See https://en.wikipedia.org/wiki/Base64 +template +absl::Status Base64Encode(absl::string_view source, bool with_padding, + T* encoded); +template +absl::Status Base64Encode(absl::string_view source, + T* encoded); // with_padding=false. + +/// \brief Converts data from web-safe base64 encoding. +/// +/// See https://en.wikipedia.org/wiki/Base64 +template +absl::Status Base64Decode(absl::string_view data, T* decoded); + +// Explicit instantiations defined in base64.cc. +extern template Status Base64Decode(StringPiece data, + std::string* decoded); +extern template Status Base64Encode(StringPiece source, + std::string* encoded); +extern template Status Base64Encode(StringPiece source, + bool with_padding, + std::string* encoded); + +extern template Status Base64Decode(StringPiece data, + tstring* decoded); +extern template Status Base64Encode(StringPiece source, + tstring* encoded); +extern template Status Base64Encode(StringPiece source, + bool with_padding, + tstring* encoded); + +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_BASE64_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/bfloat16.h b/deps/exla/cache/xla_extension/include/tsl/platform/bfloat16.h new file mode 100644 index 0000000000000000000000000000000000000000..daf5e93eca56dcc65f2ea21176d6d0cf4962c410 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/bfloat16.h @@ -0,0 +1,27 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_BFLOAT16_H_ +#define TENSORFLOW_TSL_PLATFORM_BFLOAT16_H_ + +// clang-format off +#include "Eigen/Core" // from @eigen_archive +// clang-format on + +namespace tsl { +typedef Eigen::bfloat16 bfloat16; +} // end namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_BFLOAT16_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/blocking_counter.h b/deps/exla/cache/xla_extension/include/tsl/platform/blocking_counter.h new file mode 100644 index 0000000000000000000000000000000000000000..e46fc7591ba3ac45a8074c8635ea4970de5d488a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/blocking_counter.h @@ -0,0 +1,80 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_BLOCKING_COUNTER_H_ +#define TENSORFLOW_TSL_PLATFORM_BLOCKING_COUNTER_H_ + +#include + +#include "xla/tsl/platform/logging.h" +#include "tsl/platform/mutex.h" + +namespace tsl { + +class BlockingCounter { + public: + BlockingCounter(int initial_count) + : state_(initial_count << 1), notified_(false) { + CHECK_GE(initial_count, 0); + DCHECK_EQ((initial_count << 1) >> 1, initial_count); + } + + ~BlockingCounter() {} + + inline void DecrementCount() { + unsigned int v = state_.fetch_sub(2, std::memory_order_acq_rel) - 2; + if (v != 1) { + DCHECK_NE(((v + 2) & ~1), 0); + return; // either count has not dropped to 0, or waiter is not waiting + } + mutex_lock l(mu_); + DCHECK(!notified_); + notified_ = true; + cond_var_.notify_all(); + } + + inline void Wait() { + unsigned int v = state_.fetch_or(1, std::memory_order_acq_rel); + if ((v >> 1) == 0) return; + mutex_lock l(mu_); + while (!notified_) { + cond_var_.wait(l); + } + } + // Wait for the specified time, return false iff the count has not dropped to + // zero before the timeout expired. + inline bool WaitFor(std::chrono::milliseconds ms) { + unsigned int v = state_.fetch_or(1, std::memory_order_acq_rel); + if ((v >> 1) == 0) return true; + mutex_lock l(mu_); + while (!notified_) { + const std::cv_status status = cond_var_.wait_for(l, ms); + if (status == std::cv_status::timeout) { + return false; + } + } + return true; + } + + private: + mutex mu_; + condition_variable cond_var_; + std::atomic state_; // low bit is waiter flag + bool notified_; +}; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_BLOCKING_COUNTER_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/casts.h b/deps/exla/cache/xla_extension/include/tsl/platform/casts.h new file mode 100644 index 0000000000000000000000000000000000000000..8ec9f78e8a8901e49510dd7c0f7547d27f8a2a3a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/casts.h @@ -0,0 +1,31 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_CASTS_H_ +#define TENSORFLOW_TSL_PLATFORM_CASTS_H_ + +#include "tsl/platform/platform.h" + +#if defined(PLATFORM_GOOGLE) +#include "xla/tsl/platform/google/casts.h" // IWYU pragma: export +#elif defined(PLATFORM_POSIX) || defined(PLATFORM_POSIX_ANDROID) || \ + defined(PLATFORM_GOOGLE_ANDROID) || defined(PLATFORM_POSIX_IOS) || \ + defined(PLATFORM_GOOGLE_IOS) || defined(PLATFORM_WINDOWS) +#include "xla/tsl/platform/default/casts.h" // IWYU pragma: export +#else +#error Define the appropriate PLATFORM_ macro for this platform +#endif + +#endif // TENSORFLOW_TSL_PLATFORM_CASTS_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/context.h b/deps/exla/cache/xla_extension/include/tsl/platform/context.h new file mode 100644 index 0000000000000000000000000000000000000000..525436757c8602903ceaed873428c65d196bd6e5 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/context.h @@ -0,0 +1,47 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_CONTEXT_H_ +#define TENSORFLOW_TSL_PLATFORM_CONTEXT_H_ + +#include "tsl/platform/platform.h" + +namespace tsl { + +enum class ContextKind { + // Initial state with default (empty) values. + kDefault, + // Initial state inherited from the creating or scheduling thread. + kThread, +}; + +// Context is a container for request-specific information that should be passed +// to threads that perform related work. The default constructor should capture +// all relevant context. +class Context; + +// Scoped object that sets the current thread's context until the object is +// destroyed. +class WithContext; + +} // namespace tsl + +#if defined(PLATFORM_GOOGLE) +#include "xla/tsl/platform/google/context.h" // IWYU pragma: export +#else +#include "xla/tsl/platform/default/context.h" // IWYU pragma: export +#endif + +#endif // TENSORFLOW_TSL_PLATFORM_CONTEXT_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/cord.h b/deps/exla/cache/xla_extension/include/tsl/platform/cord.h new file mode 100644 index 0000000000000000000000000000000000000000..cb1233f576ae40805b2dc1c6a59a55cc555d6c03 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/cord.h @@ -0,0 +1,26 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_CORD_H_ +#define TENSORFLOW_TSL_PLATFORM_CORD_H_ + +// It seems CORD doesn't work well with CUDA <= 10.2 +#if !defined(__CUDACC__) || ((defined(__CUDACC__) && CUDA_VERSION > 10020)) +#include "absl/strings/cord.h" // IWYU pragma: export +#define TF_CORD_SUPPORT 1 + +#endif // __CUDACC__ + +#endif // TENSORFLOW_TSL_PLATFORM_CORD_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/cpu_info.h b/deps/exla/cache/xla_extension/include/tsl/platform/cpu_info.h new file mode 100644 index 0000000000000000000000000000000000000000..30eca5c41cea44e1ceaa4e85a290b38c542239b7 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/cpu_info.h @@ -0,0 +1,201 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_CPU_INFO_H_ +#define TENSORFLOW_TSL_PLATFORM_CPU_INFO_H_ + +#include + +// TODO(ahentz): This is not strictly required here but, for historical +// reasons, many people depend on cpu_info.h in order to use kLittleEndian. +#include "xla/tsl/platform/byte_order.h" +#include "tsl/platform/platform.h" + +#if defined(_MSC_VER) +// included so __cpuidex function is available for GETCPUID on Windows +#include +#endif + +namespace tsl { +namespace port { + +// Returns an estimate of the number of schedulable CPUs for this +// process. Usually, it's constant throughout the lifetime of a +// process, but it might change if the underlying cluster management +// software can change it dynamically. If the underlying call fails, a default +// value (e.g. `4`) may be returned. +int NumSchedulableCPUs(); + +// Returns an estimate for the maximum parallelism for this process. +// Applications should avoid running more than this number of threads with +// intensive workloads concurrently to avoid performance degradation and +// contention. +// This value is either the number of schedulable CPUs, or a value specific to +// the underlying cluster management. Applications should assume this value can +// change throughout the lifetime of the process. This function must not be +// called during initialization, i.e., before main() has started. +int MaxParallelism(); + +// Returns an estimate for the maximum parallelism for this process on the +// provided numa node, or any numa node if `numa_node` is kNUMANoAffinity. +// See MaxParallelism() for more information. +int MaxParallelism(int numa_node); + +// Returns the total number of CPUs on the system. This number should +// not change even if the underlying cluster management software may +// change the number of schedulable CPUs. Unlike `NumSchedulableCPUs`, if the +// underlying call fails, an invalid value of -1 will be returned; +// the user must check for validity. +static constexpr int kUnknownCPU = -1; +int NumTotalCPUs(); + +// Returns the id of the current CPU. Returns -1 if the current CPU cannot be +// identified. If successful, the return value will be in [0, NumTotalCPUs()). +int GetCurrentCPU(); + +// Returns an estimate of the number of hyperthreads per physical core +// on the CPU +int NumHyperthreadsPerCore(); + +// Mostly ISA related features that we care about +// Do not change numeric assignments. +enum CPUFeature { + //===--------------------------------------------------------------------===// + // x86 features + //===--------------------------------------------------------------------===// + MMX = 0, + SSE = 1, + SSE2 = 2, + SSE3 = 3, + SSSE3 = 4, + SSE4_1 = 5, + SSE4_2 = 6, + CMOV = 7, + CMPXCHG8B = 8, + CMPXCHG16B = 9, + POPCNT = 10, + AES = 11, + AVX = 12, + RDRAND = 13, + AVX2 = 14, + FMA = 15, + F16C = 16, + PCLMULQDQ = 17, + RDSEED = 18, + ADX = 19, + SMAP = 20, + + // Prefetch Vector Data Into Caches with Intent to Write and T1 Hint + // http://www.felixcloutier.com/x86/PREFETCHWT1.html. + // You probably want PREFETCHW instead. + PREFETCHWT1 = 21, + + BMI1 = 22, + BMI2 = 23, + HYPERVISOR = 25, // 0 when on a real CPU, 1 on (well-behaved) hypervisor. + + // Prefetch Data into Caches in Anticipation of a Write (3D Now!). + // http://www.felixcloutier.com/x86/PREFETCHW.html + PREFETCHW = 26, + + // AVX-512: 512-bit vectors (plus masking, etc.) in Knights Landing, + // Skylake, Xeon, etc. Each of these entries is a different subset of + // instructions, various combinations of which occur on various CPU types. + AVX512F = 27, // Foundation + AVX512CD = 28, // Conflict detection + AVX512ER = 29, // Exponential and reciprocal + AVX512PF = 30, // Prefetching + AVX512VL = 31, // Shorter vector lengths + AVX512BW = 32, // Byte and word + AVX512DQ = 33, // Dword and qword + AVX512VBMI = 34, // Bit manipulation + AVX512IFMA = 35, // Integer multiply-add + AVX512_4VNNIW = 36, // Integer neural network (Intel Xeon Phi only) + AVX512_4FMAPS = 37, // Floating point neural network (Intel Xeon Phi only) + AVX512_VNNI = 38, // Integer neural network + AVX512_BF16 = 39, // Bfloat16 neural network + + // AVX version of AVX512_VNNI in CPUs such as Alder Lake and Sapphire Rapids. + AVX_VNNI = 40, // Integer neural network + + // AMX: Advanced Matrix Extension in Sapphire Rapids. + // Perform matrix multiplication on the Tile Matrix Multiply (TMUL) unit, + // supporting two popular data types in neural networks, int8 and bfloat16. + AMX_TILE = 41, // Tile configuration and load/store + AMX_INT8 = 42, // Int8 tile matrix multiplication + AMX_BF16 = 43, // Bfloat16 tile matrix multiplication + + AVX512_FP16 = 44, // Float16 neural network + AMX_FP16 = 45, // Float16 tile matrix multiplication + AVX_NE_CONVERT = 46, // Instructions for faster bfloat16, float16 convert. + AVX_VNNI_INT8 = 47, // VNNI instructions for combinations of u8, s8 dtypes. + + //===--------------------------------------------------------------------===// + // AArch64 features + //===--------------------------------------------------------------------===// + AARCH64_NEON = 1000, + AARCH64_SVE = 1001, + AARCH64_SVE2 = 1002, + AARCH64_BF16 = 1003, // BF16 on AArch64 systems +}; + +enum Aarch64CPU { + ARM_NEOVERSE_N1 = 0, // ARM NEOVERSE N1 + ARM_NEOVERSE_V1 = 1, // ARM NEOVERSE V1 +}; +// Checks whether the current AArch64 processor is supported. +bool TestAarch64CPU(Aarch64CPU cpu); + +// Checks whether the current processor supports one of the features above. +// Checks CPU registers to return hardware capabilities. +bool TestCPUFeature(CPUFeature feature); + +// Checks whether the current processor is x86. +constexpr bool IsX86CPU() { +#ifdef PLATFORM_IS_X86 + return true; +#else + return false; +#endif +} + +// Checks whether the current processor is aarch64. +constexpr bool IsAarch64CPU() { +#if defined(PLATFORM_IS_ARM64) && !defined(__APPLE__) && !defined(__OpenBSD__) + return true; +#else + return false; +#endif +} + +// Returns CPU Vendor string (i.e. 'GenuineIntel', 'AuthenticAMD', etc.) +std::string CPUVendorIDString(); + +// Returns CPU family. +int CPUFamily(); + +// Returns CPU model number. +int CPUModelNum(); + +// Returns nominal core processor cycles per second of each processor. +double NominalCPUFrequency(); + +// Returns num of hyperthreads per physical core +int CPUIDNumSMT(); + +} // namespace port +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_CPU_INFO_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/ctstring.h b/deps/exla/cache/xla_extension/include/tsl/platform/ctstring.h new file mode 100644 index 0000000000000000000000000000000000000000..f841e5f4d22af5634ac5d94ec6ca0e4d07c44516 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/ctstring.h @@ -0,0 +1,123 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_CTSTRING_H_ +#define TENSORFLOW_TSL_PLATFORM_CTSTRING_H_ + +#include +#include + +#include "tsl/platform/ctstring_internal.h" + +// Initialize a new tstring. This must be called before using any function +// below. +inline void TF_TString_Init(TF_TString *str); +// Deallocate a tstring. +inline void TF_TString_Dealloc(TF_TString *str); + +// Resizes `str' to `new_size'. This function will appropriately grow or shrink +// the string buffer to fit a `new_size' string. Grown regions of the string +// will be initialized with `c'. +inline char *TF_TString_Resize(TF_TString *str, size_t new_size, char c); +// Similar to TF_TString_Resize, except the newly allocated regions will remain +// uninitialized. This is useful if you plan on overwriting the newly grown +// regions immediately after allocation; doing so will elide a superfluous +// initialization of the new buffer. +inline char *TF_TString_ResizeUninitialized(TF_TString *str, size_t new_size); +// Reserves a string buffer with a capacity of at least `new_cap'. +// Reserve will not change the size, or the contents of the existing +// string. This is useful if you have a rough idea of `str's upperbound in +// size, and want to avoid allocations as you append to `str'. It should not be +// considered safe to write in the region between size and capacity; explicitly +// resize before doing so. +inline void TF_TString_Reserve(TF_TString *str, size_t new_cap); +// Similar to TF_TString_Reserve, except that we ensure amortized growth, i.e. +// that we grow the capacity by at least a constant factor >1. +inline void TF_TString_ReserveAmortized(TF_TString *str, size_t new_cap); + +// Returns the size of the string. +inline size_t TF_TString_GetSize(const TF_TString *str); +// Returns the capacity of the string buffer. It should not be considered safe +// to write in the region between size and capacity---call Resize or +// ResizeUninitialized before doing so. +inline size_t TF_TString_GetCapacity(const TF_TString *str); +// Returns the underlying type of the tstring: +// TF_TSTR_SMALL: +// Small string optimization; the contents of strings +// less than 22-bytes are stored in the TF_TString struct. This avoids any +// heap allocations. +// TF_TSTR_LARGE: +// Heap allocated string. +// TF_TSTR_OFFSET: (currently unused) +// An offset defined string. The string buffer begins at an internally +// defined little-endian offset from `str'; i.e. GetDataPointer() = str + +// offset. This type is useful for memory mapping or reading string tensors +// directly from file, without the need to deserialize the data. For +// security reasons, it is imperative that OFFSET based string tensors are +// validated before use, or are from a trusted source. +// TF_TSTR_VIEW: +// A view into an unowned character string. +// +// NOTE: +// VIEW and OFFSET types are immutable, so any modifcation via Append, +// AppendN, or GetMutableDataPointer of a VIEW/OFFSET based tstring will +// result in a conversion to an owned type (SMALL/LARGE). +inline TF_TString_Type TF_TString_GetType(const TF_TString *str); + +// Returns a const char pointer to the start of the underlying string. The +// underlying character buffer may not be null-terminated. +inline const char *TF_TString_GetDataPointer(const TF_TString *str); +// Returns a char pointer to a mutable representation of the underlying string. +// In the case of VIEW and OFFSET types, `src' is converted to an owned type +// (SMALL/LARGE). The underlying character buffer may not be null-terminated. +inline char *TF_TString_GetMutableDataPointer(TF_TString *str); + +// Sets `dst' as a VIEW type to `src'. `dst' will not take ownership of `src'. +// It is the user's responsibility to ensure that the lifetime of `src' exceeds +// `dst'. Any mutations to `dst' via Append, AppendN, or GetMutableDataPointer, +// will result in a copy into an owned SMALL or LARGE type, and will not modify +// `src'. +inline void TF_TString_AssignView(TF_TString *dst, const char *src, + size_t size); + +// Appends `src' onto `dst'. If `dst' is a VIEW or OFFSET type, it will first +// be converted to an owned LARGE or SMALL type. `dst' should not point to +// memory owned by `src'. +inline void TF_TString_Append(TF_TString *dst, const TF_TString *src); +inline void TF_TString_AppendN(TF_TString *dst, const char *src, size_t size); + +// Copy/Move/Assign semantics +// +// | src | dst | complexity +// Copy | * | SMALL/LARGE | fixed/O(size) +// Assign | SMALL | SMALL | fixed +// Assign | OFFSET | VIEW | fixed +// Assign | VIEW | VIEW | fixed +// Assign | LARGE | LARGE | O(size) +// Move | * | same as src | fixed + +// Copies `src' to `dst'. `dst' will be an owned type (SMALL/LARGE). `src' +// should not point to memory owned by `dst'. +inline void TF_TString_Copy(TF_TString *dst, const char *src, size_t size); +// Assigns a `src' tstring to `dst'. An OFFSET `src' type will yield a `VIEW' +// `dst'. LARGE `src' types will be copied to a new buffer; all other `src' +// types will incur a fixed cost. +inline void TF_TString_Assign(TF_TString *dst, const TF_TString *src); +// Moves a `src' tstring to `dst'. Moving a LARGE `src' to `dst' will result in +// a valid but unspecified `src'. This function incurs a fixed cost for all +// inputs. +inline void TF_TString_Move(TF_TString *dst, TF_TString *src); + +#endif // TENSORFLOW_TSL_PLATFORM_CTSTRING_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/ctstring_internal.h b/deps/exla/cache/xla_extension/include/tsl/platform/ctstring_internal.h new file mode 100644 index 0000000000000000000000000000000000000000..43e909a8065aaaa70ddb26ab45a4e222d79ba574 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/ctstring_internal.h @@ -0,0 +1,455 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_CTSTRING_INTERNAL_H_ +#define TENSORFLOW_TSL_PLATFORM_CTSTRING_INTERNAL_H_ + +#include +#include +#include +#include + +#if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ + __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \ + defined(_WIN32) +#define TF_TSTRING_LITTLE_ENDIAN 1 +#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ + __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#define TF_TSTRING_LITTLE_ENDIAN 0 +#else +#error "Unable to detect endianness." +#endif + +#if defined(__clang__) || \ + (defined(__GNUC__) && \ + ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ >= 5)) +static inline uint32_t TF_swap32(uint32_t host_int) { + return __builtin_bswap32(host_int); +} + +#elif defined(_MSC_VER) +static inline uint32_t TF_swap32(uint32_t host_int) { + return _byteswap_ulong(host_int); +} + +#elif defined(__APPLE__) +static inline uint32_t TF_swap32(uint32_t host_int) { + return OSSwapInt32(host_int); +} + +#else +static inline uint32_t TF_swap32(uint32_t host_int) { +#if defined(__GLIBC__) + return bswap_32(host_int); +#else // defined(__GLIBC__) + return (((host_int & uint32_t{0xFF}) << 24) | + ((host_int & uint32_t{0xFF00}) << 8) | + ((host_int & uint32_t{0xFF0000}) >> 8) | + ((host_int & uint32_t{0xFF000000}) >> 24)); +#endif // defined(__GLIBC__) +} +#endif + +#if TF_TSTRING_LITTLE_ENDIAN +#define TF_le32toh(x) x +#else // TF_TSTRING_LITTLE_ENDIAN +#define TF_le32toh(x) TF_swap32(x) +#endif // TF_TSTRING_LITTLE_ENDIAN + +static inline size_t TF_align16(size_t i) { return (i + 0xF) & ~0xF; } + +static inline size_t TF_max(size_t a, size_t b) { return a > b ? a : b; } +static inline size_t TF_min(size_t a, size_t b) { return a < b ? a : b; } + +typedef enum TF_TString_Type { // NOLINT + TF_TSTR_SMALL = 0x00, + TF_TSTR_LARGE = 0x01, + TF_TSTR_OFFSET = 0x02, + TF_TSTR_VIEW = 0x03, + TF_TSTR_TYPE_MASK = 0x03 +} TF_TString_Type; + +typedef struct TF_TString_Large { // NOLINT + size_t size; + size_t cap; + char *ptr; +} TF_TString_Large; + +typedef struct TF_TString_Offset { // NOLINT + uint32_t size; + uint32_t offset; + uint32_t count; +} TF_TString_Offset; + +typedef struct TF_TString_View { // NOLINT + size_t size; + const char *ptr; +} TF_TString_View; + +typedef struct TF_TString_Raw { // NOLINT + uint8_t raw[24]; +} TF_TString_Raw; + +typedef union TF_TString_Union { // NOLINT + TF_TString_Large large; + TF_TString_Offset offset; + TF_TString_View view; + TF_TString_Raw raw; +} TF_TString_Union; + +enum { + TF_TString_SmallCapacity = + (sizeof(TF_TString_Union) - sizeof(/* null delim */ char) - + sizeof(/* uint8_t size */ uint8_t)), +}; + +typedef struct TF_TString_Small { // NOLINT + uint8_t size; + char str[TF_TString_SmallCapacity + sizeof(/* null delim */ char)]; +} TF_TString_Small; + +typedef struct TF_TString { // NOLINT + union { + // small conflicts with '#define small char' in RpcNdr.h for MSVC, so we use + // smll instead. + TF_TString_Small smll; + TF_TString_Large large; + TF_TString_Offset offset; + TF_TString_View view; + TF_TString_Raw raw; + } u; +} TF_TString; + +// TODO(dero): Fix for OSS, and add C only build test. +// _Static_assert(CHAR_BIT == 8); +// _Static_assert(sizeof(TF_TString) == 24); + +static inline TF_TString_Type TF_TString_GetType(const TF_TString *str) { + return (TF_TString_Type)(str->u.raw.raw[0] & TF_TSTR_TYPE_MASK); // NOLINT +} + +// XXX(dero): For the big-endian case, this function could potentially be more +// performant and readable by always storing the string size as little-endian +// and always byte-swapping on big endian, resulting in a simple 'bswap'+'shr' +// (for architectures that have a bswap op). +static inline size_t TF_TString_ToActualSizeT(size_t size) { +#if TF_TSTRING_LITTLE_ENDIAN + return size >> 2; +#else // TF_TSTRING_LITTLE_ENDIAN + // 0xFF000000 or 0xFF00000000000000 depending on platform + static const size_t mask = ~((~(size_t)0) >> 8); + + return (((mask << 2) & size) >> 2) | (~mask & size); +#endif // TF_TSTRING_LITTLE_ENDIAN +} + +static inline size_t TF_TString_ToInternalSizeT(size_t size, + TF_TString_Type type) { +#if TF_TSTRING_LITTLE_ENDIAN + return (size << 2) | type; +#else // TF_TSTRING_LITTLE_ENDIAN + // 0xFF000000 or 0xFF00000000000000 depending on platform + static const size_t mask = ~((~(size_t)0) >> 8); + + return (mask & (size << 2)) | (~mask & size) | + ((size_t)type << ((sizeof(size_t) - 1) * 8)); // NOLINT +#endif // TF_TSTRING_LITTLE_ENDIAN +} + +static inline void TF_TString_Init(TF_TString *str) { + memset(str->u.raw.raw, 0, sizeof(TF_TString_Raw)); +} + +static inline void TF_TString_Dealloc(TF_TString *str) { + if (TF_TString_GetType(str) == TF_TSTR_LARGE && + str->u.large.ptr != NULL) { // NOLINT + free(str->u.large.ptr); + TF_TString_Init(str); + } +} + +static inline size_t TF_TString_GetSize(const TF_TString *str) { + switch (TF_TString_GetType(str)) { + case TF_TSTR_SMALL: + return str->u.smll.size >> 2; + case TF_TSTR_LARGE: + return TF_TString_ToActualSizeT(str->u.large.size); + case TF_TSTR_OFFSET: + return TF_le32toh(str->u.offset.size) >> 2; + case TF_TSTR_VIEW: + return TF_TString_ToActualSizeT(str->u.view.size); + default: + return 0; // Unreachable. + } +} + +static inline size_t TF_TString_GetCapacity(const TF_TString *str) { + switch (TF_TString_GetType(str)) { + case TF_TSTR_SMALL: + return TF_TString_SmallCapacity; + case TF_TSTR_LARGE: + return str->u.large.cap; + case TF_TSTR_OFFSET: + case TF_TSTR_VIEW: + default: + return 0; + } +} + +static inline const char *TF_TString_GetDataPointer(const TF_TString *str) { + switch (TF_TString_GetType(str)) { + case TF_TSTR_SMALL: + return str->u.smll.str; + case TF_TSTR_LARGE: + return str->u.large.ptr; + case TF_TSTR_OFFSET: + return (const char *)str + TF_le32toh(str->u.offset.offset); // NOLINT + case TF_TSTR_VIEW: + return str->u.view.ptr; + default: + // Unreachable. + return NULL; // NOLINT + } +} + +static inline char *TF_TString_ResizeUninitialized(TF_TString *str, + size_t new_size) { + size_t curr_size = TF_TString_GetSize(str); + size_t copy_size = TF_min(new_size, curr_size); + + TF_TString_Type curr_type = TF_TString_GetType(str); + const char *curr_ptr = TF_TString_GetDataPointer(str); + + // Case: SMALL/LARGE/VIEW/OFFSET -> SMALL + if (new_size <= TF_TString_SmallCapacity) { + str->u.smll.size = (uint8_t)((new_size << 2) | TF_TSTR_SMALL); // NOLINT + str->u.smll.str[new_size] = '\0'; + + if (curr_type != TF_TSTR_SMALL && copy_size) { + memcpy(str->u.smll.str, curr_ptr, copy_size); + } + + if (curr_type == TF_TSTR_LARGE) { + free((void *)curr_ptr); // NOLINT + } + + // We do not clear out the newly excluded region. + + return str->u.smll.str; + } + + // Case: SMALL/LARGE/VIEW/OFFSET -> LARGE + size_t new_cap; + size_t curr_cap = TF_TString_GetCapacity(str); + + if (new_size < curr_size && new_size < curr_cap / 2) { + // TODO(dero): Replace with shrink_to_fit flag. + new_cap = TF_align16(curr_cap / 2 + 1) - 1; + } else if (new_size > curr_cap) { + new_cap = TF_align16(new_size + 1) - 1; + } else { + new_cap = curr_cap; + } + + char *new_ptr; + if (new_cap == curr_cap) { + new_ptr = str->u.large.ptr; + } else if (curr_type == TF_TSTR_LARGE) { + new_ptr = (char *)realloc(str->u.large.ptr, new_cap + 1); // NOLINT + } else { + new_ptr = (char *)malloc(new_cap + 1); // NOLINT + if (copy_size) { + memcpy(new_ptr, curr_ptr, copy_size); + } + } + + str->u.large.size = TF_TString_ToInternalSizeT(new_size, TF_TSTR_LARGE); + str->u.large.ptr = new_ptr; + str->u.large.ptr[new_size] = '\0'; + str->u.large.cap = new_cap; + + return str->u.large.ptr; +} + +static inline char *TF_TString_GetMutableDataPointer(TF_TString *str) { + switch (TF_TString_GetType(str)) { + case TF_TSTR_SMALL: + return str->u.smll.str; + case TF_TSTR_OFFSET: + case TF_TSTR_VIEW: + // Convert OFFSET/VIEW to SMALL/LARGE + TF_TString_ResizeUninitialized(str, TF_TString_GetSize(str)); + return (TF_TString_GetType(str) == TF_TSTR_SMALL) ? str->u.smll.str + : str->u.large.ptr; + case TF_TSTR_LARGE: + return str->u.large.ptr; + default: + // Unreachable. + return NULL; // NOLINT + } +} + +static inline void TF_TString_Reserve(TF_TString *str, size_t new_cap) { + TF_TString_Type curr_type = TF_TString_GetType(str); + + if (new_cap <= TF_TString_SmallCapacity) { + // We do nothing, we let Resize/GetMutableDataPointer handle the + // conversion to SMALL from VIEW/OFFSET when the need arises. + // In the degenerate case, where new_cap <= TF_TString_SmallCapacity, + // curr_size > TF_TString_SmallCapacity, and the type is VIEW/OFFSET, we + // defer the malloc to Resize/GetMutableDataPointer. + return; + } + + if (curr_type == TF_TSTR_LARGE && new_cap <= str->u.large.cap) { + // We handle reduced cap in resize. + return; + } + + // Case: VIEW/OFFSET -> LARGE or grow an existing LARGE type + size_t curr_size = TF_TString_GetSize(str); + const char *curr_ptr = TF_TString_GetDataPointer(str); + + // Since VIEW and OFFSET types are read-only, their capacity is effectively 0. + // So we make sure we have enough room in the VIEW and OFFSET cases. + new_cap = TF_align16(TF_max(new_cap, curr_size) + 1) - 1; + + if (curr_type == TF_TSTR_LARGE) { + str->u.large.ptr = + (char *)realloc(str->u.large.ptr, new_cap + 1); // NOLINT + } else { + // Convert to Large + char *new_ptr = (char *)malloc(new_cap + 1); // NOLINT + memcpy(new_ptr, curr_ptr, curr_size); + + str->u.large.size = TF_TString_ToInternalSizeT(curr_size, TF_TSTR_LARGE); + str->u.large.ptr = new_ptr; + str->u.large.ptr[curr_size] = '\0'; + } + + str->u.large.cap = new_cap; +} + +static inline void TF_TString_ReserveAmortized(TF_TString *str, + size_t new_cap) { + const size_t curr_cap = TF_TString_GetCapacity(str); + if (new_cap > curr_cap) { + TF_TString_Reserve(str, new_cap > 2 * curr_cap ? new_cap : 2 * curr_cap); + } +} + +static inline char *TF_TString_Resize(TF_TString *str, size_t new_size, + char c) { + size_t curr_size = TF_TString_GetSize(str); + char *cstr = TF_TString_ResizeUninitialized(str, new_size); + + if (new_size > curr_size) { + memset(cstr + curr_size, c, new_size - curr_size); + } + + return cstr; +} + +static inline void TF_TString_AssignView(TF_TString *dst, const char *src, + size_t size) { + TF_TString_Dealloc(dst); + + dst->u.view.size = TF_TString_ToInternalSizeT(size, TF_TSTR_VIEW); + dst->u.view.ptr = src; +} + +static inline void TF_TString_AppendN(TF_TString *dst, const char *src, + size_t src_size) { + if (!src_size) return; + + size_t dst_size = TF_TString_GetSize(dst); + + // For append use cases, we want to ensure amortized growth. + TF_TString_ReserveAmortized(dst, dst_size + src_size); + char *dst_c = TF_TString_ResizeUninitialized(dst, dst_size + src_size); + + memcpy(dst_c + dst_size, src, src_size); +} + +static inline void TF_TString_Append(TF_TString *dst, const TF_TString *src) { + const char *src_c = TF_TString_GetDataPointer(src); + size_t size = TF_TString_GetSize(src); + + TF_TString_AppendN(dst, src_c, size); +} + +static inline void TF_TString_Copy(TF_TString *dst, const char *src, + size_t size) { + char *dst_c = TF_TString_ResizeUninitialized(dst, size); + + if (size) memcpy(dst_c, src, size); +} + +static inline void TF_TString_Assign(TF_TString *dst, const TF_TString *src) { + if (dst == src) return; + + TF_TString_Dealloc(dst); + + switch (TF_TString_GetType(src)) { + case TF_TSTR_SMALL: + case TF_TSTR_VIEW: + *dst = *src; + return; + case TF_TSTR_LARGE: { + const char *src_c = TF_TString_GetDataPointer(src); + size_t size = TF_TString_GetSize(src); + + TF_TString_Copy(dst, src_c, size); + } + return; + case TF_TSTR_OFFSET: { + const char *src_c = TF_TString_GetDataPointer(src); + size_t size = TF_TString_GetSize(src); + + TF_TString_AssignView(dst, src_c, size); + } + return; + default: + return; // Unreachable. + } +} + +static inline void TF_TString_Move(TF_TString *dst, TF_TString *src) { + if (dst == src) return; + + TF_TString_Dealloc(dst); + + switch (TF_TString_GetType(src)) { + case TF_TSTR_SMALL: + case TF_TSTR_VIEW: + *dst = *src; + return; + case TF_TSTR_LARGE: + *dst = *src; + TF_TString_Init(src); + return; + case TF_TSTR_OFFSET: { + const char *src_c = TF_TString_GetDataPointer(src); + size_t size = TF_TString_GetSize(src); + + TF_TString_AssignView(dst, src_c, size); + } + return; + default: + return; // Unreachable. + } +} + +#endif // TENSORFLOW_TSL_PLATFORM_CTSTRING_INTERNAL_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/demangle.h b/deps/exla/cache/xla_extension/include/tsl/platform/demangle.h new file mode 100644 index 0000000000000000000000000000000000000000..4b7576f8dc4f31fbacbc314c01adff0273e61b68 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/demangle.h @@ -0,0 +1,34 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_DEMANGLE_H_ +#define TENSORFLOW_TSL_PLATFORM_DEMANGLE_H_ + +#include "xla/tsl/platform/types.h" + +namespace tsl { +namespace port { + +// If the compiler supports, demangle a mangled symbol name and return +// the demangled name. Otherwise, returns 'mangled' as is. +string Demangle(const char* mangled); +inline string Demangle(const string mangled) { + return Demangle(mangled.c_str()); +} + +} // namespace port +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_DEMANGLE_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/denormal.h b/deps/exla/cache/xla_extension/include/tsl/platform/denormal.h new file mode 100644 index 0000000000000000000000000000000000000000..05e52d3ceae4f7513f4c7516eb9efcf278f09327 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/denormal.h @@ -0,0 +1,94 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_DENORMAL_H_ +#define TENSORFLOW_TSL_PLATFORM_DENORMAL_H_ + +#include "xla/tsl/platform/macros.h" + +namespace tsl { +namespace port { + +// State for handling of denormals. +class DenormalState { + public: + DenormalState(bool flush_to_zero, bool denormals_are_zero) + : flush_to_zero_(flush_to_zero), + denormals_are_zero_(denormals_are_zero) {} + + // Output denormals of floating-point operations are flushed to zero. + inline bool flush_to_zero() const { return flush_to_zero_; } + + // Input denormals to floating-point operations are treated as zero. + inline bool denormals_are_zero() const { return denormals_are_zero_; } + + bool operator==(const DenormalState& other) const; + bool operator!=(const DenormalState& other) const; + + private: + bool flush_to_zero_; + bool denormals_are_zero_; +}; + +// Gets the platform's current state for handling denormals. +DenormalState GetDenormalState(); + +// Sets handling of denormals if the platform allows it. Returns `true` if the +// platform supports setting denormals to the specified state. Otherwise the +// denormal state remains unmodified and false is returned. +bool SetDenormalState(const DenormalState& state); + +// Remembers the flush denormal state on construction and restores that same +// state on destruction. +class ScopedRestoreFlushDenormalState { + public: + ScopedRestoreFlushDenormalState(); + ~ScopedRestoreFlushDenormalState(); + + private: + DenormalState denormal_state_; + ScopedRestoreFlushDenormalState(const ScopedRestoreFlushDenormalState&) = + delete; + void operator=(const ScopedRestoreFlushDenormalState&) = delete; +}; + +// While this class is active, denormal floating point numbers are flushed +// to zero. The destructor restores the original flags. +class ScopedFlushDenormal { + public: + ScopedFlushDenormal(); + + private: + ScopedRestoreFlushDenormalState restore_; + ScopedFlushDenormal(const ScopedFlushDenormal&) = delete; + void operator=(const ScopedFlushDenormal&) = delete; +}; + +// While this class is active, denormal floating point numbers are not flushed +// to zero. The destructor restores the original flags. +class ScopedDontFlushDenormal { + public: + ScopedDontFlushDenormal(); + + private: + ScopedRestoreFlushDenormalState restore_; + ScopedDontFlushDenormal(const ScopedDontFlushDenormal&) = delete; + void operator=(const ScopedDontFlushDenormal&) = delete; +}; + +} // namespace port +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_DENORMAL_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/env.h b/deps/exla/cache/xla_extension/include/tsl/platform/env.h new file mode 100644 index 0000000000000000000000000000000000000000..806cbb1c9860bb7ae1a3b21e45b75a15f8ec3cbe --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/env.h @@ -0,0 +1,21 @@ +/* Copyright 2024 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_ENV_H_ +#define TENSORFLOW_TSL_PLATFORM_ENV_H_ + +#include "xla/tsl/platform/env.h" + +#endif // TENSORFLOW_TSL_PLATFORM_ENV_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/errors.h b/deps/exla/cache/xla_extension/include/tsl/platform/errors.h new file mode 100644 index 0000000000000000000000000000000000000000..0c28bd4188db2146c550398ee1ee1a696e644533 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/errors.h @@ -0,0 +1,21 @@ +/* Copyright 2024 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_ERRORS_H_ +#define TENSORFLOW_TSL_PLATFORM_ERRORS_H_ + +#include "xla/tsl/platform/errors.h" + +#endif // TENSORFLOW_TSL_PLATFORM_ERRORS_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/file_system.h b/deps/exla/cache/xla_extension/include/tsl/platform/file_system.h new file mode 100644 index 0000000000000000000000000000000000000000..8d55471a5766f23e5a8be8cac5d838ee68f1f2cf --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/file_system.h @@ -0,0 +1,21 @@ +/* Copyright 2024 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_FILE_SYSTEM_H_ +#define TENSORFLOW_TSL_PLATFORM_FILE_SYSTEM_H_ + +#include "xla/tsl/platform/file_system.h" + +#endif // TENSORFLOW_TSL_PLATFORM_FILE_SYSTEM_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/file_system_helper.h b/deps/exla/cache/xla_extension/include/tsl/platform/file_system_helper.h new file mode 100644 index 0000000000000000000000000000000000000000..49a0bd1c2a8f82491533a1e1af2b8dfa79abd74c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/file_system_helper.h @@ -0,0 +1,21 @@ +/* Copyright 2024 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_FILE_SYSTEM_HELPER_H_ +#define TENSORFLOW_TSL_PLATFORM_FILE_SYSTEM_HELPER_H_ + +#include "xla/tsl/platform/file_system_helper.h" + +#endif // TENSORFLOW_TSL_PLATFORM_FILE_SYSTEM_HELPER_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/fingerprint.h b/deps/exla/cache/xla_extension/include/tsl/platform/fingerprint.h new file mode 100644 index 0000000000000000000000000000000000000000..9f25d7cdfb16b87d713beb6808100fe49644f269 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/fingerprint.h @@ -0,0 +1,144 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_FINGERPRINT_H_ +#define TENSORFLOW_TSL_PLATFORM_FINGERPRINT_H_ + +#include +#include +#include + +#include "xla/tsl/platform/types.h" +#include "tsl/platform/platform.h" +#include "tsl/platform/stringpiece.h" + +#if TSL_IS_IN_OSS +#define USE_OSS_FARMHASH +#endif // TSL_IS_IN_OSS + +#ifdef USE_OSS_FARMHASH +#include +#else +#include "util/hash/farmhash_fingerprint.h" +#endif + +namespace tsl { + +struct Fprint128 { + uint64_t low64; + uint64_t high64; +}; + +inline bool operator==(const Fprint128& lhs, const Fprint128& rhs) { + return lhs.low64 == rhs.low64 && lhs.high64 == rhs.high64; +} + +struct Fprint128Hasher { + size_t operator()(const Fprint128& v) const { + // Low64 should be sufficiently mixed to allow use of it as a Hash. + return static_cast(v.low64); + } +}; + +namespace internal { +// Mixes some of the bits that got propagated to the high bits back into the +// low bits. +inline uint64_t ShiftMix(const uint64_t val) { return val ^ (val >> 47); } +} // namespace internal + +// This concatenates two 64-bit fingerprints. It is a convenience function to +// get a fingerprint for a combination of already fingerprinted components. For +// example this code is used to concatenate the hashes from each of the features +// on sparse crosses. +// +// One shouldn't expect FingerprintCat64(Fingerprint64(x), Fingerprint64(y)) +// to indicate anything about FingerprintCat64(StrCat(x, y)). This operation +// is not commutative. +// +// From a security standpoint, we don't encourage this pattern to be used +// for everything as it is vulnerable to length-extension attacks and it +// is easier to compute multicollisions. +inline uint64_t FingerprintCat64(const uint64_t fp1, const uint64_t fp2) { + static const uint64_t kMul = 0xc6a4a7935bd1e995ULL; + uint64_t result = fp1 ^ kMul; + result ^= internal::ShiftMix(fp2 * kMul) * kMul; + result *= kMul; + result = internal::ShiftMix(result) * kMul; + result = internal::ShiftMix(result); + return result; +} + +// This is a portable fingerprint interface for strings that will never change. +// However, it is not suitable for cryptography. +inline uint64_t Fingerprint64(const absl::string_view s) { +#ifdef USE_OSS_FARMHASH + return ::util::Fingerprint64(s.data(), s.size()); +#else + // Fingerprint op depends on the fact that Fingerprint64() is implemented by + // Farmhash. If the implementation ever changes, Fingerprint op should be + // modified to keep using Farmhash. + // LINT.IfChange + return farmhash::Fingerprint64(s.data(), s.size()); + // LINT.ThenChange(//tensorflow/core/kernels/fingerprint_op.cc) +#endif +} + +// 32-bit variant of Fingerprint64 above (same properties and caveats apply). +inline uint32_t Fingerprint32(const absl::string_view s) { +#ifdef USE_OSS_FARMHASH + return ::util::Fingerprint32(s.data(), s.size()); +#else + return farmhash::Fingerprint32(s.data(), s.size()); +#endif +} + +// 128-bit variant of Fingerprint64 above (same properties and caveats apply). +inline Fprint128 Fingerprint128(const absl::string_view s) { +#ifdef USE_OSS_FARMHASH + const auto fingerprint = ::util::Fingerprint128(s.data(), s.size()); + return {::util::Uint128Low64(fingerprint), + ::util::Uint128High64(fingerprint)}; +#else + const auto fingerprint = farmhash::Fingerprint128(s.data(), s.size()); + return {absl::Uint128Low64(fingerprint), absl::Uint128High64(fingerprint)}; +#endif +} + +inline Fprint128 FingerprintCat128(const Fprint128& a, const Fprint128& b) { + return {FingerprintCat64(a.low64, b.low64), + FingerprintCat64(a.high64, b.high64)}; +} + +inline Fprint128 FingerprintCat128(const Fprint128& a, const uint64_t b) { + auto x = FingerprintCat64(a.low64, b); + return {x, FingerprintCat64(a.high64, x)}; +} + +inline std::array Fprint128ToBytes(tsl::Fprint128 fprint) { + static_assert(sizeof(char) == 1, "Size of char is not 1 bytes."); + static_assert(CHAR_BIT == 8, "Size of byte is not 8 bits."); + std::array result; + for (int i = 0; i < 8; ++i) { + result[8 - i - 1] = fprint.low64 & 0xFF; + result[16 - i - 1] = fprint.high64 & 0xFF; + fprint.low64 >>= 8; + fprint.high64 >>= 8; + } + return result; +} + +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_FINGERPRINT_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/hash.h b/deps/exla/cache/xla_extension/include/tsl/platform/hash.h new file mode 100644 index 0000000000000000000000000000000000000000..174b233c2d3b25cd3f0032df7f504997dd830672 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/hash.h @@ -0,0 +1,135 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// Simple hash functions used for internal data structures + +#ifndef TENSORFLOW_TSL_PLATFORM_HASH_H_ +#define TENSORFLOW_TSL_PLATFORM_HASH_H_ + +#include +#include + +#include +#include + +#include "xla/tsl/platform/types.h" +#include "tsl/platform/stringpiece.h" + +namespace tsl { + +extern uint32 Hash32(const char* data, size_t n, uint32 seed); +extern uint64 Hash64(const char* data, size_t n, uint64 seed); + +inline uint64 Hash64(const char* data, size_t n) { + return Hash64(data, n, 0xDECAFCAFFE); +} + +inline uint64 Hash64(const char* data) { return Hash64(data, ::strlen(data)); } + +inline uint64 Hash64(const std::string& str) { + return Hash64(str.data(), str.size()); +} + +inline uint64 Hash64(const tstring& str) { + return Hash64(str.data(), str.size()); +} + +inline uint64 Hash64Combine(uint64 a, uint64 b) { + return a ^ (b + 0x9e3779b97f4a7800ULL + (a << 10) + (a >> 4)); +} + +// Combine two hashes in an order-independent way. This operation should be +// associative and compute the same hash for a collection of elements +// independent of traversal order. Note that it is better to combine hashes +// symmetrically with addition rather than XOR, since (x^x) == 0 but (x+x) != 0. +inline uint64 Hash64CombineUnordered(uint64 a, uint64 b) { return a + b; } + +// Hash functor suitable for use with power-of-two sized hashtables. Use +// instead of std::hash. +// +// In particular, tsl::hash is not the identity function for pointers. +// This is important for power-of-two sized hashtables like FlatMap and FlatSet, +// because otherwise they waste the majority of their hash buckets. +// +// The second type argument is only used for SFNIAE below. +template +struct hash { + size_t operator()(const T& t) const { return std::hash()(t); } +}; + +template +struct hash::value>::type> { + size_t operator()(T value) const { + // This works around a defect in the std::hash C++ spec that isn't fixed in + // (at least) gcc 4.8.4: + // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2148 + // + // We should be able to remove this and use the default + // tsl::hash() once we stop building with GCC versions old + // enough to not have this defect fixed. + return std::hash()(static_cast(value)); + } +}; + +template +struct hash { + size_t operator()(const T* t) const { + // Hash pointers as integers, but bring more entropy to the lower bits. + size_t k = static_cast(reinterpret_cast(t)); + return k + (k >> 6); + } +}; + +template <> +struct hash { + size_t operator()(const string& s) const { + return static_cast(Hash64(s)); + } +}; + +template <> +struct hash { + size_t operator()(const tstring& s) const { + return static_cast(Hash64(s.data(), s.size())); + } +}; + +template <> +struct hash { + size_t operator()(absl::string_view sp) const { + return static_cast(Hash64(sp.data(), sp.size())); + } +}; +using StringPieceHasher = ::tsl::hash; + +template +struct hash> { + size_t operator()(const std::pair& p) const { + return Hash64Combine(hash()(p.first), hash()(p.second)); + } +}; + +} // namespace tsl + +namespace std { +template <> +struct hash { + size_t operator()(const tsl::tstring& s) const { + return static_cast(tsl::Hash64(s.data(), s.size())); + } +}; +} // namespace std + +#endif // TENSORFLOW_TSL_PLATFORM_HASH_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/host_info.h b/deps/exla/cache/xla_extension/include/tsl/platform/host_info.h new file mode 100644 index 0000000000000000000000000000000000000000..687045c02c1a6e389fa3a2b86cefad9a718d3b56 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/host_info.h @@ -0,0 +1,58 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_HOST_INFO_H_ +#define TENSORFLOW_TSL_PLATFORM_HOST_INFO_H_ + +#include + +#include "xla/tsl/platform/types.h" + +namespace tsl { +namespace port { + +// Statistical data of IO operations performed by the job. +struct IOStatistics { + struct Distribution { + uint64_t count = 0; + double mean = 0.0; + double std_dev = 0.0; + }; + // Distribution of round trip IO latency in microseconds. + Distribution roundtrip_latency_usec; + // Distribution of data received by IO reads in bytes. + Distribution response_bytes; +}; + +// Return the hostname of the machine on which this process is running. +string Hostname(); + +// Return the job name as a string if it exists, otherwise return an empty +// string. +string JobName(); + +// Returns the Borg job UID as an int64_t if it exists. Otherwise return -1. +int64_t JobUid(); + +// Returns the Borg task ID as an int64_t if it exists. Otherwise return -1. +int64_t TaskId(); + +// Retrieves the host file read statistics. +IOStatistics GetIOStatistics(); + +} // namespace port +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_HOST_INFO_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/human_readable_json.h b/deps/exla/cache/xla_extension/include/tsl/platform/human_readable_json.h new file mode 100644 index 0000000000000000000000000000000000000000..3fedff0630e964cafc2132110dea6de1754a0f09 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/human_readable_json.h @@ -0,0 +1,50 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_HUMAN_READABLE_JSON_H_ +#define TENSORFLOW_TSL_PLATFORM_HUMAN_READABLE_JSON_H_ + +#include + +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "xla/tsl/platform/types.h" +#include "tsl/platform/protobuf.h" + +namespace tsl { + +// Converts a proto to a JSON-like string that's meant to be human-readable +// but still machine-parseable. +// +// This string may not be strictly JSON-compliant, but it must be parsable by +// HumanReadableJSONToProto. +// +// When ignore_accuracy_loss = true, this function may ignore JavaScript +// accuracy loss with large integers. +absl::StatusOr ProtoToHumanReadableJson( + const protobuf::Message& proto, bool ignore_accuracy_loss); +absl::StatusOr ProtoToHumanReadableJson( + const protobuf::MessageLite& proto, bool ignore_accuracy_loss); + +// Converts a string produced by ProtoToHumanReadableJSON to a protobuf. Not +// guaranteed to work for general JSON. +absl::Status HumanReadableJsonToProto(const string& str, + protobuf::Message* proto); +absl::Status HumanReadableJsonToProto(const string& str, + protobuf::MessageLite* proto); + +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_HUMAN_READABLE_JSON_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/init_main.h b/deps/exla/cache/xla_extension/include/tsl/platform/init_main.h new file mode 100644 index 0000000000000000000000000000000000000000..c02c1e8d1db2ba776c570e4e243a858df004ff3f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/init_main.h @@ -0,0 +1,27 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_INIT_MAIN_H_ +#define TENSORFLOW_TSL_PLATFORM_INIT_MAIN_H_ + +namespace tsl { +namespace port { + +void InitMain(const char* usage, int* argc, char*** argv); + +} // namespace port +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_INIT_MAIN_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/load_library.h b/deps/exla/cache/xla_extension/include/tsl/platform/load_library.h new file mode 100644 index 0000000000000000000000000000000000000000..5a42f2a3439fd00877e9e02625fea3c5e544f093 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/load_library.h @@ -0,0 +1,37 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_LOAD_LIBRARY_H_ +#define TENSORFLOW_TSL_PLATFORM_LOAD_LIBRARY_H_ + +#include + +#include "absl/status/status.h" + +namespace tsl { + +namespace internal { + +absl::Status LoadDynamicLibrary(const char* library_filename, void** handle); +absl::Status GetSymbolFromLibrary(void* handle, const char* symbol_name, + void** symbol); +std::string FormatLibraryFileName(const std::string& name, + const std::string& version); + +} // namespace internal + +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_LOAD_LIBRARY_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/logging.h b/deps/exla/cache/xla_extension/include/tsl/platform/logging.h new file mode 100644 index 0000000000000000000000000000000000000000..193cb9b5118f5d8a68b1ed2a999a6f64e21eced1 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/logging.h @@ -0,0 +1,21 @@ +/* Copyright 2024 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_LOGGING_H_ +#define TENSORFLOW_TSL_PLATFORM_LOGGING_H_ + +#include "xla/tsl/platform/logging.h" + +#endif // TENSORFLOW_TSL_PLATFORM_LOGGING_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/macros.h b/deps/exla/cache/xla_extension/include/tsl/platform/macros.h new file mode 100644 index 0000000000000000000000000000000000000000..960d7ed2e2accfc6a8781acb116a802a97e9e582 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/macros.h @@ -0,0 +1,21 @@ +/* Copyright 2024 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_MACROS_H_ +#define TENSORFLOW_TSL_PLATFORM_MACROS_H_ + +#include "xla/tsl/platform/macros.h" + +#endif // TENSORFLOW_TSL_PLATFORM_MACROS_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/mem.h b/deps/exla/cache/xla_extension/include/tsl/platform/mem.h new file mode 100644 index 0000000000000000000000000000000000000000..f88b4e1b197ef2fb6aba5855b0ab93d39d3b26ab --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/mem.h @@ -0,0 +1,105 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_MEM_H_ +#define TENSORFLOW_TSL_PLATFORM_MEM_H_ + +#include +#include + +// TODO(cwhipkey): remove this when callers use annotations directly. +#include "xla/tsl/platform/dynamic_annotations.h" +#include "xla/tsl/platform/types.h" +#include "tsl/platform/platform.h" + +namespace tsl { +namespace port { + +// Aligned allocation/deallocation. `minimum_alignment` must be a power of 2 +// and a multiple of sizeof(void*). +void* AlignedMalloc(size_t size, int minimum_alignment); +void AlignedFree(void* aligned_memory); +void AlignedSizedFree(void* aligned_memory, size_t alignment, size_t size); + +// An allocator that allocates memory with the given minimum alignment. +template +struct AlignedAllocator { + using value_type = T; + + value_type* allocate(size_t n) { + return static_cast( + AlignedMalloc(n * sizeof(value_type), minimum_alignment)); + } + + void deallocate(value_type* p, size_t n) { + return AlignedSizedFree(p, minimum_alignment, n); + } +}; + +void* Malloc(size_t size); +void* Realloc(void* ptr, size_t size); +void Free(void* ptr); + +// Tries to release num_bytes of free memory back to the operating +// system for reuse. Use this routine with caution -- to get this +// memory back may require faulting pages back in by the OS, and +// that may be slow. +// +// Currently, if a malloc implementation does not support this +// routine, this routine is a no-op. +void MallocExtension_ReleaseToSystem(std::size_t num_bytes); + +// Returns the actual number N of bytes reserved by the malloc for the +// pointer p. This number may be equal to or greater than the number +// of bytes requested when p was allocated. +// +// This routine is just useful for statistics collection. The +// client must *not* read or write from the extra bytes that are +// indicated by this call. +// +// Example, suppose the client gets memory by calling +// p = malloc(10) +// and GetAllocatedSize(p) may return 16. The client must only use the +// first 10 bytes p[0..9], and not attempt to read or write p[10..15]. +// +// Currently, if a malloc implementation does not support this +// routine, this routine returns 0. +std::size_t MallocExtension_GetAllocatedSize(const void* p); + +struct MemoryInfo { + int64_t total = 0; + int64_t free = 0; +}; + +struct MemoryBandwidthInfo { + int64_t bw_used = 0; // memory bandwidth used across all CPU (in MBs/second) +}; + +// Retrieves the host memory information. If any of the fields in the returned +// MemoryInfo structure is INT64_MAX, it means such information is not +// available. +MemoryInfo GetMemoryInfo(); + +// Retrieves the host memory bandwidth information. If any field in the returned +// structure is INT64_MAX, it means such information is not available. +MemoryBandwidthInfo GetMemoryBandwidthInfo(); + +// Returns the amount of RAM available in bytes, or INT64_MAX if unknown. +static inline int64_t AvailableRam() { return GetMemoryInfo().free; } + +} // namespace port +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_MEM_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/ml_dtypes.h b/deps/exla/cache/xla_extension/include/tsl/platform/ml_dtypes.h new file mode 100644 index 0000000000000000000000000000000000000000..b536e2f8a2b3dee81cc622122edc443c6270fcb6 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/ml_dtypes.h @@ -0,0 +1,42 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_ML_DTYPES_H_ +#define TENSORFLOW_TSL_PLATFORM_ML_DTYPES_H_ + +#include "ml_dtypes/include/float8.h" // from @ml_dtypes_py +#include "ml_dtypes/include/intn.h" // from @ml_dtypes_py +#include "ml_dtypes/include/mxfloat.h" // from @ml_dtypes_py + +namespace tsl { +using float4_e2m1fn = ::ml_dtypes::float4_e2m1fn; +using float8_e3m4 = ::ml_dtypes::float8_e3m4; +using float8_e4m3 = ::ml_dtypes::float8_e4m3; +using float8_e4m3fn = ::ml_dtypes::float8_e4m3fn; +using float8_e4m3fnuz = ::ml_dtypes::float8_e4m3fnuz; +using float8_e4m3b11fnuz = ::ml_dtypes::float8_e4m3b11fnuz; +using float8_e5m2 = ::ml_dtypes::float8_e5m2; +using float8_e5m2fnuz = ::ml_dtypes::float8_e5m2fnuz; +using float8_e8m0fnu = ::ml_dtypes::float8_e8m0fnu; + +using int1 = ::ml_dtypes::int1; +using uint1 = ::ml_dtypes::uint1; +using int2 = ::ml_dtypes::int2; +using uint2 = ::ml_dtypes::uint2; +using int4 = ::ml_dtypes::int4; +using uint4 = ::ml_dtypes::uint4; +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_ML_DTYPES_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/mutex.h b/deps/exla/cache/xla_extension/include/tsl/platform/mutex.h new file mode 100644 index 0000000000000000000000000000000000000000..ec9d593a40ce4ffe2a01ca3e4d2c342b79f60762 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/mutex.h @@ -0,0 +1,275 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_MUTEX_H_ +#define TENSORFLOW_TSL_PLATFORM_MUTEX_H_ + +#include // NOLINT +#include // NOLINT +// for std::try_to_lock_t and std::cv_status +#include // NOLINT +#include // NOLINT + +#include "absl/base/attributes.h" +#include "absl/base/const_init.h" +#include "absl/synchronization/mutex.h" +#include "absl/time/time.h" +#include "tsl/platform/thread_annotations.h" + +namespace tsl { + +enum ConditionResult { kCond_Timeout, kCond_MaybeNotified }; +enum LinkerInitialized { LINKER_INITIALIZED }; + +class condition_variable; +using Condition = absl::Condition; + +// Mimic std::mutex + C++17's shared_mutex, adding a LinkerInitialized +// constructor interface. This type is as fast as mutex, but is also a shared +// lock, and provides conditional critical sections (via Await()), as an +// alternative to condition variables. +class TF_LOCKABLE ABSL_DEPRECATED("Use absl::Mutex instead.") mutex { + public: + mutex(); + // The default implementation of the underlying mutex is safe to use after + // the linker initialization to zero. + explicit constexpr mutex(LinkerInitialized x) : mu_(absl::kConstInit) {} + + void lock() TF_EXCLUSIVE_LOCK_FUNCTION(); + bool try_lock() TF_EXCLUSIVE_TRYLOCK_FUNCTION(true); + void unlock() TF_UNLOCK_FUNCTION(); + void assert_held() const TF_ASSERT_EXCLUSIVE_LOCK(); + + void lock_shared() TF_SHARED_LOCK_FUNCTION(); + bool try_lock_shared() TF_SHARED_TRYLOCK_FUNCTION(true); + void unlock_shared() TF_UNLOCK_FUNCTION(); + void assert_held_shared() const TF_ASSERT_SHARED_LOCK(); + + // ------- + // Conditional critical sections. + // These represent an alternative to condition variables that is easier to + // use. The predicate must be encapsulated in a function (via Condition), + // but there is no need to use a while-loop, and no need to signal the + // condition. Example: suppose "mu" protects "counter"; we wish one thread + // to wait until counter is decremented to zero by another thread. + // // Predicate expressed as a function: + // static bool IntIsZero(int* pi) { return *pi == 0; } + // + // // Waiter: + // mu.lock(); + // mu.Await(Condition(&IntIsZero, &counter)); // no loop needed + // // lock is held and counter==0... + // mu.unlock(); + // + // // Decrementer: + // mu.lock(); + // counter--; + // mu.unlock(); // no need to signal; mutex will check condition + // + // A mutex may be used with condition variables and conditional critical + // sections at the same time. Conditional critical sections are easier to + // use, but if there are multiple conditions that are simultaneously false, + // condition variables may be faster. + + // Unlock *this and wait until cond.Eval() is true, then atomically reacquire + // *this in the same mode in which it was previously held and return. + void Await(const Condition& cond); + + // Unlock *this and wait until either cond.Eval is true, or abs_deadline_ns + // has been reached, then atomically reacquire *this in the same mode in + // which it was previously held, and return whether cond.Eval() is true. + // See tsl/tsl/platform/env_time.h for the time interface. + bool AwaitWithDeadline(const Condition& cond, uint64_t abs_deadline_ns); + // ------- + + private: + friend class condition_variable; + absl::Mutex mu_; +}; + +// Mimic a subset of the std::unique_lock functionality. +class TF_SCOPED_LOCKABLE mutex_lock { + public: + typedef ::tsl::mutex mutex_type; + + explicit mutex_lock(mutex_type& mu) TF_EXCLUSIVE_LOCK_FUNCTION(mu) + : mu_(&mu) { + mu_->lock(); + } + + mutex_lock(mutex_type& mu, std::try_to_lock_t) TF_EXCLUSIVE_LOCK_FUNCTION(mu) + : mu_(&mu) { + if (!mu.try_lock()) { + mu_ = nullptr; + } + } + + // Manually nulls out the source to prevent double-free. + // (std::move does not null the source pointer by default.) + mutex_lock(mutex_lock&& ml) noexcept TF_EXCLUSIVE_LOCK_FUNCTION(ml.mu_) + : mu_(ml.mu_) { + ml.mu_ = nullptr; + } + ~mutex_lock() TF_UNLOCK_FUNCTION() { + if (mu_ != nullptr) { + mu_->unlock(); + } + } + mutex_type* mutex() { return mu_; } + + explicit operator bool() const { return mu_ != nullptr; } + + private: + mutex_type* mu_; +}; + +// Catch bug where variable name is omitted, e.g. mutex_lock (mu); +#define mutex_lock(x) static_assert(0, "mutex_lock_decl_missing_var_name"); + +// Mimic a subset of the std::shared_lock functionality. +// Name chosen to minimize conflicts with the tf_shared_lock macro, below. +class TF_SCOPED_LOCKABLE tf_shared_lock { + public: + typedef ::tsl::mutex mutex_type; + + explicit tf_shared_lock(mutex_type& mu) TF_SHARED_LOCK_FUNCTION(mu) + : mu_(&mu) { + mu_->lock_shared(); + } + + tf_shared_lock(mutex_type& mu, std::try_to_lock_t) TF_SHARED_LOCK_FUNCTION(mu) + : mu_(&mu) { + if (!mu.try_lock_shared()) { + mu_ = nullptr; + } + } + + // Manually nulls out the source to prevent double-free. + // (std::move does not null the source pointer by default.) + tf_shared_lock(tf_shared_lock&& ml) noexcept TF_SHARED_LOCK_FUNCTION(ml.mu_) + : mu_(ml.mu_) { + ml.mu_ = nullptr; + } + ~tf_shared_lock() TF_UNLOCK_FUNCTION() { + if (mu_ != nullptr) { + mu_->unlock_shared(); + } + } + mutex_type* mutex() { return mu_; } + + explicit operator bool() const { return mu_ != nullptr; } + + private: + mutex_type* mu_; +}; + +// Catch bug where variable name is omitted, e.g. tf_shared_lock (mu); +#define tf_shared_lock(x) \ + static_assert(0, "tf_shared_lock_decl_missing_var_name"); + +// Mimic std::condition_variable. +class ABSL_DEPRECATED("Use absl::CondVar instead.") condition_variable { + public: + condition_variable(); + + void wait(mutex_lock& lock); + + template + void wait(mutex_lock& lock, Predicate stop_waiting) { + while (!stop_waiting()) { + wait(lock); + } + } + + template + std::cv_status wait_for(mutex_lock& lock, + std::chrono::duration dur); + void notify_one(); + void notify_all(); + + private: + friend ConditionResult WaitForMilliseconds(mutex_lock* mu, + condition_variable* cv, + int64_t ms); + absl::CondVar cv_; +}; + +// Like "cv->wait(*mu)", except that it only waits for up to "ms" milliseconds. +// +// Returns kCond_Timeout if the timeout expired without this +// thread noticing a signal on the condition variable. Otherwise may +// return either kCond_Timeout or kCond_MaybeNotified +inline ConditionResult WaitForMilliseconds(mutex_lock* mu, + condition_variable* cv, int64_t ms) { + std::cv_status s = cv->wait_for(*mu, std::chrono::milliseconds(ms)); + return (s == std::cv_status::timeout) ? kCond_Timeout : kCond_MaybeNotified; +} + +// ------------------------------------------------------------ +// Implementation details follow. Clients should ignore them. + +inline mutex::mutex() = default; + +inline void mutex::lock() TF_EXCLUSIVE_LOCK_FUNCTION() { mu_.Lock(); } + +inline bool mutex::try_lock() TF_EXCLUSIVE_TRYLOCK_FUNCTION(true) { + return mu_.TryLock(); +}; + +inline void mutex::unlock() TF_UNLOCK_FUNCTION() { mu_.Unlock(); } + +inline void mutex::assert_held() const TF_ASSERT_EXCLUSIVE_LOCK() { + mu_.AssertHeld(); +} + +inline void mutex::lock_shared() TF_SHARED_LOCK_FUNCTION() { mu_.ReaderLock(); } + +inline bool mutex::try_lock_shared() TF_SHARED_TRYLOCK_FUNCTION(true) { + return mu_.ReaderTryLock(); +} + +inline void mutex::unlock_shared() TF_UNLOCK_FUNCTION() { mu_.ReaderUnlock(); } + +inline void mutex::assert_held_shared() const TF_ASSERT_SHARED_LOCK() { + mu_.AssertReaderHeld(); +} + +inline void mutex::Await(const Condition& cond) { mu_.Await(cond); } + +inline bool mutex::AwaitWithDeadline(const Condition& cond, + uint64_t abs_deadline_ns) { + return mu_.AwaitWithDeadline(cond, absl::FromUnixNanos(abs_deadline_ns)); +} + +inline condition_variable::condition_variable() = default; + +inline void condition_variable::wait(mutex_lock& lock) { + cv_.Wait(&lock.mutex()->mu_); +} + +inline void condition_variable::notify_one() { cv_.Signal(); } + +inline void condition_variable::notify_all() { cv_.SignalAll(); } + +template +std::cv_status condition_variable::wait_for( + mutex_lock& lock, std::chrono::duration dur) { + bool r = cv_.WaitWithTimeout(&lock.mutex()->mu_, ::absl::FromChrono(dur)); + return r ? std::cv_status::timeout : std::cv_status::no_timeout; +} + +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_MUTEX_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/notification.h b/deps/exla/cache/xla_extension/include/tsl/platform/notification.h new file mode 100644 index 0000000000000000000000000000000000000000..4b6212ac049fc3a4a51d34b932792ab40bdc6fa5 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/notification.h @@ -0,0 +1,39 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_NOTIFICATION_H_ +#define TENSORFLOW_TSL_PLATFORM_NOTIFICATION_H_ + +#include // NOLINT +#include // NOLINT +#include +#include // NOLINT + +#include "absl/base/macros.h" +#include "absl/synchronization/notification.h" +#include "absl/time/time.h" + +// TODO: b/330223377 - This macro should eventually be provided by Abseil. +#ifndef ABSL_DEPRECATE_AND_INLINE +#define ABSL_DEPRECATE_AND_INLINE() +#endif + +namespace tsl { + +using Notification ABSL_DEPRECATE_AND_INLINE() = absl::Notification; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_NOTIFICATION_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/numa.h b/deps/exla/cache/xla_extension/include/tsl/platform/numa.h new file mode 100644 index 0000000000000000000000000000000000000000..12a65894a0cc9d4fbaad64a77aa3470e6d9d0c4f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/numa.h @@ -0,0 +1,62 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_NUMA_H_ +#define TENSORFLOW_TSL_PLATFORM_NUMA_H_ + +#include "xla/tsl/platform/types.h" +#include "tsl/platform/platform.h" + +namespace tsl { +namespace port { + +// Returns true iff NUMA functions are supported. +bool NUMAEnabled(); + +// Returns the number of NUMA nodes present with respect to CPU operations. +// Typically this will be the number of sockets where some RAM has greater +// affinity with one socket than another. +int NUMANumNodes(); + +static const int kNUMANoAffinity = -1; + +// If possible sets affinity of the current thread to the specified NUMA node. +// If node == kNUMANoAffinity removes affinity to any particular node. +void NUMASetThreadNodeAffinity(int node); + +// Returns NUMA node affinity of the current thread, kNUMANoAffinity if none. +int NUMAGetThreadNodeAffinity(); + +// Like AlignedMalloc, but allocates memory with affinity to the specified NUMA +// node. +// +// Notes: +// 1. node must be >= 0 and < NUMANumNodes. +// 1. minimum_alignment must a factor of system page size, the memory +// returned will be page-aligned. +// 2. This function is likely significantly slower than AlignedMalloc +// and should not be used for lots of small allocations. It makes more +// sense as a backing allocator for BFCAllocator, PoolAllocator, or similar. +void* NUMAMalloc(int node, size_t size, int minimum_alignment); + +// Memory allocated by NUMAMalloc must be freed via NUMAFree. +void NUMAFree(void* ptr, size_t size); + +// Returns NUMA node affinity of memory address, kNUMANoAffinity if none. +int NUMAGetMemAffinity(const void* ptr); + +} // namespace port +} // namespace tsl +#endif // TENSORFLOW_TSL_PLATFORM_NUMA_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/numbers.h b/deps/exla/cache/xla_extension/include/tsl/platform/numbers.h new file mode 100644 index 0000000000000000000000000000000000000000..8d87fc871876379d037b514d2036768ae3e15681 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/numbers.h @@ -0,0 +1,229 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_NUMBERS_H_ +#define TENSORFLOW_TSL_PLATFORM_NUMBERS_H_ + +#include +#include +#include +#include + +#include "absl/base/macros.h" +#include "absl/strings/numbers.h" +#include "absl/strings/string_view.h" +#include "xla/tsl/platform/types.h" +#include "tsl/platform/stringpiece.h" + +namespace tsl { +namespace strings { + +// ---------------------------------------------------------------------- +// FastIntToBufferLeft() +// These are intended for speed. +// +// All functions take the output buffer as an arg. FastInt() uses +// at most 22 bytes, FastTime() uses exactly 30 bytes. They all +// return a pointer to the beginning of the output, which is the same as +// the beginning of the input buffer. +// +// NOTE: In 64-bit land, sizeof(time_t) is 8, so it is possible +// to pass to FastTimeToBuffer() a time whose year cannot be +// represented in 4 digits. In this case, the output buffer +// will contain the string "Invalid:" +// ---------------------------------------------------------------------- + +// Previously documented minimums -- the buffers provided must be at least this +// long, though these numbers are subject to change: +// Int32, UInt32: 12 bytes +// Int64, UInt64, Int, Uint: 22 bytes +// Time: 30 bytes +// Use kFastToBufferSize rather than hardcoding constants. +inline constexpr int kFastToBufferSize = 32; + +// ---------------------------------------------------------------------- +// FastInt32ToBufferLeft() +// FastUInt32ToBufferLeft() +// FastInt64ToBufferLeft() +// FastUInt64ToBufferLeft() +// +// These functions convert their numeric argument to an ASCII +// representation of the numeric value in base 10, with the +// representation being left-aligned in the buffer. The caller is +// responsible for ensuring that the buffer has enough space to hold +// the output. The buffer should typically be at least kFastToBufferSize +// bytes. +// +// Returns the number of characters written. +// ---------------------------------------------------------------------- + +size_t FastInt32ToBufferLeft(int32_t i, char* buffer); // at least 12 bytes +size_t FastUInt32ToBufferLeft(uint32_t i, char* buffer); // at least 12 bytes +size_t FastInt64ToBufferLeft(int64_t i, char* buffer); // at least 22 bytes +size_t FastUInt64ToBufferLeft(uint64_t i, char* buffer); // at least 22 bytes + +// Required buffer size for DoubleToBuffer is kFastToBufferSize. +// Required buffer size for FloatToBuffer is kFastToBufferSize. +size_t DoubleToBuffer(double value, char* buffer); +size_t FloatToBuffer(float value, char* buffer); + +namespace strings_internal { +// AlphaNumBuffer allows a way to pass a string to absl::StrCat without having +// to do memory allocation. It is simply a pair of a fixed-size character +// array, and a size. Please don't use outside of the "strings" package. +struct AlphaNumBuffer { + std::array data; + size_t size; + + // Support for absl::StrCat() etc. + template + friend void AbslStringify(Sink& sink, const AlphaNumBuffer& buffer) { + sink.Append(absl::string_view(buffer.data.data(), buffer.size)); + } +}; +} // namespace strings_internal + +// Helper function for legacy google formatting. +template +const T& LegacyPrecision(const T& t) { + return t; +} + +// Have to use overloads rather than specialization because specialization can't +// change the function return type. + +// Helper function for the old strings::StrCat default "float" format, which was +// either %.6g, %.7g, %.8g, or %.9g, basically the smallest string that would +// round-trip back to the original float. This is fast. +strings_internal::AlphaNumBuffer LegacyPrecision(float f); + +// Helper function for the old strings::StrCat default "double" format, which +// was either %.15g or %.17g, depending on whether the %.15g format would +// round-trip back to the original double. This is approx. 20-30x slower than +// the others. +strings_internal::AlphaNumBuffer LegacyPrecision(double d); + +// Convert a 64-bit fingerprint value to an ASCII representation. +std::string FpToString(Fprint fp); + +// Attempt to parse a `uint64_t` in the form encoded by +// `absl::StrCat(absl::Hex(*result))`. If successful, stores the value in +// `result` and returns true. Otherwise, returns false. +bool HexStringToUint64(absl::string_view s, uint64_t* result); + +// Convert strings to 32bit integer values. +// Leading and trailing spaces are allowed. +// Return false with overflow or invalid input. +ABSL_DEPRECATE_AND_INLINE() +inline bool safe_strto32(absl::string_view str, int32_t* value) { + return absl::SimpleAtoi(str, value); +} + +// Convert strings to unsigned 32bit integer values. +// Leading and trailing spaces are allowed. +// Return false with overflow or invalid input. +ABSL_DEPRECATE_AND_INLINE() +inline bool safe_strtou32(absl::string_view str, uint32_t* value) { + return absl::SimpleAtoi(str, value); +} + +// Convert strings to 64bit integer values. +// Leading and trailing spaces are allowed. +// Return false with overflow or invalid input. +ABSL_DEPRECATE_AND_INLINE() +inline bool safe_strto64(absl::string_view str, int64_t* value) { + return absl::SimpleAtoi(str, value); +} + +// Convert strings to unsigned 64bit integer values. +// Leading and trailing spaces are allowed. +// Return false with overflow or invalid input. +ABSL_DEPRECATE_AND_INLINE() +inline bool safe_strtou64(absl::string_view str, uint64_t* value) { + return absl::SimpleAtoi(str, value); +} + +// Convert strings to floating point values. +// Leading and trailing spaces are allowed. +// Values may be rounded on over- and underflow. +// Returns false on invalid input or if `strlen(value) >= kFastToBufferSize`. +ABSL_DEPRECATE_AND_INLINE() +inline bool safe_strtof(absl::string_view str, float* value) { + return absl::SimpleAtof(str, value); +} + +// Convert strings to double precision floating point values. +// Leading and trailing spaces are allowed. +// Values may be rounded on over- and underflow. +// Returns false on invalid input or if `strlen(value) >= kFastToBufferSize`. +ABSL_DEPRECATE_AND_INLINE() +inline bool safe_strtod(absl::string_view str, double* value) { + return absl::SimpleAtod(str, value); +} + +inline bool ProtoParseNumeric(absl::string_view s, int32_t* value) { + return absl::SimpleAtoi(s, value); +} + +inline bool ProtoParseNumeric(absl::string_view s, uint32_t* value) { + return absl::SimpleAtoi(s, value); +} + +inline bool ProtoParseNumeric(absl::string_view s, int64_t* value) { + return absl::SimpleAtoi(s, value); +} + +inline bool ProtoParseNumeric(absl::string_view s, uint64_t* value) { + return absl::SimpleAtoi(s, value); +} + +inline bool ProtoParseNumeric(absl::string_view s, float* value) { + return absl::SimpleAtof(s, value); +} + +inline bool ProtoParseNumeric(absl::string_view s, double* value) { + return absl::SimpleAtod(s, value); +} + +// Convert strings to number of type T. +// Leading and trailing spaces are allowed. +// Values may be rounded on over- and underflow. +template +bool SafeStringToNumeric(absl::string_view s, T* value) { + return ProtoParseNumeric(s, value); +} + +// Converts from an int64 to a human readable string representing the +// same number, using decimal powers. e.g. 1200000 -> "1.20M". +std::string HumanReadableNum(int64_t value); + +// Converts from an int64 representing a number of bytes to a +// human readable string representing the same number. +// e.g. 12345678 -> "11.77MiB". +std::string HumanReadableNumBytes(int64_t num_bytes); + +// Converts a time interval as double to a human readable +// string. For example: +// 0.001 -> "1 ms" +// 10.0 -> "10 s" +// 933120.0 -> "10.8 days" +// 39420000.0 -> "1.25 years" +// -10 -> "-10 s" +std::string HumanReadableElapsedTime(double seconds); + +} // namespace strings +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_NUMBERS_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/path.h b/deps/exla/cache/xla_extension/include/tsl/platform/path.h new file mode 100644 index 0000000000000000000000000000000000000000..bf9537c0ee8fed51891efb2b5d82a93b0da12c96 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/path.h @@ -0,0 +1,135 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_PATH_H_ +#define TENSORFLOW_TSL_PLATFORM_PATH_H_ + +#include + +#include "xla/tsl/platform/types.h" +#include "tsl/platform/stringpiece.h" + +namespace tsl { +namespace io { +namespace internal { +std::string JoinPathImpl(std::initializer_list paths); +} + +// Utility routines for processing filenames + +#ifndef SWIG // variadic templates +// Join multiple paths together, without introducing unnecessary path +// separators. +// For example: +// +// Arguments | JoinPath +// ---------------------------+---------- +// '/foo', 'bar' | /foo/bar +// '/foo/', 'bar' | /foo/bar +// '/foo', '/bar' | /foo/bar +// +// Usage: +// string path = io::JoinPath("/mydir", filename); +// string path = io::JoinPath(FLAGS_test_srcdir, filename); +// string path = io::JoinPath("/full", "path", "to", "filename"); +template +std::string JoinPath(const T&... args) { + return internal::JoinPathImpl({args...}); +} +#endif /* SWIG */ + +// Return true if path is absolute. +bool IsAbsolutePath(absl::string_view path); + +// Returns the part of the path before the final "/". If there is a single +// leading "/" in the path, the result will be the leading "/". If there is +// no "/" in the path, the result is the empty prefix of the input. +absl::string_view Dirname(absl::string_view path); + +// Returns the part of the path after the final "/". If there is no +// "/" in the path, the result is the same as the input. +absl::string_view Basename(absl::string_view path); + +// Returns the part of the basename of path after the final ".". If +// there is no "." in the basename, the result is empty. +absl::string_view Extension(absl::string_view path); + +// Returns the part of the basename of path before the final ".". If +// there is no "." in the basename, the result is empty. +absl::string_view BasenamePrefix(absl::string_view path); + +// Returns the largest common subpath of `paths`. +// +// For example, for "/alpha/beta/gamma" and "/alpha/beta/ga" returns +// "/alpha/beta/". For "/alpha/beta/gamma" and "/alpha/beta/gamma" returns +// "/alpha/beta/". +// +// Does not perform any path normalization. +std::string CommonPathPrefix(absl::Span paths); + +// Collapse duplicate "/"s, resolve ".." and "." path elements, remove +// trailing "/". +// +// NOTE: This respects relative vs. absolute paths, but does not +// invoke any system calls (getcwd(2)) in order to resolve relative +// paths with respect to the actual working directory. That is, this is purely +// string manipulation, completely independent of process state. +std::string CleanPath(absl::string_view path); + +// Populates the scheme, host, and path from a URI. scheme, host, and path are +// guaranteed by this function to point into the contents of uri, even if +// empty. +// +// Corner cases: +// - If the URI is invalid, scheme and host are set to empty strings and the +// passed string is assumed to be a path +// - If the URI omits the path (e.g. file://host), then the path is left empty. +void ParseURI(absl::string_view uri, absl::string_view* scheme, + absl::string_view* host, absl::string_view* path); + +// Creates a URI from a scheme, host, and path. If the scheme is empty, we just +// return the path. +std::string CreateURI(absl::string_view scheme, absl::string_view host, + absl::string_view path); + +// Creates a temporary file name with an extension. +std::string GetTempFilename(const std::string& extension); + +// Returns whether the test workspace directory is known. If it's known and dir +// != nullptr then sets *dir to that. +// +// The test workspace directory is known to be TEST_SRCDIR/TEST_WORKSPACE if +// both the TEST_SRCDIR and TEST_WORKSPACE environment variables are set. +bool GetTestWorkspaceDir(std::string* dir); + +// Returns whether the TEST_UNDECLARED_OUTPUTS_DIR environment variable is set. +// If it's set and dir != nullptr then sets *dir to that. +bool GetTestUndeclaredOutputsDir(std::string* dir); + +// Resolves paths to help tests find files in their workspace or output +// directory. Returns whether the path can be resolved. If it can be then sets +// resolved_path to that. +// +// Currently the TEST_WORKSPACE and the TEST_UNDECLARED_OUTPUTS_DIR prefixes can +// be resolved. +bool ResolveTestPrefixes(absl::string_view path, std::string& resolved_path); + +// Appends `.exe` if `PLATFORM_WINDOWS` is defined. +[[maybe_unused]] std::string& AppendDotExeIfWindows(std::string& path); + +} // namespace io +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_PATH_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/platform.h b/deps/exla/cache/xla_extension/include/tsl/platform/platform.h new file mode 100644 index 0000000000000000000000000000000000000000..ebc3173d557a0efe82400301a8dc4952d31bba50 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/platform.h @@ -0,0 +1,98 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_PLATFORM_H_ +#define TENSORFLOW_TSL_PLATFORM_PLATFORM_H_ + +// Set one PLATFORM_* macro and set IS_MOBILE_PLATFORM if the platform is for +// mobile. + +#if !defined(PLATFORM_POSIX) && !defined(PLATFORM_GOOGLE) && \ + !defined(PLATFORM_POSIX_ANDROID) && !defined(PLATFORM_GOOGLE_ANDROID) && \ + !defined(PLATFORM_WINDOWS) + +// Choose which platform we are on. +#if defined(ANDROID) || defined(__ANDROID__) +#define PLATFORM_POSIX_ANDROID +#define IS_MOBILE_PLATFORM + +#elif defined(__APPLE__) +#include "TargetConditionals.h" +#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE +#define PLATFORM_POSIX_IOS +#define IS_MOBILE_PLATFORM +#else +// If no platform specified, use: +#define PLATFORM_POSIX +#endif + +#elif defined(_WIN32) +#define PLATFORM_WINDOWS + +#elif defined(__EMSCRIPTEN__) +#define PLATFORM_PORTABLE_GOOGLE +#define PLATFORM_POSIX +// EMSCRIPTEN builds are considered "mobile" for the sake of portability. +#define IS_MOBILE_PLATFORM + +#elif defined(__TF_CHROMIUMOS__) +#define PLATFORM_PORTABLE_GOOGLE +#define PLATFORM_POSIX +#define PLATFORM_CHROMIUMOS + +#elif defined(__Fuchsia__) +#define PLATFORM_FUCHSIA +// PLATFORM_GOOGLE needs to be defined by default to get the right header +// files. +#define PLATFORM_GOOGLE + +#elif defined(__CHROME__) +#define PLATFORM_POSIX +#define PLATFORM_PORTABLE_GOOGLE + +#else +// If no platform specified, use: +#define PLATFORM_POSIX + +#endif +#endif + +// Look for both gcc/clang and Visual Studio macros indicating we're compiling +// for an x86 device. +#if defined(__x86_64__) || defined(__amd64__) || defined(_M_IX86) || \ + defined(_M_X64) +#define PLATFORM_IS_X86 +#endif + +// Check if we are compiling for an arm device. +#if defined(__arm__) || defined(__aarch64__) +#define PLATFORM_IS_ARM +#if defined(__aarch64__) +#define PLATFORM_IS_ARM64 +#else +#define PLATFORM_IS_ARM32 +#endif +#endif + +#define TSL_IS_IN_OSS 1 + +#ifdef __cplusplus +namespace tsl { +// Constant which is false internally and true in open source. +inline constexpr bool kIsOpenSource = TSL_IS_IN_OSS; +} // namespace tsl +#endif + +#endif // TENSORFLOW_TSL_PLATFORM_PLATFORM_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/protobuf.h b/deps/exla/cache/xla_extension/include/tsl/platform/protobuf.h new file mode 100644 index 0000000000000000000000000000000000000000..301404b78a6114864c40d25950b01ed84e82e240 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/protobuf.h @@ -0,0 +1,137 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_PROTOBUF_H_ +#define TENSORFLOW_TSL_PLATFORM_PROTOBUF_H_ + +#include + +#include "xla/tsl/platform/types.h" +#include "tsl/platform/platform.h" + +// Import whatever namespace protobuf comes from into the +// ::tsl::protobuf namespace. +// +// TensorFlow code should use the ::tensorflow::protobuf namespace to +// refer to all protobuf APIs. + +#include "google/protobuf/descriptor.pb.h" // IWYU pragma: export +#include "google/protobuf/arena.h" // IWYU pragma: export +#include "google/protobuf/descriptor.h" // IWYU pragma: export +#include "google/protobuf/dynamic_message.h" // IWYU pragma: export +#include "google/protobuf/io/coded_stream.h" // IWYU pragma: export +#include "google/protobuf/io/tokenizer.h" // IWYU pragma: export +#include "google/protobuf/io/zero_copy_stream.h" // IWYU pragma: export +#include "google/protobuf/io/zero_copy_stream_impl_lite.h" // IWYU pragma: export +#include "google/protobuf/map.h" // IWYU pragma: export +#include "google/protobuf/message.h" // IWYU pragma: export +#include "google/protobuf/repeated_field.h" // IWYU pragma: export +#include "google/protobuf/repeated_ptr_field.h" // IWYU pragma: export +#include "google/protobuf/text_format.h" // IWYU pragma: export +#include "google/protobuf/util/delimited_message_util.h" // IWYU pragma: export +#include "google/protobuf/util/field_comparator.h" // IWYU pragma: export +#include "google/protobuf/util/json_util.h" // IWYU pragma: export +#include "google/protobuf/util/message_differencer.h" // IWYU pragma: export +#include "google/protobuf/util/type_resolver_util.h" // IWYU pragma: export + +#if !TSL_IS_IN_OSS +#define TENSORFLOW_PROTOBUF_USES_CORD 1 +#endif // TSL_IS_IN_OSS + +namespace tsl { + +namespace protobuf = ::google::protobuf; +using protobuf_int64 = int64_t; +using protobuf_uint64 = uint64_t; +extern const char* kProtobufInt64Typename; +extern const char* kProtobufUint64Typename; + +// Parses a protocol buffer contained in a string in the binary wire format. +// Returns true on success. Note: Unlike protobuf's builtin ParseFromString, +// this function has no size restrictions on the total size of the encoded +// protocol buffer. +bool ParseProtoUnlimited(protobuf::MessageLite* proto, + const std::string& serialized); +bool ParseProtoUnlimited(protobuf::MessageLite* proto, const void* serialized, + size_t size); +inline bool ParseProtoUnlimited(protobuf::MessageLite* proto, + const tstring& serialized) { + return ParseProtoUnlimited(proto, serialized.data(), serialized.size()); +} + +// Returns the string value for the value of a string or bytes protobuf field. +inline const std::string& ProtobufStringToString(const std::string& s) { + return s; +} + +// Set to . Swapping is allowed, as does not need to be +// preserved. +inline void SetProtobufStringSwapAllowed(std::string* src, std::string* dest) { + *dest = std::move(*src); +} + +#if defined(TENSORFLOW_PROTOBUF_USES_CORD) +// These versions of ProtobufStringToString and SetProtobufString get used by +// tools/proto_text's generated code. They have the same name as the versions +// in tsl/platform/protobuf.h, so the generation code doesn't need to determine +// if the type is Cord or string at generation time. +inline std::string ProtobufStringToString(const absl::Cord& s) { + return std::string(s); +} +inline void SetProtobufStringSwapAllowed(std::string* src, absl::Cord* dest) { + *dest = *src; +} +#endif // defined(TENSORFLOW_PROTOBUF_USES_CORD) + +inline bool SerializeToTString(const protobuf::MessageLite& proto, + tstring* output) { + size_t size = proto.ByteSizeLong(); + output->resize_uninitialized(size); + return proto.SerializeWithCachedSizesToArray( + reinterpret_cast(output->data())); +} + +inline bool ParseFromTString(const tstring& input, + protobuf::MessageLite* proto) { + return proto->ParseFromArray(input.data(), static_cast(input.size())); +} + +// Analogue to StringOutputStream for tstring. +class TStringOutputStream : public protobuf::io::ZeroCopyOutputStream { + public: + explicit TStringOutputStream(tstring* target); + ~TStringOutputStream() override = default; + + TStringOutputStream(const TStringOutputStream&) = delete; + void operator=(const TStringOutputStream&) = delete; + + bool Next(void** data, int* size) override; + void BackUp(int count) override; + int64_t ByteCount() const override; + + private: + static constexpr int kMinimumSize = 16; + + tstring* target_; +}; + +std::string LegacyUnredactedDebugString(const tsl::protobuf::Message& message); +std::string LegacyUnredactedDebugString( + const tsl::protobuf::MessageLite& message); +std::string LegacyUnredactedShortDebugString( + const tsl::protobuf::Message& message); +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_PROTOBUF_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/random.h b/deps/exla/cache/xla_extension/include/tsl/platform/random.h new file mode 100644 index 0000000000000000000000000000000000000000..680520d08a4264ef6cdf9b0e7af41912345c1b73 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/random.h @@ -0,0 +1,38 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_RANDOM_H_ +#define TENSORFLOW_TSL_PLATFORM_RANDOM_H_ + +#include "xla/tsl/platform/types.h" + +namespace tsl { +namespace random { + +// Return a 64-bit random value. Different sequences are generated +// in different processes. +uint64 New64(); + +// Same as previous method, but uses a different RNG for each thread. +uint64 ThreadLocalNew64(); + +// Return a 64-bit random value. Uses +// std::mersenne_twister_engine::default_seed as seed value. +uint64 New64DefaultSeed(); + +} // namespace random +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_RANDOM_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/raw_coding.h b/deps/exla/cache/xla_extension/include/tsl/platform/raw_coding.h new file mode 100644 index 0000000000000000000000000000000000000000..409b01d449fea13268adbd9ddd74204489828568 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/raw_coding.h @@ -0,0 +1,72 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_RAW_CODING_H_ +#define TENSORFLOW_TSL_PLATFORM_RAW_CODING_H_ + +#include + +#include "xla/tsl/platform/byte_order.h" +#include "xla/tsl/platform/types.h" + +namespace tsl { +namespace core { + +// Lower-level versions of Get... that read directly from a character buffer +// without any bounds checking. + +inline uint16 DecodeFixed16(const char* ptr) { + if (port::kLittleEndian) { + // Load the raw bytes + uint16 result; + memcpy(&result, ptr, sizeof(result)); // gcc optimizes this to a plain load + return result; + } else { + return ((static_cast(static_cast(ptr[0]))) | + (static_cast(static_cast(ptr[1])) << 8)); + } +} + +inline uint32 DecodeFixed32(const char* ptr) { + if (port::kLittleEndian) { + // Load the raw bytes + uint32 result; + memcpy(&result, ptr, sizeof(result)); // gcc optimizes this to a plain load + return result; + } else { + return ((static_cast(static_cast(ptr[0]))) | + (static_cast(static_cast(ptr[1])) << 8) | + (static_cast(static_cast(ptr[2])) << 16) | + (static_cast(static_cast(ptr[3])) << 24)); + } +} + +inline uint64 DecodeFixed64(const char* ptr) { + if (port::kLittleEndian) { + // Load the raw bytes + uint64 result; + memcpy(&result, ptr, sizeof(result)); // gcc optimizes this to a plain load + return result; + } else { + uint64 lo = DecodeFixed32(ptr); + uint64 hi = DecodeFixed32(ptr + 4); + return (hi << 32) | lo; + } +} + +} // namespace core +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_RAW_CODING_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/refcount.h b/deps/exla/cache/xla_extension/include/tsl/platform/refcount.h new file mode 100644 index 0000000000000000000000000000000000000000..5af30791b398007be8a6f04d6d6c1bff39c485ed --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/refcount.h @@ -0,0 +1,355 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_REFCOUNT_H_ +#define TENSORFLOW_TSL_PLATFORM_REFCOUNT_H_ + +#include +#include +#include + +#include "xla/tsl/platform/logging.h" +#include "tsl/platform/mutex.h" +#include "tsl/platform/thread_annotations.h" + +namespace tsl { +namespace core { + +class RefCounted { + public: + // Initial reference count is one. + RefCounted(); + + // Increments reference count by one. + void Ref() const; + + // Decrements reference count by one. If the count remains + // positive, returns false. When the count reaches zero, returns + // true and deletes this, in which case the caller must not access + // the object afterward. + bool Unref() const; + + // Gets the current reference count. + int_fast32_t RefCount() const; + + // Return whether the reference count is one. + // If the reference count is used in the conventional way, a + // reference count of 1 implies that the current thread owns the + // reference and no other thread shares it. + // This call performs the test for a reference count of one, and + // performs the memory barrier needed for the owning thread + // to act on the object, knowing that it has exclusive access to the + // object. + bool RefCountIsOne() const; + + protected: + // Make destructor protected so that RefCounted objects cannot + // be instantiated directly. Only subclasses can be instantiated. + virtual ~RefCounted(); + + // Increments reference count by one if the object is not being destructed. + // This function is used by WeakRefCounted for securely acquiring a + // strong reference. It is only safe to call this as part of the weak + // reference implementation. + bool TryRef() const; + + // Notifies the instance is deleted. This function is used by WeakRefCounted + // for securely propagating the delete notification before the destruction + // sequence starts. + virtual void NotifyDeleted() const; + + private: + mutable std::atomic_int_fast32_t ref_; + + RefCounted(const RefCounted&) = delete; + void operator=(const RefCounted&) = delete; +}; + +// A deleter class to form a std::unique_ptr that unrefs objects. +struct RefCountDeleter { + void operator()(const RefCounted* o) const { o->Unref(); } +}; + +template +class RefCountPtr; + +// Adds a new reference to a RefCounted pointer. +template +ABSL_MUST_USE_RESULT RefCountPtr GetNewRef(T* ptr) { + static_assert(std::is_base_of::value); + + if (ptr == nullptr) return RefCountPtr(); + ptr->Ref(); + RefCountPtr ret(ptr); + return ret; +} + +// A unique_ptr that unrefs the owned object on destruction. +template +class RefCountPtr : public std::unique_ptr { + public: + using std::unique_ptr::unique_ptr; + ABSL_MUST_USE_RESULT RefCountPtr GetNewRef() const { + if (this->get() == nullptr) return RefCountPtr(); + this->get()->Ref(); + return RefCountPtr(this->get()); + } +}; + +// Helper class to unref an object when out-of-scope. +class ScopedUnref { + public: + explicit ScopedUnref(const RefCounted* o) : obj_(o) {} + ~ScopedUnref() { + if (obj_) obj_->Unref(); + } + + private: + const RefCounted* obj_; + + ScopedUnref(const ScopedUnref&) = delete; + void operator=(const ScopedUnref&) = delete; +}; + +// Forward declaration for friend class of WeakRefCounted. +template +class WeakPtr; + +// A WeakNotifyFn is called when the weakly referred object is being destroyed. +// The object may already be destructed when the call occurs. A WeakNotifyFn +// can be passed into WeakPtr at construction. +using WeakNotifyFn = std::function; + +// A base class for RefCounted objects that allow weak references by WeakPtr. +// WeakRefCounted and every WeakPtr to it, each holds a strong reference to a +// WeakRefData. +// +// If the WeakRefCounted is valid, WeakPtr::GetNewRef() returns a new strong +// reference to the WeakRefCounted. +// If the WeakRefCounted is being destructed, `WeakRefCounted::ref_ == 0`; +// if the WeakRefcounted is already destructed,`WeakRefData::ptr == nullptr`. +// In either case, WeakPtr::GetNewRef() returns a nullptr. +class WeakRefCounted : public RefCounted { + public: + int WeakRefCount() const { + // Each weak ref owns one ref to data_, and *this owns the last one. + return data_->RefCount() - 1; + } + + protected: + void NotifyDeleted() const override { data_->Notify(); } + + private: + struct WeakRefData : public RefCounted { + explicit WeakRefData(WeakRefCounted* ptr) : ptr(ptr), next_notifier_id(1) {} + + mutable mutex mu; + WeakRefCounted* ptr TF_GUARDED_BY(mu); + std::map notifiers; + int next_notifier_id; + + // Notifies WeakPtr instances that this object is being destructed. + void Notify() { + mutex_lock ml(mu); + + while (!notifiers.empty()) { + auto iter = notifiers.begin(); + WeakNotifyFn notify_fn = std::move(iter->second); + notifiers.erase(iter); + + mu.unlock(); + notify_fn(); + mu.lock(); + } + ptr = nullptr; + } + + WeakRefCounted* GetNewRef() { + mutex_lock ml(mu); + if (ptr != nullptr && ptr->TryRef()) { + return ptr; + } + return nullptr; + } + + // Inserts notify_fn and returns a non-zero id. + // Returns 0 if insertion fails due to the object is being destroyed. + // 0 is also used by WeakPtr to represent "no notify_fn". + int AddNotifier(WeakNotifyFn notify_fn) { + mutex_lock ml(mu); + if (ptr == nullptr) { + return 0; + } + int notifier_id = next_notifier_id++; + notifiers.emplace(notifier_id, std::move(notify_fn)); + return notifier_id; + } + + int DupNotifier(int notifier_id) { + mutex_lock ml(mu); + auto iter = notifiers.find(notifier_id); + if (iter != notifiers.end()) { + int notifier_id = next_notifier_id++; + notifiers.emplace(notifier_id, iter->second); + return notifier_id; + } + return 0; + } + + void RemoveNotifier(int notifier_id) { + mutex_lock ml(mu); + notifiers.erase(notifier_id); + } + }; + + mutable RefCountPtr data_{new WeakRefData(this)}; + + template + friend class WeakPtr; + // MSVC14 workaround: access permission of a nested class member is not + // treated as an ordinary member in MSVC14. + friend struct WeakRefData; +}; + +// A weak reference to a WeakRefCounted object. Refer to WeakRefCounted. +template +class WeakPtr { + public: + // Creates a weak reference. + // When the object is being destroyed, notify_fn is called. + explicit WeakPtr(WeakRefCounted* ptr = nullptr, + WeakNotifyFn notify_fn = nullptr) + : data_(nullptr), notifier_id_(0) { + if (ptr != nullptr) { + ptr->data_->Ref(); + data_.reset(ptr->data_.get()); + if (notify_fn) { + notifier_id_ = data_->AddNotifier(notify_fn); + } + } + } + + ~WeakPtr() { + if (data_ != nullptr && notifier_id_ != 0) { + data_->RemoveNotifier(notifier_id_); + } + } + + WeakPtr(const WeakPtr& other) { operator=(other); } + + WeakPtr& operator=(const WeakPtr& other) { + if (data_ != nullptr && notifier_id_ != 0) { + data_->RemoveNotifier(notifier_id_); + } + other.data_->Ref(); + data_.reset(other.data_.get()); + notifier_id_ = data_->DupNotifier(other.notifier_id_); + return *this; + } + + WeakPtr(WeakPtr&& other) noexcept { + data_ = std::move(other.data_); + notifier_id_ = other.notifier_id_; + other.notifier_id_ = 0; + } + + WeakPtr& operator=(WeakPtr&& other) noexcept { + if (this != &other) { + if (data_ != nullptr && notifier_id_ != 0) { + data_->RemoveNotifier(notifier_id_); + } + data_ = std::move(other.data_); + notifier_id_ = other.notifier_id_; + other.notifier_id_ = 0; + } + return *this; + } + + // Returns a new strong reference to the referred object, or nullptr if the + // object is in an invalid state (being destructed or already destructed). + RefCountPtr GetNewRef() const { + RefCountPtr ref; + if (data_ != nullptr) { + WeakRefCounted* ptr = data_->GetNewRef(); + ref.reset(static_cast(ptr)); + } + return std::move(ref); + } + + private: + RefCountPtr data_; + int notifier_id_; +}; + +// Inlined routines, since these are performance critical +inline RefCounted::RefCounted() : ref_(1) {} + +inline RefCounted::~RefCounted() { + // A destructing object has ref_ == 0. + // It is a bug if the object is resurrected (ref_ > 0) before delete is + // called by Unref(). + DCHECK_EQ(ref_.load(), 0); +} + +inline void RefCounted::Ref() const { + // Ref() uses relaxed order because it is never called with old_ref == 0. + // When old_ref >= 1, no actions depend on the new value of ref. + int_fast32_t old_ref = ref_.fetch_add(1, std::memory_order_relaxed); + DCHECK_GT(old_ref, 0); +} + +inline bool RefCounted::TryRef() const { + // This is not on a hot path. + // Be conservative and use seq_cst to prevent racing with Unref() when + // old_ref == 0, as done in LLVM libstdc++. + int_fast32_t old_ref = ref_.load(); + while (old_ref != 0) { + if (ref_.compare_exchange_weak(old_ref, old_ref + 1)) { + return true; + } + } + // Already destructing, cannot increase ref. + return false; +} + +inline bool RefCounted::Unref() const { + DCHECK_GT(ref_.load(), 0); + // acq_rel is used to prevent reordering introduces object access after + // destruction. + + // Using release alone is a bug on systems where acq_rel differs from release. + // (e.g. arm), according to Herb Sutter's 2012 talk on "Atomic<> Weapons". + if (ref_.fetch_sub(1, std::memory_order_acq_rel) == 1) { + NotifyDeleted(); + delete this; + return true; + } + return false; +} + +inline int_fast32_t RefCounted::RefCount() const { + return ref_.load(std::memory_order_acquire); +} + +inline void RefCounted::NotifyDeleted() const {} + +inline bool RefCounted::RefCountIsOne() const { + return (ref_.load(std::memory_order_acquire) == 1); +} + +} // namespace core +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_REFCOUNT_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/regexp.h b/deps/exla/cache/xla_extension/include/tsl/platform/regexp.h new file mode 100644 index 0000000000000000000000000000000000000000..fac545c266aae33ce9ece110a98d7ac0f48d0f3a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/regexp.h @@ -0,0 +1,27 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_REGEXP_H_ +#define TENSORFLOW_TSL_PLATFORM_REGEXP_H_ + +#include "tsl/platform/platform.h" + +#if TSL_IS_IN_OSS +#include "re2/re2.h" // IWYU pragma: export +#else +#include "third_party/re2/re2.h" // IWYU pragma: export +#endif // TSL_IS_IN_OSS + +#endif // TENSORFLOW_TSL_PLATFORM_REGEXP_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/scanner.h b/deps/exla/cache/xla_extension/include/tsl/platform/scanner.h new file mode 100644 index 0000000000000000000000000000000000000000..4eb70b8244bc71711417aa0a738625b747906f5c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/scanner.h @@ -0,0 +1,249 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_SCANNER_H_ +#define TENSORFLOW_TSL_PLATFORM_SCANNER_H_ + +#include + +#include "xla/tsl/platform/macros.h" +#include "tsl/platform/str_util.h" +#include "tsl/platform/stringpiece.h" + +namespace tsl { +namespace strings { + +// Scanner provides simplified string parsing, in which a string is parsed as a +// series of scanning calls (e.g. One, Any, Many, OneLiteral, Eos), and then +// finally GetResult is called. If GetResult returns true, then it also returns +// the remaining characters and any captured substring. +// +// The range to capture can be controlled with RestartCapture and StopCapture; +// by default, all processed characters are captured. +class Scanner { + public: + // Classes of characters. Each enum name is to be read as the union of the + // parts - e.g., class LETTER_DIGIT means the class includes all letters and + // all digits. + // + // LETTER means ascii letter a-zA-Z. + // DIGIT means ascii digit: 0-9. + enum CharClass { + // NOTE: When adding a new CharClass, update the AllCharClasses ScannerTest + // in scanner_test.cc + ALL, + DIGIT, + LETTER, + LETTER_DIGIT, + LETTER_DIGIT_DASH_UNDERSCORE, + LETTER_DIGIT_DASH_DOT_SLASH, // SLASH is / only, not backslash + LETTER_DIGIT_DASH_DOT_SLASH_UNDERSCORE, // SLASH is / only, not backslash + LETTER_DIGIT_DOT, + LETTER_DIGIT_DOT_PLUS_MINUS, + LETTER_DIGIT_DOT_UNDERSCORE, + LETTER_DIGIT_UNDERSCORE, + LOWERLETTER, + LOWERLETTER_DIGIT, + LOWERLETTER_DIGIT_UNDERSCORE, + NON_ZERO_DIGIT, + SPACE, + UPPERLETTER, + RANGLE, + }; + + explicit Scanner(absl::string_view source) : cur_(source) { + RestartCapture(); + } + + // Consume the next character of the given class from input. If the next + // character is not in the class, then GetResult will ultimately return false. + Scanner& One(CharClass clz) { + if (cur_.empty() || !Matches(clz, cur_[0])) { + return Error(); + } + cur_.remove_prefix(1); + return *this; + } + + // Consume the next s.size() characters of the input, if they match . If + // they don't match , this is a no-op. + Scanner& ZeroOrOneLiteral(absl::string_view s) { + absl::ConsumePrefix(&cur_, s); + return *this; + } + + // Consume the next s.size() characters of the input, if they match . If + // they don't match , then GetResult will ultimately return false. + Scanner& OneLiteral(absl::string_view s) { + if (!absl::ConsumePrefix(&cur_, s)) { + error_ = true; + } + return *this; + } + + // Consume characters from the input as long as they match . Zero + // characters is still considered a match, so it will never cause GetResult to + // return false. + Scanner& Any(CharClass clz) { + while (!cur_.empty() && Matches(clz, cur_[0])) { + cur_.remove_prefix(1); + } + return *this; + } + + // Shorthand for One(clz).Any(clz). + Scanner& Many(CharClass clz) { return One(clz).Any(clz); } + + // Reset the capture start point. + // + // Later, when GetResult is called and if it returns true, the capture + // returned will start at the position at the time this was called. + Scanner& RestartCapture() { + capture_start_ = cur_.data(); + capture_end_ = nullptr; + return *this; + } + + // Stop capturing input. + // + // Later, when GetResult is called and if it returns true, the capture + // returned will end at the position at the time this was called. + Scanner& StopCapture() { + capture_end_ = cur_.data(); + return *this; + } + + // If not at the input of input, then GetResult will ultimately return false. + Scanner& Eos() { + if (!cur_.empty()) error_ = true; + return *this; + } + + // Shorthand for Any(SPACE). + Scanner& AnySpace() { return Any(SPACE); } + + // This scans input until is reached. is NOT consumed. + Scanner& ScanUntil(char end_ch) { + ScanUntilImpl(end_ch, false); + return *this; + } + + // This scans input until is reached. is NOT consumed. + // Backslash escape sequences are skipped. + // Used for implementing quoted string scanning. + Scanner& ScanEscapedUntil(char end_ch) { + ScanUntilImpl(end_ch, true); + return *this; + } + + // Return the next character that will be scanned, or if there + // are no more characters to scan. + // Note that if a scan operation has failed (so GetResult() returns false), + // then the value of Peek may or may not have advanced since the scan + // operation that failed. + char Peek(char default_value = '\0') const { + return cur_.empty() ? default_value : cur_[0]; + } + + // Returns false if there are no remaining characters to consume. + int empty() const { return cur_.empty(); } + + // Returns true if the input string successfully matched. When true is + // returned, the remaining string is returned in and the captured + // string returned in , if non-NULL. + bool GetResult(absl::string_view* remaining = nullptr, + absl::string_view* capture = nullptr); + + private: + void ScanUntilImpl(char end_ch, bool escaped); + + Scanner& Error() { + error_ = true; + return *this; + } + + static bool IsLetter(char ch) { + return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'); + } + + static bool IsLowerLetter(char ch) { return ch >= 'a' && ch <= 'z'; } + + static bool IsDigit(char ch) { return ch >= '0' && ch <= '9'; } + + static bool IsSpace(char ch) { + return (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\v' || ch == '\f' || + ch == '\r'); + } + + static bool Matches(CharClass clz, char ch) { + switch (clz) { + case ALL: + return true; + case DIGIT: + return IsDigit(ch); + case LETTER: + return IsLetter(ch); + case LETTER_DIGIT: + return IsLetter(ch) || IsDigit(ch); + case LETTER_DIGIT_DASH_UNDERSCORE: + return (IsLetter(ch) || IsDigit(ch) || ch == '-' || ch == '_'); + case LETTER_DIGIT_DASH_DOT_SLASH: + return IsLetter(ch) || IsDigit(ch) || ch == '-' || ch == '.' || + ch == '/'; + case LETTER_DIGIT_DASH_DOT_SLASH_UNDERSCORE: + return (IsLetter(ch) || IsDigit(ch) || ch == '-' || ch == '.' || + ch == '/' || ch == '_'); + case LETTER_DIGIT_DOT: + return IsLetter(ch) || IsDigit(ch) || ch == '.'; + case LETTER_DIGIT_DOT_PLUS_MINUS: + return IsLetter(ch) || IsDigit(ch) || ch == '+' || ch == '-' || + ch == '.'; + case LETTER_DIGIT_DOT_UNDERSCORE: + return IsLetter(ch) || IsDigit(ch) || ch == '.' || ch == '_'; + case LETTER_DIGIT_UNDERSCORE: + return IsLetter(ch) || IsDigit(ch) || ch == '_'; + case LOWERLETTER: + return ch >= 'a' && ch <= 'z'; + case LOWERLETTER_DIGIT: + return IsLowerLetter(ch) || IsDigit(ch); + case LOWERLETTER_DIGIT_UNDERSCORE: + return IsLowerLetter(ch) || IsDigit(ch) || ch == '_'; + case NON_ZERO_DIGIT: + return IsDigit(ch) && ch != '0'; + case SPACE: + return IsSpace(ch); + case UPPERLETTER: + return ch >= 'A' && ch <= 'Z'; + case RANGLE: + return ch == '>'; + } + return false; + } + + absl::string_view cur_; + const char* capture_start_ = nullptr; + const char* capture_end_ = nullptr; + bool error_ = false; + + friend class ScannerTest; + + Scanner(const Scanner&) = delete; + void operator=(const Scanner&) = delete; +}; + +} // namespace strings +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_SCANNER_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/setround.h b/deps/exla/cache/xla_extension/include/tsl/platform/setround.h new file mode 100644 index 0000000000000000000000000000000000000000..503bda014819e7aad47e205fe181fabfea3d721b --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/setround.h @@ -0,0 +1,55 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_SETROUND_H_ +#define TENSORFLOW_TSL_PLATFORM_SETROUND_H_ + +#if defined(__ANDROID_API__) && (__ANDROID_API__ < 21) +// The header is broken pre-API 21 for several NDK releases. +#define TF_BROKEN_CFENV +#endif + +#if defined(TF_BROKEN_CFENV) +#include // NOLINT +#else +#include // NOLINT +#endif + +#include "xla/tsl/platform/macros.h" + +namespace tsl { +namespace port { + +// While this class is active, floating point rounding mode is set to the given +// mode. The mode can be one of the modes defined in , i.e. FE_DOWNWARD, +// FE_TONEAREST, FE_TOWARDZERO, or FE_UPWARD. The destructor restores the +// original rounding mode if it could be determined. If the original rounding +// mode could not be determined, the destructor sets it to FE_TONEAREST. +class ScopedSetRound { + public: + ScopedSetRound(int mode); + ~ScopedSetRound(); + + private: + int original_mode_; + + ScopedSetRound(const ScopedSetRound&) = delete; + void operator=(const ScopedSetRound&) = delete; +}; + +} // namespace port +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_SETROUND_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/snappy.h b/deps/exla/cache/xla_extension/include/tsl/platform/snappy.h new file mode 100644 index 0000000000000000000000000000000000000000..d2acb88796350ac29a092652fdbdf47371dee614 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/snappy.h @@ -0,0 +1,54 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_SNAPPY_H_ +#define TENSORFLOW_TSL_PLATFORM_SNAPPY_H_ + +#include "xla/tsl/platform/types.h" + +#if !defined(PLATFORM_WINDOWS) +#include +namespace tsl { +using ::iovec; // NOLINT(misc-unused-using-decls) +} // namespace tsl +#else +namespace tsl { +struct iovec { + void* iov_base; + size_t iov_len; +}; +} // namespace tsl +#endif + +namespace tsl { +namespace port { + +// Snappy compression/decompression support +bool Snappy_Compress(const char* input, size_t length, string* output); + +bool Snappy_CompressFromIOVec(const struct iovec* iov, + size_t uncompressed_length, string* output); + +bool Snappy_GetUncompressedLength(const char* input, size_t length, + size_t* result); +bool Snappy_Uncompress(const char* input, size_t length, char* output); + +bool Snappy_UncompressToIOVec(const char* compressed, size_t compressed_length, + const struct iovec* iov, size_t iov_cnt); + +} // namespace port +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_SNAPPY_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/stacktrace.h b/deps/exla/cache/xla_extension/include/tsl/platform/stacktrace.h new file mode 100644 index 0000000000000000000000000000000000000000..b4f4f4a0e0f73cb9a1cfca60f8fc45545671fab7 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/stacktrace.h @@ -0,0 +1,34 @@ +/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_STACKTRACE_H_ +#define TENSORFLOW_TSL_PLATFORM_STACKTRACE_H_ + +#include "tsl/platform/platform.h" // IWYU pragma: export + +// Include appropriate platform-dependent implementation. +#if defined(PLATFORM_GOOGLE) +#include "xla/tsl/platform/google/stacktrace.h" // IWYU pragma: export +#elif defined(PLATFORM_POSIX) || defined(PLATFORM_POSIX_ANDROID) || \ + defined(PLATFORM_GOOGLE_ANDROID) || defined(PLATFORM_POSIX_IOS) || \ + defined(PLATFORM_GOOGLE_IOS) +#include "xla/tsl/platform/default/stacktrace.h" // IWYU pragma: export +#elif defined(PLATFORM_WINDOWS) +#include "xla/tsl/platform/windows/stacktrace.h" // IWYU pragma: export +#else +#error Define the appropriate PLATFORM_ macro for this platform +#endif + +#endif // TENSORFLOW_TSL_PLATFORM_STACKTRACE_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/status.h b/deps/exla/cache/xla_extension/include/tsl/platform/status.h new file mode 100644 index 0000000000000000000000000000000000000000..fdd9343ac610f1fd09c8bb10b7c6c4c6d9cfa1b1 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/status.h @@ -0,0 +1,21 @@ +/* Copyright 2024 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_STATUS_H_ +#define TENSORFLOW_TSL_PLATFORM_STATUS_H_ + +#include "xla/tsl/platform/status.h" + +#endif // TENSORFLOW_TSL_PLATFORM_STATUS_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/statusor.h b/deps/exla/cache/xla_extension/include/tsl/platform/statusor.h new file mode 100644 index 0000000000000000000000000000000000000000..c4e6da3721d76d775091d9ed580268a24de1f7bf --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/statusor.h @@ -0,0 +1,21 @@ +/* Copyright 2024 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_STATUSOR_H_ +#define TENSORFLOW_TSL_PLATFORM_STATUSOR_H_ + +#include "xla/tsl/platform/statusor.h" + +#endif // TENSORFLOW_TSL_PLATFORM_STATUSOR_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/str_util.h b/deps/exla/cache/xla_extension/include/tsl/platform/str_util.h new file mode 100644 index 0000000000000000000000000000000000000000..ff7c4cd64e54849f6b296c72ef47b07dbf9bd6bf --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/str_util.h @@ -0,0 +1,238 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_STR_UTIL_H_ +#define TENSORFLOW_TSL_PLATFORM_STR_UTIL_H_ + +#include +#include +#include + +#include "absl/base/macros.h" +#include "absl/strings/ascii.h" +#include "absl/strings/escaping.h" +#include "absl/strings/match.h" +#include "absl/strings/str_join.h" +#include "absl/strings/str_split.h" +#include "absl/strings/strip.h" +#include "xla/tsl/platform/macros.h" +#include "xla/tsl/platform/types.h" +#include "tsl/platform/stringpiece.h" + +// TODO: b/323943471 - This macro should eventually be provided by Abseil. +#ifndef ABSL_DEPRECATE_AND_INLINE +#define ABSL_DEPRECATE_AND_INLINE() +#endif + +// Basic string utility routines +namespace tsl { +namespace str_util { + +// Returns a version of 'src' where unprintable characters have been +// escaped using C-style escape sequences. +ABSL_DEPRECATE_AND_INLINE() inline std::string CEscape(absl::string_view src) { + return absl::CEscape(src); +} + +// Copies "source" to "dest", rewriting C-style escape sequences -- +// '\n', '\r', '\\', '\ooo', etc -- to their ASCII equivalents. +// +// Errors: Sets the description of the first encountered error in +// 'error'. To disable error reporting, set 'error' to NULL. +// +// NOTE: Does not support \u or \U! +ABSL_DEPRECATE_AND_INLINE() +inline bool CUnescape(absl::string_view source, std::string* dest, + std::string* error) { + return absl::CUnescape(source, dest, error); +} + +// Removes any trailing whitespace from "*s". +ABSL_DEPRECATE_AND_INLINE() +inline void StripTrailingWhitespace(std::string* s) { + absl::StripTrailingAsciiWhitespace(s); +} + +// Removes leading ascii_isspace() characters. +// Returns number of characters removed. +size_t RemoveLeadingWhitespace(absl::string_view* text); + +// Removes trailing ascii_isspace() characters. +// Returns number of characters removed. +size_t RemoveTrailingWhitespace(absl::string_view* text); + +// Removes leading and trailing ascii_isspace() chars. +// Returns number of chars removed. +size_t RemoveWhitespaceContext(absl::string_view* text); + +// Consume a leading positive integer value. If any digits were +// found, store the value of the leading unsigned number in "*val", +// advance "*s" past the consumed number, and return true. If +// overflow occurred, returns false. Otherwise, returns false. +bool ConsumeLeadingDigits(absl::string_view* s, uint64_t* val); + +// Consume a leading token composed of non-whitespace characters only. +// If *s starts with a non-zero number of non-whitespace characters, store +// them in *val, advance *s past them, and return true. Else return false. +bool ConsumeNonWhitespace(absl::string_view* s, absl::string_view* val); + +// If "*s" starts with "expected", consume it and return true. +// Otherwise, return false. +ABSL_DEPRECATE_AND_INLINE() +inline bool ConsumePrefix(absl::string_view* s, absl::string_view expected) { + return absl::ConsumePrefix(s, expected); +} + +// If "*s" ends with "expected", remove it and return true. +// Otherwise, return false. +ABSL_DEPRECATE_AND_INLINE() +inline bool ConsumeSuffix(absl::string_view* s, absl::string_view expected) { + return absl::ConsumeSuffix(s, expected); +} + +// If "s" starts with "expected", return a view into "s" after "expected" but +// keep "s" unchanged. +// Otherwise, return the original "s". +ABSL_DEPRECATE_AND_INLINE() +TF_MUST_USE_RESULT inline absl::string_view StripPrefix( + absl::string_view s, absl::string_view expected) { + return absl::StripPrefix(s, expected); +} + +// If "s" ends with "expected", return a view into "s" until "expected" but +// keep "s" unchanged. +// Otherwise, return the original "s". +ABSL_DEPRECATE_AND_INLINE() +TF_MUST_USE_RESULT inline absl::string_view StripSuffix( + absl::string_view s, absl::string_view expected) { + return absl::StripSuffix(s, expected); +} + +// Return lower-cased version of s. +ABSL_DEPRECATE_AND_INLINE() inline std::string Lowercase(absl::string_view s) { + return absl::AsciiStrToLower(s); +} + +// Return upper-cased version of s. +ABSL_DEPRECATE_AND_INLINE() inline std::string Uppercase(absl::string_view s) { + return absl::AsciiStrToUpper(s); +} + +// Capitalize first character of each word in "*s". "delimiters" is a +// set of characters that can be used as word boundaries. +void TitlecaseString(std::string* s, absl::string_view delimiters); + +// Replaces the first occurrence (if replace_all is false) or all occurrences +// (if replace_all is true) of oldsub in s with newsub. +std::string StringReplace(absl::string_view s, absl::string_view oldsub, + absl::string_view newsub, bool replace_all); + +// Join functionality +template +ABSL_DEPRECATE_AND_INLINE() +std::string Join(const T& s, const char* sep) { + return absl::StrJoin(s, sep); +} + +// A variant of Join where for each element of "s", f(&dest_string, elem) +// is invoked (f is often constructed with a lambda of the form: +// [](string* result, ElemType elem) +template +ABSL_DEPRECATE_AND_INLINE() +std::string Join(const T& s, const char* sep, Formatter f) { + return absl::StrJoin(s, sep, f); +} + +struct AllowEmpty { + bool operator()(absl::string_view sp) const { return true; } +}; +struct SkipEmpty { + bool operator()(absl::string_view sp) const { return !sp.empty(); } +}; +struct SkipWhitespace { + bool operator()(absl::string_view sp) const { + return !absl::StripTrailingAsciiWhitespace(sp).empty(); + } +}; + +// Split strings using any of the supplied delimiters. For example: +// Split("a,b.c,d", ".,") would return {"a", "b", "c", "d"}. +inline std::vector Split(absl::string_view text, + absl::string_view delims) { + return text.empty() ? std::vector() + : absl::StrSplit(text, absl::ByAnyChar(delims)); +} + +template +std::vector Split(absl::string_view text, absl::string_view delims, + Predicate p) { + return text.empty() ? std::vector() + : absl::StrSplit(text, absl::ByAnyChar(delims), p); +} + +inline std::vector Split(absl::string_view text, char delim) { + return text.empty() ? std::vector() : absl::StrSplit(text, delim); +} + +template +std::vector Split(absl::string_view text, char delim, Predicate p) { + return text.empty() ? std::vector() : absl::StrSplit(text, delim, p); +} + +// StartsWith() +// +// Returns whether a given string `text` begins with `prefix`. +ABSL_DEPRECATE_AND_INLINE() +inline bool StartsWith(absl::string_view text, absl::string_view prefix) { + return absl::StartsWith(text, prefix); +} + +// EndsWith() +// +// Returns whether a given string `text` ends with `suffix`. +ABSL_DEPRECATE_AND_INLINE() +inline bool EndsWith(absl::string_view text, absl::string_view suffix) { + return absl::EndsWith(text, suffix); +} + +// StrContains() +// +// Returns whether a given string `haystack` contains the substring `needle`. +ABSL_DEPRECATE_AND_INLINE() +inline bool StrContains(absl::string_view haystack, absl::string_view needle) { + return absl::StrContains(haystack, needle); +} + +// Returns the length of the given null-terminated byte string 'str'. +// Returns 'string_max_len' if the null character was not found in the first +// 'string_max_len' bytes of 'str'. +size_t Strnlen(const char* str, const size_t string_max_len); + +// ----- NON STANDARD, TF SPECIFIC METHOD ----- +// Converts "^2ILoveYou!" to "i_love_you_". More specifically: +// - converts all non-alphanumeric characters to underscores +// - replaces each occurrence of a capital letter (except the very +// first character and if there is already an '_' before it) with '_' +// followed by this letter in lower case +// - Skips leading non-alpha characters +// This method is useful for producing strings matching "[a-z][a-z0-9_]*" +// as required by OpDef.ArgDef.name. The resulting string is either empty or +// matches this regex. +std::string ArgDefCase(absl::string_view s); + +} // namespace str_util +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_STR_UTIL_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/strcat.h b/deps/exla/cache/xla_extension/include/tsl/platform/strcat.h new file mode 100644 index 0000000000000000000000000000000000000000..e2aa39e73010709fd425ac5581a8b37d7ac798d9 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/strcat.h @@ -0,0 +1,243 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// #status: RECOMMENDED +// #category: operations on strings +// #summary: Merges strings or numbers with no delimiter. +// +#ifndef TENSORFLOW_TSL_PLATFORM_STRCAT_H_ +#define TENSORFLOW_TSL_PLATFORM_STRCAT_H_ + +#include + +#include "absl/base/attributes.h" +#include "absl/base/macros.h" +#include "absl/strings/str_cat.h" +#include "xla/tsl/platform/macros.h" +#include "xla/tsl/platform/types.h" +#include "tsl/platform/numbers.h" +#include "tsl/platform/stringpiece.h" + +// The AlphaNum type was designed to be used as the parameter type for StrCat(). +// Any routine accepting either a string or a number may accept it. +// The basic idea is that by accepting a "const AlphaNum &" as an argument +// to your function, your callers will automatically convert bools, integers, +// and floating point values to strings for you. +// +// NOTE: Use of AlphaNum outside of the "strings" package is unsupported except +// for the specific case of function parameters of type "AlphaNum" or "const +// AlphaNum &". In particular, instantiating AlphaNum directly as a stack +// variable is not supported. +// +// Conversion from 8-bit values is not accepted because if it were, then an +// attempt to pass ':' instead of ":" might result in a 58 ending up in your +// result. +// +// Bools convert to "0" or "1". +// +// Floating point values are converted to a string which, if passed to strtod(), +// would produce the exact same original double (except in case of NaN; all NaNs +// are considered the same value). We try to keep the string short but it's not +// guaranteed to be as short as possible. +// +// You can convert to Hexadecimal output rather than Decimal output using Hex. +// To do this, pass strings::Hex(my_int) as a parameter to StrCat. You may +// specify a minimum field width using a separate parameter, so the equivalent +// of Printf("%04x", my_int) is StrCat(Hex(my_int, absl::kZeroPad4)) +// +// This class has implicit constructors. +namespace tsl { +namespace strings { + +using PadSpec ABSL_DEPRECATE_AND_INLINE() = absl::PadSpec; +using absl::kNoPad; +using absl::kZeroPad10; +using absl::kZeroPad11; +using absl::kZeroPad12; +using absl::kZeroPad13; +using absl::kZeroPad14; +using absl::kZeroPad15; +using absl::kZeroPad16; +using absl::kZeroPad2; +using absl::kZeroPad3; +using absl::kZeroPad4; +using absl::kZeroPad5; +using absl::kZeroPad6; +using absl::kZeroPad7; +using absl::kZeroPad8; +using absl::kZeroPad9; +using Hex ABSL_DEPRECATE_AND_INLINE() = absl::Hex; + +class AlphaNum { + // NOLINTBEGIN(google-explicit-constructor) + public: + // No bool ctor -- bools convert to an integral type. + // A bool ctor would also convert incoming pointers (bletch). + AlphaNum(int i32) // NOLINT(runtime/explicit) + : piece_(digits_, FastInt32ToBufferLeft(i32, digits_)) {} + AlphaNum(unsigned int u32) // NOLINT(runtime/explicit) + : piece_(digits_, FastUInt32ToBufferLeft(u32, digits_)) {} + AlphaNum(long x) // NOLINT(runtime/explicit) + : piece_(digits_, FastInt64ToBufferLeft(x, digits_)) {} + AlphaNum(unsigned long x) // NOLINT(runtime/explicit) + : piece_(digits_, FastUInt64ToBufferLeft(x, digits_)) {} + AlphaNum(long long int i64) // NOLINT(runtime/explicit) + : piece_(digits_, FastInt64ToBufferLeft(i64, digits_)) {} + AlphaNum(unsigned long long int u64) // NOLINT(runtime/explicit) + : piece_(digits_, FastUInt64ToBufferLeft(u64, digits_)) {} + + AlphaNum(float f) // NOLINT(runtime/explicit) + : piece_(digits_, FloatToBuffer(f, digits_)) {} + AlphaNum(double f) // NOLINT(runtime/explicit) + : piece_(digits_, DoubleToBuffer(f, digits_)) {} + AlphaNum(bfloat16 bf) // NOLINT(runtime/explicit) + : piece_(digits_, FloatToBuffer(static_cast(bf), digits_)) {} + + AlphaNum(Hex hex); // NOLINT(runtime/explicit) + + AlphaNum(const char *c_str) : piece_(c_str) {} // NOLINT(runtime/explicit) + AlphaNum(const absl::string_view &pc) + : piece_(pc) {} // NOLINT(runtime/explicit) + AlphaNum(const std::string &str) // NOLINT(runtime/explicit) + : piece_(str) {} + AlphaNum(const tstring &str) // NOLINT(runtime/explicit) + : piece_(str) {} + template + AlphaNum(const std::basic_string, A> &str) + : piece_(str) {} // NOLINT(runtime/explicit) + + absl::string_view::size_type size() const { return piece_.size(); } + const char *data() const { return piece_.data(); } + absl::string_view Piece() const { return piece_; } + + private: + absl::string_view piece_; + char digits_[kFastToBufferSize]; + + // Use ":" not ':' + AlphaNum(char c); // NOLINT(runtime/explicit) + + // NOLINTEND(google-explicit-constructor) + AlphaNum(const AlphaNum &) = delete; + void operator=(const AlphaNum &) = delete; +}; + +// ---------------------------------------------------------------------- +// StrCat() +// This merges the given strings or numbers, with no delimiter. This +// is designed to be the fastest possible way to construct a string out +// of a mix of raw C strings, StringPieces, strings, bool values, +// and numeric values. +// +// Don't use this for user-visible strings. The localization process +// works poorly on strings built up out of fragments. +// +// For clarity and performance, don't use StrCat when appending to a +// string. In particular, avoid using any of these (anti-)patterns: +// str.append(StrCat(...)) +// str += StrCat(...) +// str = StrCat(str, ...) +// where the last is the worse, with the potential to change a loop +// from a linear time operation with O(1) dynamic allocations into a +// quadratic time operation with O(n) dynamic allocations. StrAppend +// is a better choice than any of the above, subject to the restriction +// of StrAppend(&str, a, b, c, ...) that none of the a, b, c, ... may +// be a reference into str. +// ---------------------------------------------------------------------- + +// For performance reasons, we have specializations for <= 4 args. +ABSL_DEPRECATED("Use absl::StrCat() instead.") +std::string StrCat(const AlphaNum &a) TF_MUST_USE_RESULT; +ABSL_DEPRECATED("Use absl::StrCat() instead.") +std::string StrCat(const AlphaNum &a, const AlphaNum &b) TF_MUST_USE_RESULT; +ABSL_DEPRECATED("Use absl::StrCat() instead.") +std::string StrCat(const AlphaNum &a, const AlphaNum &b, + const AlphaNum &c) TF_MUST_USE_RESULT; +ABSL_DEPRECATED("Use absl::StrCat() instead.") +std::string StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c, + const AlphaNum &d) TF_MUST_USE_RESULT; + +namespace internal { + +// Do not call directly - this is not part of the public API. +std::string CatPieces(std::initializer_list pieces); +void AppendPieces(std::string *dest, + std::initializer_list pieces); + +} // namespace internal + +// Support 5 or more arguments +template +ABSL_DEPRECATED("Use absl::StrCat() instead.") +std::string StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c, + const AlphaNum &d, const AlphaNum &e, + const AV &...args) TF_MUST_USE_RESULT; + +template +ABSL_DEPRECATED("Use absl::StrCat() instead.") +std::string StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c, + const AlphaNum &d, const AlphaNum &e, const AV &...args) { + return internal::CatPieces({a.Piece(), b.Piece(), c.Piece(), d.Piece(), + e.Piece(), + static_cast(args).Piece()...}); +} + +// ---------------------------------------------------------------------- +// StrAppend() +// Same as above, but adds the output to the given string. +// WARNING: For speed, StrAppend does not try to check each of its input +// arguments to be sure that they are not a subset of the string being +// appended to. That is, while this will work: +// +// string s = "foo"; +// s += s; +// +// This will not (necessarily) work: +// +// string s = "foo"; +// StrAppend(&s, s); +// +// Note: while StrCat supports appending up to 26 arguments, StrAppend +// is currently limited to 9. That's rarely an issue except when +// automatically transforming StrCat to StrAppend, and can easily be +// worked around as consecutive calls to StrAppend are quite efficient. +// ---------------------------------------------------------------------- + +ABSL_DEPRECATED("Use absl::StrAppend() instead.") +void StrAppend(std::string *dest, const AlphaNum &a); +ABSL_DEPRECATED("Use absl::StrAppend() instead.") +void StrAppend(std::string *dest, const AlphaNum &a, const AlphaNum &b); +ABSL_DEPRECATED("Use absl::StrAppend() instead.") +void StrAppend(std::string *dest, const AlphaNum &a, const AlphaNum &b, + const AlphaNum &c); +ABSL_DEPRECATED("Use absl::StrAppend() instead.") +void StrAppend(std::string *dest, const AlphaNum &a, const AlphaNum &b, + const AlphaNum &c, const AlphaNum &d); + +// Support 5 or more arguments +template +ABSL_DEPRECATED("Use absl::StrAppend() instead.") +inline void StrAppend(std::string *dest, const AlphaNum &a, const AlphaNum &b, + const AlphaNum &c, const AlphaNum &d, const AlphaNum &e, + const AV &...args) { + internal::AppendPieces(dest, + {a.Piece(), b.Piece(), c.Piece(), d.Piece(), e.Piece(), + static_cast(args).Piece()...}); +} + +} // namespace strings +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_STRCAT_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/stringpiece.h b/deps/exla/cache/xla_extension/include/tsl/platform/stringpiece.h new file mode 100644 index 0000000000000000000000000000000000000000..058d1d98da36b28955de14806408be36897533bc --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/stringpiece.h @@ -0,0 +1,43 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// StringPiece is a simple structure containing a pointer into some external +// storage and a size. The user of a StringPiece must ensure that the slice +// is not used after the corresponding external storage has been +// deallocated. +// +// Multiple threads can invoke const methods on a StringPiece without +// external synchronization, but if any of the threads may call a +// non-const method, all threads accessing the same StringPiece must use +// external synchronization. + +#ifndef TENSORFLOW_TSL_PLATFORM_STRINGPIECE_H_ +#define TENSORFLOW_TSL_PLATFORM_STRINGPIECE_H_ + +#include "absl/base/macros.h" +#include "absl/strings/string_view.h" // IWYU pragma: export + +// TODO: b/323943471 - This macro should eventually be provided by Abseil. +#ifndef ABSL_DEPRECATE_AND_INLINE +#define ABSL_DEPRECATE_AND_INLINE() +#endif + +namespace tsl { + +using StringPiece ABSL_DEPRECATE_AND_INLINE() = absl::string_view; + +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_STRINGPIECE_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/stringprintf.h b/deps/exla/cache/xla_extension/include/tsl/platform/stringprintf.h new file mode 100644 index 0000000000000000000000000000000000000000..6e1268dfa352dc2a2aacd8794d9e0b203e155b74 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/stringprintf.h @@ -0,0 +1,52 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// Printf variants that place their output in a C++ string. +// +// Usage: +// string result = strings::Printf("%d %s\n", 10, "hello"); +// strings::Appendf(&result, "%d %s\n", 20, "there"); + +#ifndef TENSORFLOW_TSL_PLATFORM_STRINGPRINTF_H_ +#define TENSORFLOW_TSL_PLATFORM_STRINGPRINTF_H_ + +#include + +#include + +#include "xla/tsl/platform/macros.h" +#include "xla/tsl/platform/types.h" + +namespace tsl { +namespace strings { + +// Return a C++ string +std::string Printf(const char* format, ...) + // Tell the compiler to do printf format string checking. + TF_PRINTF_ATTRIBUTE(1, 2); + +// Append result to a supplied string +void Appendf(std::string* dst, const char* format, ...) + // Tell the compiler to do printf format string checking. + TF_PRINTF_ATTRIBUTE(2, 3); + +// Lower-level routine that takes a va_list and appends to a specified +// string. All other routines are just convenience wrappers around it. +void Appendv(std::string* dst, const char* format, va_list ap); + +} // namespace strings +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_STRINGPRINTF_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/tensor_float_32_utils.h b/deps/exla/cache/xla_extension/include/tsl/platform/tensor_float_32_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..d956340c30330971e37e8e14664120f12a632a74 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/tensor_float_32_utils.h @@ -0,0 +1,29 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_TENSOR_FLOAT_32_UTILS_H_ +#define TENSORFLOW_TSL_PLATFORM_TENSOR_FLOAT_32_UTILS_H_ + +namespace tsl { + +// NOTE: The usage of this function is only supported through the Tensorflow +// framework. +void enable_tensor_float_32_execution(bool enabled); + +bool tensor_float_32_execution_enabled(); + +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_TENSOR_FLOAT_32_UTILS_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/thread_annotations.h b/deps/exla/cache/xla_extension/include/tsl/platform/thread_annotations.h new file mode 100644 index 0000000000000000000000000000000000000000..4f9604d6b695ce099e9e12207cfdffcbf4340348 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/thread_annotations.h @@ -0,0 +1,165 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// This header file contains the macro definitions for thread safety +// annotations that allow the developers to document the locking policies +// of their multi-threaded code. The annotations can also help program +// analysis tools to identify potential thread safety issues. +// +// The primary documentation on these annotations is external: +// http://clang.llvm.org/docs/ThreadSafetyAnalysis.html +// +// The annotations are implemented using compiler attributes. +// Using the macros defined here instead of the raw attributes allows +// for portability and future compatibility. +// +// When referring to mutexes in the arguments of the attributes, you should +// use variable names or more complex expressions (e.g. my_object->mutex_) +// that evaluate to a concrete mutex object whenever possible. If the mutex +// you want to refer to is not in scope, you may use a member pointer +// (e.g. &MyClass::mutex_) to refer to a mutex in some (unknown) object. +// + +#ifndef TENSORFLOW_TSL_PLATFORM_THREAD_ANNOTATIONS_H_ +#define TENSORFLOW_TSL_PLATFORM_THREAD_ANNOTATIONS_H_ + +// IWYU pragma: private, include "tsl/platform/thread_annotations.h" +// IWYU pragma: friend third_party/tensorflow/tsl/platform/thread_annotations.h + +#if defined(__clang__) && (!defined(SWIG)) +#define TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(x) __attribute__((x)) +#else +#define TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(x) // no-op +#endif + +// Document if a shared variable/field needs to be protected by a mutex. +// TF_GUARDED_BY allows the user to specify a particular mutex that should be +// held when accessing the annotated variable. GUARDED_VAR indicates that +// a shared variable is guarded by some unspecified mutex, for use in rare +// cases where a valid mutex expression cannot be specified. +#define TF_GUARDED_BY(x) TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(guarded_by(x)) +#define GUARDED_VAR // no-op + +// Document if the memory location pointed to by a pointer should be guarded +// by a mutex when dereferencing the pointer. PT_GUARDED_VAR is analogous to +// GUARDED_VAR. Note that a pointer variable to a shared memory location +// could itself be a shared variable. For example, if a shared global pointer +// q, which is guarded by mu1, points to a shared memory location that is +// guarded by mu2, q should be annotated as follows: +// int *q TF_GUARDED_BY(mu1) TF_PT_GUARDED_BY(mu2); +#define TF_PT_GUARDED_BY(x) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(pt_guarded_by(x)) +#define TF_PT_GUARDED_VAR // no-op + +// Document the acquisition order between locks that can be held +// simultaneously by a thread. For any two locks that need to be annotated +// to establish an acquisition order, only one of them needs the annotation. +// (i.e. You don't have to annotate both locks with both TF_ACQUIRED_AFTER +// and TF_ACQUIRED_BEFORE.) +#define TF_ACQUIRED_AFTER(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(acquired_after(__VA_ARGS__)) + +#define TF_ACQUIRED_BEFORE(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(acquired_before(__VA_ARGS__)) + +#define TF_ACQUIRE(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(acquire_capability(__VA_ARGS__)) + +#define TF_ACQUIRE_SHARED(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE( \ + acquire_shared_capability(__VA_ARGS__)) + +#define TF_RELEASE(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(release_capability(__VA_ARGS__)) + +// Document a function that expects a mutex to be held prior to entry. +// The mutex is expected to be held both on entry to and exit from the +// function. +#define TF_EXCLUSIVE_LOCKS_REQUIRED(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(exclusive_locks_required(__VA_ARGS__)) + +#define TF_SHARED_LOCKS_REQUIRED(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(shared_locks_required(__VA_ARGS__)) + +// Document the locks acquired in the body of the function. These locks +// cannot be held when calling this function (for instance, when the +// mutex implementation is non-reentrant). +#define TF_LOCKS_EXCLUDED(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(locks_excluded(__VA_ARGS__)) + +// Document a function that returns a mutex without acquiring it. For example, +// a public getter method that returns a pointer to a private mutex should +// be annotated with TF_LOCK_RETURNED. +#define TF_LOCK_RETURNED(x) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(lock_returned(x)) + +// Document if a class/type is a lockable type (such as the Mutex class). +#define TF_LOCKABLE TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(lockable) + +// Document if a class does RAII locking (such as the MutexLock class). +// The constructor should use LOCK_FUNCTION to specify the mutex that is +// acquired, and the destructor should use TF_UNLOCK_FUNCTION with no arguments; +// the analysis will assume that the destructor unlocks whatever the +// constructor locked. +#define TF_SCOPED_LOCKABLE \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(scoped_lockable) + +// Document functions that acquire a lock in the body of a function, and do +// not release it. +#define TF_EXCLUSIVE_LOCK_FUNCTION(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(exclusive_lock_function(__VA_ARGS__)) + +#define TF_SHARED_LOCK_FUNCTION(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(shared_lock_function(__VA_ARGS__)) + +// Document functions that expect a lock to be held on entry to the function, +// and release it in the body of the function. +#define TF_UNLOCK_FUNCTION(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(unlock_function(__VA_ARGS__)) + +// Document functions that try to acquire a lock, and return success or failure +// (or a non-boolean value that can be interpreted as a boolean). +// The first argument should be true for functions that return true on success, +// or false for functions that return false on success. The second argument +// specifies the mutex that is locked on success. If unspecified, it is assumed +// to be 'this'. +#define TF_EXCLUSIVE_TRYLOCK_FUNCTION(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE( \ + exclusive_trylock_function(__VA_ARGS__)) + +#define TF_SHARED_TRYLOCK_FUNCTION(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(shared_trylock_function(__VA_ARGS__)) + +// Document functions that dynamically check to see if a lock is held, and fail +// if it is not held. +#define TF_ASSERT_EXCLUSIVE_LOCK(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(assert_exclusive_lock(__VA_ARGS__)) + +#define TF_ASSERT_SHARED_LOCK(...) \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(assert_shared_lock(__VA_ARGS__)) + +// Turns off thread safety checking within the body of a particular function. +// This is used as an escape hatch for cases where either (a) the function +// is correct, but the locking is more complicated than the analyzer can handle, +// or (b) the function contains race conditions that are known to be benign. +#define TF_NO_THREAD_SAFETY_ANALYSIS \ + TF_INTERNAL_THREAD_ANNOTATION_ATTRIBUTE(no_thread_safety_analysis) + +// TF_TS_UNCHECKED should be placed around lock expressions that are not valid +// C++ syntax, but which are present for documentation purposes. These +// annotations will be ignored by the analysis. +#define TF_TS_UNCHECKED(x) "" + +#endif // TENSORFLOW_TSL_PLATFORM_THREAD_ANNOTATIONS_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/threadpool.h b/deps/exla/cache/xla_extension/include/tsl/platform/threadpool.h new file mode 100644 index 0000000000000000000000000000000000000000..3ab00c4d498b2b0352a608450f71a02a6548c28e --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/threadpool.h @@ -0,0 +1,21 @@ +/* Copyright 2024 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_THREADPOOL_H_ +#define TENSORFLOW_TSL_PLATFORM_THREADPOOL_H_ + +#include "xla/tsl/platform/threadpool.h" + +#endif // TENSORFLOW_TSL_PLATFORM_THREADPOOL_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/threadpool_async_executor.h b/deps/exla/cache/xla_extension/include/tsl/platform/threadpool_async_executor.h new file mode 100644 index 0000000000000000000000000000000000000000..deadc9511168566b2431192a18b33076f46e1c6a --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/threadpool_async_executor.h @@ -0,0 +1,21 @@ +/* Copyright 2024 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_THREADPOOL_ASYNC_EXECUTOR_H_ +#define TENSORFLOW_TSL_PLATFORM_THREADPOOL_ASYNC_EXECUTOR_H_ + +#include "xla/tsl/platform/threadpool_async_executor.h" + +#endif // TENSORFLOW_TSL_PLATFORM_THREADPOOL_ASYNC_EXECUTOR_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/tracing.h b/deps/exla/cache/xla_extension/include/tsl/platform/tracing.h new file mode 100644 index 0000000000000000000000000000000000000000..07a725f22031066195b8f3a35a41b3dae936113f --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/tracing.h @@ -0,0 +1,150 @@ +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_TRACING_H_ +#define TENSORFLOW_TSL_PLATFORM_TRACING_H_ + +// Tracing interface + +#include + +#include "xla/tsl/platform/macros.h" +#include "xla/tsl/platform/types.h" +#include "tsl/platform/platform.h" +#include "tsl/platform/stringpiece.h" + +namespace tsl { +namespace tracing { + +// This enumeration contains the identifiers of all TensorFlow CPU profiler +// events. It must be kept in sync with the code in GetEventCategoryName(). +enum struct EventCategory : unsigned { + kScheduleClosure = 0, + kRunClosure = 1, + kCompute = 2, + kNumCategories = 3 // sentinel - keep last +}; +constexpr unsigned GetNumEventCategories() { + return static_cast(EventCategory::kNumCategories); +} +const char* GetEventCategoryName(EventCategory); + +// Interface for CPU profiler events. +class EventCollector { + public: + virtual ~EventCollector() {} + virtual void RecordEvent(uint64 arg) const = 0; + virtual void StartRegion(uint64 arg) const = 0; + virtual void StopRegion() const = 0; + + // Annotates the current thread with a name. + static void SetCurrentThreadName(const char* name); + // Returns whether event collection is enabled. + static bool IsEnabled(); + + private: + friend void SetEventCollector(EventCategory, const EventCollector*); + friend const EventCollector* GetEventCollector(EventCategory); + + static std::array instances_; +}; +// Set the callback for RecordEvent and ScopedRegion of category. +// Not thread safe. Only call while EventCollector::IsEnabled returns false. +void SetEventCollector(EventCategory category, const EventCollector* collector); + +// Returns the callback for RecordEvent and ScopedRegion of category if +// EventCollector::IsEnabled(), otherwise returns null. +inline const EventCollector* GetEventCollector(EventCategory category) { + if (EventCollector::IsEnabled()) { + return EventCollector::instances_[static_cast(category)]; + } + return nullptr; +} + +// Returns a unique id to pass to RecordEvent/ScopedRegion. Never returns zero. +uint64 GetUniqueArg(); + +// Returns an id for name to pass to RecordEvent/ScopedRegion. +uint64 GetArgForName(absl::string_view name); + +// Records an atomic event through the currently registered EventCollector. +inline void RecordEvent(EventCategory category, uint64 arg) { + if (auto collector = GetEventCollector(category)) { + collector->RecordEvent(arg); + } +} + +// Records an event for the duration of the instance lifetime through the +// currently registered EventCollector. +class ScopedRegion { + public: + ScopedRegion(ScopedRegion&& other) noexcept // Move-constructible. + : collector_(other.collector_) { + other.collector_ = nullptr; + } + + ScopedRegion(EventCategory category, uint64 arg) + : collector_(GetEventCollector(category)) { + if (collector_) { + collector_->StartRegion(arg); + } + } + + // Same as ScopedRegion(category, GetUniqueArg()), but faster if + // EventCollector::IsEnabled() returns false. + explicit ScopedRegion(EventCategory category) + : collector_(GetEventCollector(category)) { + if (collector_) { + collector_->StartRegion(GetUniqueArg()); + } + } + + // Same as ScopedRegion(category, GetArgForName(name)), but faster if + // EventCollector::IsEnabled() returns false. + ScopedRegion(EventCategory category, absl::string_view name) + : collector_(GetEventCollector(category)) { + if (collector_) { + collector_->StartRegion(GetArgForName(name)); + } + } + + ~ScopedRegion() { + if (collector_ && EventCollector::IsEnabled()) { + collector_->StopRegion(); + } + } + + bool IsEnabled() const { return collector_ != nullptr; } + + private: + ScopedRegion(const ScopedRegion&) = delete; + void operator=(const ScopedRegion&) = delete; + + const EventCollector* collector_; +}; + +// Return the pathname of the directory where we are writing log files. +const char* GetLogDir(); + +} // namespace tracing +} // namespace tsl + +#if defined(PLATFORM_GOOGLE) +#include "xla/tsl/platform/google/tracing_impl.h" +#else +#include "xla/tsl/platform/default/tracing_impl.h" +#endif + +#endif // TENSORFLOW_TSL_PLATFORM_TRACING_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/tstring.h b/deps/exla/cache/xla_extension/include/tsl/platform/tstring.h new file mode 100644 index 0000000000000000000000000000000000000000..9c10389fc04379b3355c5b03ab99cbc4be651834 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/tstring.h @@ -0,0 +1,579 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_TSTRING_H_ +#define TENSORFLOW_TSL_PLATFORM_TSTRING_H_ + +#include + +#include +#include + +#include "tsl/platform/cord.h" +#include "tsl/platform/ctstring.h" +#include "tsl/platform/platform.h" +#include "tsl/platform/stringpiece.h" + +namespace tsl { + +// tensorflow::tstring is the scalar type for DT_STRING tensors. +// +// tstrings are meant to be used when interfacing with string tensors, and +// should not be considered as a general replacement for std::string in +// tensorflow. The primary purpose of tstring is to provide a unified and +// stable ABI for string tensors across TF Core/C-API/Lite/etc---mitigating +// unnecessary conversions across language boundaries, and allowing for compiler +// agnostic interoperability across dynamically loaded modules. +// +// In addition to ABI stability, tstrings features two string subtypes, VIEW and +// OFFSET. +// +// VIEW tstrings are views into unowned character buffers; they can be used to +// pass around existing character strings without incurring a per object heap +// allocation. Note that, like std::string_view, it is the user's +// responsibility to ensure that the underlying buffer of a VIEW tstring exceeds +// the lifetime of the associated tstring object. +// +// TODO(dero): Methods for creating OFFSET tensors are not currently +// implemented. +// +// OFFSET tstrings are platform independent offset defined strings which can be +// directly mmaped or copied into a tensor buffer without the need for +// deserialization or processing. For security reasons, it is imperative that +// OFFSET based string tensors are validated before use, or are from a trusted +// source. +// +// Underlying VIEW and OFFSET buffers are considered immutable, so l-value +// assignment, mutation, or non-const access to data() of tstrings will result +// in the conversion to an owned SMALL/LARGE type. +// +// The interface for tstring largely overlaps with std::string. Except where +// noted, expect equivalent semantics with synonymous std::string methods. +class tstring { + TF_TString tstr_; + + public: + enum Type { + // See cstring.h + SMALL = TF_TSTR_SMALL, + LARGE = TF_TSTR_LARGE, + OFFSET = TF_TSTR_OFFSET, + VIEW = TF_TSTR_VIEW, + }; + + // Assignment to a tstring object with a tstring::view type will create a VIEW + // type tstring. + class view { + const char* data_; + size_t size_; + + public: + explicit view(const char* data, size_t size) : data_(data), size_(size) {} + explicit view(const char* data) : data_(data), size_(::strlen(data)) {} + + const char* data() const { return data_; } + + size_t size() const { return size_; } + + view() = delete; + view(const view&) = delete; + view& operator=(const view&) = delete; + }; + + typedef const char* const_iterator; + + // Ctor + tstring(); + tstring(const std::string& str); // NOLINT TODO(b/147740521): Make explicit. + tstring(const char* str, size_t len); + tstring(const char* str); // NOLINT TODO(b/147740521): Make explicit. + tstring(size_t n, char c); + explicit tstring(const absl::string_view str); +#ifdef PLATFORM_GOOGLE + explicit tstring(const absl::Cord& cord); +#endif // PLATFORM_GOOGLE + + // Copy + tstring(const tstring& str); + + // Move + tstring(tstring&& str) noexcept; + + // Dtor + ~tstring(); + + // Copy Assignment + tstring& operator=(const tstring& str); + tstring& operator=(const std::string& str); + tstring& operator=(const char* str); + tstring& operator=(char ch); + tstring& operator=(const absl::string_view str); +#ifdef PLATFORM_GOOGLE + tstring& operator=(const absl::Cord& cord); +#endif // PLATFORM_GOOGLE + + // View Assignment + tstring& operator=(const view& tsv); + + // Move Assignment + tstring& operator=(tstring&& str) noexcept; + + // Comparison + int compare(const char* str, size_t len) const; + bool operator<(const tstring& o) const; + bool operator>(const tstring& o) const; + bool operator==(const char* str) const; + bool operator==(const tstring& o) const; + bool operator!=(const char* str) const; + bool operator!=(const tstring& o) const; + + // Conversion Operators + // TODO(b/147740521): Make explicit. + operator std::string() const; // NOLINT + // TODO(b/147740521): Make explicit. + operator absl::string_view() const; // NOLINT + + // Attributes + size_t size() const; + size_t length() const; + size_t capacity() const; + bool empty() const; + Type type() const; + + // Allocation + void resize(size_t new_size, char c = 0); + // Similar to resize, but will leave the newly grown region uninitialized. + void resize_uninitialized(size_t new_size); + void clear() noexcept; + void reserve(size_t n); + + // Iterators + const_iterator begin() const; + const_iterator end() const; + + // Const Element Access + const char* c_str() const; + const char* data() const; + const char& operator[](size_t i) const; + const char& back() const; + + // Mutable Element Access + // NOTE: For VIEW/OFFSET types, calling these methods will result in the + // conversion to a SMALL or heap allocated LARGE type. As a result, + // previously obtained pointers, references, or iterators to the underlying + // buffer will point to the original VIEW/OFFSET and not the new allocation. + char* mdata(); + char* data(); // DEPRECATED: Use mdata(). + char& operator[](size_t i); + + // Assignment + tstring& assign(const char* str, size_t len); + tstring& assign(const char* str); + + // View Assignment + tstring& assign_as_view(const tstring& str); + tstring& assign_as_view(const std::string& str); + tstring& assign_as_view(const absl::string_view str); + tstring& assign_as_view(const char* str, size_t len); + tstring& assign_as_view(const char* str); + + // Modifiers + // NOTE: Invalid input will result in undefined behavior. + tstring& append(const tstring& str); + tstring& append(const char* str, size_t len); + tstring& append(const char* str); + tstring& append(size_t n, char c); + + tstring& erase(size_t pos, size_t len); + + tstring& insert(size_t pos, const tstring& str, size_t subpos, size_t sublen); + tstring& insert(size_t pos, size_t n, char c); + void swap(tstring& str) noexcept; + void push_back(char ch); + + // Friends + friend bool operator==(const char* a, const tstring& b); + friend bool operator==(const std::string& a, const tstring& b); + friend tstring operator+(const tstring& a, const tstring& b); + friend std::ostream& operator<<(std::ostream& o, const tstring& str); + friend std::hash; + // Support for absl::StrCat() etc. + template + friend void AbslStringify(Sink& sink, const tstring& str) { + sink.Append(absl::string_view(str)); + } +}; + +// Non-member function overloads + +bool operator==(const char* a, const tstring& b); +bool operator==(const std::string& a, const tstring& b); +tstring operator+(const tstring& a, const tstring& b); +std::ostream& operator<<(std::ostream& o, const tstring& str); + +// Implementations + +// Ctor + +inline tstring::tstring() { TF_TString_Init(&tstr_); } + +inline tstring::tstring(const char* str, size_t len) { + TF_TString_Init(&tstr_); + TF_TString_Copy(&tstr_, str, len); +} + +inline tstring::tstring(const char* str) : tstring(str, ::strlen(str)) {} + +inline tstring::tstring(size_t n, char c) { + TF_TString_Init(&tstr_); + TF_TString_Resize(&tstr_, n, c); +} + +inline tstring::tstring(const std::string& str) + : tstring(str.data(), str.size()) {} + +inline tstring::tstring(const absl::string_view str) + : tstring(str.data(), str.size()) {} + +#ifdef PLATFORM_GOOGLE +inline tstring::tstring(const absl::Cord& cord) { + TF_TString_Init(&tstr_); + TF_TString_ResizeUninitialized(&tstr_, cord.size()); + + cord.CopyToArray(data()); +} +#endif // PLATFORM_GOOGLE + +// Copy + +inline tstring::tstring(const tstring& str) { + TF_TString_Init(&tstr_); + TF_TString_Assign(&tstr_, &str.tstr_); +} + +// Move + +inline tstring::tstring(tstring&& str) noexcept { + TF_TString_Init(&tstr_); + TF_TString_Move(&tstr_, &str.tstr_); +} + +// Dtor + +inline tstring::~tstring() { TF_TString_Dealloc(&tstr_); } + +// Copy Assignment + +inline tstring& tstring::operator=(const tstring& str) { + TF_TString_Assign(&tstr_, &str.tstr_); + + return *this; +} + +inline tstring& tstring::operator=(const std::string& str) { + TF_TString_Copy(&tstr_, str.data(), str.size()); + return *this; +} + +inline tstring& tstring::operator=(const char* str) { + TF_TString_Copy(&tstr_, str, ::strlen(str)); + + return *this; +} + +inline tstring& tstring::operator=(char c) { + resize_uninitialized(1); + (*this)[0] = c; + + return *this; +} + +inline tstring& tstring::operator=(const absl::string_view str) { + TF_TString_Copy(&tstr_, str.data(), str.size()); + + return *this; +} + +#ifdef PLATFORM_GOOGLE +inline tstring& tstring::operator=(const absl::Cord& cord) { + TF_TString_ResizeUninitialized(&tstr_, cord.size()); + + cord.CopyToArray(data()); + + return *this; +} +#endif // PLATFORM_GOOGLE + +// View Assignment + +inline tstring& tstring::operator=(const tstring::view& tsv) { + assign_as_view(tsv.data(), tsv.size()); + + return *this; +} + +// Move Assignment + +inline tstring& tstring::operator=(tstring&& str) noexcept { + TF_TString_Move(&tstr_, &str.tstr_); + + return *this; +} + +// Comparison + +inline int tstring::compare(const char* str, size_t len) const { + int ret = ::memcmp(data(), str, std::min(len, size())); + + if (ret < 0) return -1; + if (ret > 0) return +1; + + if (size() < len) return -1; + if (size() > len) return +1; + + return 0; +} + +inline bool tstring::operator<(const tstring& o) const { + return compare(o.data(), o.size()) < 0; +} + +inline bool tstring::operator>(const tstring& o) const { + return compare(o.data(), o.size()) > 0; +} + +inline bool tstring::operator==(const char* str) const { + return ::strlen(str) == size() && ::memcmp(data(), str, size()) == 0; +} + +inline bool tstring::operator==(const tstring& o) const { + return o.size() == size() && ::memcmp(data(), o.data(), size()) == 0; +} + +inline bool tstring::operator!=(const char* str) const { + return !(*this == str); +} + +inline bool tstring::operator!=(const tstring& o) const { + return !(*this == o); +} + +// Conversion Operators + +inline tstring::operator std::string() const { + return std::string(data(), size()); +} + +inline tstring::operator absl::string_view() const { + return absl::string_view(data(), size()); +} + +// Attributes + +inline size_t tstring::size() const { return TF_TString_GetSize(&tstr_); } + +inline size_t tstring::length() const { return size(); } + +inline size_t tstring::capacity() const { + return TF_TString_GetCapacity(&tstr_); +} + +inline bool tstring::empty() const { return size() == 0; } + +inline tstring::Type tstring::type() const { + return static_cast(TF_TString_GetType(&tstr_)); +} + +// Allocation + +inline void tstring::resize(size_t new_size, char c) { + TF_TString_Resize(&tstr_, new_size, c); +} + +inline void tstring::resize_uninitialized(size_t new_size) { + TF_TString_ResizeUninitialized(&tstr_, new_size); +} + +inline void tstring::clear() noexcept { + TF_TString_ResizeUninitialized(&tstr_, 0); +} + +inline void tstring::reserve(size_t n) { TF_TString_Reserve(&tstr_, n); } + +// Iterators + +inline tstring::const_iterator tstring::begin() const { return &(*this)[0]; } +inline tstring::const_iterator tstring::end() const { return &(*this)[size()]; } + +// Element Access + +inline const char* tstring::c_str() const { return data(); } + +inline const char* tstring::data() const { + return TF_TString_GetDataPointer(&tstr_); +} + +inline const char& tstring::operator[](size_t i) const { return data()[i]; } + +inline const char& tstring::back() const { return (*this)[size() - 1]; } + +inline char* tstring::mdata() { + return TF_TString_GetMutableDataPointer(&tstr_); +} + +inline char* tstring::data() { + // Deprecated + return mdata(); +} + +inline char& tstring::operator[](size_t i) { return mdata()[i]; } + +// Assignment + +inline tstring& tstring::assign(const char* str, size_t len) { + TF_TString_Copy(&tstr_, str, len); + + return *this; +} + +inline tstring& tstring::assign(const char* str) { + assign(str, ::strlen(str)); + + return *this; +} + +// View Assignment + +inline tstring& tstring::assign_as_view(const tstring& str) { + assign_as_view(str.data(), str.size()); + + return *this; +} + +inline tstring& tstring::assign_as_view(const std::string& str) { + assign_as_view(str.data(), str.size()); + + return *this; +} + +inline tstring& tstring::assign_as_view(const absl::string_view str) { + assign_as_view(str.data(), str.size()); + + return *this; +} + +inline tstring& tstring::assign_as_view(const char* str, size_t len) { + TF_TString_AssignView(&tstr_, str, len); + + return *this; +} + +inline tstring& tstring::assign_as_view(const char* str) { + assign_as_view(str, ::strlen(str)); + + return *this; +} + +// Modifiers + +inline tstring& tstring::append(const tstring& str) { + TF_TString_Append(&tstr_, &str.tstr_); + + return *this; +} + +inline tstring& tstring::append(const char* str, size_t len) { + TF_TString_AppendN(&tstr_, str, len); + + return *this; +} + +inline tstring& tstring::append(const char* str) { + append(str, ::strlen(str)); + + return *this; +} + +inline tstring& tstring::append(size_t n, char c) { + // For append use cases, we want to ensure amortized growth. + const size_t new_size = size() + n; + TF_TString_ReserveAmortized(&tstr_, new_size); + resize(new_size, c); + + return *this; +} + +inline tstring& tstring::erase(size_t pos, size_t len) { + memmove(mdata() + pos, data() + pos + len, size() - len - pos); + + resize(size() - len); + + return *this; +} + +inline tstring& tstring::insert(size_t pos, const tstring& str, size_t subpos, + size_t sublen) { + size_t orig_size = size(); + TF_TString_ResizeUninitialized(&tstr_, orig_size + sublen); + + memmove(mdata() + pos + sublen, data() + pos, orig_size - pos); + memmove(mdata() + pos, str.data() + subpos, sublen); + + return *this; +} + +inline tstring& tstring::insert(size_t pos, size_t n, char c) { + size_t size_ = size(); + TF_TString_ResizeUninitialized(&tstr_, size_ + n); + + memmove(mdata() + pos + n, data() + pos, size_ - pos); + memset(mdata() + pos, c, n); + + return *this; +} + +inline void tstring::swap(tstring& str) noexcept { + // TODO(dero): Invalid for OFFSET (unimplemented). + std::swap(tstr_, str.tstr_); +} + +inline void tstring::push_back(char ch) { append(1, ch); } + +// Friends + +inline bool operator==(const char* a, const tstring& b) { + return ::strlen(a) == b.size() && ::memcmp(a, b.data(), b.size()) == 0; +} + +inline bool operator==(const std::string& a, const tstring& b) { + return a.size() == b.size() && ::memcmp(a.data(), b.data(), b.size()) == 0; +} + +inline tstring operator+(const tstring& a, const tstring& b) { + tstring r; + r.reserve(a.size() + b.size()); + r.append(a); + r.append(b); + + return r; +} + +inline std::ostream& operator<<(std::ostream& o, const tstring& str) { + return o.write(str.data(), str.size()); +} + +} // namespace tsl + +#endif // TENSORFLOW_TSL_PLATFORM_TSTRING_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/platform/types.h b/deps/exla/cache/xla_extension/include/tsl/platform/types.h new file mode 100644 index 0000000000000000000000000000000000000000..90aa7993f7dbbc5e23e7de6f951402eec7d66478 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/platform/types.h @@ -0,0 +1,21 @@ +/* Copyright 2024 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PLATFORM_TYPES_H_ +#define TENSORFLOW_TSL_PLATFORM_TYPES_H_ + +#include "xla/tsl/platform/types.h" + +#endif // TENSORFLOW_TSL_PLATFORM_TYPES_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/profiler/lib/connected_traceme.h b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/connected_traceme.h new file mode 100644 index 0000000000000000000000000000000000000000..422e8271ee4fc30f822d3c76c41905343eb0552e --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/connected_traceme.h @@ -0,0 +1,120 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#ifndef TENSORFLOW_TSL_PROFILER_LIB_CONNECTED_TRACEME_H_ +#define TENSORFLOW_TSL_PROFILER_LIB_CONNECTED_TRACEME_H_ + +#include +#include +#include + +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" +#include "xla/tsl/platform/types.h" +#include "tsl/profiler/lib/context_types.h" +#include "tsl/profiler/lib/traceme.h" +#include "tsl/profiler/lib/traceme_encode.h" + +namespace tsl { +namespace profiler { + +/* + * TraceMeProducer and TraceMeConsumer are used to correlate TraceMe events on + * different threads. TraceMeProducer generates the context information to be + * passed to TraceMeConsumer, which consists of the context id and optionally + * the context type. They may be provided by the user. Then, the events of the + * same context information can be correlated during the analysis. + * + * Example Usages: + * (1) Using the user-provided context type and id. The user is responsible for + * providing the same context type and id to TraceMeProducer and + * TraceMeConsumer. + * [Producer Thread] + * // user_context_id is provided by the user. + * TraceMeProducer producer( + * [&] { return TraceMeEncode("op_dispatch", {{"op_type", "matmul"}}); }, + * ContextType::kTfExecutor, user_context_id); + * [Consumer Thread] + * // user_context_id is provided by the user. + * TraceMeConsumer consumer( + * [&] { return "op_execute"; }, ContextType::kTfExecutor, user_context_id); + * + * (2) Using the user-provided context type and generic id. The user is + * responsible for passing the TraceMeProducer's context id to + * TraceMeConsumer as well as providing the same context type to + * TraceMeProducer and TraceMeConsumer. + * [Producer Thread] + * TraceMeProducer producer( + * [&] { return TraceMeEncode("op_dispatch", {{"op_type", "matmul"}}); }, + * ContextType::kTfExecutor); + * context_id = producer.GetContextId(); + * // Pass context_id to the consumer thread. + * [Consumer Thread] + * // context_id is passed from the producer thread. + * TraceMeConsumer consumer( + * [&] { return "op_execute"; }, ContextType::kTfExecutor, context_id); + * + * (3) Using the generic context information. The user is responsible for + * passing the TraceMeProducer's context id to TraceMeConsumer. + * [Producer Thread] + * TraceMeProducer producer( + * [&] { return TraceMeEncode("op_dispatch", {{"op_type", "matmul"}}); }); + * context_id = producer.GetContextId(); + * // Pass context_id to the consumer thread. + * [Consumer Thread] + * // context_id is passed from the producer thread. + * TraceMeConsumer consumer([&] { return "op_execute"; }, context_id); + */ +class TraceMeProducer : public TraceMe { + public: + template + explicit TraceMeProducer(NameT&& name, + ContextType context_type = ContextType::kGeneric, + std::optional context_id = std::nullopt, + int level = 2) + : TraceMe(std::forward(name), level), + context_id_(context_id.has_value() ? context_id.value() + : TraceMe::NewActivityId()) { + AppendMetadata([&] { + return TraceMeEncode({{"_pt", context_type}, {"_p", context_id_}}); + }); + } + + uint64 GetContextId() const { return context_id_; } + + private: + uint64 context_id_; +}; + +class TraceMeConsumer : public TraceMe { + public: + template + TraceMeConsumer(NameT&& name, ContextType context_type, uint64 context_id, + int level = 2) + : TraceMe(std::forward(name), level) { + AppendMetadata([&] { + return TraceMeEncode({{"_ct", context_type}, {"_c", context_id}}); + }); + } + + template + TraceMeConsumer(NameT&& name, uint64 context_id, int level = 2) + : TraceMeConsumer(std::forward(name), ContextType::kGeneric, + context_id, level) {} +}; + +} // namespace profiler +} // namespace tsl + +#endif // TENSORFLOW_TSL_PROFILER_LIB_CONNECTED_TRACEME_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/profiler/lib/context_types.h b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/context_types.h new file mode 100644 index 0000000000000000000000000000000000000000..1e07a038272abd24e631cc7a0b96226e336ff7cf --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/context_types.h @@ -0,0 +1,61 @@ +/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#ifndef TENSORFLOW_TSL_PROFILER_LIB_CONTEXT_TYPES_H_ +#define TENSORFLOW_TSL_PROFILER_LIB_CONTEXT_TYPES_H_ + +#include + +namespace tsl { +namespace profiler { + +// Note: Please add new context type after all existing ones. +enum class ContextType : int { + kGeneric = 0, + kLegacy, + kTfExecutor, + kTfrtExecutor, + kSharedBatchScheduler, + kPjRt, + kAdaptiveSharedBatchScheduler, + kTfrtTpuRuntime, + kTpuEmbeddingEngine, + kGpuLaunch, + kBatcher, + kTpuStream, + kTpuLaunch, + kPathwaysExecutor, + kPjrtLibraryCall, + kThreadpoolEvent, + kJaxServingExecutor, + kLastContextType = ContextType::kJaxServingExecutor, +}; + +// In XFlow we encode context type as flow category as 6 bits. +static_assert(static_cast(ContextType::kLastContextType) < 64, + "Should have less than 64 categories."); + +const char* GetContextTypeString(ContextType context_type); + +inline ContextType GetSafeContextType(uint32_t context_type) { + if (context_type > static_cast(ContextType::kLastContextType)) { + return ContextType::kGeneric; + } + return static_cast(context_type); +} + +} // namespace profiler +} // namespace tsl + +#endif // TENSORFLOW_TSL_PROFILER_LIB_CONTEXT_TYPES_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/profiler/lib/nvtx_utils.h b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/nvtx_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..4d65c39e4bbd0ef287fd560c2796abf9a36c5165 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/nvtx_utils.h @@ -0,0 +1,82 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_TSL_PROFILER_LIB_NVTX_UTILS_H_ +#define TENSORFLOW_TSL_PROFILER_LIB_NVTX_UTILS_H_ + +#include + +#include +#include + +namespace tsl::profiler { +struct String; +// Opaque handle to a string that has been pre-registered with the profiler/NVTX +// implementation +using StringHandle = String*; + +struct ProfilerDomain; +// Opaque handle to a domain in the profiler/NVTX implementation +using ProfilerDomainHandle = ProfilerDomain*; + +// Get the "TSL" domain if NVTX profiling is enabled, otherwise null +ProfilerDomainHandle DefaultProfilerDomain(); + +// Assign a human-readable name to the current thread +void NameCurrentThread(const std::string&); + +// Assign a human-readable name to the given local device +void NameDevice(int device_id, const std::string& device_name); + +struct Stream; +// Opaque handle to an execution stream +using StreamHandle = Stream*; + +// Assign a human-readable name to the given execution stream +void NameStream(StreamHandle stream, const std::string& stream_name); + +// Register a string with the profiler/NVTX implementation for faster use +StringHandle RegisterString(ProfilerDomainHandle, const std::string&); + +// End a range that was created on this thread by RangePush +void RangePop(ProfilerDomainHandle); + +// Older/simpler version; NVTX implementation copies a C-style string each time +void RangePush(ProfilerDomainHandle domain, const char*); +inline void RangePush(ProfilerDomainHandle domain, const std::string& str) { + RangePush(domain, str.c_str()); +} + +namespace detail { +void RangePush(ProfilerDomainHandle domain, StringHandle title, + uint64_t schema_id, const void* payload, size_t payload_size); +} + +// More powerful version: pass a registered string instead of a C-style +// string, and attach a generic payload. The Annotation type must implement a +// method called NvtxSchemaId() that allows the NVTX backend to interpret the +// payload. +template +void RangePush(ProfilerDomainHandle domain, StringHandle title, + const Annotation& annotation) { + return detail::RangePush(domain, title, annotation.NvtxSchemaId(), + &annotation, sizeof(Annotation)); +} + +// Register the schema of a custom payload type, for use with the more powerful +// version of RangePush +uint64_t RegisterSchema(ProfilerDomainHandle domain, const void* schemaAttr); +} // namespace tsl::profiler +#endif // TENSORFLOW_TSL_PROFILER_LIB_NVTX_UTILS_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/profiler/lib/scoped_annotation.h b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/scoped_annotation.h new file mode 100644 index 0000000000000000000000000000000000000000..6ea66b6bde2734e4ffa10d88f7d9219f9e3343d1 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/scoped_annotation.h @@ -0,0 +1,113 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#ifndef TENSORFLOW_TSL_PROFILER_LIB_SCOPED_ANNOTATION_H_ +#define TENSORFLOW_TSL_PROFILER_LIB_SCOPED_ANNOTATION_H_ + +#include + +#include +#include +#include +#include + +#include "absl/strings/string_view.h" +#include "xla/tsl/platform/macros.h" +#include "tsl/platform/platform.h" // IWYU pragma: keep +#include "tsl/profiler/lib/nvtx_utils.h" + +#if !defined(IS_MOBILE_PLATFORM) +#include "xla/tsl/profiler/backends/cpu/annotation_stack.h" +#endif + +namespace tsl::profiler { + +// Adds an annotation to all activities through the currently registered +// TraceCollector until PopAnnotation() is called. +template +void PushAnnotation(const T& generator) { + if (auto domain = DefaultProfilerDomain(); + TF_PREDICT_FALSE(domain != nullptr)) { + RangePush(domain, generator()); + return; + } + +#if !defined(IS_MOBILE_PLATFORM) + if (TF_PREDICT_FALSE(AnnotationStack::IsEnabled())) { + AnnotationStack::PushAnnotation( + static_cast(generator())); + } +#endif +} + +inline void PushAnnotation(const char* name) { + PushAnnotation([&] { return name; }); +} +inline void PushAnnotation(const std::string& name) { + PushAnnotation([&] { return name; }); +} + +inline void PopAnnotation() { + // TODO(b/137971921): without this memory fence, two presubmit tests will + // fail probably due to compiler in that presubmit config. + std::atomic_thread_fence(std::memory_order_acquire); + + if (auto domain = DefaultProfilerDomain(); + TF_PREDICT_FALSE(domain != nullptr)) { + RangePop(domain); + return; + } + +#if !defined(IS_MOBILE_PLATFORM) + if (TF_PREDICT_FALSE(AnnotationStack::IsEnabled())) { + AnnotationStack::PopAnnotation(); + } +#endif +} + +// Adds an annotation to all activities for the duration of the instance +// lifetime through the currently registered TraceCollector. +// +// Usage: { +// ScopedAnnotation annotation("my kernels"); +// Kernel1<<>>; +// LaunchKernel2(); // Launches a CUDA kernel. +// } +// This will add 'my kernels' to both kernels in the profiler UI +class ScopedAnnotation { + public: + template + explicit ScopedAnnotation(T&& annotation) { + PushAnnotation(std::forward(annotation)); + } + + // Pops the name passed in the constructor from the current annotation. + ~ScopedAnnotation() { PopAnnotation(); } + + static bool IsEnabled() { +#if !defined(IS_MOBILE_PLATFORM) + return AnnotationStack::IsEnabled(); +#else + return false; +#endif + } + + private: + ScopedAnnotation(const ScopedAnnotation&) = delete; + ScopedAnnotation& operator=(const ScopedAnnotation&) = delete; +}; + +} // namespace tsl::profiler + +#endif // TENSORFLOW_TSL_PROFILER_LIB_SCOPED_ANNOTATION_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/profiler/lib/scoped_memory_debug_annotation.h b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/scoped_memory_debug_annotation.h new file mode 100644 index 0000000000000000000000000000000000000000..078e865807b3ef3ba64e1f7d2f37aa571e87f1e8 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/scoped_memory_debug_annotation.h @@ -0,0 +1,117 @@ +/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#ifndef TENSORFLOW_TSL_PROFILER_LIB_SCOPED_MEMORY_DEBUG_ANNOTATION_H_ +#define TENSORFLOW_TSL_PROFILER_LIB_SCOPED_MEMORY_DEBUG_ANNOTATION_H_ + +#include +#include +#include +#include + +#include "absl/strings/string_view.h" + +namespace tsl { +namespace profiler { + +std::string DefaultPendingShapeFunc(); + +// Annotations for memory profiling and debugging purpose. +// ScopedMemoryDebugAnnotation will cache the annotations in thread-local +// memory, and some allocators will try to tag allocations with the annotations. +struct MemoryDebugAnnotation { + absl::string_view pending_op_name; + int64_t pending_step_id = 0; + absl::string_view pending_region_type; + int32_t pending_data_type = 0; + // A lambda function, when invoked, it will generate the string that describe + // the shape of the pending tensor. By default, the TensorShape string is an + // empty string. + std::function pending_shape_func = DefaultPendingShapeFunc; +}; + +// Wrapper class of MemoryDebugAnnotation for RAII. +class ScopedMemoryDebugAnnotation { + public: + static const MemoryDebugAnnotation& CurrentAnnotation() { + return *ThreadMemoryDebugAnnotation(); + } + + explicit ScopedMemoryDebugAnnotation(absl::string_view op_name) { + MemoryDebugAnnotation* thread_local_annotation = + ThreadMemoryDebugAnnotation(); + last_annotation_ = *thread_local_annotation; + *thread_local_annotation = MemoryDebugAnnotation(); + thread_local_annotation->pending_op_name = op_name; + } + + explicit ScopedMemoryDebugAnnotation(absl::string_view op_name, + int64_t step_id) { + MemoryDebugAnnotation* thread_local_annotation = + ThreadMemoryDebugAnnotation(); + last_annotation_ = *thread_local_annotation; + *thread_local_annotation = MemoryDebugAnnotation(); + thread_local_annotation->pending_op_name = op_name; + thread_local_annotation->pending_step_id = step_id; + } + + // This constructor keeps the pending_op_name and pending_step_id from parent + // (if any). Otherwise it overwrites with op_name. + explicit ScopedMemoryDebugAnnotation( + absl::string_view op_name, absl::string_view region_type, + int32_t data_type, std::function&& pending_shape_func) { + MemoryDebugAnnotation* thread_local_annotation = + ThreadMemoryDebugAnnotation(); + last_annotation_ = *thread_local_annotation; + if (thread_local_annotation->pending_op_name.empty()) { + thread_local_annotation->pending_op_name = op_name; + } + thread_local_annotation->pending_region_type = region_type; + thread_local_annotation->pending_data_type = data_type; + thread_local_annotation->pending_shape_func = std::move(pending_shape_func); + } + + explicit ScopedMemoryDebugAnnotation( + absl::string_view op_name, int64_t step_id, absl::string_view region_type, + int32_t data_type, std::function&& pending_shape_func) { + MemoryDebugAnnotation* thread_local_annotation = + ThreadMemoryDebugAnnotation(); + last_annotation_ = *thread_local_annotation; + thread_local_annotation->pending_op_name = op_name; + thread_local_annotation->pending_step_id = step_id; + thread_local_annotation->pending_region_type = region_type; + thread_local_annotation->pending_data_type = data_type; + thread_local_annotation->pending_shape_func = std::move(pending_shape_func); + } + + ~ScopedMemoryDebugAnnotation() { + *ThreadMemoryDebugAnnotation() = last_annotation_; + } + + private: + // Returns a pointer to the MemoryDebugAnnotation for the current thread. + static MemoryDebugAnnotation* ThreadMemoryDebugAnnotation(); + + // Stores the previous values in case the annotations are nested. + MemoryDebugAnnotation last_annotation_; + + ScopedMemoryDebugAnnotation(const ScopedMemoryDebugAnnotation&) = delete; + ScopedMemoryDebugAnnotation& operator=(const ScopedMemoryDebugAnnotation&) = + delete; +}; + +} // namespace profiler +} // namespace tsl + +#endif // TENSORFLOW_TSL_PROFILER_LIB_SCOPED_MEMORY_DEBUG_ANNOTATION_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/profiler/lib/traceme.h b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/traceme.h new file mode 100644 index 0000000000000000000000000000000000000000..566dfef0a876bb4d5b41acaa3803b89703dc4dc2 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/traceme.h @@ -0,0 +1,343 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#ifndef TENSORFLOW_TSL_PROFILER_LIB_TRACEME_H_ +#define TENSORFLOW_TSL_PROFILER_LIB_TRACEME_H_ + +#include + +#include +#include +#include +#include +#include + +#include "absl/strings/string_view.h" +#include "xla/tsl/platform/logging.h" +#include "xla/tsl/platform/macros.h" +#include "xla/tsl/profiler/utils/no_init.h" +#include "tsl/profiler/lib/traceme_encode.h" // IWYU pragma: export + +#if !defined(IS_MOBILE_PLATFORM) +#include "xla/tsl/profiler/backends/cpu/traceme_recorder.h" +#include "xla/tsl/profiler/utils/time_utils.h" +#endif + +namespace tsl { +namespace profiler { + +constexpr uint64_t kTraceMeDefaultFilterMask = + std::numeric_limits::max(); + +// Predefined levels: +// - Level 1 (kCritical) is the default and used only for user instrumentation. +// - Level 2 (kInfo) is used by profiler for instrumenting high level program +// execution details (expensive TF ops, XLA ops, etc). +// - Level 3 (kVerbose) is also used by profiler to instrument more verbose +// (low-level) program execution details (cheap TF ops, etc). +enum TraceMeLevel { + kCritical = 1, + kInfo = 2, + kVerbose = 3, +}; + +// This is specifically used for instrumenting Tensorflow ops. +// Takes input as whether a TF op is expensive or not and returns the TraceMe +// level to be assigned to trace that particular op. Assigns level 2 for +// expensive ops (these are high-level details and shown by default in profiler +// UI). Assigns level 3 for cheap ops (low-level details not shown by default). +inline int GetTFTraceMeLevel(bool is_expensive) { + return is_expensive ? kInfo : kVerbose; +} + +// This class permits user-specified (CPU) tracing activities. A trace activity +// is started when an object of this class is created and stopped when the +// object is destroyed. +// +// CPU tracing can be useful when trying to understand what parts of GPU +// computation (e.g., kernels and memcpy) correspond to higher level activities +// in the overall program. For instance, a collection of kernels maybe +// performing one "step" of a program that is better visualized together than +// interspersed with kernels from other "steps". Therefore, a TraceMe object +// can be created at each "step". +// +// Two APIs are provided: +// (1) Scoped object: a TraceMe object starts tracing on construction, and +// stops tracing when it goes out of scope. +// { +// TraceMe trace("step"); +// ... do some work ... +// } +// TraceMe objects can be members of a class, or allocated on the heap. +// (2) Static methods: ActivityStart and ActivityEnd may be called in pairs. +// auto id = ActivityStart("step"); +// ... do some work ... +// ActivityEnd(id); +// The two static methods should be called within the same thread. +class TraceMe { + public: + // Constructor that traces a user-defined activity labeled with name + // in the UI. Level defines the trace priority, used for filtering TraceMe + // events. By default, traces with TraceMe level <= 2 are recorded. Levels: + // - Must be a positive integer. + // - Can be a value in enum TraceMeLevel. + // Users are welcome to use level > 3 in their code, if they wish to filter + // out their host traces based on verbosity. + explicit TraceMe(absl::string_view name, int level = 1, + uint64_t filter_mask = kTraceMeDefaultFilterMask) { + DCHECK_GE(level, 1); +#if !defined(IS_MOBILE_PLATFORM) + if (TF_PREDICT_FALSE(TraceMeRecorder::Active(level) && + TraceMeRecorder::CheckFilter(filter_mask))) { + name_.Emplace(std::string(name)); + start_time_ = GetCurrentTimeNanos(); + } +#endif + } + + // Do not allow passing a temporary string as the overhead of generating that + // string should only be incurred when tracing is enabled. Wrap the temporary + // string generation (e.g., StrCat) in a lambda and use the name_generator + // template instead. + explicit TraceMe(std::string&& name, int level = 1, + uint64_t filter_mask = kTraceMeDefaultFilterMask) = delete; + + // Do not allow passing strings by reference or value since the caller + // may unintentionally maintain ownership of the name. + // Explicitly wrap the name in a string_view if you really wish to maintain + // ownership of a string already generated for other purposes. For temporary + // strings (e.g., result of StrCat) use the name_generator template. + explicit TraceMe(const std::string& name, int level = 1, + uint64_t filter_mask = kTraceMeDefaultFilterMask) = delete; + + // This overload is necessary to make TraceMe's with string literals work. + // Otherwise, the name_generator template would be used. + explicit TraceMe(const char* raw, int level = 1, + uint64_t filter_mask = kTraceMeDefaultFilterMask) + : TraceMe(absl::string_view(raw), level, filter_mask) {} + + // This overload only generates the name (and possibly metadata) if tracing is + // enabled. Useful for avoiding expensive operations (e.g., string + // concatenation) when tracing is disabled. + // name_generator may be a lambda or functor that returns a type that the + // string() constructor can take, e.g., the result of TraceMeEncode. + // name_generator is templated, rather than a std::function to avoid + // allocations std::function might make even if never called. + // Example Usage: + // TraceMe trace_me([&]() { + // return StrCat("my_trace", id); + // } + // TraceMe op_trace_me([&]() { + // return TraceMeOp(op_name, op_type); + // } + // TraceMe trace_me_with_metadata([&value1]() { + // return TraceMeEncode("my_trace", {{"key1", value1}, {"key2", 42}}); + // }); + template , bool> = true> + explicit TraceMe(NameGeneratorT&& name_generator, int level = 1, + uint64_t filter_mask = kTraceMeDefaultFilterMask) { + DCHECK_GE(level, 1); +#if !defined(IS_MOBILE_PLATFORM) + if (TF_PREDICT_FALSE(TraceMeRecorder::Active(level) && + TraceMeRecorder::CheckFilter(filter_mask))) { + name_.Emplace(std::forward(name_generator)()); + start_time_ = GetCurrentTimeNanos(); + } +#endif + } + + // Movable. + TraceMe(TraceMe&& other) noexcept { *this = std::move(other); } + TraceMe& operator=(TraceMe&& other) noexcept { +#if !defined(IS_MOBILE_PLATFORM) + if (TF_PREDICT_FALSE(other.start_time_ != kUntracedActivity)) { + name_.Emplace(std::move(other.name_).Consume()); + start_time_ = std::exchange(other.start_time_, kUntracedActivity); + } +#endif + return *this; + } + + ~TraceMe() { Stop(); } + + // Stop tracing the activity. Called by the destructor, but exposed to allow + // stopping tracing before the object goes out of scope. Only has an effect + // the first time it is called. + void Stop() { + // We do not need to check the trace level again here. + // - If tracing wasn't active to start with, we have kUntracedActivity. + // - If tracing was active and was stopped, we have + // TraceMeRecorder::Active(). + // - If tracing was active and was restarted at a lower level, we may + // spuriously record the event. This is extremely rare, and acceptable as + // event will be discarded when its start timestamp fall outside of the + // start/stop session timestamp. +#if !defined(IS_MOBILE_PLATFORM) + if (TF_PREDICT_FALSE(start_time_ != kUntracedActivity)) { + if (TF_PREDICT_TRUE(TraceMeRecorder::Active())) { + TraceMeRecorder::Record( + {std::move(name_.value), start_time_, GetCurrentTimeNanos()}); + } + name_.Destroy(); + start_time_ = kUntracedActivity; + } +#endif + } + + // Appends new_metadata to the TraceMe name passed to the constructor. + // metadata_generator may be a lambda or functor that returns a type that the + // string() constructor can take, e.g., the result of TraceMeEncode. + // metadata_generator is only evaluated when tracing is enabled. + // metadata_generator is templated, rather than a std::function to avoid + // allocations std::function might make even if never called. + // Example Usage: + // trace_me.AppendMetadata([&value1]() { + // return TraceMeEncode({{"key1", value1}, {"key2", 42}}); + // }); + template < + typename MetadataGeneratorT, + std::enable_if_t, bool> = true> + void AppendMetadata(MetadataGeneratorT&& metadata_generator) { +#if !defined(IS_MOBILE_PLATFORM) + if (TF_PREDICT_FALSE(start_time_ != kUntracedActivity)) { + if (TF_PREDICT_TRUE(TraceMeRecorder::Active())) { + traceme_internal::AppendMetadata( + &name_.value, + std::forward(metadata_generator)()); + } + } +#endif + } + + // Static API, for use when scoped objects are inconvenient. + + // Record the start time of an activity. + // Returns the activity ID, which is used to stop the activity. + // Calls `name_generator` to get the name for activity. + template , bool> = true> + static int64_t ActivityStart( + NameGeneratorT&& name_generator, int level = 1, + uint64_t filter_mask = kTraceMeDefaultFilterMask) { +#if !defined(IS_MOBILE_PLATFORM) + if (TF_PREDICT_FALSE(TraceMeRecorder::Active(level) && + TraceMeRecorder::CheckFilter(filter_mask))) { + int64_t activity_id = TraceMeRecorder::NewActivityId(); + TraceMeRecorder::Record({std::forward(name_generator)(), + GetCurrentTimeNanos(), -activity_id}); + return activity_id; + } +#endif + return kUntracedActivity; + } + + // Record the start time of an activity. + // Returns the activity ID, which is used to stop the activity. + static int64_t ActivityStart( + absl::string_view name, int level = 1, + uint64_t filter_mask = kTraceMeDefaultFilterMask) { +#if !defined(IS_MOBILE_PLATFORM) + if (TF_PREDICT_FALSE(TraceMeRecorder::Active(level) && + TraceMeRecorder::CheckFilter(filter_mask))) { + int64_t activity_id = TraceMeRecorder::NewActivityId(); + TraceMeRecorder::Record( + {std::string(name), GetCurrentTimeNanos(), -activity_id}); + return activity_id; + } +#endif + return kUntracedActivity; + } + + // Same as ActivityStart above, an overload for "const std::string&" + static int64_t ActivityStart( + const std::string& name, int level = 1, + uint64_t filter_mask = kTraceMeDefaultFilterMask) { + return ActivityStart(absl::string_view(name), level, filter_mask); + } + + // Same as ActivityStart above, an overload for "const char*" + static int64_t ActivityStart( + const char* name, int level = 1, + uint64_t filter_mask = kTraceMeDefaultFilterMask) { + return ActivityStart(absl::string_view(name), level, filter_mask); + } + + // Record the end time of an activity started by ActivityStart(). + static void ActivityEnd(int64_t activity_id) { +#if !defined(IS_MOBILE_PLATFORM) + // We don't check the level again (see TraceMe::Stop()). + if (TF_PREDICT_FALSE(activity_id != kUntracedActivity)) { + if (TF_PREDICT_TRUE(TraceMeRecorder::Active())) { + TraceMeRecorder::Record( + {std::string(), -activity_id, GetCurrentTimeNanos()}); + } + } +#endif + } + + // Records the time of an instant activity. + template , bool> = true> + static void InstantActivity( + NameGeneratorT&& name_generator, int level = 1, + uint64_t filter_mask = kTraceMeDefaultFilterMask) { +#if !defined(IS_MOBILE_PLATFORM) + if (TF_PREDICT_FALSE(TraceMeRecorder::Active(level) && + TraceMeRecorder::CheckFilter(filter_mask))) { + int64_t now = GetCurrentTimeNanos(); + TraceMeRecorder::Record({std::forward(name_generator)(), + /*start_time=*/now, /*end_time=*/now}); + } +#endif + } + + static bool Active(int level = 1) { +#if !defined(IS_MOBILE_PLATFORM) + return TraceMeRecorder::Active(level); +#else + return false; +#endif + } + + static int64_t NewActivityId() { +#if !defined(IS_MOBILE_PLATFORM) + return TraceMeRecorder::NewActivityId(); +#else + return 0; +#endif + } + + private: + // Start time used when tracing is disabled. + constexpr static int64_t kUntracedActivity = 0; + + TraceMe(const TraceMe&) = delete; + void operator=(const TraceMe&) = delete; + + NoInit name_; + + int64_t start_time_ = kUntracedActivity; +}; + +// Whether OpKernel::TraceString will populate additional information for +// profiler, such as tensor shapes. +inline bool TfOpDetailsEnabled() { + return TraceMe::Active(TraceMeLevel::kVerbose); +} + +} // namespace profiler +} // namespace tsl + +#endif // TENSORFLOW_TSL_PROFILER_LIB_TRACEME_H_ diff --git a/deps/exla/cache/xla_extension/include/tsl/profiler/lib/traceme_encode.h b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/traceme_encode.h new file mode 100644 index 0000000000000000000000000000000000000000..69f12dd0825e3662a0cb3cdc28b83593828a2c93 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/tsl/profiler/lib/traceme_encode.h @@ -0,0 +1,174 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#ifndef TENSORFLOW_TSL_PROFILER_LIB_TRACEME_ENCODE_H_ +#define TENSORFLOW_TSL_PROFILER_LIB_TRACEME_ENCODE_H_ + +#include + +#include +#include + +#include "absl/base/attributes.h" +#include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" +#include "xla/tsl/platform/logging.h" +#include "xla/tsl/platform/macros.h" + +namespace tsl { +namespace profiler { + +// An argument passed to TraceMeEncode. +struct TraceMeArg { + // String conversions of value types are supported via AlphaNum. We keep a + // reference to the AlphaNum's internal buffer here, so it must remain valid + // for the lifetime of this object. We cannot store it by value because it is + // not safe to construct an AlphaNum as a member of a class, particularly when + // AbslStringify is being used (it may reference default arguments that are on + // the caller's stack, if we constructed it here those default arguments would + // be destroyed before they are used). + TraceMeArg(absl::string_view k, + const absl::AlphaNum& v ABSL_ATTRIBUTE_LIFETIME_BOUND) + : key(k), value(v.Piece()) {} + + TraceMeArg(const TraceMeArg&) = delete; + void operator=(const TraceMeArg&) = delete; + + absl::string_view key; + absl::string_view value; +}; + +namespace traceme_internal { + +// Copies the contents of str to the address pointed by out. +// Returns the address after the copy. +// REQUIRED: The address range [out, out + str.size()] must have been allocated. +TF_ATTRIBUTE_ALWAYS_INLINE inline char* Append(char* out, + absl::string_view str) { + DCHECK(!absl::StrContains(str, '#')) + << "'#' is not a valid character in TraceMeEncode"; + const size_t str_size = str.size(); + if (TF_PREDICT_TRUE(str_size > 0)) { + memcpy(out, str.data(), str_size); + out += str_size; + } + return out; +} + +// Appends args encoded as TraceMe metadata to name. +TF_ATTRIBUTE_ALWAYS_INLINE inline std::string AppendArgs( + std::string name, std::initializer_list args) { + if (TF_PREDICT_TRUE(args.size() > 0)) { + const auto old_size = name.size(); + auto new_size = old_size + args.size() * 2 + 1; + for (const auto& arg : args) { + new_size += arg.key.size() + arg.value.size(); + } + name.resize(new_size); + char* const begin = &name[0]; + char* out = begin + old_size; + *out++ = '#'; + for (const auto& arg : args) { + out = Append(out, arg.key); + *out++ = '='; + out = Append(out, arg.value); + *out++ = ','; + } + *(out - 1) = '#'; + DCHECK_EQ(out, begin + new_size); + } + return name; +} + +// Appends new_metadata to the metadata part of name. +TF_ATTRIBUTE_ALWAYS_INLINE inline void AppendMetadata( + std::string* name, absl::string_view new_metadata) { + if (!TF_PREDICT_FALSE(new_metadata.empty())) { + if (!name->empty() && name->back() == '#') { // name already has metadata + name->back() = ','; + if (TF_PREDICT_TRUE(new_metadata.front() == '#')) { + new_metadata.remove_prefix(1); + } + } + name->append(new_metadata.data(), new_metadata.size()); + } +} + +} // namespace traceme_internal + +// Encodes an event name and arguments into TraceMe metadata. +// Use within a lambda to avoid expensive operations when tracing is disabled. +// Example Usage: +// TraceMe trace_me([value1]() { +// return TraceMeEncode("my_trace", {{"key1", value1}, {"key2", 42}}); +// }); +TF_ATTRIBUTE_ALWAYS_INLINE inline std::string TraceMeEncode( + std::string name, std::initializer_list args) { + return traceme_internal::AppendArgs(std::move(name), args); +} +TF_ATTRIBUTE_ALWAYS_INLINE inline std::string TraceMeEncode( + absl::string_view name, std::initializer_list args) { + return traceme_internal::AppendArgs(std::string(name), args); +} +TF_ATTRIBUTE_ALWAYS_INLINE inline std::string TraceMeEncode( + const char* name, std::initializer_list args) { + return traceme_internal::AppendArgs(std::string(name), args); +} + +// Encodes arguments into TraceMe metadata. +// Use within a lambda to avoid expensive operations when tracing is disabled. +// Example Usage: +// TraceMe trace_me("my_trace"); +// ... +// trace_me.AppendMetadata([value1]() { +// return TraceMeEncode({{"key1", value1}, {"key2", 42}}); +// }); +TF_ATTRIBUTE_ALWAYS_INLINE inline std::string TraceMeEncode( + std::initializer_list args) { + return traceme_internal::AppendArgs(std::string(), args); +} + +// Concatenates op_name and op_type. +TF_ATTRIBUTE_ALWAYS_INLINE inline std::string TraceMeOp( + absl::string_view op_name, absl::string_view op_type) { + return absl::StrCat(op_name, ":", op_type); +} + +TF_ATTRIBUTE_ALWAYS_INLINE inline std::string TraceMeOp(const char* op_name, + const char* op_type) { + return absl::StrCat(op_name, ":", op_type); +} + +TF_ATTRIBUTE_ALWAYS_INLINE inline std::string TraceMeOp( + std::string&& op_name, absl::string_view op_type) { + absl::StrAppend(&op_name, ":", op_type); + return op_name; +} + +// Concatenates op_name and op_type. +TF_ATTRIBUTE_ALWAYS_INLINE inline std::string TraceMeOpOverride( + absl::string_view op_name, absl::string_view op_type) { + return absl::StrCat("#tf_op=", op_name, ":", op_type, "#"); +} + +TF_ATTRIBUTE_ALWAYS_INLINE inline std::string TraceMeOpOverride( + const char* op_name, const char* op_type) { + return absl::StrCat("#tf_op=", op_name, ":", op_type, "#"); +} + +} // namespace profiler +} // namespace tsl + +#endif // TENSORFLOW_TSL_PROFILER_LIB_TRACEME_ENCODE_H_ diff --git a/deps/exla/cache/xla_extension/include/upb/decode.h b/deps/exla/cache/xla_extension/include/upb/decode.h new file mode 100644 index 0000000000000000000000000000000000000000..9de8638de5cddf5fc3b6bde035c2de930df315da --- /dev/null +++ b/deps/exla/cache/xla_extension/include/upb/decode.h @@ -0,0 +1,21 @@ +/* +** upb_decode: parsing into a upb_msg using a upb_msglayout. +*/ + +#ifndef UPB_DECODE_H_ +#define UPB_DECODE_H_ + +#include "upb/msg.h" + +#ifdef __cplusplus +extern "C" { +#endif + +bool upb_decode(const char *buf, size_t size, upb_msg *msg, + const upb_msglayout *l, upb_arena *arena); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* UPB_DECODE_H_ */ diff --git a/deps/exla/cache/xla_extension/include/upb/encode.h b/deps/exla/cache/xla_extension/include/upb/encode.h new file mode 100644 index 0000000000000000000000000000000000000000..68427770585a7338aa6e7db2a64400aace34da34 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/upb/encode.h @@ -0,0 +1,21 @@ +/* +** upb_encode: parsing into a upb_msg using a upb_msglayout. +*/ + +#ifndef UPB_ENCODE_H_ +#define UPB_ENCODE_H_ + +#include "upb/msg.h" + +#ifdef __cplusplus +extern "C" { +#endif + +char *upb_encode(const void *msg, const upb_msglayout *l, upb_arena *arena, + size_t *size); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* UPB_ENCODE_H_ */ diff --git a/deps/exla/cache/xla_extension/include/upb/generated_util.h b/deps/exla/cache/xla_extension/include/upb/generated_util.h new file mode 100644 index 0000000000000000000000000000000000000000..234bcdad3c97a38948922a7733789a69729cdf33 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/upb/generated_util.h @@ -0,0 +1,105 @@ +/* +** Functions for use by generated code. These are not public and users must +** not call them directly. +*/ + +#ifndef UPB_GENERATED_UTIL_H_ +#define UPB_GENERATED_UTIL_H_ + +#include +#include "upb/msg.h" + +#include "upb/port_def.inc" + +#define PTR_AT(msg, ofs, type) (type*)((const char*)msg + ofs) + +UPB_INLINE const void *_upb_array_accessor(const void *msg, size_t ofs, + size_t *size) { + const upb_array *arr = *PTR_AT(msg, ofs, const upb_array*); + if (arr) { + if (size) *size = arr->len; + return arr->data; + } else { + if (size) *size = 0; + return NULL; + } +} + +UPB_INLINE void *_upb_array_mutable_accessor(void *msg, size_t ofs, + size_t *size) { + upb_array *arr = *PTR_AT(msg, ofs, upb_array*); + if (arr) { + if (size) *size = arr->len; + return arr->data; + } else { + if (size) *size = 0; + return NULL; + } +} + +/* TODO(haberman): this is a mess. It will improve when upb_array no longer + * carries reflective state (type, elem_size). */ +UPB_INLINE void *_upb_array_resize_accessor(void *msg, size_t ofs, size_t size, + size_t elem_size, + upb_fieldtype_t type, + upb_arena *arena) { + upb_array *arr = *PTR_AT(msg, ofs, upb_array*); + + if (!arr) { + arr = upb_array_new(arena); + if (!arr) return NULL; + *PTR_AT(msg, ofs, upb_array*) = arr; + } + + if (size > arr->size) { + size_t new_size = UPB_MAX(arr->size, 4); + size_t old_bytes = arr->size * elem_size; + size_t new_bytes; + while (new_size < size) new_size *= 2; + new_bytes = new_size * elem_size; + arr->data = upb_arena_realloc(arena, arr->data, old_bytes, new_bytes); + if (!arr->data) { + return NULL; + } + arr->size = new_size; + } + + arr->len = size; + return arr->data; +} + +UPB_INLINE bool _upb_array_append_accessor(void *msg, size_t ofs, + size_t elem_size, + upb_fieldtype_t type, + const void *value, + upb_arena *arena) { + upb_array *arr = *PTR_AT(msg, ofs, upb_array*); + size_t i = arr ? arr->len : 0; + void *data = + _upb_array_resize_accessor(msg, ofs, i + 1, elem_size, type, arena); + if (!data) return false; + memcpy(PTR_AT(data, i * elem_size, char), value, elem_size); + return true; +} + +UPB_INLINE bool _upb_has_field(const void *msg, size_t idx) { + return (*PTR_AT(msg, idx / 8, const char) & (1 << (idx % 8))) != 0; +} + +UPB_INLINE bool _upb_sethas(const void *msg, size_t idx) { + return (*PTR_AT(msg, idx / 8, char)) |= (char)(1 << (idx % 8)); +} + +UPB_INLINE bool _upb_clearhas(const void *msg, size_t idx) { + return (*PTR_AT(msg, idx / 8, char)) &= (char)(~(1 << (idx % 8))); +} + +UPB_INLINE bool _upb_has_oneof_field(const void *msg, size_t case_ofs, int32_t num) { + return *PTR_AT(msg, case_ofs, int32_t) == num; +} + +#undef PTR_AT + +#include "upb/port_undef.inc" + +#endif /* UPB_GENERATED_UTIL_H_ */ diff --git a/deps/exla/cache/xla_extension/include/upb/msg.h b/deps/exla/cache/xla_extension/include/upb/msg.h new file mode 100644 index 0000000000000000000000000000000000000000..4bec023bd3e1d2787594e6c0badd93148391829c --- /dev/null +++ b/deps/exla/cache/xla_extension/include/upb/msg.h @@ -0,0 +1,69 @@ +/* +** Data structures for message tables, used for parsing and serialization. +** This are much lighter-weight than full reflection, but they are do not +** have enough information to convert to text format, JSON, etc. +** +** The definitions in this file are internal to upb. +**/ + +#ifndef UPB_MSG_H_ +#define UPB_MSG_H_ + +#include +#include +#include "upb/upb.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void upb_msg; + +/** upb_msglayout *************************************************************/ + +/* upb_msglayout represents the memory layout of a given upb_msgdef. The + * members are public so generated code can initialize them, but users MUST NOT + * read or write any of its members. */ + +typedef struct { + uint32_t number; + uint16_t offset; + int16_t presence; /* If >0, hasbit_index+1. If <0, oneof_index+1. */ + uint16_t submsg_index; /* undefined if descriptortype != MESSAGE or GROUP. */ + uint8_t descriptortype; + uint8_t label; +} upb_msglayout_field; + +typedef struct upb_msglayout { + const struct upb_msglayout *const* submsgs; + const upb_msglayout_field *fields; + /* Must be aligned to sizeof(void*). Doesn't include internal members like + * unknown fields, extension dict, pointer to msglayout, etc. */ + uint16_t size; + uint16_t field_count; + bool extendable; +} upb_msglayout; + +/** Message internal representation *******************************************/ + +/* Our internal representation for repeated fields. */ +typedef struct { + void *data; /* Each element is element_size. */ + size_t len; /* Measured in elements. */ + size_t size; /* Measured in elements. */ +} upb_array; + +upb_msg *upb_msg_new(const upb_msglayout *l, upb_arena *a); +upb_msg *upb_msg_new(const upb_msglayout *l, upb_arena *a); + +void upb_msg_addunknown(upb_msg *msg, const char *data, size_t len, + upb_arena *arena); +const char *upb_msg_getunknown(const upb_msg *msg, size_t *len); + +upb_array *upb_array_new(upb_arena *a); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* UPB_MSG_H_ */ diff --git a/deps/exla/cache/xla_extension/include/upb/port_def.inc b/deps/exla/cache/xla_extension/include/upb/port_def.inc new file mode 100644 index 0000000000000000000000000000000000000000..a8967b36794355104cc9c529cc2261ed1750edd5 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/upb/port_def.inc @@ -0,0 +1,152 @@ +/* +* This is where we define macros used across upb. +* +* All of these macros are undef'd in port_undef.inc to avoid leaking them to +* users. +* +* The correct usage is: +* +* #include "upb/foobar.h" +* #include "upb/baz.h" +* +* // MUST be last included header. +* #include "upb/port_def.inc" +* +* // Code for this file. +* // <...> +* +* // Can be omitted for .c files, required for .h. +* #include "upb/port_undef.inc" +* +* This file is private and must not be included by users! +*/ +#ifndef UINTPTR_MAX +#error must include stdint.h first +#endif + +#if UINTPTR_MAX == 0xffffffff +#define UPB_SIZE(size32, size64) size32 +#else +#define UPB_SIZE(size32, size64) size64 +#endif + +#define UPB_FIELD_AT(msg, fieldtype, offset) \ + *(fieldtype*)((const char*)(msg) + offset) + +#define UPB_READ_ONEOF(msg, fieldtype, offset, case_offset, case_val, default) \ + UPB_FIELD_AT(msg, int, case_offset) == case_val \ + ? UPB_FIELD_AT(msg, fieldtype, offset) \ + : default + +#define UPB_WRITE_ONEOF(msg, fieldtype, offset, value, case_offset, case_val) \ + UPB_FIELD_AT(msg, int, case_offset) = case_val; \ + UPB_FIELD_AT(msg, fieldtype, offset) = value; + +/* UPB_INLINE: inline if possible, emit standalone code if required. */ +#ifdef __cplusplus +#define UPB_INLINE inline +#elif defined (__GNUC__) || defined(__clang__) +#define UPB_INLINE static __inline__ +#else +#define UPB_INLINE static +#endif + +/* Hints to the compiler about likely/unlikely branches. */ +#if defined (__GNUC__) || defined(__clang__) +#define UPB_LIKELY(x) __builtin_expect((x),1) +#define UPB_UNLIKELY(x) __builtin_expect((x),0) +#else +#define UPB_LIKELY(x) (x) +#define UPB_UNLIKELY(x) (x) +#endif + +/* Define UPB_BIG_ENDIAN manually if you're on big endian and your compiler + * doesn't provide these preprocessor symbols. */ +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) +#define UPB_BIG_ENDIAN +#endif + +/* Macros for function attributes on compilers that support them. */ +#ifdef __GNUC__ +#define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) +#define UPB_NOINLINE __attribute__((noinline)) +#define UPB_NORETURN __attribute__((__noreturn__)) +#else /* !defined(__GNUC__) */ +#define UPB_FORCEINLINE +#define UPB_NOINLINE +#define UPB_NORETURN +#endif + +#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L +/* C99/C++11 versions. */ +#include +#define _upb_snprintf snprintf +#define _upb_vsnprintf vsnprintf +#define _upb_va_copy(a, b) va_copy(a, b) +#elif defined(_MSC_VER) +/* Microsoft C/C++ versions. */ +#include +#include +#if _MSC_VER < 1900 +int msvc_snprintf(char* s, size_t n, const char* format, ...); +int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg); +#define UPB_MSVC_VSNPRINTF +#define _upb_snprintf msvc_snprintf +#define _upb_vsnprintf msvc_vsnprintf +#else +#define _upb_snprintf snprintf +#define _upb_vsnprintf vsnprintf +#endif +#define _upb_va_copy(a, b) va_copy(a, b) +#elif defined __GNUC__ +/* A few hacky workarounds for functions not in C89. + * For internal use only! + * TODO(haberman): fix these by including our own implementations, or finding + * another workaround. + */ +#define _upb_snprintf __builtin_snprintf +#define _upb_vsnprintf __builtin_vsnprintf +#define _upb_va_copy(a, b) __va_copy(a, b) +#else +#error Need implementations of [v]snprintf and va_copy +#endif + +#ifdef __cplusplus +#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || \ + (defined(_MSC_VER) && _MSC_VER >= 1900) +/* C++11 is present */ +#else +#error upb requires C++11 for C++ support +#endif +#endif + +#define UPB_MAX(x, y) ((x) > (y) ? (x) : (y)) +#define UPB_MIN(x, y) ((x) < (y) ? (x) : (y)) + +#define UPB_UNUSED(var) (void)var + +/* UPB_ASSERT(): in release mode, we use the expression without letting it be + * evaluated. This prevents "unused variable" warnings. */ +#ifdef NDEBUG +#define UPB_ASSERT(expr) do {} while (false && (expr)) +#else +#define UPB_ASSERT(expr) assert(expr) +#endif + +/* UPB_ASSERT_DEBUGVAR(): assert that uses functions or variables that only + * exist in debug mode. This turns into regular assert. */ +#define UPB_ASSERT_DEBUGVAR(expr) assert(expr) + +#if defined(__GNUC__) || defined(__clang__) +#define UPB_UNREACHABLE() do { assert(0); __builtin_unreachable(); } while(0) +#else +#define UPB_UNREACHABLE() do { assert(0); } while(0) +#endif + +/* UPB_INFINITY representing floating-point positive infinity. */ +#include +#ifdef INFINITY +#define UPB_INFINITY INFINITY +#else +#define UPB_INFINITY (1.0 / 0.0) +#endif diff --git a/deps/exla/cache/xla_extension/include/upb/port_undef.inc b/deps/exla/cache/xla_extension/include/upb/port_undef.inc new file mode 100644 index 0000000000000000000000000000000000000000..103180b7fbdbf72545eaf5c6cd263ee0a11e9819 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/upb/port_undef.inc @@ -0,0 +1,21 @@ +/* See port_def.inc. This should #undef all macros #defined there. */ + +#undef UPB_SIZE +#undef UPB_FIELD_AT +#undef UPB_READ_ONEOF +#undef UPB_WRITE_ONEOF +#undef UPB_INLINE +#undef UPB_FORCEINLINE +#undef UPB_NOINLINE +#undef UPB_NORETURN +#undef UPB_MAX +#undef UPB_MIN +#undef UPB_UNUSED +#undef UPB_ASSERT +#undef UPB_ASSERT_DEBUGVAR +#undef UPB_UNREACHABLE +#undef UPB_INFINITY +#undef UPB_MSVC_VSNPRINTF +#undef _upb_snprintf +#undef _upb_vsnprintf +#undef _upb_va_copy diff --git a/deps/exla/cache/xla_extension/include/upb/table.int.h b/deps/exla/cache/xla_extension/include/upb/table.int.h new file mode 100644 index 0000000000000000000000000000000000000000..23b0b2f2213a95887bf5f551f93d06daa7af6274 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/upb/table.int.h @@ -0,0 +1,507 @@ +/* +** upb_table +** +** This header is INTERNAL-ONLY! Its interfaces are not public or stable! +** This file defines very fast int->upb_value (inttable) and string->upb_value +** (strtable) hash tables. +** +** The table uses chained scatter with Brent's variation (inspired by the Lua +** implementation of hash tables). The hash function for strings is Austin +** Appleby's "MurmurHash." +** +** The inttable uses uintptr_t as its key, which guarantees it can be used to +** store pointers or integers of at least 32 bits (upb isn't really useful on +** systems where sizeof(void*) < 4). +** +** The table must be homogenous (all values of the same type). In debug +** mode, we check this on insert and lookup. +*/ + +#ifndef UPB_TABLE_H_ +#define UPB_TABLE_H_ + +#include +#include +#include "upb/upb.h" + +#include "upb/port_def.inc" + +#ifdef __cplusplus +extern "C" { +#endif + + +/* upb_value ******************************************************************/ + +/* A tagged union (stored untagged inside the table) so that we can check that + * clients calling table accessors are correctly typed without having to have + * an explosion of accessors. */ +typedef enum { + UPB_CTYPE_INT32 = 1, + UPB_CTYPE_INT64 = 2, + UPB_CTYPE_UINT32 = 3, + UPB_CTYPE_UINT64 = 4, + UPB_CTYPE_BOOL = 5, + UPB_CTYPE_CSTR = 6, + UPB_CTYPE_PTR = 7, + UPB_CTYPE_CONSTPTR = 8, + UPB_CTYPE_FPTR = 9, + UPB_CTYPE_FLOAT = 10, + UPB_CTYPE_DOUBLE = 11 +} upb_ctype_t; + +typedef struct { + uint64_t val; +#ifndef NDEBUG + /* In debug mode we carry the value type around also so we can check accesses + * to be sure the right member is being read. */ + upb_ctype_t ctype; +#endif +} upb_value; + +#ifdef NDEBUG +#define SET_TYPE(dest, val) UPB_UNUSED(val) +#else +#define SET_TYPE(dest, val) dest = val +#endif + +/* Like strdup(), which isn't always available since it's not ANSI C. */ +char *upb_strdup(const char *s, upb_alloc *a); +/* Variant that works with a length-delimited rather than NULL-delimited string, + * as supported by strtable. */ +char *upb_strdup2(const char *s, size_t len, upb_alloc *a); + +UPB_INLINE char *upb_gstrdup(const char *s) { + return upb_strdup(s, &upb_alloc_global); +} + +UPB_INLINE void _upb_value_setval(upb_value *v, uint64_t val, + upb_ctype_t ctype) { + v->val = val; + SET_TYPE(v->ctype, ctype); +} + +UPB_INLINE upb_value _upb_value_val(uint64_t val, upb_ctype_t ctype) { + upb_value ret; + _upb_value_setval(&ret, val, ctype); + return ret; +} + +/* For each value ctype, define the following set of functions: + * + * // Get/set an int32 from a upb_value. + * int32_t upb_value_getint32(upb_value val); + * void upb_value_setint32(upb_value *val, int32_t cval); + * + * // Construct a new upb_value from an int32. + * upb_value upb_value_int32(int32_t val); */ +#define FUNCS(name, membername, type_t, converter, proto_type) \ + UPB_INLINE void upb_value_set ## name(upb_value *val, type_t cval) { \ + val->val = (converter)cval; \ + SET_TYPE(val->ctype, proto_type); \ + } \ + UPB_INLINE upb_value upb_value_ ## name(type_t val) { \ + upb_value ret; \ + upb_value_set ## name(&ret, val); \ + return ret; \ + } \ + UPB_INLINE type_t upb_value_get ## name(upb_value val) { \ + UPB_ASSERT_DEBUGVAR(val.ctype == proto_type); \ + return (type_t)(converter)val.val; \ + } + +FUNCS(int32, int32, int32_t, int32_t, UPB_CTYPE_INT32) +FUNCS(int64, int64, int64_t, int64_t, UPB_CTYPE_INT64) +FUNCS(uint32, uint32, uint32_t, uint32_t, UPB_CTYPE_UINT32) +FUNCS(uint64, uint64, uint64_t, uint64_t, UPB_CTYPE_UINT64) +FUNCS(bool, _bool, bool, bool, UPB_CTYPE_BOOL) +FUNCS(cstr, cstr, char*, uintptr_t, UPB_CTYPE_CSTR) +FUNCS(ptr, ptr, void*, uintptr_t, UPB_CTYPE_PTR) +FUNCS(constptr, constptr, const void*, uintptr_t, UPB_CTYPE_CONSTPTR) +FUNCS(fptr, fptr, upb_func*, uintptr_t, UPB_CTYPE_FPTR) + +#undef FUNCS + +UPB_INLINE void upb_value_setfloat(upb_value *val, float cval) { + memcpy(&val->val, &cval, sizeof(cval)); + SET_TYPE(val->ctype, UPB_CTYPE_FLOAT); +} + +UPB_INLINE void upb_value_setdouble(upb_value *val, double cval) { + memcpy(&val->val, &cval, sizeof(cval)); + SET_TYPE(val->ctype, UPB_CTYPE_DOUBLE); +} + +UPB_INLINE upb_value upb_value_float(float cval) { + upb_value ret; + upb_value_setfloat(&ret, cval); + return ret; +} + +UPB_INLINE upb_value upb_value_double(double cval) { + upb_value ret; + upb_value_setdouble(&ret, cval); + return ret; +} + +#undef SET_TYPE + + +/* upb_tabkey *****************************************************************/ + +/* Either: + * 1. an actual integer key, or + * 2. a pointer to a string prefixed by its uint32_t length, owned by us. + * + * ...depending on whether this is a string table or an int table. We would + * make this a union of those two types, but C89 doesn't support statically + * initializing a non-first union member. */ +typedef uintptr_t upb_tabkey; + +UPB_INLINE char *upb_tabstr(upb_tabkey key, uint32_t *len) { + char* mem = (char*)key; + if (len) memcpy(len, mem, sizeof(*len)); + return mem + sizeof(*len); +} + + +/* upb_tabval *****************************************************************/ + +typedef struct { + uint64_t val; +} upb_tabval; + +#define UPB_TABVALUE_EMPTY_INIT {-1} + + +/* upb_table ******************************************************************/ + +typedef struct _upb_tabent { + upb_tabkey key; + upb_tabval val; + + /* Internal chaining. This is const so we can create static initializers for + * tables. We cast away const sometimes, but *only* when the containing + * upb_table is known to be non-const. This requires a bit of care, but + * the subtlety is confined to table.c. */ + const struct _upb_tabent *next; +} upb_tabent; + +typedef struct { + size_t count; /* Number of entries in the hash part. */ + size_t mask; /* Mask to turn hash value -> bucket. */ + upb_ctype_t ctype; /* Type of all values. */ + uint8_t size_lg2; /* Size of the hashtable part is 2^size_lg2 entries. */ + + /* Hash table entries. + * Making this const isn't entirely accurate; what we really want is for it to + * have the same const-ness as the table it's inside. But there's no way to + * declare that in C. So we have to make it const so that we can statically + * initialize const hash tables. Then we cast away const when we have to. + */ + const upb_tabent *entries; + +#ifndef NDEBUG + /* This table's allocator. We make the user pass it in to every relevant + * function and only use this to check it in debug mode. We do this solely + * to keep upb_table as small as possible. This might seem slightly paranoid + * but the plan is to use upb_table for all map fields and extension sets in + * a forthcoming message representation, so there could be a lot of these. + * If this turns out to be too annoying later, we can change it (since this + * is an internal-only header file). */ + upb_alloc *alloc; +#endif +} upb_table; + +typedef struct { + upb_table t; +} upb_strtable; + +typedef struct { + upb_table t; /* For entries that don't fit in the array part. */ + const upb_tabval *array; /* Array part of the table. See const note above. */ + size_t array_size; /* Array part size. */ + size_t array_count; /* Array part number of elements. */ +} upb_inttable; + +#define UPB_INTTABLE_INIT(count, mask, ctype, size_lg2, ent, a, asize, acount) \ + {UPB_TABLE_INIT(count, mask, ctype, size_lg2, ent), a, asize, acount} + +#define UPB_EMPTY_INTTABLE_INIT(ctype) \ + UPB_INTTABLE_INIT(0, 0, ctype, 0, NULL, NULL, 0, 0) + +#define UPB_ARRAY_EMPTYENT -1 + +UPB_INLINE size_t upb_table_size(const upb_table *t) { + if (t->size_lg2 == 0) + return 0; + else + return 1 << t->size_lg2; +} + +/* Internal-only functions, in .h file only out of necessity. */ +UPB_INLINE bool upb_tabent_isempty(const upb_tabent *e) { + return e->key == 0; +} + +/* Used by some of the unit tests for generic hashing functionality. */ +uint32_t upb_murmur_hash2(const void * key, size_t len, uint32_t seed); + +UPB_INLINE uintptr_t upb_intkey(uintptr_t key) { + return key; +} + +UPB_INLINE uint32_t upb_inthash(uintptr_t key) { + return (uint32_t)key; +} + +static const upb_tabent *upb_getentry(const upb_table *t, uint32_t hash) { + return t->entries + (hash & t->mask); +} + +UPB_INLINE bool upb_arrhas(upb_tabval key) { + return key.val != (uint64_t)-1; +} + +/* Initialize and uninitialize a table, respectively. If memory allocation + * failed, false is returned that the table is uninitialized. */ +bool upb_inttable_init2(upb_inttable *table, upb_ctype_t ctype, upb_alloc *a); +bool upb_strtable_init2(upb_strtable *table, upb_ctype_t ctype, upb_alloc *a); +void upb_inttable_uninit2(upb_inttable *table, upb_alloc *a); +void upb_strtable_uninit2(upb_strtable *table, upb_alloc *a); + +UPB_INLINE bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype) { + return upb_inttable_init2(table, ctype, &upb_alloc_global); +} + +UPB_INLINE bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype) { + return upb_strtable_init2(table, ctype, &upb_alloc_global); +} + +UPB_INLINE void upb_inttable_uninit(upb_inttable *table) { + upb_inttable_uninit2(table, &upb_alloc_global); +} + +UPB_INLINE void upb_strtable_uninit(upb_strtable *table) { + upb_strtable_uninit2(table, &upb_alloc_global); +} + +/* Returns the number of values in the table. */ +size_t upb_inttable_count(const upb_inttable *t); +UPB_INLINE size_t upb_strtable_count(const upb_strtable *t) { + return t->t.count; +} + +void upb_inttable_packedsize(const upb_inttable *t, size_t *size); +void upb_strtable_packedsize(const upb_strtable *t, size_t *size); +upb_inttable *upb_inttable_pack(const upb_inttable *t, void *p, size_t *ofs, + size_t size); +upb_strtable *upb_strtable_pack(const upb_strtable *t, void *p, size_t *ofs, + size_t size); + +/* Inserts the given key into the hashtable with the given value. The key must + * not already exist in the hash table. For string tables, the key must be + * NULL-terminated, and the table will make an internal copy of the key. + * Inttables must not insert a value of UINTPTR_MAX. + * + * If a table resize was required but memory allocation failed, false is + * returned and the table is unchanged. */ +bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val, + upb_alloc *a); +bool upb_strtable_insert3(upb_strtable *t, const char *key, size_t len, + upb_value val, upb_alloc *a); + +UPB_INLINE bool upb_inttable_insert(upb_inttable *t, uintptr_t key, + upb_value val) { + return upb_inttable_insert2(t, key, val, &upb_alloc_global); +} + +UPB_INLINE bool upb_strtable_insert2(upb_strtable *t, const char *key, + size_t len, upb_value val) { + return upb_strtable_insert3(t, key, len, val, &upb_alloc_global); +} + +/* For NULL-terminated strings. */ +UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key, + upb_value val) { + return upb_strtable_insert2(t, key, strlen(key), val); +} + +/* Looks up key in this table, returning "true" if the key was found. + * If v is non-NULL, copies the value for this key into *v. */ +bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v); +bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len, + upb_value *v); + +/* For NULL-terminated strings. */ +UPB_INLINE bool upb_strtable_lookup(const upb_strtable *t, const char *key, + upb_value *v) { + return upb_strtable_lookup2(t, key, strlen(key), v); +} + +/* Removes an item from the table. Returns true if the remove was successful, + * and stores the removed item in *val if non-NULL. */ +bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val); +bool upb_strtable_remove3(upb_strtable *t, const char *key, size_t len, + upb_value *val, upb_alloc *alloc); + +UPB_INLINE bool upb_strtable_remove2(upb_strtable *t, const char *key, + size_t len, upb_value *val) { + return upb_strtable_remove3(t, key, len, val, &upb_alloc_global); +} + +/* For NULL-terminated strings. */ +UPB_INLINE bool upb_strtable_remove(upb_strtable *t, const char *key, + upb_value *v) { + return upb_strtable_remove2(t, key, strlen(key), v); +} + +/* Updates an existing entry in an inttable. If the entry does not exist, + * returns false and does nothing. Unlike insert/remove, this does not + * invalidate iterators. */ +bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val); + +/* Handy routines for treating an inttable like a stack. May not be mixed with + * other insert/remove calls. */ +bool upb_inttable_push2(upb_inttable *t, upb_value val, upb_alloc *a); +upb_value upb_inttable_pop(upb_inttable *t); + +UPB_INLINE bool upb_inttable_push(upb_inttable *t, upb_value val) { + return upb_inttable_push2(t, val, &upb_alloc_global); +} + +/* Convenience routines for inttables with pointer keys. */ +bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val, + upb_alloc *a); +bool upb_inttable_removeptr(upb_inttable *t, const void *key, upb_value *val); +bool upb_inttable_lookupptr( + const upb_inttable *t, const void *key, upb_value *val); + +UPB_INLINE bool upb_inttable_insertptr(upb_inttable *t, const void *key, + upb_value val) { + return upb_inttable_insertptr2(t, key, val, &upb_alloc_global); +} + +/* Optimizes the table for the current set of entries, for both memory use and + * lookup time. Client should call this after all entries have been inserted; + * inserting more entries is legal, but will likely require a table resize. */ +void upb_inttable_compact2(upb_inttable *t, upb_alloc *a); + +UPB_INLINE void upb_inttable_compact(upb_inttable *t) { + upb_inttable_compact2(t, &upb_alloc_global); +} + +/* A special-case inlinable version of the lookup routine for 32-bit + * integers. */ +UPB_INLINE bool upb_inttable_lookup32(const upb_inttable *t, uint32_t key, + upb_value *v) { + *v = upb_value_int32(0); /* Silence compiler warnings. */ + if (key < t->array_size) { + upb_tabval arrval = t->array[key]; + if (upb_arrhas(arrval)) { + _upb_value_setval(v, arrval.val, t->t.ctype); + return true; + } else { + return false; + } + } else { + const upb_tabent *e; + if (t->t.entries == NULL) return false; + for (e = upb_getentry(&t->t, upb_inthash(key)); true; e = e->next) { + if ((uint32_t)e->key == key) { + _upb_value_setval(v, e->val.val, t->t.ctype); + return true; + } + if (e->next == NULL) return false; + } + } +} + +/* Exposed for testing only. */ +bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_alloc *a); + +/* Iterators ******************************************************************/ + +/* Iterators for int and string tables. We are subject to some kind of unusual + * design constraints: + * + * For high-level languages: + * - we must be able to guarantee that we don't crash or corrupt memory even if + * the program accesses an invalidated iterator. + * + * For C++11 range-based for: + * - iterators must be copyable + * - iterators must be comparable + * - it must be possible to construct an "end" value. + * + * Iteration order is undefined. + * + * Modifying the table invalidates iterators. upb_{str,int}table_done() is + * guaranteed to work even on an invalidated iterator, as long as the table it + * is iterating over has not been freed. Calling next() or accessing data from + * an invalidated iterator yields unspecified elements from the table, but it is + * guaranteed not to crash and to return real table elements (except when done() + * is true). */ + + +/* upb_strtable_iter **********************************************************/ + +/* upb_strtable_iter i; + * upb_strtable_begin(&i, t); + * for(; !upb_strtable_done(&i); upb_strtable_next(&i)) { + * const char *key = upb_strtable_iter_key(&i); + * const upb_value val = upb_strtable_iter_value(&i); + * // ... + * } + */ + +typedef struct { + const upb_strtable *t; + size_t index; +} upb_strtable_iter; + +void upb_strtable_begin(upb_strtable_iter *i, const upb_strtable *t); +void upb_strtable_next(upb_strtable_iter *i); +bool upb_strtable_done(const upb_strtable_iter *i); +const char *upb_strtable_iter_key(const upb_strtable_iter *i); +size_t upb_strtable_iter_keylength(const upb_strtable_iter *i); +upb_value upb_strtable_iter_value(const upb_strtable_iter *i); +void upb_strtable_iter_setdone(upb_strtable_iter *i); +bool upb_strtable_iter_isequal(const upb_strtable_iter *i1, + const upb_strtable_iter *i2); + + +/* upb_inttable_iter **********************************************************/ + +/* upb_inttable_iter i; + * upb_inttable_begin(&i, t); + * for(; !upb_inttable_done(&i); upb_inttable_next(&i)) { + * uintptr_t key = upb_inttable_iter_key(&i); + * upb_value val = upb_inttable_iter_value(&i); + * // ... + * } + */ + +typedef struct { + const upb_inttable *t; + size_t index; + bool array_part; +} upb_inttable_iter; + +void upb_inttable_begin(upb_inttable_iter *i, const upb_inttable *t); +void upb_inttable_next(upb_inttable_iter *i); +bool upb_inttable_done(const upb_inttable_iter *i); +uintptr_t upb_inttable_iter_key(const upb_inttable_iter *i); +upb_value upb_inttable_iter_value(const upb_inttable_iter *i); +void upb_inttable_iter_setdone(upb_inttable_iter *i); +bool upb_inttable_iter_isequal(const upb_inttable_iter *i1, + const upb_inttable_iter *i2); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "upb/port_undef.inc" + +#endif /* UPB_TABLE_H_ */ diff --git a/deps/exla/cache/xla_extension/include/upb/upb.h b/deps/exla/cache/xla_extension/include/upb/upb.h new file mode 100644 index 0000000000000000000000000000000000000000..79c19d281e90e7eb43c02b3b5aa52edee853d5c0 --- /dev/null +++ b/deps/exla/cache/xla_extension/include/upb/upb.h @@ -0,0 +1,364 @@ +/* +** This file contains shared definitions that are widely used across upb. +** +** This is a mixed C/C++ interface that offers a full API to both languages. +** See the top-level README for more information. +*/ + +#ifndef UPB_H_ +#define UPB_H_ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +#include +namespace upb { +class Arena; +class Status; +template class InlinedArena; +} +#endif + +#include "upb/port_def.inc" + +/* upb_status *****************************************************************/ + +/* upb_status represents a success or failure status and error message. + * It owns no resources and allocates no memory, so it should work + * even in OOM situations. */ + +/* The maximum length of an error message before it will get truncated. */ +#define UPB_STATUS_MAX_MESSAGE 127 + +typedef struct { + bool ok; + char msg[UPB_STATUS_MAX_MESSAGE]; /* Error message; NULL-terminated. */ +} upb_status; + +#ifdef __cplusplus +extern "C" { +#endif + +const char *upb_status_errmsg(const upb_status *status); +bool upb_ok(const upb_status *status); + +/* Any of the functions that write to a status object allow status to be NULL, + * to support use cases where the function's caller does not care about the + * status message. */ +void upb_status_clear(upb_status *status); +void upb_status_seterrmsg(upb_status *status, const char *msg); +void upb_status_seterrf(upb_status *status, const char *fmt, ...); +void upb_status_vseterrf(upb_status *status, const char *fmt, va_list args); + +UPB_INLINE void upb_status_setoom(upb_status *status) { + upb_status_seterrmsg(status, "out of memory"); +} + +#ifdef __cplusplus +} /* extern "C" */ + +class upb::Status { + public: + Status() { upb_status_clear(&status_); } + + upb_status* ptr() { return &status_; } + + /* Returns true if there is no error. */ + bool ok() const { return upb_ok(&status_); } + + /* Guaranteed to be NULL-terminated. */ + const char *error_message() const { return upb_status_errmsg(&status_); } + + /* The error message will be truncated if it is longer than + * UPB_STATUS_MAX_MESSAGE-4. */ + void SetErrorMessage(const char *msg) { upb_status_seterrmsg(&status_, msg); } + void SetFormattedErrorMessage(const char *fmt, ...) { + va_list args; + va_start(args, fmt); + upb_status_vseterrf(&status_, fmt, args); + va_end(args); + } + + /* Resets the status to a successful state with no message. */ + void Clear() { upb_status_clear(&status_); } + + private: + upb_status status_; +}; + +#endif /* __cplusplus */ + +/** upb_strview ************************************************************/ + +typedef struct { + const char *data; + size_t size; +} upb_strview; + +UPB_INLINE upb_strview upb_strview_make(const char *data, size_t size) { + upb_strview ret; + ret.data = data; + ret.size = size; + return ret; +} + +UPB_INLINE upb_strview upb_strview_makez(const char *data) { + return upb_strview_make(data, strlen(data)); +} + +UPB_INLINE bool upb_strview_eql(upb_strview a, upb_strview b) { + return a.size == b.size && memcmp(a.data, b.data, a.size) == 0; +} + +#define UPB_STRVIEW_INIT(ptr, len) {ptr, len} + +#define UPB_STRVIEW_FORMAT "%.*s" +#define UPB_STRVIEW_ARGS(view) (int)(view).size, (view).data + +/** upb_alloc *****************************************************************/ + +/* A upb_alloc is a possibly-stateful allocator object. + * + * It could either be an arena allocator (which doesn't require individual + * free() calls) or a regular malloc() (which does). The client must therefore + * free memory unless it knows that the allocator is an arena allocator. */ + +struct upb_alloc; +typedef struct upb_alloc upb_alloc; + +/* A malloc()/free() function. + * If "size" is 0 then the function acts like free(), otherwise it acts like + * realloc(). Only "oldsize" bytes from a previous allocation are preserved. */ +typedef void *upb_alloc_func(upb_alloc *alloc, void *ptr, size_t oldsize, + size_t size); + +struct upb_alloc { + upb_alloc_func *func; +}; + +UPB_INLINE void *upb_malloc(upb_alloc *alloc, size_t size) { + UPB_ASSERT(alloc); + return alloc->func(alloc, NULL, 0, size); +} + +UPB_INLINE void *upb_realloc(upb_alloc *alloc, void *ptr, size_t oldsize, + size_t size) { + UPB_ASSERT(alloc); + return alloc->func(alloc, ptr, oldsize, size); +} + +UPB_INLINE void upb_free(upb_alloc *alloc, void *ptr) { + assert(alloc); + alloc->func(alloc, ptr, 0, 0); +} + +/* The global allocator used by upb. Uses the standard malloc()/free(). */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern upb_alloc upb_alloc_global; + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* Functions that hard-code the global malloc. + * + * We still get benefit because we can put custom logic into our global + * allocator, like injecting out-of-memory faults in debug/testing builds. */ + +UPB_INLINE void *upb_gmalloc(size_t size) { + return upb_malloc(&upb_alloc_global, size); +} + +UPB_INLINE void *upb_grealloc(void *ptr, size_t oldsize, size_t size) { + return upb_realloc(&upb_alloc_global, ptr, oldsize, size); +} + +UPB_INLINE void upb_gfree(void *ptr) { + upb_free(&upb_alloc_global, ptr); +} + +/* upb_arena ******************************************************************/ + +/* upb_arena is a specific allocator implementation that uses arena allocation. + * The user provides an allocator that will be used to allocate the underlying + * arena blocks. Arenas by nature do not require the individual allocations + * to be freed. However the Arena does allow users to register cleanup + * functions that will run when the arena is destroyed. + * + * A upb_arena is *not* thread-safe. + * + * You could write a thread-safe arena allocator that satisfies the + * upb_alloc interface, but it would not be as efficient for the + * single-threaded case. */ + +typedef void upb_cleanup_func(void *ud); + +struct upb_arena; +typedef struct upb_arena upb_arena; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Creates an arena from the given initial block (if any -- n may be 0). + * Additional blocks will be allocated from |alloc|. If |alloc| is NULL, this + * is a fixed-size arena and cannot grow. */ +upb_arena *upb_arena_init(void *mem, size_t n, upb_alloc *alloc); +void upb_arena_free(upb_arena *a); +bool upb_arena_addcleanup(upb_arena *a, void *ud, upb_cleanup_func *func); +size_t upb_arena_bytesallocated(const upb_arena *a); + +UPB_INLINE upb_alloc *upb_arena_alloc(upb_arena *a) { return (upb_alloc*)a; } + +/* Convenience wrappers around upb_alloc functions. */ + +UPB_INLINE void *upb_arena_malloc(upb_arena *a, size_t size) { + return upb_malloc(upb_arena_alloc(a), size); +} + +UPB_INLINE void *upb_arena_realloc(upb_arena *a, void *ptr, size_t oldsize, + size_t size) { + return upb_realloc(upb_arena_alloc(a), ptr, oldsize, size); +} + +UPB_INLINE upb_arena *upb_arena_new(void) { + return upb_arena_init(NULL, 0, &upb_alloc_global); +} + +#ifdef __cplusplus +} /* extern "C" */ + +class upb::Arena { + public: + /* A simple arena with no initial memory block and the default allocator. */ + Arena() : ptr_(upb_arena_new(), upb_arena_free) {} + + upb_arena* ptr() { return ptr_.get(); } + + /* Allows this arena to be used as a generic allocator. + * + * The arena does not need free() calls so when using Arena as an allocator + * it is safe to skip them. However they are no-ops so there is no harm in + * calling free() either. */ + upb_alloc *allocator() { return upb_arena_alloc(ptr_.get()); } + + /* Add a cleanup function to run when the arena is destroyed. + * Returns false on out-of-memory. */ + bool AddCleanup(void *ud, upb_cleanup_func* func) { + return upb_arena_addcleanup(ptr_.get(), ud, func); + } + + /* Total number of bytes that have been allocated. It is undefined what + * Realloc() does to &arena_ counter. */ + size_t BytesAllocated() const { return upb_arena_bytesallocated(ptr_.get()); } + + private: + std::unique_ptr ptr_; +}; + +#endif + +/* upb::InlinedArena **********************************************************/ + +/* upb::InlinedArena seeds the arenas with a predefined amount of memory. No + * heap memory will be allocated until the initial block is exceeded. + * + * These types only exist in C++ */ + +#ifdef __cplusplus + +template class upb::InlinedArena : public upb::Arena { + public: + InlinedArena() : ptr_(upb_arena_new(&initial_block_, N, &upb_alloc_global)) {} + + upb_arena* ptr() { return ptr_.get(); } + + private: + InlinedArena(const InlinedArena*) = delete; + InlinedArena& operator=(const InlinedArena*) = delete; + + std::unique_ptr ptr_; + char initial_block_[N]; +}; + +#endif /* __cplusplus */ + +/* Constants ******************************************************************/ + +/* Generic function type. */ +typedef void upb_func(void); + +/* A list of types as they are encoded on-the-wire. */ +typedef enum { + UPB_WIRE_TYPE_VARINT = 0, + UPB_WIRE_TYPE_64BIT = 1, + UPB_WIRE_TYPE_DELIMITED = 2, + UPB_WIRE_TYPE_START_GROUP = 3, + UPB_WIRE_TYPE_END_GROUP = 4, + UPB_WIRE_TYPE_32BIT = 5 +} upb_wiretype_t; + +/* The types a field can have. Note that this list is not identical to the + * types defined in descriptor.proto, which gives INT32 and SINT32 separate + * types (we distinguish the two with the "integer encoding" enum below). */ +typedef enum { + /* Types stored in 1 byte. */ + UPB_TYPE_BOOL = 1, + /* Types stored in 4 bytes. */ + UPB_TYPE_FLOAT = 2, + UPB_TYPE_INT32 = 3, + UPB_TYPE_UINT32 = 4, + UPB_TYPE_ENUM = 5, /* Enum values are int32. */ + /* Types stored as pointers (probably 4 or 8 bytes). */ + UPB_TYPE_STRING = 6, + UPB_TYPE_BYTES = 7, + UPB_TYPE_MESSAGE = 8, + /* Types stored as 8 bytes. */ + UPB_TYPE_DOUBLE = 9, + UPB_TYPE_INT64 = 10, + UPB_TYPE_UINT64 = 11 +} upb_fieldtype_t; + +/* The repeated-ness of each field; this matches descriptor.proto. */ +typedef enum { + UPB_LABEL_OPTIONAL = 1, + UPB_LABEL_REQUIRED = 2, + UPB_LABEL_REPEATED = 3 +} upb_label_t; + +/* Descriptor types, as defined in descriptor.proto. */ +typedef enum { + UPB_DESCRIPTOR_TYPE_DOUBLE = 1, + UPB_DESCRIPTOR_TYPE_FLOAT = 2, + UPB_DESCRIPTOR_TYPE_INT64 = 3, + UPB_DESCRIPTOR_TYPE_UINT64 = 4, + UPB_DESCRIPTOR_TYPE_INT32 = 5, + UPB_DESCRIPTOR_TYPE_FIXED64 = 6, + UPB_DESCRIPTOR_TYPE_FIXED32 = 7, + UPB_DESCRIPTOR_TYPE_BOOL = 8, + UPB_DESCRIPTOR_TYPE_STRING = 9, + UPB_DESCRIPTOR_TYPE_GROUP = 10, + UPB_DESCRIPTOR_TYPE_MESSAGE = 11, + UPB_DESCRIPTOR_TYPE_BYTES = 12, + UPB_DESCRIPTOR_TYPE_UINT32 = 13, + UPB_DESCRIPTOR_TYPE_ENUM = 14, + UPB_DESCRIPTOR_TYPE_SFIXED32 = 15, + UPB_DESCRIPTOR_TYPE_SFIXED64 = 16, + UPB_DESCRIPTOR_TYPE_SINT32 = 17, + UPB_DESCRIPTOR_TYPE_SINT64 = 18 +} upb_descriptortype_t; + +extern const uint8_t upb_desctype_to_fieldtype[]; + +#include "upb/port_undef.inc" + +#endif /* UPB_H_ */ diff --git a/deps/exla/cache/xla_snapshot.txt b/deps/exla/cache/xla_snapshot.txt new file mode 100644 index 0000000000000000000000000000000000000000..d53c6d1017cb7f74c82da092871a4d263f179cba --- /dev/null +++ b/deps/exla/cache/xla_snapshot.txt @@ -0,0 +1 @@ +/home/saru/.cache/xla/0.9.1/download/xla_extension-0.9.1-x86_64-linux-gnu-cpu.tar.gz \ No newline at end of file